Search in sources :

Example 76 with CompositeName

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

the class WritableServiceBasedNamingStoreTestCase method testOwnerBindingReferences.

@Test
public void testOwnerBindingReferences() throws Exception {
    final Name name = new CompositeName("test");
    final ServiceName serviceName = store.buildServiceName(name);
    final Object value = new Object();
    // ensure bind does not exists
    try {
        store.lookup(name);
        fail("Should have thrown name not found");
    } catch (NameNotFoundException expect) {
    }
    final RuntimeBindReleaseService.References duBindingReferences = (RuntimeBindReleaseService.References) container.getService(JndiNamingDependencyProcessor.serviceName(OWNER_FOO)).getValue();
    WritableServiceBasedNamingStore.pushOwner(OWNER_FOO);
    try {
        store.bind(name, value);
        // Foo's RuntimeBindReleaseService should now have a reference to the new bind
        assertTrue(duBindingReferences.contains(serviceName));
        store.rebind(name, value);
        // after rebind, Foo's RuntimeBindReleaseService should continue to have a reference to the bind
        assertTrue(duBindingReferences.contains(serviceName));
        store.unbind(name);
    } finally {
        WritableServiceBasedNamingStore.popOwner();
    }
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) NameNotFoundException(javax.naming.NameNotFoundException) CompositeName(javax.naming.CompositeName) RuntimeBindReleaseService(org.jboss.as.naming.deployment.RuntimeBindReleaseService) CompositeName(javax.naming.CompositeName) Name(javax.naming.Name) ServiceName(org.jboss.msc.service.ServiceName) Test(org.junit.Test)

Example 77 with CompositeName

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

the class NamingContextTestCase method testLookupWitResolveResult.

@Test
public void testLookupWitResolveResult() throws Exception {
    namingStore.bind(new CompositeName("test/nested"), "test");
    final Reference reference = new Reference(String.class.getName(), new StringRefAddr("blahh", "test"), TestObjectFactoryWithNameResolution.class.getName(), null);
    namingStore.bind(new CompositeName("comp"), reference);
    Object result = namingContext.lookup(new CompositeName("comp/nested"));
    assertEquals("test", result);
    //the same with security permissions
    result = testActionPermission(JndiPermission.ACTION_LOOKUP, Arrays.asList(new JndiPermission("test/nested", "lookup")), namingContext, "comp/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 78 with CompositeName

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

the class NamingContextTestCase method testCreateSubcontext.

@Test
public void testCreateSubcontext() throws Exception {
    assertTrue(namingContext.createSubcontext(new CompositeName("test")) instanceof NamingContext);
    //the same with security permissions
    assertTrue(testActionPermission(JndiPermission.ACTION_CREATE_SUBCONTEXT, namingContext, "securitytest") instanceof NamingContext);
}
Also used : CompositeName(javax.naming.CompositeName) Test(org.junit.Test)

Example 79 with CompositeName

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

the class NamingContextTestCase method testLookupReference.

@Test
public void testLookupReference() throws Exception {
    final Name name = new CompositeName("test");
    final Reference reference = new Reference(String.class.getName(), new StringRefAddr("blah", "test"), TestObjectFactory.class.getName(), null);
    namingStore.bind(name, reference);
    Object result = namingContext.lookup(name);
    assertEquals("test", result);
    //the same with security permissions
    result = testActionPermission(JndiPermission.ACTION_LOOKUP, namingContext, "test");
    assertEquals("test", result);
}
Also used : StringRefAddr(javax.naming.StringRefAddr) Reference(javax.naming.Reference) CompositeName(javax.naming.CompositeName) CompositeName(javax.naming.CompositeName) Name(javax.naming.Name) Test(org.junit.Test)

Example 80 with CompositeName

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

the class NamingContextTestCase method testRebind.

@Test
public void testRebind() throws Exception {
    final Name name = new CompositeName("test");
    final Object value = new Object();
    namingStore.bind(name, value);
    Object newValue = new Object();
    namingContext.rebind(name, newValue);
    assertEquals(newValue, namingStore.lookup(name));
    //the same with security permissions
    newValue = new Object();
    testActionPermission(JndiPermission.ACTION_REBIND, namingContext, "test", newValue);
    assertEquals(newValue, namingStore.lookup(name));
}
Also used : CompositeName(javax.naming.CompositeName) CompositeName(javax.naming.CompositeName) Name(javax.naming.Name) 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