JavaCompilerCore/test/bytecode/GeneralTest.java
2014-03-13 01:21:02 +01:00

36 lines
810 B
Java

package bytecode;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Vector;
import junit.framework.TestCase;
import org.junit.Test;
import sun.misc.IOUtils;
import mycompiler.mybytecode.ClassFile;
public class GeneralTest extends TestCase{
@Test
public void test(){
Vector<ClassFile> cfs = null;
try {
cfs = BytecodeTester.readFileAndTestCodegen("FieldTest.jav");
} catch (IOException e) {
e.printStackTrace();
fail();
}
assertTrue("Es darf nur eine ClassFile erstellt werden", cfs.size()==1);
try {
FileOutputStream output = new FileOutputStream(new File(BytecodeTester.rootDirectory+"FieldTest.class"));
output.write(cfs.firstElement().getBytecode());
} catch (IOException e) {
e.printStackTrace();
fail();
}
}
}