Search in sources :

Example 26 with URLClassPathCreator

use of Utilities.URLClassPathCreator in project openj9 by eclipse.

the class NullURLStoreTest method run.

public void run() {
    boolean result = false;
    URLClassPathCreator pathCreator = new URLClassPathCreator("./Pets;");
    URL[] urls = pathCreator.createURLClassPath();
    CustomURLLoader loader = new CustomURLLoader(urls);
    loader.loadClassNullStore("Dog");
    result = loader.isClassInSharedCache(0, "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)

Example 27 with URLClassPathCreator

use of Utilities.URLClassPathCreator in project openj9 by eclipse.

the class MultiLoadURLClassPathMatchingTest method executeTest.

public boolean executeTest(String[] urls, String[][] classesToLoad, String[][] classesToFind, String[][] results) {
    String urlsString = urls[0];
    for (int index = 0; 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;
    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(loaderArray[urlIndex].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) URL(java.net.URL)

Example 28 with URLClassPathCreator

use of Utilities.URLClassPathCreator in project openj9 by eclipse.

the class URLStoreFindTest 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.isClassInSharedCache(0, "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)

Example 29 with URLClassPathCreator

use of Utilities.URLClassPathCreator in project openj9 by eclipse.

the class URLClassPathMatchingTest method executeTest.

public boolean executeTest(String[] urls, String[][] classesToLoad, String[][] classesToFind, String[][] results) {
    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 creator = new URLClassPathCreator(urlsString);
    URL[] urlPath;
    urlPath = creator.createURLClassPath();
    CustomURLLoader cl = new CustomURLLoader(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.loadClassFrom(classToLoad, urlIndex);
            }
        }
    }
    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(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) URL(java.net.URL)

Example 30 with URLClassPathCreator

use of Utilities.URLClassPathCreator in project openj9 by eclipse.

the class URLStaleClassPathEntryTest 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();
    CustomURLLoader cl = new CustomURLLoader(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) {
                System.out.println("classToLoad = " + classToLoad);
            }
        }
    }
    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.loadClassFrom(classToLoad, urlIndex);
            }
        }
    }
    /*Sleep for 2 s ... otherwise time stamps may not match ...*/
    try {
        Thread.sleep(2000);
    } catch (Exception 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(urlIndex, classToFind));
                if (!(expectedResult.equals(testResult))) {
                    System.out.println("testResult = \"" + testResult + "\"");
                    System.out.println("urlIndex = \"" + urlIndex + "\"");
                    System.out.println("classToFind = \"" + classToFind + "\"");
                    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) URL(java.net.URL)

Aggregations

URLClassPathCreator (Utilities.URLClassPathCreator)32 URL (java.net.URL)24 CustomURLLoader (CustomCLs.CustomURLLoader)13 CustomURLClassLoader (CustomCLs.CustomURLClassLoader)9 CustomTokenClassLoader (CustomCLs.CustomTokenClassLoader)6 CustomURLClassLoader (CustomClassloaders.CustomURLClassLoader)5 CustomURLLoader (CustomClassloaders.CustomURLLoader)5 HelperAlreadyDefinedException (com.ibm.oti.shared.HelperAlreadyDefinedException)5 CustomPartitioningURLLoader (CustomCLs.CustomPartitioningURLLoader)3 SharedClassHelperFactory (com.ibm.oti.shared.SharedClassHelperFactory)3 SharedClassURLClasspathHelper (com.ibm.oti.shared.SharedClassURLClasspathHelper)3 Method (java.lang.reflect.Method)3 CustomPartitioningURLCL (CustomCLs.CustomPartitioningURLCL)2 CustomPartitioningURLClassLoader (CustomClassloaders.CustomPartitioningURLClassLoader)2 CustomPartitioningURLLoader (CustomClassloaders.CustomPartitioningURLLoader)2 CustomTokenClassLoader (CustomClassloaders.CustomTokenClassLoader)1 CannotSetClasspathException (com.ibm.oti.shared.CannotSetClasspathException)1