Search in sources :

Example 1 with CustomURLLoader

use of CustomCLs.CustomURLLoader in project openj9 by eclipse.

the class URLHelperURLClassPathHelperStaleEntryCompatibilityTest method executeTest.

private boolean executeTest(String[] urls, String[][] classesToLoad, String classPath, String[] classesToFind, String[] results, String batchFile, String[] foundAt, 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]).append(File.pathSeparatorChar).toString();
    }
    System.out.println("\n** urlsString: " + urlsString);
    URLClassPathCreator creator = new URLClassPathCreator(urlsString);
    URL[] urlPath;
    urlPath = creator.createURLClassPath();
    CustomURLLoader[] loaderArray = new CustomURLLoader[urls.length];
    for (int urlIndex = 0; urlIndex < urls.length; urlIndex++) {
        for (int classIndex = 0; classIndex < classesToLoad[urlIndex].length; classIndex++) {
            loaderArray[urlIndex] = new CustomURLLoader(urlPath, this.getClass().getClassLoader());
            String classToLoad = classesToLoad[urlIndex][classIndex];
            if (classToLoad != null) {
                loaderArray[urlIndex].loadClassFrom(classToLoad, urlIndex);
            }
        }
    }
    runBatchFile(batchFile, javacpath);
    boolean result = true;
    URLClassPathCreator creator2 = new URLClassPathCreator(classPath);
    URL[] urlPath2;
    urlPath2 = creator2.createURLClassPath();
    CustomURLClassLoader cl = new CustomURLClassLoader(urlPath2, this.getClass().getClassLoader());
    for (int classIndex = 0; classIndex < classesToLoad.length; classIndex++) {
        String classToFind = classesToFind[classIndex];
        String expectedResult = results[classIndex];
        if (classToFind != null) {
            String testResult = String.valueOf(cl.isClassInSharedCache(classToFind));
            if (!(expectedResult.equals(testResult))) {
                System.out.println("\nFailure finding class: " + classToFind + " result: " + testResult + " expecting: " + expectedResult);
                result = false;
            } else {
                if (testResult.equals("true")) {
                    result = validateReturnedClass(classToFind, foundAt[classIndex], cl);
                }
            }
        }
    }
    return result;
}
Also used : CustomURLLoader(CustomCLs.CustomURLLoader) URLClassPathCreator(Utilities.URLClassPathCreator) CustomURLClassLoader(CustomCLs.CustomURLClassLoader) URL(java.net.URL)

Example 2 with CustomURLLoader

use of CustomCLs.CustomURLLoader in project openj9 by eclipse.

the class URLHelperURLClassPathHelperCompatibilityTest method executeTest.

private boolean executeTest(String[] urls, String[][] classesToLoad, String classPath, String[] classesToFind, String[] results, String[] foundAt) {
    String urlsString = urls[0];
    for (int index = 1; index < urls.length; index++) {
        urlsString = new StringBuffer(urls[index].length() + 1).append(urlsString).append(urls[index]).append(File.pathSeparatorChar).toString();
    }
    URLClassPathCreator creator = new URLClassPathCreator(urlsString);
    URL[] urlPath;
    urlPath = creator.createURLClassPath();
    CustomURLLoader[] loaderArray = new CustomURLLoader[urls.length];
    for (int urlIndex = 0; urlIndex < urls.length; urlIndex++) {
        for (int classIndex = 0; classIndex < classesToLoad[urlIndex].length; classIndex++) {
            loaderArray[urlIndex] = new CustomURLLoader(urlPath, this.getClass().getClassLoader());
            String classToLoad = classesToLoad[urlIndex][classIndex];
            if (classToLoad != null) {
                loaderArray[urlIndex].loadClassFrom(classToLoad, urlIndex);
            }
        }
    }
    boolean result = true;
    URLClassPathCreator creator2 = new URLClassPathCreator(classPath);
    URL[] urlPath2;
    urlPath2 = creator2.createURLClassPath();
    CustomURLClassLoader cl = new CustomURLClassLoader(urlPath2, this.getClass().getClassLoader());
    for (int classIndex = 0; classIndex < classesToLoad.length; classIndex++) {
        String classToFind = classesToFind[classIndex];
        String expectedResult = results[classIndex];
        if (classToFind != null) {
            String testResult = String.valueOf(cl.isClassInSharedCache(classToFind));
            if (!(expectedResult.equals(testResult))) {
                System.out.println("\nFailure finding class: " + classToFind + " result: " + testResult + " expecting: " + expectedResult);
                result = false;
            } else {
                if (testResult.equals("true")) {
                    result = validateReturnedClass(classToFind, foundAt[classIndex], cl);
                }
            }
        }
    }
    return result;
}
Also used : CustomURLLoader(CustomCLs.CustomURLLoader) URLClassPathCreator(Utilities.URLClassPathCreator) CustomURLClassLoader(CustomCLs.CustomURLClassLoader) URL(java.net.URL)

