package insertGenerics; import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericGenratorResultForSourceFile; import de.dhbwstuttgart.core.JavaTXCompiler; import de.dhbwstuttgart.syntaxtree.SourceFile; import de.dhbwstuttgart.syntaxtree.visual.ASTPrinter; import de.dhbwstuttgart.syntaxtree.visual.ASTTypePrinter; import de.dhbwstuttgart.typedeployment.TypeInsert; import de.dhbwstuttgart.typedeployment.TypeInsertFactory; import de.dhbwstuttgart.typeinference.result.ResultSet; import org.junit.Test; import java.io.File; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.net.URL; import java.net.URLClassLoader; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Paths; import java.util.HashSet; import java.util.List; import java.util.Set; public class TestGGFinder { private static final String rootDirectory = System.getProperty("user.dir")+"/src/test/resources/insertGenericsJav/"; private String pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/"; private static ClassLoader loader; private static Class classToTest; private static Object instanceOfClass; private static String className = "TestGGFinder"; @Test public void ggFinder() throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { execute(new File(rootDirectory+className+".jav")); } private static class TestResultSet{ } public TestResultSet execute(File fileToTest) throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { JavaTXCompiler compiler = new JavaTXCompiler(fileToTest); List results = compiler.typeInference(); List simplifyResultsForAllSourceFiles = compiler.getGeneratedGenericResultsForAllSourceFiles(results); compiler.generateBytecode(new File(pathToClassFile), results, simplifyResultsForAllSourceFiles); loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)}); classToTest = loader.loadClass(className); instanceOfClass = classToTest.getDeclaredConstructor().newInstance(); return new TestResultSet(); } }