JavaCompilerCore/test/bytecode/GeneralTest.java

36 lines
810 B
Java
Raw Normal View History

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 {
2014-03-13 00:21:02 +00:00
FileOutputStream output = new FileOutputStream(new File(BytecodeTester.rootDirectory+"FieldTest.class"));
output.write(cfs.firstElement().getBytecode());
} catch (IOException e) {
e.printStackTrace();
fail();
}
}
}