Search in sources :

Example 81 with CompositeName

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) {
    }
}
Also used : NameNotFoundException(javax.naming.NameNotFoundException) CompositeName(javax.naming.CompositeName) CompositeName(javax.naming.CompositeName) Name(javax.naming.Name) Test(org.junit.Test)

Example 82 with CompositeName

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);
}
Also used : Binding(javax.naming.Binding) CompositeName(javax.naming.CompositeName) Test(org.junit.Test)

Example 83 with CompositeName

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));
}
Also used : CompositeName(javax.naming.CompositeName) CompositeName(javax.naming.CompositeName) Name(javax.naming.Name) Test(org.junit.Test)

Example 84 with CompositeName

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());
}
Also used : CompositeName(javax.naming.CompositeName) Test(org.junit.Test)

Example 85 with CompositeName

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());
}
Also used : CompositeName(javax.naming.CompositeName) Test(org.junit.Test)

Aggregations

CompositeName (javax.naming.CompositeName)124 Test (org.junit.Test)69 Name (javax.naming.Name)43 NameNotFoundException (javax.naming.NameNotFoundException)27 NamingException (javax.naming.NamingException)25 Reference (javax.naming.Reference)19 Context (javax.naming.Context)18 InvalidNameException (javax.naming.InvalidNameException)13 NotContextException (javax.naming.NotContextException)12 ServiceName (org.jboss.msc.service.ServiceName)11 Test (org.junit.jupiter.api.Test)10 JndiPermission (org.wildfly.naming.java.permission.JndiPermission)10 Hashtable (java.util.Hashtable)9 Binding (javax.naming.Binding)8 LinkRef (javax.naming.LinkRef)8 OperationNotSupportedException (javax.naming.OperationNotSupportedException)8 CallableWithoutResult (org.apereo.portal.concurrency.CallableWithoutResult)7 IEntityGroup (org.apereo.portal.groups.IEntityGroup)7 BaseAggrEventsJpaDaoTest (org.apereo.portal.test.BaseAggrEventsJpaDaoTest)7 StringRefAddr (javax.naming.StringRefAddr)5