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