Search in sources :

Example 26 with CompositeName

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

the class NamingContextTestCase method bindList.

private void bindList() throws NamingException {
    final Name name = new CompositeName("test");
    final Object object = new Object();
    namingStore.bind(name, object);
    final Name nameTwo = new CompositeName("testTwo");
    final Object objectTwo = new Object();
    namingStore.bind(nameTwo, objectTwo);
    final Name nameThree = new CompositeName("testThree");
    final Object objectThree = new Object();
    namingStore.bind(nameThree, objectThree);
    namingStore.bind(new CompositeName("testContext/test"), "testNested");
}
Also used : CompositeName(javax.naming.CompositeName) CompositeName(javax.naming.CompositeName) Name(javax.naming.Name)

Example 27 with CompositeName

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

the class NamingContextTestCase method testListNameNotFound.

@Test
public void testListNameNotFound() throws Exception {
    try {
        namingContext.list(new CompositeName("test"));
        fail("Should have thrown and NameNotFoundException");
    } catch (NameNotFoundException expected) {
    }
    //the same with security permissions
    try {
        testActionPermission(JndiPermission.ACTION_LIST, 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)

Example 28 with CompositeName

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

the class NamingContextTestCase method testBindReferenceable.

@Test
public void testBindReferenceable() throws Exception {
    Name name = new CompositeName("test");
    final TestObjectReferenceable referenceable = new TestObjectReferenceable("addr");
    namingContext.bind(name, referenceable);
    Object result = namingContext.lookup(name);
    assertEquals(referenceable.addr, result);
    //the same with security permissions
    name = new CompositeName("securitytest");
    testActionPermission(JndiPermission.ACTION_BIND, namingContext, "securitytest", referenceable);
    result = testActionPermission(JndiPermission.ACTION_LOOKUP, namingContext, "securitytest");
    assertEquals(referenceable.addr, result);
}
Also used : CompositeName(javax.naming.CompositeName) CompositeName(javax.naming.CompositeName) Name(javax.naming.Name) Test(org.junit.Test)

Example 29 with CompositeName

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

the class NamingContextTestCase method testRebindReferenceable.

@Test
public void testRebindReferenceable() throws Exception {
    final Name name = new CompositeName("test");
    final TestObjectReferenceable referenceable = new TestObjectReferenceable("addr");
    namingContext.bind(name, referenceable);
    TestObjectReferenceable newReferenceable = new TestObjectReferenceable("newAddr");
    namingContext.rebind(name, newReferenceable);
    Object result = namingContext.lookup(name);
    assertEquals(newReferenceable.addr, result);
    //the same with security permissions
    newReferenceable = new TestObjectReferenceable("yetAnotherNewAddr");
    testActionPermission(JndiPermission.ACTION_REBIND, namingContext, "test", newReferenceable);
    result = namingContext.lookup(name);
    assertEquals(newReferenceable.addr, result);
}
Also used : CompositeName(javax.naming.CompositeName) CompositeName(javax.naming.CompositeName) Name(javax.naming.Name) Test(org.junit.Test)

Example 30 with CompositeName

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

the class NamingContextTestCase method testListBindingsWithContinuation.

@Test
@SuppressWarnings("unchecked")
public void testListBindingsWithContinuation() throws Exception {
    bindListWithContinuations();
    NamingEnumeration<Binding> results = namingContext.listBindings(new CompositeName("comp"));
    checkListWithContinuationsResults(results);
    //the same with security permissions
    results = (NamingEnumeration<Binding>) testActionPermission(JndiPermission.ACTION_LIST_BINDINGS, Arrays.asList(new JndiPermission("test", "listBindings")), namingContext, "comp");
    checkListWithContinuationsResults(results);
}
Also used : Binding(javax.naming.Binding) CompositeName(javax.naming.CompositeName) JndiPermission(org.wildfly.naming.java.permission.JndiPermission) 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