<p>I have the following legacy code:</p>

<pre><code>public class MyLegacyClass
{
    private static final String jndiName = "java:comp/env/jdbc/LegacyDataSource"

    public static SomeLegacyClass doSomeLegacyStuff(SomeOtherLegacyClass legacyObj)
    {
       // do stuff using jndiName
    }
}
</code></pre>

<p>This class is working in a J2EE-Container.</p>

<p>Now I would like to test the class outside of the container.</p>

<p>What is the best strategy?
Refactoring is basically allowed.</p>

<p>Accessing the LegacyDataSource is allowed (the test does not have to be a "pure" unit-test).</p>

<p>EDIT: Introducing additional runtime-frameworks is not allowed.</p>

Refactor the code to use dependency injection.  Then use you preferred DI framework (Spring, Guice, ...) to inject your resources.  That will make it easy to switch between resource objects and strategies at runtime.
In this case, you can inject your datasource.
EDIT: Based on your new restriction, you can accomplish the same thing by using a strategy pattern to set your datasource at runtime.  You can probably just use a properties file to distinguish which strategy to create and supply the datasource.  This would require no new framework, you would just be hand coding the same basic functionality.  We used this exact idea with a ServiceLocator to supply a mock datasource when testing outside of the Java EE container.