use of javax.naming.NameClassPair in project tomee by apache.
the class JndiTest method assertNameClassPair.
private void assertNameClassPair(NamingEnumeration<NameClassPair> namingEnumeration) {
assertNotNull("namingEnumeration", namingEnumeration);
Map<String, String> map = new HashMap<String, String>();
while (namingEnumeration.hasMoreElements()) {
NameClassPair pair = namingEnumeration.nextElement();
map.put(pair.getName(), pair.getClassName());
}
assertTrue("OrangeRemote", map.containsKey("OrangeRemote"));
assertTrue("AppleRemote", map.containsKey("AppleRemote"));
assertTrue("PeachRemote", map.containsKey("PeachRemote"));
assertTrue("PearRemote", map.containsKey("PearRemote"));
assertTrue("PlumRemote", map.containsKey("PlumRemote"));
}
use of javax.naming.NameClassPair in project tomee by apache.
the class IvmContextTest method testListContextListsAllFederatedContextBindings.
public void testListContextListsAllFederatedContextBindings() throws SystemException, NamingException {
// mimic logic from EnterpriseBeanBuilder.build, create compJndiContext and bind in it module, app, global
Context compContext = new IvmContext();
compContext.bind("java:comp/env/dummy", "dummy");
Context moduleContext = new IvmContext();
moduleContext.bind("module/env/test", String.class);
moduleContext.bind("module/env/sub/test2", String.class);
Context originalModuleSubContext = (IvmContext) moduleContext.lookup("module");
compContext.bind("module", originalModuleSubContext);
Context referencedModuleEnvSubContext = (IvmContext) compContext.lookup("module/env");
NamingEnumeration<NameClassPair> referencedEnvLookupResult = referencedModuleEnvSubContext.list("");
boolean testFound = false;
boolean subFound = false;
while (referencedEnvLookupResult.hasMore()) {
String currentName = referencedEnvLookupResult.next().getName();
if ("test".equals(currentName)) {
testFound = true;
} else if ("sub".equals(currentName)) {
subFound = true;
} else {
fail();
}
}
assertTrue(testFound);
assertTrue(subFound);
}
use of javax.naming.NameClassPair in project tomee by apache.
the class NameClassPairEnumeration method writeExternal.
@Override
public void writeExternal(final ObjectOutput out) throws IOException {
// write out the version of the serialized data for future use
out.writeByte(1);
out.writeInt(list.size());
for (final NameClassPair pair : list) {
out.writeObject(pair.getName());
out.writeObject(pair.getClassName());
}
}
use of javax.naming.NameClassPair in project aries by apache.
the class BlueprintURLContextTest method testList.
/**
* Validate that list() function works for BlueprintURLContext.
* This returns an enumeration of component id -> component class name pairs
*/
@Test
public void testList() throws Exception {
InitialContext ctx = new InitialContext();
NamingEnumeration<NameClassPair> compList = ctx.list("blueprint:comp");
Set<String> expectedCompIds = new BlueprintContainerStub().getComponentIds();
while (compList.hasMore()) {
NameClassPair ncp = compList.next();
String compId = ncp.getName();
String compClass = ncp.getClassName();
if (compId.equals("comp1")) {
assertEquals("comp1 class wrong in list", SimpleComponent.class.getName(), compClass);
} else if (compId.equals("comp2")) {
assertEquals("comp2 class wrong in list", AnotherComponent.class.getName(), compClass);
}
expectedCompIds.remove(compId);
}
assertEquals("Not all expected components were found", expectedCompIds.size(), 0);
}
use of javax.naming.NameClassPair in project aries by apache.
the class ServiceRegistryContextTest method listRepositoryContents.
/**
* This test checks that we can list the contents of the repository using the
* list method
*
* @throws NamingException
*/
public void listRepositoryContents() throws NamingException {
InitialContext ctx = new InitialContext();
NamingEnumeration<NameClassPair> serviceList = ctx.list("osgi:service/java.lang.Runnable/(rubbish=smelly)");
checkThreadRetrievedViaListMethod(serviceList);
assertFalse("The repository contained more objects than we expected", serviceList.hasMoreElements());
// Now add a second service
registerService(new Thread());
serviceList = ctx.list("osgi:service/java.lang.Runnable/(rubbish=smelly)");
checkThreadRetrievedViaListMethod(serviceList);
checkThreadRetrievedViaListMethod(serviceList);
assertFalse("The repository contained more objects than we expected", serviceList.hasMoreElements());
}
Aggregations