remove unused testcase

This commit is contained in:
Till Schnell 2021-04-14 10:50:01 +02:00
parent f548548788
commit cd2f030ac6

View File

@ -1,55 +0,0 @@
package inferWildcards;
import static org.junit.Assert.assertEquals;
import java.io.File;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import de.dhbwstuttgart.core.JavaTXCompiler;
public class TestClass1Test {
private static String path;
private static File fileToTest;
private static JavaTXCompiler compiler;
private static ClassLoader loader;
private static Class<?> classToTest;
private static String pathToClassFile;
private static Object instanceOfClass;
public void generateBC() throws Exception {
String resourcePath = System.getProperty("user.dir") + "/src/test/resources/inferWildcards";
path = resourcePath + "/TestClass1.java";
fileToTest = new File(path);
compiler = new JavaTXCompiler(fileToTest);
compiler.generateBytecode(resourcePath + "/generatedBC/");
pathToClassFile = resourcePath + "/generatedBC/";
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
classToTest = loader.loadClass("TestClass1");
classToTest.getConstructors(); // this will fail
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
Method getFact = classToTest.getDeclaredMethod("test", Integer.class);
// Field fact = classToTest.getDeclaredField("fact");
// Class<?> lambda = m.invoke(instanceOfClass).getClass();
// Class<?> lambda = fact.getType();
// System.out.println(fact.getType().getName());
// Method apply = lambda.getMethod("apply", Object.class);
// System.out.println(lambda.getMethods()[0]);
// System.out.println(instanceOfClass.toString());
// // Damit man auf die Methode zugreifen kann
// apply.setAccessible(true);
// Field value
// Object fieldVal = fact.get(instanceOfClass);
Integer i = 3;
// Method applyFromField = fieldVal.getClass().getDeclaredMethod("apply", Object.class);
// applyFromField.setAccessible(true);
// Integer result = (Integer) apply.invoke(lambda,i);
Integer result = (Integer) getFact.invoke(instanceOfClass,i);
System.out.println(result);
assertEquals(new Integer(3), result);
}
}