use of javax.naming.CompositeName in project wildfly by wildfly.
the class NamingContextTestCase method testUnbind.
@Test
public void testUnbind() throws Exception {
final Name name = new CompositeName("test");
final Object value = new Object();
namingStore.bind(name, value);
namingContext.unbind(name);
try {
namingStore.lookup(name);
fail("Should have thrown name not found");
} catch (NameNotFoundException expect) {
}
//the same with security permissions
testActionPermission(JndiPermission.ACTION_BIND, namingContext, "test", value);
testActionPermission(JndiPermission.ACTION_UNBIND, namingContext, "test");
try {
namingStore.lookup(name);
fail("Should have thrown name not found");
} catch (NameNotFoundException expect) {
}
}
use of javax.naming.CompositeName in project wildfly by wildfly.
the class NamingContextTestCase method testListBindings.
@Test
@SuppressWarnings("unchecked")
public void testListBindings() throws Exception {
bindList();
NamingEnumeration<Binding> results = namingContext.listBindings(new CompositeName());
checkListResults(results);
//the same with security permissions
results = (NamingEnumeration<Binding>) testActionPermission(JndiPermission.ACTION_LIST_BINDINGS, namingContext, null);
checkListResults(results);
}
use of javax.naming.CompositeName in project wildfly by wildfly.
the class NamingContextTestCase method testBind.
@Test
public void testBind() throws Exception {
Name name = new CompositeName("test");
final Object value = new Object();
namingContext.bind(name, value);
assertEquals(value, namingStore.lookup(name));
//the same with security permissions
name = new CompositeName("securitytest");
testActionPermission(JndiPermission.ACTION_BIND, namingContext, "securitytest", value);
assertEquals(value, namingStore.lookup(name));
}
use of javax.naming.CompositeName in project wildfly by wildfly.
the class NamingEventCoordinatorTestCase method testFireObjectEvent.
@Test
public void testFireObjectEvent() throws Exception {
final NamingEventCoordinator coordinator = new NamingEventCoordinator();
final CollectingListener objectListener = new CollectingListener(1);
coordinator.addListener("test/path", EventContext.OBJECT_SCOPE, objectListener);
final CollectingListener subtreeListener = new CollectingListener(0);
coordinator.addListener("test", EventContext.SUBTREE_SCOPE, subtreeListener);
final CollectingListener oneLevelListener = new CollectingListener(0);
coordinator.addListener("test", EventContext.ONELEVEL_SCOPE, oneLevelListener);
coordinator.fireEvent(context, new CompositeName("test/path"), null, null, NamingEvent.OBJECT_ADDED, "bind", EventContext.OBJECT_SCOPE);
objectListener.latch.await(1, TimeUnit.SECONDS);
assertEquals(1, objectListener.capturedEvents.size());
assertTrue(oneLevelListener.capturedEvents.isEmpty());
assertTrue(subtreeListener.capturedEvents.isEmpty());
}
use of javax.naming.CompositeName in project wildfly by wildfly.
the class NamingEventCoordinatorTestCase method testFireOneLevelEvent.
@Test
public void testFireOneLevelEvent() throws Exception {
final NamingEventCoordinator coordinator = new NamingEventCoordinator();
final CollectingListener objectListener = new CollectingListener(0);
coordinator.addListener("test/path", EventContext.OBJECT_SCOPE, objectListener);
final CollectingListener subtreeListener = new CollectingListener(0);
coordinator.addListener("test", EventContext.SUBTREE_SCOPE, subtreeListener);
final CollectingListener oneLevelListener = new CollectingListener(1);
coordinator.addListener("test", EventContext.ONELEVEL_SCOPE, oneLevelListener);
coordinator.fireEvent(context, new CompositeName("test/path"), null, null, NamingEvent.OBJECT_ADDED, "bind", EventContext.ONELEVEL_SCOPE);
oneLevelListener.latch.await(1, TimeUnit.SECONDS);
assertTrue(objectListener.capturedEvents.isEmpty());
assertTrue(subtreeListener.capturedEvents.isEmpty());
assertEquals(1, oneLevelListener.capturedEvents.size());
}
Aggregations