1.1 --- a/vmtest/src/test/java/org/apidesign/bck2brwsr/vmtest/impl/ZipFileTest.java Tue Feb 05 08:48:23 2013 +0100
1.2 +++ b/vmtest/src/test/java/org/apidesign/bck2brwsr/vmtest/impl/ZipFileTest.java Tue Feb 05 13:20:07 2013 +0100
1.3 @@ -76,6 +76,28 @@
1.4 assertEquals(ret, "Hello World!", "Can read the bytes");
1.5 }
1.6
1.7 + @GenerateZip(name = "cpattr.zip", contents = {
1.8 + "META-INF/MANIFEST.MF", "Manifest-Version: 1.0\n"
1.9 + + "Created-By: hand\n"
1.10 + + "Class-Path: realJar.jar\n\n\n"
1.11 + })
1.12 + @Http({
1.13 + @Http.Resource(path = "/readComplexEntry.jar", mimeType = "x-application/zip", content = "", resource="cpattr.zip"),
1.14 + @Http.Resource(path = "/realJar.jar", mimeType = "x-application/zip", content = "", resource="readAnEntry.zip"),
1.15 + })
1.16 + @BrwsrTest public void understandsClassPathAttr() throws IOException {
1.17 + Object res = loadVMResource("/my/main/file.txt", "/readComplexEntry.jar");
1.18 + assert res instanceof InputStream : "Got array of bytes: " + res;
1.19 + InputStream is = (InputStream)res;
1.20 +
1.21 + byte[] arr = new byte[4096];
1.22 + int len = is.read(arr);
1.23 +
1.24 + final String ret = new String(arr, 0, len, "UTF-8");
1.25 +
1.26 + assertEquals(ret, "Hello World!", "Can read the bytes from secondary JAR");
1.27 + }
1.28 +
1.29 private static void assertEquals(Object real, Object exp, String msg) {
1.30 assert Objects.equals(exp, real) : msg + " exp: " + exp + " real: " + real;
1.31 }