54 lines
1.9 KiB
Java
54 lines
1.9 KiB
Java
|
package packages;
|
||
|
|
||
|
import com.google.common.collect.Lists;
|
||
|
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;
|
||
|
import java.net.URL;
|
||
|
|
||
|
public class mathStrucVectorTest extends TestCase {
|
||
|
|
||
|
public static final String rootDirectory = System.getProperty("user.dir")+"/src/test/resources/javFiles/packageTest/de/test/";
|
||
|
|
||
|
|
||
|
public mathStrucVectorTest() throws ClassNotFoundException, IOException {
|
||
|
/*
|
||
|
Generate ToImport class in rootDirectory and in output-Directory
|
||
|
*/
|
||
|
|
||
|
JavaTXCompiler compiler = new JavaTXCompiler(new File(rootDirectory+"mathStruc.jav"));
|
||
|
compiler.typeInference();
|
||
|
compiler.generateBytecode(rootDirectory + "output/");
|
||
|
File f = new File(rootDirectory + "output/de/test/mathStruc.class");
|
||
|
assertTrue(f.exists());
|
||
|
|
||
|
compiler = new JavaTXCompiler(new File(rootDirectory+"vectorAdd.jav"));
|
||
|
compiler.typeInference();
|
||
|
compiler.generateBytecode(rootDirectory + "output/");
|
||
|
f = new File(rootDirectory + "output/de/test/vectorAdd.class");
|
||
|
assertTrue(f.exists());
|
||
|
|
||
|
}
|
||
|
|
||
|
@Test
|
||
|
public void testSetPackageNameInBytecodeAndOutputFolder() throws IOException, ClassNotFoundException {
|
||
|
JavaTXCompiler compiler = new JavaTXCompiler(
|
||
|
Lists.newArrayList(new File(rootDirectory+"mathStrucVector.jav")),
|
||
|
Lists.newArrayList(new URL("file://"+rootDirectory+"output/")));
|
||
|
compiler.typeInference();
|
||
|
File f = new File(rootDirectory + "output/de/test/mathStrucVector.class");
|
||
|
if(f.exists() && !f.isDirectory()) {
|
||
|
f.delete();
|
||
|
}
|
||
|
compiler.generateBytecode(rootDirectory + "output/");
|
||
|
f = new File(rootDirectory + "output/de/test/mathStrucVector.class");
|
||
|
assertTrue(f.exists());
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|