2019-12-23 15:34:07 +00:00
|
|
|
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
|
|
|
|
*/
|
|
|
|
|
2019-12-26 14:22:40 +00:00
|
|
|
JavaTXCompiler compiler = new JavaTXCompiler(new File(rootDirectory+"mathStruc.jav"));
|
2019-12-23 15:34:07 +00:00
|
|
|
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());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|