jdk/test/tools/pack200/TestExceptions.java
author darcy
Wed, 29 Apr 2015 10:25:53 -0700
changeset 30046 cf2c86e1819e
parent 18594 b6a3c9f71ac8
permissions -rw-r--r--
8078334: Mark regression tests using randomness Reviewed-by: xuelei, alanb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7171
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
     1
/*
18594
b6a3c9f71ac8 8017463: [TEST_BUG] 2 tests from tools/pack200/ remain about 1 GB of data in work directory after execution
ksrini
parents: 7171
diff changeset
     2
 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
7171
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
     4
 *
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
     7
 * published by the Free Software Foundation.
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
     8
 *
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    13
 * accompanied this code).
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    14
 *
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    18
 *
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    21
 * questions.
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    22
 */
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    23
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    24
import java.io.ByteArrayOutputStream;
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    25
import java.io.Closeable;
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    26
import java.io.File;
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    27
import java.io.FileInputStream;
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    28
import java.io.IOException;
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    29
import java.io.InputStream;
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    30
import java.io.OutputStream;
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    31
import java.util.ArrayList;
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    32
import java.util.List;
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    33
import java.util.jar.JarFile;
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    34
import java.util.jar.JarInputStream;
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    35
import java.util.jar.JarOutputStream;
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    36
import java.util.jar.Pack200;
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    37
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    38
/*
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    39
 * @test
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    40
 * @bug 6985763
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    41
 * @summary verify that proper exceptions are thrown
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    42
 * @compile -XDignore.symbol.file Utils.java TestExceptions.java
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    43
 * @run main TestExceptions
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    44
 * @author ksrini
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    45
 */
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    46
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    47
public class TestExceptions {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    48
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    49
    static final File testJar = new File("test.jar");
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    50
    static final File testPackFile = new File("test.pack");
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    51
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    52
    static void init() {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    53
        Utils.jar("cvf", testJar.getAbsolutePath(), ".");
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    54
        JarFile jf = null;
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    55
        try {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    56
            jf = new JarFile(testJar);
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    57
            Utils.pack(jf, testPackFile);
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    58
        } catch (IOException ioe) {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    59
            throw new Error("Initialization error", ioe);
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    60
        } finally {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    61
            Utils.close(jf);
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    62
        }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    63
    }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    64
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    65
    // a test that closes the input jarFile.
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    66
    static void pack200Test1() {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    67
        PackTestInput ti = null;
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    68
        // setup the scenario
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    69
        try {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    70
            ti = new PackTestInput(new JarFile(testJar), new ByteArrayOutputStream());
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    71
        } catch (Exception e) {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    72
            throw new Error("Initialization error", e);
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    73
        } finally {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    74
            Utils.close(ti.getJarFile());
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    75
        }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    76
        // test the scenario
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    77
        try {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    78
            System.out.println(ti);
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    79
            Pack200.Packer p = Pack200.newPacker();
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    80
            p.pack(ti.getJarFile(), ti.getOutputStream());
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    81
        } catch (Exception e) {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    82
            ti.checkException(e);
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    83
        } finally {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    84
            if (ti != null) {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    85
                ti.close();
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    86
            }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    87
        }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    88
    }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    89
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    90
    // test the Pack200.pack(JarFile, OutputStream);
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    91
    static void pack200Test2() {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    92
        List<PackTestInput> tlist = new ArrayList<PackTestInput>();
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    93
        try {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    94
            // setup the test scenarios
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    95
            try {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    96
                tlist.add(new PackTestInput((JarFile)null, null));
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    97
                tlist.add(new PackTestInput(new JarFile(testJar), null));
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    98
                tlist.add(new PackTestInput((JarFile)null, new ByteArrayOutputStream()));
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
    99
            } catch (Exception e) {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   100
                throw new Error("Initialization error", e);
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   101
            }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   102
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   103
            // test the scenarios
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   104
            for (PackTestInput ti : tlist) {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   105
                System.out.println(ti);
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   106
                try {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   107
                    Pack200.Packer p = Pack200.newPacker();
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   108
                    p.pack(ti.getJarFile(), ti.getOutputStream());
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   109
                } catch (Exception e) {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   110
                    ti.checkException(e);
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   111
                }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   112
            }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   113
        } finally { // keep jprt happy
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   114
            for (TestInput ti : tlist) {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   115
                if (ti != null) {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   116
                    ti.close();
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   117
                }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   118
            }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   119
        }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   120
    }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   121
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   122
    // test the Pack200.pack(JarInputStream, OutputStream);
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   123
    static void pack200Test3() {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   124
        List<PackTestJarInputStream> tlist = new ArrayList<PackTestJarInputStream>();
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   125
        try {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   126
            // setup the test scenarios
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   127
            try {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   128
                tlist.add(new PackTestJarInputStream((JarInputStream)null, null));
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   129
                tlist.add(new PackTestJarInputStream((JarInputStream)null,
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   130
                        new ByteArrayOutputStream()));
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   131
                tlist.add(new PackTestJarInputStream(
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   132
                        new JarInputStream(new FileInputStream(testJar)), null));
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   133
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   134
            } catch (Exception e) {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   135
                throw new Error("Initialization error", e);
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   136
            }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   137
            for (PackTestJarInputStream ti : tlist) {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   138
                System.out.println(ti);
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   139
                try {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   140
                    Pack200.Packer p = Pack200.newPacker();
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   141
                    p.pack(ti.getJarInputStream(), ti.getOutputStream());
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   142
                } catch (Exception e) {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   143
                    ti.checkException(e);
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   144
                }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   145
            }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   146
        } finally { // keep jprt happy
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   147
            for (PackTestJarInputStream ti : tlist) {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   148
                if (ti != null) {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   149
                    ti.close();
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   150
                }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   151
            }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   152
        }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   153
    }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   154
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   155
    // test the Pack200.unpack(InputStream, OutputStream);
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   156
    static void unpack200Test1() {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   157
        List<UnpackTestInput> tlist = new ArrayList<UnpackTestInput>();
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   158
        try {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   159
            // setup the test scenarios
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   160
            try {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   161
                tlist.add(new UnpackTestInput((InputStream)null, null));
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   162
                tlist.add(new UnpackTestInput(new FileInputStream(testPackFile),
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   163
                        null));
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   164
                tlist.add(new UnpackTestInput((InputStream) null,
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   165
                        new JarOutputStream(new ByteArrayOutputStream())));
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   166
            } catch (Exception e) {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   167
                throw new Error("Initialization error", e);
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   168
            }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   169
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   170
            // test the scenarios
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   171
            for (UnpackTestInput ti : tlist) {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   172
                System.out.println(ti);
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   173
                try {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   174
                    Pack200.Unpacker unpacker = Pack200.newUnpacker();
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   175
                    unpacker.unpack(ti.getInputStream(), ti.getJarOutputStream());
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   176
                } catch (Exception e) {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   177
                    ti.checkException(e);
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   178
                }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   179
            }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   180
        } finally { // keep jprt happy
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   181
            for (TestInput ti : tlist) {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   182
                if (ti != null) {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   183
                    ti.close();
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   184
                }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   185
            }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   186
        }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   187
    }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   188
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   189
    // test the Pack200.unpack(File, OutputStream);
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   190
    static void unpack200Test2() {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   191
        List<UnpackTestFileInput> tlist = new ArrayList<UnpackTestFileInput>();
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   192
        try {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   193
            // setup the test scenarios
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   194
            try {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   195
                tlist.add(new UnpackTestFileInput((File)null, null));
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   196
                tlist.add(new UnpackTestFileInput(testPackFile, null));
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   197
                tlist.add(new UnpackTestFileInput((File)null,
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   198
                        new JarOutputStream(new ByteArrayOutputStream())));
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   199
            } catch (Exception e) {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   200
                throw new Error("Initialization error", e);
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   201
            }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   202
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   203
            // test the scenarios
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   204
            for (UnpackTestFileInput ti : tlist) {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   205
                System.out.println(ti);
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   206
                try {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   207
                    Pack200.Unpacker unpacker = Pack200.newUnpacker();
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   208
                    unpacker.unpack(ti.getInputFile(), ti.getJarOutputStream());
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   209
                } catch (Exception e) {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   210
                    ti.checkException(e);
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   211
                }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   212
            }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   213
        } finally { // keep jprt happy
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   214
            for (TestInput ti : tlist) {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   215
                if (ti != null) {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   216
                    ti.close();
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   217
                }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   218
            }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   219
        }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   220
    }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   221
18594
b6a3c9f71ac8 8017463: [TEST_BUG] 2 tests from tools/pack200/ remain about 1 GB of data in work directory after execution
ksrini
parents: 7171
diff changeset
   222
    public static void main(String... args) throws IOException {
7171
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   223
        init();
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   224
        pack200Test1();
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   225
        pack200Test2();
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   226
        pack200Test3();
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   227
        unpack200Test1();
18594
b6a3c9f71ac8 8017463: [TEST_BUG] 2 tests from tools/pack200/ remain about 1 GB of data in work directory after execution
ksrini
parents: 7171
diff changeset
   228
        Utils.cleanup();
7171
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   229
    }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   230
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   231
    // containers for test inputs and management
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   232
    static abstract class TestInput {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   233
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   234
        private final Object in;
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   235
        private final Object out;
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   236
        final boolean shouldNPE;
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   237
        final String testname;
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   238
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   239
        public TestInput(String name, Object in, Object out) {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   240
            this.testname = name;
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   241
            this.in = in;
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   242
            this.out = out;
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   243
            shouldNPE = (in == null || out == null);
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   244
        }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   245
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   246
        @Override
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   247
        public String toString() {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   248
            StringBuilder outStr = new StringBuilder(testname);
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   249
            outStr.append(", input:").append(in);
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   250
            outStr.append(", output:").append(this.out);
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   251
            outStr.append(", should NPE:").append(shouldNPE);
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   252
            return outStr.toString();
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   253
        }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   254
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   255
        void close() {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   256
            if (in != null && (in instanceof Closeable)) {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   257
                Utils.close((Closeable) in);
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   258
            }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   259
            if (out != null && (out instanceof Closeable)) {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   260
                Utils.close((Closeable) out);
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   261
            }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   262
        }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   263
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   264
        void checkException(Throwable t) {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   265
            if (shouldNPE) {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   266
                if (t instanceof NullPointerException) {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   267
                    System.out.println("Got expected exception");
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   268
                    return;
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   269
                } else {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   270
                    throw new RuntimeException("Expected NPE, but got ", t);
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   271
                }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   272
            }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   273
            if (t instanceof IOException) {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   274
                System.out.println("Got expected exception");
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   275
                return;
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   276
            } else {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   277
                throw new RuntimeException("Expected IOException but got ", t);
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   278
            }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   279
        }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   280
    }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   281
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   282
    static class PackTestInput extends TestInput {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   283
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   284
        public PackTestInput(JarFile jf, OutputStream out) {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   285
            super("PackTestInput", jf, out);
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   286
        }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   287
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   288
        JarFile getJarFile() {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   289
            return (JarFile) super.in;
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   290
        }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   291
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   292
        OutputStream getOutputStream() {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   293
            return (OutputStream) super.out;
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   294
        }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   295
    };
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   296
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   297
    static class PackTestJarInputStream extends TestInput {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   298
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   299
        public PackTestJarInputStream(JarInputStream in, OutputStream out) {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   300
            super("PackTestJarInputStream", in, out);
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   301
        }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   302
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   303
        JarInputStream getJarInputStream() {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   304
            return (JarInputStream) super.in;
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   305
        }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   306
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   307
        OutputStream getOutputStream() {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   308
            return (OutputStream) super.out;
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   309
        }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   310
    };
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   311
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   312
    static class UnpackTestInput extends TestInput {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   313
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   314
        public UnpackTestInput(InputStream in, JarOutputStream out) {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   315
            super("UnpackTestInput", in, out);
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   316
        }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   317
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   318
        InputStream getInputStream() {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   319
            return (InputStream) super.in;
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   320
        }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   321
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   322
        JarOutputStream getJarOutputStream() {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   323
            return (JarOutputStream) super.out;
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   324
        }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   325
    };
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   326
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   327
    static class UnpackTestFileInput extends TestInput {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   328
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   329
        public UnpackTestFileInput(File in, JarOutputStream out) {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   330
            super("UnpackTestInput", in, out);
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   331
        }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   332
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   333
        File getInputFile() {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   334
            return (File) super.in;
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   335
        }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   336
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   337
        JarOutputStream getJarOutputStream() {
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   338
            return (JarOutputStream) super.out;
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   339
        }
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   340
    };
ee97f78e7482 6985763: Pack200.Packer.pack(...) and Pack200.Unpacker.unpack(...) throw unspecified exceptions
ksrini
parents:
diff changeset
   341
}