vmtest/src/test/java/org/apidesign/bck2brwsr/vmtest/impl/ZipFileTest.java
branchemul
changeset 640 693745d01b55
parent 611 9839e9a75bcf
child 644 cfbd4eecb941
     1.1 --- a/vmtest/src/test/java/org/apidesign/bck2brwsr/vmtest/impl/ZipFileTest.java	Wed Jan 30 14:03:49 2013 +0100
     1.2 +++ b/vmtest/src/test/java/org/apidesign/bck2brwsr/vmtest/impl/ZipFileTest.java	Fri Feb 01 18:02:16 2013 +0100
     1.3 @@ -19,9 +19,13 @@
     1.4  
     1.5  import java.io.IOException;
     1.6  import java.io.InputStream;
     1.7 +import java.util.Objects;
     1.8  import java.util.zip.ZipEntry;
     1.9  import java.util.zip.ZipInputStream;
    1.10 +import org.apidesign.bck2brwsr.core.JavaScriptBody;
    1.11 +import org.apidesign.bck2brwsr.vmtest.BrwsrTest;
    1.12  import org.apidesign.bck2brwsr.vmtest.Compare;
    1.13 +import org.apidesign.bck2brwsr.vmtest.HttpResource;
    1.14  import org.apidesign.bck2brwsr.vmtest.VMTest;
    1.15  import org.testng.annotations.Factory;
    1.16  
    1.17 @@ -29,23 +33,29 @@
    1.18   *
    1.19   * @author Jaroslav Tulach <jtulach@netbeans.org>
    1.20   */
    1.21 +@GenerateZip(name = "readAnEntry.zip", contents = { 
    1.22 +    "my/main/file.txt", "Hello World!"
    1.23 +})
    1.24  public class ZipFileTest {
    1.25      
    1.26 -    @GenerateZip(name = "readAnEntry.zip", contents = { "my/main/file.txt", "Hello World!" })
    1.27      @Compare public String readAnEntry() throws IOException {
    1.28          InputStream is = ZipFileTest.class.getResourceAsStream("readAnEntry.zip");
    1.29          ZipInputStream zip = new ZipInputStream(is);
    1.30          ZipEntry entry = zip.getNextEntry();
    1.31          assertEquals(entry.getName(), "my/main/file.txt", "Correct entry");
    1.32 -        
    1.33 +
    1.34          byte[] arr = new byte[4096];
    1.35          int len = zip.read(arr);
    1.36          
    1.37 -        return new String(arr, 0, len, "UTF-8");
    1.38 +        assertEquals(zip.getNextEntry(), null, "No next entry");
    1.39 +        
    1.40 +        final String ret = new String(arr, 0, len, "UTF-8");
    1.41 +        return ret;
    1.42      }
    1.43 -
    1.44 -    private static void assertEquals(String real, String exp, String msg) {
    1.45 -        assert exp.equals(real) : msg + " exp: " + exp + " real: " + real;
    1.46 +    
    1.47 +    
    1.48 +    private static void assertEquals(Object real, Object exp, String msg) {
    1.49 +        assert Objects.equals(exp, real) : msg + " exp: " + exp + " real: " + real;
    1.50      }
    1.51      
    1.52      @Factory public static Object[] create() {