Search in sources :

Example 21 with CompositeName

use of javax.naming.CompositeName in project wildfly by wildfly.

the class InMemoryNamingStoreTestCase method testListBindings.

@Test
public void testListBindings() throws Exception {
    final Name name = new CompositeName("test");
    final Object object = new Object();
    nameStore.bind(name, object);
    final Name nameTwo = new CompositeName("testTwo");
    final Object objectTwo = new Object();
    nameStore.bind(nameTwo, objectTwo);
    final Name nameThree = new CompositeName("testThree");
    final Object objectThree = new Object();
    nameStore.bind(nameThree, objectThree);
    nameStore.bind(new CompositeName("testContext/test"), "test");
    final List<Binding> results = nameStore.listBindings(new CompositeName());
    assertEquals(4, results.size());
    final Set<String> expected = new HashSet<String>(Arrays.asList("test", "testTwo", "testThree", "testContext"));
    for (Binding result : results) {
        final String resultName = result.getName();
        if ("test".equals(resultName)) {
            assertEquals(Object.class.getName(), result.getClassName());
            assertEquals(object, result.getObject());
        } else if ("testTwo".equals(resultName)) {
            assertEquals(Object.class.getName(), result.getClassName());
            assertEquals(objectTwo, result.getObject());
        } else if ("testThree".equals(resultName)) {
            assertEquals(Object.class.getName(), result.getClassName());
            assertEquals(objectThree, result.getObject());
        } else if ("testContext".equals(resultName)) {
            assertEquals(Context.class.getName(), result.getClassName());
        } else {
            fail("Unknown result name: " + resultName);
        }
        expected.remove(resultName);
    }
    assertTrue("Not all expected results were returned", expected.isEmpty());
}
Also used : Binding(javax.naming.Binding) CompositeName(javax.naming.CompositeName) CompositeName(javax.naming.CompositeName) Name(javax.naming.Name) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 22 with CompositeName

use of javax.naming.CompositeName in project wildfly by wildfly.

the class InMemoryNamingStoreTestCase method testListBindingsNameNotFound.

@Test
public void testListBindingsNameNotFound() throws Exception {
    try {
        nameStore.listBindings(new CompositeName("test"));
        fail("Should have thrown and NameNotFoundException");
    } catch (NameNotFoundException expected) {
    }
}
Also used : NameNotFoundException(javax.naming.NameNotFoundException) CompositeName(javax.naming.CompositeName) Test(org.junit.Test)

Example 23 with CompositeName

use of javax.naming.CompositeName in project wildfly by wildfly.

the class NamingContextTestCase method bindListWithContinuations.

private void bindListWithContinuations() throws NamingException {
    final Name name = new CompositeName("test/test");
    final Object object = new Object();
    namingStore.bind(name, object);
    final Name nameTwo = new CompositeName("test/testTwo");
    final Object objectTwo = new Object();
    namingStore.bind(nameTwo, objectTwo);
    final Name nameThree = new CompositeName("test/testThree");
    final Object objectThree = new Object();
    namingStore.bind(nameThree, objectThree);
    final Reference reference = new Reference(String.class.getName(), new StringRefAddr("nns", "test"), TestObjectFactoryWithNameResolution.class.getName(), null);
    namingStore.bind(new CompositeName("comp"), reference);
}
Also used : StringRefAddr(javax.naming.StringRefAddr) Reference(javax.naming.Reference) CompositeName(javax.naming.CompositeName) CompositeName(javax.naming.CompositeName) Name(javax.naming.Name)

Example 24 with CompositeName

use of javax.naming.CompositeName in project wildfly by wildfly.

the class NamingContextTestCase method testListWithContinuation.

@Test
@SuppressWarnings("unchecked")
public void testListWithContinuation() throws Exception {
    bindListWithContinuations();
    NamingEnumeration<NameClassPair> results = namingContext.list(new CompositeName("comp"));
    checkListWithContinuationsResults(results);
    //the same with security permissions
    results = (NamingEnumeration<NameClassPair>) testActionPermission(JndiPermission.ACTION_LIST, Arrays.asList(new JndiPermission("test", "list")), namingContext, "comp");
    checkListWithContinuationsResults(results);
}
Also used : NameClassPair(javax.naming.NameClassPair) CompositeName(javax.naming.CompositeName) JndiPermission(org.wildfly.naming.java.permission.JndiPermission) Test(org.junit.Test)

Example 25 with CompositeName

use of javax.naming.CompositeName in project wildfly by wildfly.

the class NamingContextTestCase method testListBindingsNameNotFound.

@Test
public void testListBindingsNameNotFound() throws Exception {
    try {
        namingContext.listBindings(new CompositeName("test"));
        fail("Should have thrown and NameNotFoundException");
    } catch (NameNotFoundException expected) {
    }
    //the same with security permissions
    try {
        testActionPermission(JndiPermission.ACTION_LIST_BINDINGS, namingContext, "test");
        fail("Should have thrown and NameNotFoundException with appropriate permissions");
    } catch (NameNotFoundException expected) {
    }
}
Also used : NameNotFoundException(javax.naming.NameNotFoundException) 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