forked from JavaTX/JavaCompilerCore
Overloading Test überarbeitet
This commit is contained in:
parent
040a1f4088
commit
52be0a1af3
@ -2,7 +2,10 @@ package bytecode.types;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.junit.Test;
|
||||
@ -24,17 +27,22 @@ public class OverloadingTest extends BytecodeTest{
|
||||
Class cls = getClassToTest();
|
||||
Object obj = cls.newInstance();
|
||||
|
||||
Vector<String> stringVector = new Vector<String>();
|
||||
File file = new File(rootDirectory);
|
||||
URL url = file.toURL();
|
||||
URL[] urls = new URL[]{url};
|
||||
|
||||
ClassLoader classLoader = new URLClassLoader(urls);
|
||||
|
||||
Class stringVector = classLoader.loadClass("java%util%Vector%%java%lang%String%");
|
||||
|
||||
Class[] params = new Class[1];
|
||||
params[0] = stringVector.getClass();
|
||||
params[0] = stringVector;
|
||||
|
||||
Method method = cls.getDeclaredMethod("method", params);
|
||||
method.invoke(obj, stringVector);
|
||||
method.invoke(obj, stringVector.newInstance());
|
||||
assertTrue(true);
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,17 +52,22 @@ public class OverloadingTest extends BytecodeTest{
|
||||
Class cls = getClassToTest();
|
||||
Object obj = cls.newInstance();
|
||||
|
||||
Vector<Integer> stringVector = new Vector<Integer>();
|
||||
File file = new File(rootDirectory);
|
||||
URL url = file.toURL();
|
||||
URL[] urls = new URL[]{url};
|
||||
|
||||
ClassLoader classLoader = new URLClassLoader(urls);
|
||||
|
||||
Class integerVector = classLoader.loadClass("java%util%Vector%%java%lang%Integer%");
|
||||
|
||||
Class[] params = new Class[1];
|
||||
params[0] = stringVector.getClass();
|
||||
params[0] = integerVector;
|
||||
|
||||
Method method = cls.getDeclaredMethod("method", params);
|
||||
method.invoke(obj, stringVector);
|
||||
method.invoke(obj, integerVector.newInstance());
|
||||
assertTrue(true);
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user