use of javax.naming.NameClassPair in project wildfly by wildfly.
the class ServiceBasedNamingStoreTestCase method testList.
@Test
public void testList() throws Exception {
final Object value = new Object();
bindObject(ServiceName.JBOSS.append("TestBean"), value);
bindObject(ServiceName.JBOSS.append("foo", "TestBean"), value);
bindObject(ServiceName.JBOSS.append("foo", "bar", "TestBean"), value);
bindObject(ServiceName.JBOSS.append("foo", "bar", "baz", "TestBean"), value);
store.add(ServiceName.JBOSS.append("foos", "bar"));
store.add(ServiceName.JBOSS.append("fo", "bar"));
store.add(ServiceName.JBOSS.append("foo", "ba", "baz"));
store.add(ServiceName.JBOSS.append("foo", "bart", "baz"));
store.add(ServiceName.JBOSS.append("foo", "bar", "ba"));
store.add(ServiceName.JBOSS.append("foo", "bar", "bazt"));
store.add(ServiceName.JBOSS.append("foo", "bar", "art"));
store.add(ServiceName.JBOSS.append("other", "one"));
List<NameClassPair> list = store.list(new CompositeName(""));
assertEquals(5, list.size());
assertContains(list, "TestBean", Object.class);
assertContains(list, "foo", Context.class);
assertContains(list, "fo", Context.class);
assertContains(list, "foos", Context.class);
assertContains(list, "other", Context.class);
list = store.list(new CompositeName("foo"));
assertEquals(4, list.size());
assertContains(list, "TestBean", Object.class);
assertContains(list, "ba", Context.class);
assertContains(list, "bart", Context.class);
assertContains(list, "bar", Context.class);
}
use of javax.naming.NameClassPair in project wildfly by wildfly.
the class NamingContextTestCase method testList.
@Test
@SuppressWarnings("unchecked")
public void testList() throws Exception {
bindList();
NamingEnumeration<NameClassPair> results = namingContext.list(new CompositeName());
checkListResults(results);
// the same with security permissions
results = (NamingEnumeration<NameClassPair>) testActionPermission(JndiPermission.ACTION_LIST, namingContext, null);
checkListResults(results);
}
use of javax.naming.NameClassPair in project wildfly by wildfly.
the class InMemoryNamingStoreTestCase method testList.
@Test
public void testList() throws Exception {
final Name name = new CompositeName("test");
final Object object = new Object();
nameStore.bind(name, object, Object.class);
final Name nameTwo = new CompositeName("testTwo");
final Object objectTwo = new Object();
nameStore.bind(nameTwo, objectTwo, Object.class);
final Name nameThree = new CompositeName("testThree");
final Object objectThree = new Object();
nameStore.bind(nameThree, objectThree, Object.class);
nameStore.bind(new CompositeName("testContext/test"), "test");
final List<NameClassPair> results = nameStore.list(new CompositeName());
assertEquals(4, results.size());
final Set<String> expected = new HashSet<String>(Arrays.asList("test", "testTwo", "testThree", "testContext"));
for (NameClassPair result : results) {
final String resultName = result.getName();
if ("test".equals(resultName) || "testTwo".equals(resultName) || "testThree".equals(resultName)) {
assertEquals(Object.class.getName(), result.getClassName());
} 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.NameClassPair in project aries by apache.
the class ServiceRegistryContextTest method checkServiceListList.
@Test
public void checkServiceListList() throws NamingException {
BundleMock mock = new BundleMock("scooby.doo", new Properties());
Thread.currentThread().setContextClassLoader(mock.getClassLoader());
InitialContext ctx = new InitialContext();
String className = Runnable.class.getName();
Runnable t = Skeleton.newMock(Runnable.class);
// we don't want the default service
reg.unregister();
ServiceRegistration reg = bc.registerService(className, t, null);
ServiceRegistration reg2 = bc.registerService(className, new Thread(), null);
NamingEnumeration<NameClassPair> ne = ctx.list("osgi:servicelist/" + className);
assertTrue(ne.hasMoreElements());
NameClassPair ncp = ne.nextElement();
assertEquals(String.valueOf(reg.getReference().getProperty(Constants.SERVICE_ID)), ncp.getName());
assertTrue("Class name not correct. Was: " + ncp.getClassName(), ncp.getClassName().contains("Proxy"));
assertTrue(ne.hasMoreElements());
ncp = ne.nextElement();
assertEquals(String.valueOf(reg2.getReference().getProperty(Constants.SERVICE_ID)), ncp.getName());
assertEquals("Class name not correct.", Thread.class.getName(), ncp.getClassName());
assertFalse(ne.hasMoreElements());
}
use of javax.naming.NameClassPair in project pentaho-kettle by pentaho.
the class LDAPConnection method getPaths.
@SuppressWarnings("rawtypes")
private void getPaths(String rootName, Map<String, Attributes> childs, List<String> paths) throws Exception {
NamingEnumeration ne = getInitialContext().list(rootName);
while (ne.hasMore()) {
NameClassPair nameCP = (NameClassPair) ne.next();
childs.put(nameCP.getName() + "," + rootName, getInitialContext().getAttributes(nameCP.getName() + "," + rootName));
getPaths(nameCP.getName() + "," + rootName, childs, paths);
paths.add(nameCP.getName() + "," + rootName);
}
}
Aggregations