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));
}
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);
}
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);
}
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);
}
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));
}
Aggregations