jdk/test/java/util/zip/ZipFile/Assortment.java
author ohair
Wed, 06 Apr 2011 22:06:11 -0700
changeset 9035 1255eb81cc2f
parent 8553 46c2babb1e44
child 17910 82d10099a8a6
permissions -rw-r--r--
7033660: Update copyright year to 2011 on any files changed in 2011 Reviewed-by: dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
9035
1255eb81cc2f 7033660: Update copyright year to 2011 on any files changed in 2011
ohair
parents: 8553
diff changeset
     2
 * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
/* @test
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
 * @bug 4770745 6234507
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
 * @summary test a variety of zip file entries
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 * @author Martin Buchholz
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.util.zip.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.util.jar.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.io.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
public class Assortment {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
    static int passed = 0, failed = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
    static void fail(String msg) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
        failed++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
        new Exception(msg).printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    static void unexpected(Throwable t) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
        failed++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
        t.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    static void check(boolean condition, String msg) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
        if (! condition)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
            fail(msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    static void check(boolean condition) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
        check(condition, "Something's wrong");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    private static class Entry {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        private String name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        private int    method;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        private byte[] data;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        private byte[] extra;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
        private String comment;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        Entry(String name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
              int    method,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
              byte[] data,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
              byte[] extra,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
              String comment) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
            this.name    = name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
            this.method  = method;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
            this.data    = data;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
            this.extra   = extra;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
            this.comment = comment;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        void write(ZipOutputStream s) throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
            ZipEntry e = new ZipEntry(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
            CRC32 crc32 = new CRC32();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
            e.setMethod(method);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
            if (method == ZipEntry.STORED) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
                e.setSize(data == null ? 0 : data.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
                crc32.reset();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
                if (data != null) crc32.update(data);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
                e.setCrc(crc32.getValue());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
                e.setSize(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
                e.setCrc(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
            if (comment != null) e.setComment(comment);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
            if (extra   != null) e.setExtra(extra);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
            s.putNextEntry(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
            if (data != null) s.write(data);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        byte[] getData(ZipFile f, ZipEntry e) throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
            byte[] fdata = new byte[(int)e.getSize()];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
            InputStream is = f.getInputStream(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
            is.read(fdata);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
            return fdata;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        void verify(ZipFile f) throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
            ZipEntry e = f.getEntry(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
            byte[] data  = (this.data == null) ? new byte[]{} : this.data;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
            byte[] extra = (this.extra != null && this.extra.length == 0) ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
                null : this.extra;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
            check(name.equals(e.getName()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
            check(method == e.getMethod());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
            check((((comment == null) || comment.equals(""))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
                   && (e.getComment() == null))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
                  || comment.equals(e.getComment()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
            check(Arrays.equals(extra, e.getExtra()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
            check(Arrays.equals(data, getData(f, e)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
            check(e.getSize() == data.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
            check((method == ZipEntry.DEFLATED) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
                  (e.getCompressedSize() == data.length));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        void verify(JarInputStream jis) throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
            // JarInputStream "automatically" reads the manifest
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
            if (name.equals("meta-iNf/ManIfEst.Mf"))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
            ZipEntry e = jis.getNextEntry();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
            byte[] data = (this.data == null) ? new byte[]{} : this.data;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
            byte[] otherData = new byte[data.length];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
            jis.read(otherData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
            check(Arrays.equals(data, otherData));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
            byte[] extra = (this.extra != null && this.extra.length == 0) ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
                null : this.extra;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
            check(Arrays.equals(extra, e.getExtra()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
            check(name.equals(e.getName()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
            check(method == e.getMethod());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
            check(e.getSize() == -1 || e.getSize() == data.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
            check((method == ZipEntry.DEFLATED) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
                  (e.getCompressedSize() == data.length));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    private static int uniquifier = 86;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    private static String uniquify(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        return name + (uniquifier++);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    private static byte[] toBytes(String s) throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        return s.getBytes("UTF-8");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    private static byte[] toExtra(byte[] bytes) throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        if (bytes == null) return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        // Construct a fake extra field with valid header length
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        byte[] v = new byte[bytes.length + 4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        v[0] = (byte) 0x47;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        v[1] = (byte) 0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        v[2] = (byte) bytes.length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        v[3] = (byte) (bytes.length << 8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        System.arraycopy(bytes, 0, v, 4, bytes.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        return v;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    private static Random random = new Random();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    private static String makeName(int length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        StringBuilder sb = new StringBuilder(length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        for (int i = 0; i < length; i++)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
            sb.append((char)(random.nextInt(10000)+1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        return sb.toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    public static void main(String[] args) throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        File zipName = new File("x.zip");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        int[]    methods  = {ZipEntry.STORED, ZipEntry.DEFLATED};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        String[] names    = {makeName(1), makeName(160), makeName(9000)};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        byte[][] datas    = {null, new byte[]{}, new byte[]{'d'}};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        byte[][] extras   = {null, new byte[]{}, new byte[]{'e'}};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        String[] comments = {null, "", "c"};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        List<Entry> entries = new ArrayList<Entry>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        // Highly unusual manifest
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        entries.add(new Entry("meta-iNf/ManIfEst.Mf",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
                              ZipEntry.STORED,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
                              toBytes("maNiFest-VeRsIon: 1.0\n"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
                              toExtra(toBytes("Can manifests have extra??")),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
                              "Can manifests have comments??"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        // The emptiest possible entry
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        entries.add(new Entry("", ZipEntry.STORED,   null, null, ""));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        for (String name : names)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
            for (int method : methods)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                for (byte[] data : datas) // datae??
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
                    for (byte[] extra : extras)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                        for (String comment : comments)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                            entries.add(new Entry(uniquify(name), method, data,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
                                                  toExtra(extra), comment));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        //----------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        // Write zip file using ZipOutputStream
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        //----------------------------------------------------------------
8553
46c2babb1e44 7021582: convert jar/zip code and tests to use try-with-resources
smarks
parents: 5506
diff changeset
   204
        try (FileOutputStream fos = new FileOutputStream(zipName);
46c2babb1e44 7021582: convert jar/zip code and tests to use try-with-resources
smarks
parents: 5506
diff changeset
   205
             ZipOutputStream zos = new ZipOutputStream(fos))
46c2babb1e44 7021582: convert jar/zip code and tests to use try-with-resources
smarks
parents: 5506
diff changeset
   206
        {
46c2babb1e44 7021582: convert jar/zip code and tests to use try-with-resources
smarks
parents: 5506
diff changeset
   207
            for (Entry e : entries)
46c2babb1e44 7021582: convert jar/zip code and tests to use try-with-resources
smarks
parents: 5506
diff changeset
   208
                e.write(zos);
46c2babb1e44 7021582: convert jar/zip code and tests to use try-with-resources
smarks
parents: 5506
diff changeset
   209
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        //----------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        // Verify zip file contents using JarFile class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        //----------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        JarFile f = new JarFile(zipName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        check(f.getManifest() != null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        for (Entry e : entries)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
            e.verify(f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        f.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        //----------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        // Verify zip file contents using JarInputStream class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        //----------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        JarInputStream jis = new JarInputStream(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
            new FileInputStream(zipName));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        // JarInputStream "automatically" reads the manifest
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        check(jis.getManifest() != null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        for (Entry e : entries)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
            e.verify(jis);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        jis.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
//      String cmd = "unzip -t " + zipName.getPath() + " >/dev/tty";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
//      new ProcessBuilder(new String[]{"/bin/sh", "-c", cmd}).start().waitFor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        zipName.deleteOnExit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        System.out.printf("passed = %d, failed = %d%n", passed, failed);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        if (failed > 0) throw new Exception("Some tests failed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
}