From 52be0a1af39d99c5635ac83215c334ff404c0447 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrico=20Schr=C3=B6dter?= Date: Fri, 23 Oct 2015 19:04:13 +0200 Subject: [PATCH] =?UTF-8?q?Overloading=20Test=20=C3=BCberarbeitet?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/bytecode/types/OverloadingTest.java | 33 +++++++++++++++++------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/test/bytecode/types/OverloadingTest.java b/test/bytecode/types/OverloadingTest.java index 9e6b3a22..514264a3 100644 --- a/test/bytecode/types/OverloadingTest.java +++ b/test/bytecode/types/OverloadingTest.java @@ -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 stringVector = new Vector(); + 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 stringVector = new Vector(); + 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); } }