Map javaCompBindings = new HashMap();
javaCompBindings.put("foo", "bar");
// a regular context doesn't contain env
Thread.currentThread().setContextClassLoader(javaURLContextFactory.class.getClassLoader());
RootContext.setComponentContext(new ImmutableContext(javaCompBindings));
try {
new InitialContext(contextEnv).lookup("java:comp/env");
fail("Expected NameNotFoundException");
} catch (NotContextException expected) {
// expected
} catch (NameNotFoundException expected) {
// expected
}
// ENC adds env if not present
javaCompBindings.put("comp/env/foo", "bar");
RootContext.setComponentContext(new ImmutableContext(javaCompBindings));
new InitialContext(contextEnv).lookup("java:comp/env");
}