use of com.ibm.j9ddr.view.dtfj.comparators.JavaClassComparator in project openj9 by eclipse.
the class JavaClassLoaderTest method findClassTest.
@SuppressWarnings("unchecked")
@Test
public void findClassTest() throws Exception {
JavaClassComparator comparator = new JavaClassComparator();
assertEquals(jextractTestObjects.size(), ddrTestObjects.size());
for (int i = 0; i < ddrTestObjects.size(); i++) {
JavaClassLoader ddrLoader = (JavaClassLoader) ddrTestObjects.get(i);
JavaClassLoader jextractLoader = (JavaClassLoader) jextractTestObjects.get(i);
Iterator ddrClasses = ddrLoader.getDefinedClasses();
// loop the defined classes trying to find each one
Iterator jextractClasses = jextractLoader.getDefinedClasses();
while (ddrClasses.hasNext() || jextractClasses.hasNext()) {
assertTrue("DDR classloader has less items than the jextract equivalent : " + ddrLoader.toString(), ddrClasses.hasNext());
assertTrue("Jextract classloader has less items than the jextract equivalent : " + jextractLoader.toString(), jextractClasses.hasNext());
JavaClass ddrClass = (JavaClass) ddrClasses.next();
JavaClass jextractClass = (JavaClass) jextractClasses.next();
assertEquals("Different class names : ddr = " + ddrClass.getName() + " jx = " + jextractClass.getName(), jextractClass.getName(), ddrClass.getName());
String name = ddrClass.getName();
JavaClass ddrFound = ddrLoader.findClass(name);
assertNotNull("DDR loader could not find class : " + name, ddrFound);
JavaClass jextractFound = jextractLoader.findClass(name);
assertNotNull("JX loader could not find class : " + name, jextractFound);
comparator.testEquals(ddrFound, jextractFound, javaClassComparator.getDefaultMask());
}
}
}
Aggregations