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