Search in sources :

Example 86 with Name

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

the class InMemoryNamingStoreTestCase method testBindAndRebind.

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

Example 87 with Name

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

the class InMemoryNamingStoreTestCase method testBindAndLookup.

@Test
public void testBindAndLookup() 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);
}
Also used : CompositeName(javax.naming.CompositeName) CompositeName(javax.naming.CompositeName) Name(javax.naming.Name) Test(org.junit.Test)

Example 88 with Name

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

the class NamingContextTestCase method testLookupLink.

@Test
public void testLookupLink() throws Exception {
    final Name name = new CompositeName("test");
    namingStore.bind(name, "testValue", String.class);
    final Name linkName = new CompositeName("link");
    namingStore.bind(linkName, new LinkRef("./test"));
    Object result = namingContext.lookup(linkName);
    assertEquals("testValue", result);
    //the same with security permissions
    result = testActionPermission(JndiPermission.ACTION_LOOKUP, Arrays.asList(new JndiPermission("test", "lookup")), namingContext, "link");
    assertEquals("testValue", result);
    System.setProperty(Context.INITIAL_CONTEXT_FACTORY, InitialContextFactory.class.getName());
    namingStore.rebind(linkName, new LinkRef(name));
    result = namingContext.lookup(linkName);
    assertEquals("testValue", result);
    //the same with security permissions
    result = testActionPermission(JndiPermission.ACTION_LOOKUP, Arrays.asList(new JndiPermission("test", "lookup")), namingContext, "link");
    assertEquals("testValue", result);
}
Also used : CompositeName(javax.naming.CompositeName) JndiPermission(org.wildfly.naming.java.permission.JndiPermission) CompositeName(javax.naming.CompositeName) Name(javax.naming.Name) LinkRef(javax.naming.LinkRef) Test(org.junit.Test)

Example 89 with Name

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

the class NamingContextTestCase method testLookup.

@Test
public void testLookup() throws Exception {
    final Name name = new CompositeName("test");
    final Object object = new Object();
    namingStore.bind(name, object);
    Object result = namingContext.lookup(name);
    assertEquals(object, result);
    //the same with security permissions
    result = testActionPermission(JndiPermission.ACTION_LOOKUP, namingContext, "test");
    assertEquals(object, result);
}
Also used : CompositeName(javax.naming.CompositeName) CompositeName(javax.naming.CompositeName) Name(javax.naming.Name) Test(org.junit.Test)

Example 90 with Name

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

the class WritableServiceBasedNamingStoreTestCase method testRebind.

@Test
public void testRebind() throws Exception {
    final Name name = new CompositeName("test");
    final Object value = new Object();
    final Object newValue = new Object();
    WritableServiceBasedNamingStore.pushOwner(OWNER_FOO);
    try {
        store.bind(name, value);
        store.rebind(name, newValue);
    } finally {
        WritableServiceBasedNamingStore.popOwner();
    }
    assertEquals(newValue, 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)

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