JavaCompilerCore/src/test/java/packages/mathStrucVectorTest.java
2022-11-18 09:50:35 +01:00

55 lines
2.0 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")+"/resources/javFiles/packageTest/de/test/";
public mathStrucVectorTest() throws ClassNotFoundException, IOException {
/*
Generate ToImport class in rootDirectory and in output-Directory
*/
/* PL 2020-01-07 kann z.Zt. nicht erzeugt werden (siehe Bug 170, http://bugzilla.ba-horb.de/show_bug.cgi?id=170)
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());
*/
JavaTXCompiler compiler = new JavaTXCompiler(new File(rootDirectory+"vectorAdd.jav"));
compiler.typeInference();
compiler.generateBytecode(rootDirectory + "output/");
File 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 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());
}
}