Search in sources :

Example 1 with CustomPartitioningURLLoader

use of CustomCLs.CustomPartitioningURLLoader in project openj9 by eclipse.

the class URLPartitioningStoreFindTest method runTest.

private boolean runTest(String[] urls, String[] partitionStrings, String[][] classesToLoad, String[][] classesToFind, String[][] results, String batchFile) {
    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();
    CustomPartitioningURLLoader cl = new CustomPartitioningURLLoader(urlPath, this.getClass().getClassLoader());
    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) {
                cl.setPartition(partitionStrings[urlIndex]);
                cl.loadClassFrom(classToLoad, urlIndex);
            }
        }
    }
    if (0 != batchFile.length()) {
        runBatchFile(batchFile);
    }
    boolean result = true;
    for (int urlIndex = 0; urlIndex < urls.length; urlIndex++) {
        cl.setPartition(partitionStrings[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(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 : URLClassPathCreator(Utilities.URLClassPathCreator) CustomPartitioningURLLoader(CustomCLs.CustomPartitioningURLLoader) URL(java.net.URL)

Example 2 with CustomPartitioningURLLoader

use of CustomCLs.CustomPartitioningURLLoader in project openj9 by eclipse.

the class PartitioningURLClassPathHelperURLHelperStaleEntryCompatibilityTest method executeTest.

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

Example 3 with CustomPartitioningURLLoader

use of CustomCLs.CustomPartitioningURLLoader in project openj9 by eclipse.

the class PartitioningURLHelperURLClassPathHelperStaleEntryCompatibilityTest method executeTest.

private boolean executeTest(String[] urls, String[] partitionStrings, String[][] classesToLoad, String classPath, String partition, 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();
    CustomPartitioningURLLoader[] loaderArray = new CustomPartitioningURLLoader[urls.length];
    for (int urlIndex = 0; urlIndex < urls.length; urlIndex++) {
        loaderArray[urlIndex] = new CustomPartitioningURLLoader(urlPath, this.getClass().getClassLoader());
        loaderArray[urlIndex].setPartition(partitionStrings[urlIndex]);
        for (int classIndex = 0; classIndex < classesToLoad[urlIndex].length; classIndex++) {
            String classToLoad = classesToLoad[urlIndex][classIndex];
            if (classToLoad != null) {
                loaderArray[urlIndex].loadClassFrom(classToLoad, urlIndex);
            }
        }
    }
    if (0 != batchFile.length()) {
        runBatchFile(batchFile, javacpath);
    }
    boolean result = true;
    URLClassPathCreator creator2 = new URLClassPathCreator(classPath);
    URL[] urlPath2;
    urlPath2 = creator2.createURLClassPath();
    CustomPartitioningURLCL cl = new CustomPartitioningURLCL(urlPath2, this.getClass().getClassLoader());
    cl.setPartition(partition);
    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 : URLClassPathCreator(Utilities.URLClassPathCreator) CustomPartitioningURLCL(CustomCLs.CustomPartitioningURLCL) CustomPartitioningURLLoader(CustomCLs.CustomPartitioningURLLoader) URL(java.net.URL)

Aggregations

CustomPartitioningURLLoader (CustomCLs.CustomPartitioningURLLoader)3 URLClassPathCreator (Utilities.URLClassPathCreator)3 URL (java.net.URL)3 CustomPartitioningURLCL (CustomCLs.CustomPartitioningURLCL)2