Add ImportTest

This commit is contained in:
JanUlrich 2019-12-15 14:57:03 +01:00
parent c82abcaae5
commit bb75fca0d7
3 changed files with 57 additions and 0 deletions

View 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());
}
}

View File

@ -0,0 +1,9 @@
package de.test;
import de.test.ToImport;
class ImportTest{
void methode(){
new ToImport();
}
}

View File

@ -0,0 +1,4 @@
package de.test;
class ToImport{
}