Search in sources :

Example 1 with JavaClassComparator

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());
        }
    }
}
Also used : JavaClassComparator(com.ibm.j9ddr.view.dtfj.comparators.JavaClassComparator) JavaClassLoader(com.ibm.dtfj.java.JavaClassLoader) JavaClass(com.ibm.dtfj.java.JavaClass) Iterator(java.util.Iterator) Test(org.junit.Test)

Aggregations

JavaClass (com.ibm.dtfj.java.JavaClass)1 JavaClassLoader (com.ibm.dtfj.java.JavaClassLoader)1 JavaClassComparator (com.ibm.j9ddr.view.dtfj.comparators.JavaClassComparator)1 Iterator (java.util.Iterator)1 Test (org.junit.Test)1