use of javax.naming.CompositeName 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.CompositeName 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) {
}
}
use of javax.naming.CompositeName 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);
}
use of javax.naming.CompositeName in project wildfly by wildfly.
the class NamingContextTestCase method testListWithContinuation.
@Test
@SuppressWarnings("unchecked")
public void testListWithContinuation() throws Exception {
bindListWithContinuations();
NamingEnumeration<NameClassPair> results = namingContext.list(new CompositeName("comp"));
checkListWithContinuationsResults(results);
//the same with security permissions
results = (NamingEnumeration<NameClassPair>) testActionPermission(JndiPermission.ACTION_LIST, Arrays.asList(new JndiPermission("test", "list")), namingContext, "comp");
checkListWithContinuationsResults(results);
}
use of javax.naming.CompositeName in project wildfly by wildfly.
the class NamingContextTestCase method testListBindingsNameNotFound.
@Test
public void testListBindingsNameNotFound() throws Exception {
try {
namingContext.listBindings(new CompositeName("test"));
fail("Should have thrown and NameNotFoundException");
} catch (NameNotFoundException expected) {
}
//the same with security permissions
try {
testActionPermission(JndiPermission.ACTION_LIST_BINDINGS, namingContext, "test");
fail("Should have thrown and NameNotFoundException with appropriate permissions");
} catch (NameNotFoundException expected) {
}
}
Aggregations