use of CustomClassloaders.CustomURLLoader in project openj9 by eclipse.
the class URLHelperURLClassPathHelperCompatabilityTest 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;
}
use of CustomClassloaders.CustomURLLoader in project openj9 by eclipse.
the class URLGetDifferentHelperTest method run.
public void run() {
boolean resultURL = false;
boolean resultToken = false;
URLClassPathCreator pathCreator = new URLClassPathCreator("./Pets;");
CustomURLLoader loader = new CustomURLLoader(pathCreator.createURLClassPath());
try {
loader.getURLClasspathHelper();
} catch (HelperAlreadyDefinedException e) {
resultURL = true;
}
try {
loader.getTokenHelper();
} catch (Exception e) {
resultToken = true;
}
if ((resultURL == true) && (resultToken == true)) {
System.out.println("\nTEST PASSED");
} else {
System.out.println("\nTEST FAILED");
}
}
use of CustomClassloaders.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");
}
}
use of CustomClassloaders.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");
}
}
use of CustomClassloaders.CustomURLLoader in project openj9 by eclipse.
the class URLHelperURLClassPathHelperStaleEntryCompatabilityTest 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;
}
Aggregations