Search in sources :

Example 36 with Name

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

the class WritableServiceBasedNamingStoreTestCase method testBind.

@Test
public void testBind() throws Exception {
    final Name name = new CompositeName("test");
    final Object value = new Object();
    WritableServiceBasedNamingStore.pushOwner(OWNER_FOO);
    try {
        store.bind(name, value);
    } finally {
        WritableServiceBasedNamingStore.popOwner();
    }
    assertEquals(value, store.lookup(name));
}
Also used : CompositeName(javax.naming.CompositeName) CompositeName(javax.naming.CompositeName) Name(javax.naming.Name) ServiceName(org.jboss.msc.service.ServiceName) Test(org.junit.Test)

Example 37 with Name

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

the class WritableServiceBasedNamingStoreTestCase method testBindNested.

@Test
public void testBindNested() throws Exception {
    final Name name = new CompositeName("nested/test");
    final Object value = new Object();
    WritableServiceBasedNamingStore.pushOwner(OWNER_FOO);
    try {
        store.bind(name, value);
    } finally {
        WritableServiceBasedNamingStore.popOwner();
    }
    assertEquals(value, store.lookup(name));
}
Also used : CompositeName(javax.naming.CompositeName) CompositeName(javax.naming.CompositeName) Name(javax.naming.Name) ServiceName(org.jboss.msc.service.ServiceName) Test(org.junit.Test)

Example 38 with Name

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

the class InMemoryNamingStoreTestCase method testRebindAndLookup.

@Test
public void testRebindAndLookup() throws Exception {
    final Name name = new CompositeName("test");
    final Object object = new Object();
    nameStore.rebind(name, object, Object.class);
    final Object result = nameStore.lookup(name);
    assertEquals(object, result);
}
Also used : CompositeName(javax.naming.CompositeName) CompositeName(javax.naming.CompositeName) Name(javax.naming.Name) Test(org.junit.Test)

Example 39 with Name

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

the class InMemoryNamingStoreTestCase method testListBindings.

@Test
public void testListBindings() throws Exception {
    final Name name = new CompositeName("test");
    final Object object = new Object();
    nameStore.bind(name, object);
    final Name nameTwo = new CompositeName("testTwo");
    final Object objectTwo = new Object();
    nameStore.bind(nameTwo, objectTwo);
    final Name nameThree = new CompositeName("testThree");
    final Object objectThree = new Object();
    nameStore.bind(nameThree, objectThree);
    nameStore.bind(new CompositeName("testContext/test"), "test");
    final List<Binding> results = nameStore.listBindings(new CompositeName());
    assertEquals(4, results.size());
    final Set<String> expected = new HashSet<String>(Arrays.asList("test", "testTwo", "testThree", "testContext"));
    for (Binding result : results) {
        final String resultName = result.getName();
        if ("test".equals(resultName)) {
            assertEquals(Object.class.getName(), result.getClassName());
            assertEquals(object, result.getObject());
        } else if ("testTwo".equals(resultName)) {
            assertEquals(Object.class.getName(), result.getClassName());
            assertEquals(objectTwo, result.getObject());
        } else if ("testThree".equals(resultName)) {
            assertEquals(Object.class.getName(), result.getClassName());
            assertEquals(objectThree, result.getObject());
        } else if ("testContext".equals(resultName)) {
            assertEquals(Context.class.getName(), result.getClassName());
        } else {
            fail("Unknown result name: " + resultName);
        }
        expected.remove(resultName);
    }
    assertTrue("Not all expected results were returned", expected.isEmpty());
}
Also used : Binding(javax.naming.Binding) CompositeName(javax.naming.CompositeName) CompositeName(javax.naming.CompositeName) Name(javax.naming.Name) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 40 with Name

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

the class NamingContextTestCase method bindListWithContinuations.

private void bindListWithContinuations() throws NamingException {
    final Name name = new CompositeName("test/test");
    final Object object = new Object();
    namingStore.bind(name, object);
    final Name nameTwo = new CompositeName("test/testTwo");
    final Object objectTwo = new Object();
    namingStore.bind(nameTwo, objectTwo);
    final Name nameThree = new CompositeName("test/testThree");
    final Object objectThree = new Object();
    namingStore.bind(nameThree, objectThree);
    final Reference reference = new Reference(String.class.getName(), new StringRefAddr("nns", "test"), TestObjectFactoryWithNameResolution.class.getName(), null);
    namingStore.bind(new CompositeName("comp"), reference);
}
Also used : StringRefAddr(javax.naming.StringRefAddr) Reference(javax.naming.Reference) CompositeName(javax.naming.CompositeName) CompositeName(javax.naming.CompositeName) Name(javax.naming.Name)

Aggregations

Name (javax.naming.Name)107 CompositeName (javax.naming.CompositeName)48 NamingException (javax.naming.NamingException)38 Context (javax.naming.Context)37 InitialContext (javax.naming.InitialContext)36 NameNotFoundException (javax.naming.NameNotFoundException)34 Test (org.junit.Test)32 Reference (javax.naming.Reference)24 NotContextException (javax.naming.NotContextException)22 Binding (javax.naming.Binding)19 CompoundName (javax.naming.CompoundName)19 NameAlreadyBoundException (javax.naming.NameAlreadyBoundException)19 NameParser (javax.naming.NameParser)17 OperationNotSupportedException (javax.naming.OperationNotSupportedException)16 InvalidNameException (javax.naming.InvalidNameException)10 NamingContext (org.eclipse.jetty.jndi.NamingContext)10 IOException (java.io.IOException)8 LinkRef (javax.naming.LinkRef)7 ServiceName (org.jboss.msc.service.ServiceName)7 Referenceable (javax.naming.Referenceable)6