Search in sources :

Example 31 with NameNotFoundException

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

the class WritableServiceBasedNamingStoreTestCase method testUnbind.

@Test
public void testUnbind() throws Exception {
    final Name name = new CompositeName("test");
    final Object value = new Object();
    WritableServiceBasedNamingStore.pushOwner(OWNER_FOO);
    try {
        store.bind(name, value);
        store.unbind(name);
    } finally {
        WritableServiceBasedNamingStore.popOwner();
    }
    try {
        store.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) ServiceName(org.jboss.msc.service.ServiceName) Test(org.junit.Test)

Example 32 with NameNotFoundException

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

the class WritableServiceBasedNamingStoreTestCase method testMultipleOwnersBindingReferences.

@Test
public void testMultipleOwnersBindingReferences() 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) {
    }
    // ensure the owners RuntimeBindReleaseService have no reference to the future bind
    final RuntimeBindReleaseService.References fooDuBindingReferences = (RuntimeBindReleaseService.References) container.getService(JndiNamingDependencyProcessor.serviceName(OWNER_FOO)).getValue();
    assertFalse(fooDuBindingReferences.contains(serviceName));
    final RuntimeBindReleaseService.References barDuBindingReferences = (RuntimeBindReleaseService.References) container.getService(JndiNamingDependencyProcessor.serviceName(OWNER_BAR)).getValue();
    assertFalse(barDuBindingReferences.contains(serviceName));
    WritableServiceBasedNamingStore.pushOwner(OWNER_FOO);
    try {
        store.bind(name, value);
        // Foo's RuntimeBindReleaseService should now have a reference to the new bind
        assertTrue(fooDuBindingReferences.contains(serviceName));
        // Bar's RuntimeBindReleaseService reference to the bind should not exist
        assertFalse(barDuBindingReferences.contains(serviceName));
    } finally {
        WritableServiceBasedNamingStore.popOwner();
    }
    WritableServiceBasedNamingStore.pushOwner(OWNER_BAR);
    try {
        store.rebind(name, value);
        // after rebind, Foo's RuntimeBindReleaseService reference to the bind should still exist
        assertTrue(fooDuBindingReferences.contains(serviceName));
        // after rebind, Bar's RuntimeBindReleaseService reference to the bind should now exist
        assertTrue(barDuBindingReferences.contains(serviceName));
    } finally {
        WritableServiceBasedNamingStore.popOwner();
    }
    WritableServiceBasedNamingStore.pushOwner(OWNER_FOO);
    try {
        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 33 with NameNotFoundException

use of javax.naming.NameNotFoundException 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 34 with NameNotFoundException

use of javax.naming.NameNotFoundException 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)

Example 35 with NameNotFoundException

use of javax.naming.NameNotFoundException 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)

Aggregations

NameNotFoundException (javax.naming.NameNotFoundException)112 InitialContext (javax.naming.InitialContext)56 Context (javax.naming.Context)51 NamingException (javax.naming.NamingException)51 Test (org.junit.Test)36 Name (javax.naming.Name)33 Reference (javax.naming.Reference)27 NotContextException (javax.naming.NotContextException)24 NameAlreadyBoundException (javax.naming.NameAlreadyBoundException)23 CompositeName (javax.naming.CompositeName)22 Binding (javax.naming.Binding)21 OperationNotSupportedException (javax.naming.OperationNotSupportedException)21 CompoundName (javax.naming.CompoundName)16 NamingContext (org.eclipse.jetty.jndi.NamingContext)12 IOException (java.io.IOException)11 InvalidNameException (javax.naming.InvalidNameException)7 ContainerSystem (org.apache.openejb.spi.ContainerSystem)7 ArrayList (java.util.ArrayList)6 LinkRef (javax.naming.LinkRef)6 Properties (java.util.Properties)5