use of javax.naming.CompositeName in project wildfly by wildfly.
the class NamingContextTestCase method testLookupContextLink.
@Test
public void testLookupContextLink() throws Exception {
final Name name = new CompositeName("test/value");
namingStore.bind(name, "testValue");
final Name linkName = new CompositeName("link");
namingStore.bind(linkName, new LinkRef("./test"));
Object result = namingContext.lookup("link/value");
assertEquals("testValue", result);
//the same with security permissions
result = testActionPermission(JndiPermission.ACTION_LOOKUP, Arrays.asList(new JndiPermission("test", "lookup"), new JndiPermission("test/value", "lookup")), namingContext, "link/value");
assertEquals("testValue", result);
}
use of javax.naming.CompositeName in project wildfly by wildfly.
the class NamingContextTestCase method testLookupWithContinuation.
@Test
public void testLookupWithContinuation() throws Exception {
namingStore.bind(new CompositeName("comp/nested"), "test");
final Reference reference = new Reference(String.class.getName(), new StringRefAddr("nns", "comp"), TestObjectFactoryWithNameResolution.class.getName(), null);
namingStore.bind(new CompositeName("test"), reference);
Object result = namingContext.lookup(new CompositeName("test/nested"));
assertEquals("test", result);
//the same with security permissions
result = testActionPermission(JndiPermission.ACTION_LOOKUP, Arrays.asList(new JndiPermission("comp/nested", "lookup")), namingContext, "test/nested");
assertEquals("test", result);
}
use of javax.naming.CompositeName in project wildfly by wildfly.
the class NamingEventCoordinatorTestCase method testFireMultiLevelEvent.
@Test
public void testFireMultiLevelEvent() throws Exception {
final NamingEventCoordinator coordinator = new NamingEventCoordinator();
final CollectingListener subtreeListener = new CollectingListener(1);
coordinator.addListener("foo", EventContext.SUBTREE_SCOPE, subtreeListener);
final CollectingListener subtreeListenerTwo = new CollectingListener(1);
coordinator.addListener("foo/bar", EventContext.SUBTREE_SCOPE, subtreeListenerTwo);
final CollectingListener subtreeListenerThree = new CollectingListener(1);
coordinator.addListener("foo/bar/baz", EventContext.SUBTREE_SCOPE, subtreeListenerThree);
coordinator.fireEvent(context, new CompositeName("foo/bar/baz/boo"), null, null, NamingEvent.OBJECT_ADDED, "bind", EventContext.OBJECT_SCOPE, EventContext.ONELEVEL_SCOPE, EventContext.SUBTREE_SCOPE);
subtreeListener.latch.await(1, TimeUnit.SECONDS);
subtreeListenerTwo.latch.await(1, TimeUnit.SECONDS);
subtreeListenerThree.latch.await(1, TimeUnit.SECONDS);
assertEquals(1, subtreeListener.capturedEvents.size());
assertEquals(1, subtreeListenerTwo.capturedEvents.size());
assertEquals(1, subtreeListenerThree.capturedEvents.size());
}
use of javax.naming.CompositeName in project wildfly by wildfly.
the class ObjectFactoryTestCase method testBindAndRetrieveObjectFactoryFromInitialContext.
@Test
public void testBindAndRetrieveObjectFactoryFromInitialContext() throws Exception {
final Reference reference = new Reference("java.util.String", TestObjectFactory.class.getName(), null);
namingStore.bind(new CompositeName("test"), reference);
final InitialContext initialContext = new InitialContext();
final Object result = initialContext.lookup("test");
assertTrue(result instanceof String);
assertEquals("Test ParsedResult", result);
}
use of javax.naming.CompositeName in project wildfly by wildfly.
the class InMemoryNamingStoreTestCase method testRebindEmptyName.
@Test
public void testRebindEmptyName() throws Exception {
try {
nameStore.rebind(new CompositeName(), new Object(), Object.class);
fail("Should have thrown and InvalidNameException");
} catch (InvalidNameException expected) {
}
try {
nameStore.rebind(new CompositeName(""), new Object(), Object.class);
fail("Should have thrown and InvalidNameException");
} catch (InvalidNameException expected) {
}
}
Aggregations