2020-03-30 14:17:52 +00:00
import static org.junit.Assert.* ;
import java.io.File ;
import java.lang.reflect.Field ;
import java.net.URL ;
import java.net.URLClassLoader ;
import java.util.Arrays ;
import org.junit.BeforeClass ;
import org.junit.Test ;
import com.google.common.collect.Lists ;
import de.dhbwstuttgart.core.JavaTXCompiler ;
public class AllgemeinTest {
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 ;
@Test
public void test ( ) throws Exception {
//String className = "GenTest";
//String className = "Overloading_Generics";
//String className = "Generics";
//String className = "OverloadingMain";
//String className = "OverrideMain";
//String className = "OverrideMainRet";
//String className = "FCTest1";
//String className = "FCTest2";
//String className = "Pair";
2020-04-20 12:29:15 +00:00
//String className = "FCTest3";
2020-04-24 21:05:42 +00:00
//String className = "Var";
2020-10-16 12:54:36 +00:00
//String className = "Put";
2021-01-13 18:39:01 +00:00
//String className = "Twice";
String className = " TestSubTypless " ;
2020-03-30 14:17:52 +00:00
//PL 2019-10-24: genutzt fuer unterschiedliche Tests
path = System . getProperty ( " user.dir " ) + " /src/test/resources/AllgemeinTest/ " + className + " .jav " ;
//path = System.getProperty("user.dir")+"/src/test/resources/AllgemeinTest/Overloading_Generics.jav";
//path = System.getProperty("user.dir")+"/src/test/resources/bytecode/javFiles/mathStrucInteger.jav";
//compiler = new JavaTXCompiler(Lists.newArrayList(new File(System.getProperty("user.dir")+"/src/test/resources/AllgemeinTest/Overloading_Generics.jav")));
///*
compiler = new JavaTXCompiler (
Lists . newArrayList ( new File ( path ) ) ,
Lists . newArrayList ( new File ( System . getProperty ( " user.dir " ) + " /src/test/resources/testBytecode/generatedBC/ " ) ) ) ;
//*/
compiler . generateBytecode ( System . getProperty ( " user.dir " ) + " /src/test/resources/testBytecode/generatedBC/ " ) ;
pathToClassFile = System . getProperty ( " user.dir " ) + " /src/test/resources/testBytecode/generatedBC/ " ;
loader = new URLClassLoader ( new URL [ ] { new URL ( " file:// " + pathToClassFile ) } ) ;
classToTest = loader . loadClass ( className ) ;
//classToTest = loader.loadClass("Overloading_Generics");
//instanceOfClass = classToTest.getDeclaredConstructor().newInstance("A");
//classToTest = loader.loadClass("Overloading_Generics1");
//instanceOfClass = classToTest.getDeclaredConstructor(Object.class).newInstance("B");
}
}