Search in sources :

Example 51 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 52 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 53 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 54 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 55 with NameNotFoundException

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

the class BusinessViewAnnotationProcessorTestCase method testEJB32MultipleLocalViews.

/**
 * Tests that if a bean has a {@link javax.ejb.Local} annotation without any specific value and if the bean implements n (valid) interfaces, then all those n (valid) interfaces are considered
 * as local business interfaces
 *
 * @throws Exception
 */
@Test
public void testEJB32MultipleLocalViews() throws Exception {
    final Context ctx = new InitialContext();
    final One interfaceOne = (One) ctx.lookup("java:module/" + MultipleLocalViewBean.class.getSimpleName() + "!" + One.class.getName());
    assertNotNull("View " + One.class.getName() + " not found", interfaceOne);
    final Two interfaceTwo = (Two) ctx.lookup("java:module/" + MultipleLocalViewBean.class.getSimpleName() + "!" + Two.class.getName());
    assertNotNull("View " + Two.class.getName() + " not found", interfaceTwo);
    final Three interfaceThree = (Three) ctx.lookup("java:module/" + MultipleLocalViewBean.class.getSimpleName() + "!" + Three.class.getName());
    assertNotNull("View " + Three.class.getName() + " not found", interfaceThree);
    try {
        final Object view = ctx.lookup("java:module/" + MultipleLocalViewBean.class.getSimpleName() + "!" + Serializable.class.getName());
        Assert.fail("Unexpected view found: " + view + " for interface " + Serializable.class.getName());
    } catch (NameNotFoundException nnfe) {
    // expected
    }
    try {
        final Object view = ctx.lookup("java:module/" + MultipleLocalViewBean.class.getSimpleName() + "!" + Externalizable.class.getName());
        Assert.fail("Unexpected view found: " + view + " for interface " + Externalizable.class.getName());
    } catch (NameNotFoundException nnfe) {
    // expected
    }
}
Also used : InitialContext(javax.naming.InitialContext) Context(javax.naming.Context) NameNotFoundException(javax.naming.NameNotFoundException) InitialContext(javax.naming.InitialContext) Test(org.junit.Test)

Aggregations

NameNotFoundException (javax.naming.NameNotFoundException)168 NamingException (javax.naming.NamingException)81 InitialContext (javax.naming.InitialContext)75 Context (javax.naming.Context)71 Reference (javax.naming.Reference)40 Test (org.junit.Test)39 NotContextException (javax.naming.NotContextException)35 Name (javax.naming.Name)34 NameAlreadyBoundException (javax.naming.NameAlreadyBoundException)33 OperationNotSupportedException (javax.naming.OperationNotSupportedException)29 CompositeName (javax.naming.CompositeName)27 Binding (javax.naming.Binding)22 CompoundName (javax.naming.CompoundName)16 LinkRef (javax.naming.LinkRef)16 IOException (java.io.IOException)12 NamingContext (org.eclipse.jetty.jndi.NamingContext)12 ArrayList (java.util.ArrayList)10 InvalidNameException (javax.naming.InvalidNameException)10 Attributes (javax.naming.directory.Attributes)10 HashMap (java.util.HashMap)7