use of org.apache.openejb.core.ivm.naming.IvmContext in project tomee by apache.
the class IvmContextTest method testBindFromRootSetsTheCorrectParent_lookupRelativeToTheCurrentNode.
@Test
public void testBindFromRootSetsTheCorrectParent_lookupRelativeToTheCurrentNode() throws Exception {
final IvmContext root = IvmContext.createRootContext();
root.bind("a/b/c", null);
IvmContext a = (IvmContext) root.lookup("a");
// TODO Do we want ROOT to be a parent to the top-level contexts ?
requireCorrectParentChildRelationship(null, a);
IvmContext b = (IvmContext) a.lookup("b");
requireCorrectParentChildRelationship(a, b);
}
use of org.apache.openejb.core.ivm.naming.IvmContext in project tomee by apache.
the class IvmContextTest method unbindWithSubContext.
@Test
public void unbindWithSubContext() throws NamingException {
final IvmContext context = new IvmContext("");
context.bind("global/foo/Bar", "Bar");
Contexts.createSubcontexts(context, "global/foo/Bar");
assertEquals("Bar", context.lookup("global/foo/Bar"));
context.unbind("global/foo/Bar");
try {
context.lookup("global/foo/Bar");
fail();
} catch (final NamingException ne) {
// ok
}
try {
((Context) ((Context) context.lookup("global")).lookup("foo")).lookup("Bar");
fail();
} catch (final NamingException ne) {
// ok
}
}
use of org.apache.openejb.core.ivm.naming.IvmContext in project tomee by apache.
the class IvmContextTest method testBindFromRootUnbindFromCurrentContext.
@Test(expected = NameNotFoundException.class)
public void testBindFromRootUnbindFromCurrentContext() throws Exception {
IvmContext root = IvmContext.createRootContext();
root.bind("a/b/object", new Object());
IvmContext b = (IvmContext) root.lookup("a/b");
b.unbind("object");
// must fail with NameNotFoundException
Object object = root.lookup("a/b/object");
fail("Lookup should have failed. Instead it returned: " + object);
}
use of org.apache.openejb.core.ivm.naming.IvmContext in project tomee by apache.
the class IvmContextTest method unbind.
@Test
public void unbind() throws NamingException {
final IvmContext context = new IvmContext();
context.bind("global/foo/Bar", "Bar");
assertEquals("Bar", context.lookup("global/foo/Bar"));
context.unbind("global/foo/Bar");
try {
context.lookup("global/foo/Bar");
fail();
} catch (final NamingException ne) {
// ok
}
try {
final Context subCtx = (Context) context.lookup("global/foo");
subCtx.lookup("Bar");
fail();
} catch (final NamingException ne) {
// ok
}
}
use of org.apache.openejb.core.ivm.naming.IvmContext in project tomee by apache.
the class IvmContextTest method testBindRelativeToRootAndLookupRelativeToTheCurrentContext.
@Test
public void testBindRelativeToRootAndLookupRelativeToTheCurrentContext() throws Exception {
final IvmContext root = IvmContext.createRootContext();
final Object boundObject = new Object();
root.bind("a/b/object", boundObject);
IvmContext b = (IvmContext) root.lookup("a/b");
final Object lookedUpObject = b.lookup("object");
assertSame(boundObject, lookedUpObject);
}
Aggregations