forked from JavaTX/JavaCompilerCore
Add ImportTest
This commit is contained in:
parent
c82abcaae5
commit
bb75fca0d7
44
src/test/java/packages/ImportTest.java
Normal file
44
src/test/java/packages/ImportTest.java
Normal file
@ -0,0 +1,44 @@
|
||||
package packages;
|
||||
|
||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||
import junit.framework.TestCase;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class ImportTest extends TestCase {
|
||||
|
||||
public static final String rootDirectory = System.getProperty("user.dir")+"/src/test/resources/javFiles/packageTest/de/test/";
|
||||
|
||||
|
||||
public ImportTest() throws ClassNotFoundException, IOException {
|
||||
/*
|
||||
Generate ToImport class in rootDirectory and in output-Directory
|
||||
*/
|
||||
JavaTXCompiler compiler = new JavaTXCompiler(new File(rootDirectory+"ToImport.jav"));
|
||||
compiler.typeInference();
|
||||
compiler.generateBytecode(rootDirectory + "output/");
|
||||
File f = new File(rootDirectory + "output/de/test/ToImport.class");
|
||||
assertTrue(f.exists());
|
||||
compiler = new JavaTXCompiler(new File(rootDirectory+"ToImport.jav"));
|
||||
compiler.typeInference();
|
||||
compiler.generateBytecode(null);
|
||||
f = new File(rootDirectory + "output/de/test/ToImport.class");
|
||||
assertTrue(f.exists());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetPackageNameInBytecodeAndOutputFolder() throws IOException, ClassNotFoundException {
|
||||
JavaTXCompiler compiler = new JavaTXCompiler(new File(rootDirectory+"ImportTest.jav"));
|
||||
compiler.typeInference();
|
||||
File f = new File(rootDirectory + "output/de/test/ImportTest.class");
|
||||
if(f.exists() && !f.isDirectory()) {
|
||||
f.delete();
|
||||
}
|
||||
compiler.generateBytecode(rootDirectory + "output/");
|
||||
f = new File(rootDirectory + "output/de/test/ImportTest.class");
|
||||
assertTrue(f.exists());
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package de.test;
|
||||
|
||||
import de.test.ToImport;
|
||||
|
||||
class ImportTest{
|
||||
void methode(){
|
||||
new ToImport();
|
||||
}
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
package de.test;
|
||||
|
||||
class ToImport{
|
||||
}
|
Loading…
Reference in New Issue
Block a user