Search in sources :

Example 36 with NameNotFoundException

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

the class InMemoryNamingStoreTestCase method testRebindInvalidContext.

@Test
public void testRebindInvalidContext() throws Exception {
    try {
        nameStore.rebind(new CompositeName("subcontext/test"), new Object(), Object.class);
        fail("Should have thrown and NameNotFoundException");
    } catch (NameNotFoundException expected) {
    }
}
Also used : NameNotFoundException(javax.naming.NameNotFoundException) CompositeName(javax.naming.CompositeName) Test(org.junit.Test)

Example 37 with NameNotFoundException

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

the class InMemoryNamingStoreTestCase method testBindUnbindLookup.

@Test
public void testBindUnbindLookup() throws Exception {
    final Name name = new CompositeName("test");
    final Object object = new Object();
    nameStore.bind(name, object, Object.class);
    final Object result = nameStore.lookup(name);
    assertEquals(object, result);
    nameStore.unbind(name);
    try {
        nameStore.lookup(name);
        fail("Should have thrown and NameNotFoundException");
    } catch (NameNotFoundException expected) {
    }
}
Also used : NameNotFoundException(javax.naming.NameNotFoundException) CompositeName(javax.naming.CompositeName) CompositeName(javax.naming.CompositeName) Name(javax.naming.Name) Test(org.junit.Test)

Example 38 with NameNotFoundException

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

the class InMemoryNamingStoreTestCase method testListNameNotFound.

@Test
public void testListNameNotFound() throws Exception {
    try {
        nameStore.list(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 39 with NameNotFoundException

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

the class OptionalEnvEntryBean method checkLookup.

public void checkLookup() {
    try {
        InitialContext ctx = new InitialContext();
        ctx.lookup("java:comp/env/entry");
        throw new RuntimeException("Should have thrown a NameNotFoundException");
    } catch (NameNotFoundException e) {
    // okay
    } catch (NamingException e) {
        throw new RuntimeException(e);
    }
}
Also used : NameNotFoundException(javax.naming.NameNotFoundException) NamingException(javax.naming.NamingException) InitialContext(javax.naming.InitialContext)

Example 40 with NameNotFoundException

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

the class EEConcurrentManagementTestCase method testManagedScheduledExecutorServiceManagement.

@Test
public void testManagedScheduledExecutorServiceManagement() throws Exception {
    final PathAddress pathAddress = EE_SUBSYSTEM_PATH_ADDRESS.append(EESubsystemModel.MANAGED_SCHEDULED_EXECUTOR_SERVICE, RESOURCE_NAME);
    // add
    final ModelNode addOperation = Util.createAddOperation(pathAddress);
    final String jndiName = "java:jboss/ee/concurrency/scheduledexecutor/" + RESOURCE_NAME;
    addOperation.get(ManagedScheduledExecutorServiceResourceDefinition.JNDI_NAME).set(jndiName);
    addOperation.get(ManagedScheduledExecutorServiceResourceDefinition.CORE_THREADS).set(2);
    final ModelNode addResult = managementClient.getControllerClient().execute(addOperation);
    Assert.assertFalse(addResult.get(FAILURE_DESCRIPTION).toString(), addResult.get(FAILURE_DESCRIPTION).isDefined());
    try {
        // lookup
        Assert.assertNotNull(new InitialContext().lookup(jndiName));
    } finally {
        // remove
        final ModelNode removeOperation = Util.createRemoveOperation(pathAddress);
        removeOperation.get(OPERATION_HEADERS, ALLOW_RESOURCE_SERVICE_RESTART).set(true);
        final ModelNode removeResult = managementClient.getControllerClient().execute(removeOperation);
        Assert.assertFalse(removeResult.get(FAILURE_DESCRIPTION).toString(), removeResult.get(FAILURE_DESCRIPTION).isDefined());
        try {
            new InitialContext().lookup(jndiName);
            Assert.fail();
        } catch (NameNotFoundException e) {
        // expected
        }
    }
}
Also used : NameNotFoundException(javax.naming.NameNotFoundException) PathAddress(org.jboss.as.controller.PathAddress) ModelNode(org.jboss.dmr.ModelNode) InitialContext(javax.naming.InitialContext) 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