vm/src/test/java/org/apidesign/vm4brwsr/VMinVMTest.java
changeset 334 b5dd05670bef
parent 303 c12342170235
child 405 e41809be6106
child 708 59d5596a9c6c
     1.1 --- a/vm/src/test/java/org/apidesign/vm4brwsr/VMinVMTest.java	Tue Dec 11 11:05:06 2012 +0100
     1.2 +++ b/vm/src/test/java/org/apidesign/vm4brwsr/VMinVMTest.java	Sun Dec 16 20:48:21 2012 +0100
     1.3 @@ -20,7 +20,6 @@
     1.4  import java.io.File;
     1.5  import java.io.FileWriter;
     1.6  import java.io.IOException;
     1.7 -import java.io.InputStream;
     1.8  import static org.testng.Assert.*;
     1.9  import javax.script.Invocable;
    1.10  import org.testng.annotations.BeforeClass;
    1.11 @@ -36,13 +35,13 @@
    1.12      private static Invocable code;
    1.13      
    1.14      @Test public void compareGeneratedCodeForArrayClass() throws Exception {
    1.15 -        compareCode("/org/apidesign/vm4brwsr/Array.class");
    1.16 +        compareCode("org/apidesign/vm4brwsr/Array.class");
    1.17      }
    1.18  
    1.19      @Test public void compareGeneratedCodeForClassesClass() throws Exception {
    1.20 -        compareCode("/org/apidesign/vm4brwsr/Classes.class");
    1.21 +        compareCode("org/apidesign/vm4brwsr/Classes.class");
    1.22      }
    1.23 -    
    1.24 +
    1.25      @BeforeClass
    1.26      public void compileTheCode() throws Exception {
    1.27          StringBuilder sb = new StringBuilder();
    1.28 @@ -52,20 +51,8 @@
    1.29          codeSeq = sb;
    1.30      }
    1.31      
    1.32 -    private static byte[] readClass(String res) throws IOException {
    1.33 -        InputStream is1 = VMinVMTest.class.getResourceAsStream(res);
    1.34 -        assertNotNull(is1, "Stream found");
    1.35 -        byte[] arr = new byte[is1.available()];
    1.36 -        int len = is1.read(arr);
    1.37 -        is1.close();
    1.38 -        if (len != arr.length) {
    1.39 -            throw new IOException("Wrong len " + len + " for arr: " + arr.length);
    1.40 -        }
    1.41 -        return arr;
    1.42 -    }
    1.43 -
    1.44      private void compareCode(final String nm) throws Exception, IOException {
    1.45 -        byte[] arr = readClass(nm);
    1.46 +        byte[] arr = BytesLoader.readClass(nm);
    1.47          String ret1 = VMinVM.toJavaScript(arr);
    1.48          
    1.49          Object ret;