

import static org.junit.jupiter.api.Assertions.*;
import static targetast.TestCodegen.generateClassFiles;

import java.io.File;
import java.lang.reflect.Field;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Arrays;

import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

import com.google.common.collect.Lists;

import de.dhbwstuttgart.core.ConsoleInterface;
import de.dhbwstuttgart.core.JavaTXCompiler;
import de.dhbwstuttgart.util.Logger.LogLevel;

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 {
		ConsoleInterface.logLevel = LogLevel.DEBUG;
		//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";
		//String className = "FCTest3";
		//String className = "Var";
		//String className = "Put";
		//String className = "Twice";
		//String className = "Twice2";
		//String className = "TestSubTypless";
		//String className = "addList";
		//String className = "M";
		//String className = "Wildcard_Andi";
		//String className = "Box";
		//String className = "Box_Main";
		//String className = "wildcardPair";
		//String className = "VectorConstAdd";
		//String className = "VectorNotObject";
		//String className = "WildcardCaptureConversionTest";
		//String className = "CaptureConversion";
		//String className = "Pair";
		//String className = "DublicateWildcard";
		//String className = "UseWildcardPair";
		//String className = "Assign";
		//String className = "StreamTest";
		//String className = "Iteration";

		//String className = "Cycle";
		//String className = "TripleTest";
		//String className = "WildcardList";
		//String className = "List";
		//String className = "Box";
		//String className = "GenBox";
		//String className = "InnerInf";
		//String className = "Foo";
		//String className = "Kombinatoren_failure";
		String className = "Kombinatoren_After_Lazy";
		//String className = "Parser";
		//PL 2019-10-24: genutzt fuer unterschiedliche Tests
		path = System.getProperty("user.dir")+"/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")+"/resources/AllgemeinTest/")),
			   	new File(System.getProperty("user.dir")+"/resources/bytecode/classFiles/"), true);
		//*/
		compiler.generateBytecode();
		pathToClassFile = System.getProperty("user.dir")+"/resources/bytecode/classFiles/";
		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");
	}

}
