40 lines
1.4 KiB
Java
40 lines
1.4 KiB
Java
|
package packages;
|
||
|
|
||
|
import com.google.common.collect.Lists;
|
||
|
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||
|
import de.dhbwstuttgart.environment.CompilationEnvironment;
|
||
|
import junit.framework.TestCase;
|
||
|
import org.junit.Test;
|
||
|
|
||
|
import java.io.File;
|
||
|
import java.io.IOException;
|
||
|
import java.net.URL;
|
||
|
import java.net.URLClassLoader;
|
||
|
|
||
|
public class LoadDefaultPackageClassesTest extends TestCase {
|
||
|
|
||
|
public static final String rootDirectory = System.getProperty("user.dir")+"/src/test/resources/javFiles/packageTest/";
|
||
|
|
||
|
|
||
|
public LoadDefaultPackageClassesTest() throws ClassNotFoundException, IOException {
|
||
|
/*
|
||
|
Generate ToImport class in rootDirectory and in output-Directory
|
||
|
*/
|
||
|
JavaTXCompiler compiler = new JavaTXCompiler(new File(rootDirectory+"Gen.jav"));
|
||
|
compiler.typeInference();
|
||
|
compiler.generateBytecode();
|
||
|
File f = new File(rootDirectory + "Gen.class");
|
||
|
assertTrue(f.exists());
|
||
|
}
|
||
|
|
||
|
public void testLoadGenClass() throws IOException, ClassNotFoundException {
|
||
|
CompilationEnvironment.loadDefaultPackageClasses(new File( rootDirectory + "Test.jav"), ClassLoader.getSystemClassLoader());
|
||
|
|
||
|
}
|
||
|
public void testURLClassLoader() throws IOException, ClassNotFoundException {
|
||
|
URLClassLoader cl = new URLClassLoader(new URL[]{new URL("file://"+rootDirectory)}, ClassLoader.getSystemClassLoader());
|
||
|
cl.loadClass("Gen");
|
||
|
}
|
||
|
|
||
|
}
|