Example 3 with CustomURLLoader

use of CustomCLs.CustomURLLoader in project openj9 by eclipse.

the class URLClassPathHelperURLHelperCompatibilityTest method executeTest.

private boolean executeTest(String classPath, String[] classesToLoad, String[] urls, String[][] classesToFind, String[][] results) {
    URLClassPathCreator creator = new URLClassPathCreator(classPath);
    URL[] urlPath;
    urlPath = creator.createURLClassPath();
    CustomURLClassLoader cl = new CustomURLClassLoader(urlPath, this.getClass().getClassLoader());
    for (int classIndex = 0; classIndex < classesToLoad.length; classIndex++) {
        String classToLoad = classesToLoad[classIndex];
        if (classToLoad != null) {
            try {
                cl.loadClass(classToLoad);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    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 creator2 = new URLClassPathCreator(urlsString);
    URL[] urlPath2;
    urlPath2 = creator2.createURLClassPath();
    CustomURLLoader urlcl = new CustomURLLoader(urlPath2, this.getClass().getClassLoader());
    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(urlcl.isClassInSharedCache(urlIndex, 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 : CustomURLLoader(CustomCLs.CustomURLLoader) URLClassPathCreator(Utilities.URLClassPathCreator) CustomURLClassLoader(CustomCLs.CustomURLClassLoader) URL(java.net.URL)

Example 4 with CustomURLLoader

use of CustomCLs.CustomURLLoader in project openj9 by eclipse.

the class URLMultipleGetHelperCallTest method run.

public void run() {
    boolean result = false;
    URLClassPathCreator pathCreator = new URLClassPathCreator("./Pets;");
    CustomURLLoader loader = new CustomURLLoader(pathCreator.createURLClassPath());
    result = loader.getHelper();
    if (result == true) {
        System.out.println("\nTEST PASSED");
    } else {
        System.out.println("\nTEST FAILED");
    }
}
Also used : CustomURLLoader(CustomCLs.CustomURLLoader) URLClassPathCreator(Utilities.URLClassPathCreator)

Example 5 with CustomURLLoader

use of CustomCLs.CustomURLLoader in project openj9 by eclipse.

the class NullURLFindTest method run.

public void run() {
    boolean result = false;
    URLClassPathCreator pathCreator = new URLClassPathCreator("./Pets;");
    URL[] urls = pathCreator.createURLClassPath();
    CustomURLLoader loader = new CustomURLLoader(urls);
    loader.loadClassFrom("Dog", 0);
    result = loader.isClassInSharedCacheNullFind("Dog");
    if (result != true) {
        System.out.println("\nTEST PASSED");
    } else {
        System.out.println("\nTEST FAILED");
    }
}
Also used : CustomURLLoader(CustomCLs.CustomURLLoader) URLClassPathCreator(Utilities.URLClassPathCreator) URL(java.net.URL)

Aggregations

CustomURLLoader (CustomCLs.CustomURLLoader)13 URLClassPathCreator (Utilities.URLClassPathCreator)13 URL (java.net.URL)11 CustomURLClassLoader (CustomCLs.CustomURLClassLoader)5 CustomTokenClassLoader (CustomCLs.CustomTokenClassLoader)1 HelperAlreadyDefinedException (com.ibm.oti.shared.HelperAlreadyDefinedException)1