Search in sources :

Example 6 with CustomTokenClassLoader

use of CustomCLs.CustomTokenClassLoader in project openj9 by eclipse.

the class TimeStampingTest method executeTest.

public boolean executeTest(String[] urls, String[][] classesToLoad, String[][] classesToFind, String[][] results, String batchFile, String javacpath) {
    String urlsString = urls[0];
    for (int index = 1; index < urls.length; index++) {
        urlsString = new StringBuffer(urls[index].length() + 1).append(urlsString).append(urls[index]).toString();
    }
    System.out.println("\n** urlsString: " + urlsString);
    URLClassPathCreator creator = new URLClassPathCreator(urlsString);
    URL[] urlPath;
    urlPath = creator.createURLClassPath();
    CustomTokenClassLoader cl = new CustomTokenClassLoader(urlPath, this.getClass().getClassLoader());
    String token = new String("TimeStamping");
    cl.setToken(token);
    for (int urlIndex = 0; urlIndex < urls.length; urlIndex++) {
        for (int classIndex = 0; classIndex < classesToLoad[urlIndex].length; classIndex++) {
            String classToLoad = classesToLoad[urlIndex][classIndex];
            if (classToLoad != null) {
                try {
                    cl.loadClass(classToLoad);
                } catch (ClassNotFoundException e) {
                    e.printStackTrace();
                }
            }
        }
    }
    runBatchFile(batchFile, javacpath);
    boolean result = true;
    for (int urlIndex = 0; urlIndex < urls.length; urlIndex++) {
        for (int classIndex = 0; classIndex < classesToFind[urlIndex].length; classIndex++) {
            String classToFind = classesToFind[urlIndex][classIndex];
            String expectedResult = results[urlIndex][classIndex];
            if (classToFind != null) {
                String testResult = String.valueOf(cl.isClassInSharedCache(token, classToFind));
                if (!(expectedResult.equals(testResult))) {
                    System.out.println("\nFailure finding class: " + classToFind + " on path: " + urls[urlIndex] + " which is index: " + urlIndex + " result: " + testResult + " expecting: " + expectedResult);
                    result = false;
                }
            }
        }
    }
    return result;
}
Also used : CustomTokenClassLoader(CustomCLs.CustomTokenClassLoader) URLClassPathCreator(Utilities.URLClassPathCreator) URL(java.net.URL)

Aggregations

CustomTokenClassLoader (CustomCLs.CustomTokenClassLoader)6 URLClassPathCreator (Utilities.URLClassPathCreator)6 URL (java.net.URL)3 CustomURLClassLoader (CustomCLs.CustomURLClassLoader)1 CustomURLLoader (CustomCLs.CustomURLLoader)1 HelperAlreadyDefinedException (com.ibm.oti.shared.HelperAlreadyDefinedException)1