Search in sources :

Example 31 with CompositeName

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

Example 32 with CompositeName

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);
}
Also used : StringRefAddr(javax.naming.StringRefAddr) Reference(javax.naming.Reference) CompositeName(javax.naming.CompositeName) JndiPermission(org.wildfly.naming.java.permission.JndiPermission) Test(org.junit.Test)

Example 33 with CompositeName

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

Example 34 with CompositeName

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

Example 35 with CompositeName

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) {
    }
}
Also used : InvalidNameException(javax.naming.InvalidNameException) 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