jdk/test/tools/jar/UpdateManifest.java
author mchung
Wed, 12 Oct 2016 15:41:00 -0700
changeset 41484 834b7539ada3
parent 30820 0d4717a011d3
permissions -rw-r--r--
8164689: Retrofit jar, jlink, jmod as a ToolProvider Reviewed-by: alanb, lancea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
6883
bbd0cba11983 6984046: java/jar jar/pack source needs vendor rebranding changes (jdk7 only)
sherman
parents: 5813
diff changeset
     2
 * Copyright (c) 2006, 2010, 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
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
 * @test
6883
bbd0cba11983 6984046: java/jar jar/pack source needs vendor rebranding changes (jdk7 only)
sherman
parents: 5813
diff changeset
    26
 * @bug 6434207 6442687 6984046
41484
834b7539ada3 8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents: 30820
diff changeset
    27
 * @modules jdk.jartool
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 * @summary Ensure that jar ufm actually updates the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * existing jar file's manifest with contents of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * manifest file.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.io.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.util.logging.*;
41484
834b7539ada3 8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents: 30820
diff changeset
    35
import java.util.spi.ToolProvider;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.util.zip.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
public class UpdateManifest {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
    static PrintStream out = System.out;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    static PrintStream err = System.err;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    static boolean debug = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
41484
834b7539ada3 8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents: 30820
diff changeset
    43
    static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar")
834b7539ada3 8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents: 30820
diff changeset
    44
        .orElseThrow(() ->
834b7539ada3 8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents: 30820
diff changeset
    45
            new RuntimeException("jar tool not found")
834b7539ada3 8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents: 30820
diff changeset
    46
        );
834b7539ada3 8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents: 30820
diff changeset
    47
22261
e82547d2e78a 8031525: Logger created in test/tools/jar/UpdateManifest.java might get gc'ed too early.
dfuchs
parents: 6883
diff changeset
    48
    static final Logger JAR_LOGGER = Logger.getLogger("java.util.jar");
e82547d2e78a 8031525: Logger created in test/tools/jar/UpdateManifest.java might get gc'ed too early.
dfuchs
parents: 6883
diff changeset
    49
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    public static void realMain(String[] args) throws Throwable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
        if (args.length == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
            debug = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
            File tmp = File.createTempFile("system-out-err", ".txt");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
            tmp.deleteOnExit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
            out = new PrintStream(new FileOutputStream(tmp));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
            err = out;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
            // Attributes.read() can log a message we don't care to see.
22261
e82547d2e78a 8031525: Logger created in test/tools/jar/UpdateManifest.java might get gc'ed too early.
dfuchs
parents: 6883
diff changeset
    58
            JAR_LOGGER.setLevel(Level.OFF);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        try { testManifestExistence(); } catch (Throwable t) { unexpected(t); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
        try { testManifestContents(); } catch (Throwable t) { unexpected(t); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    static void testManifestExistence() throws Throwable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        // Create a file to put in a jar file
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        File existence = createTextFile("existence");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        // Create a jar file, specifying a Main-Class
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        final String jarFileName = "um-existence.jar";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        new File(jarFileName).delete(); // remove pre-existing first!
41484
834b7539ada3 8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents: 30820
diff changeset
    72
        int status = JAR_TOOL.run(out, err, "cfe", jarFileName,
834b7539ada3 8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents: 30820
diff changeset
    73
                                  "Hello", existence.getPath());
834b7539ada3 8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents: 30820
diff changeset
    74
        check(status == 0);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        checkManifest(jarFileName, "Hello");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        // Update that jar file by changing the Main-Class
41484
834b7539ada3 8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents: 30820
diff changeset
    78
        status = JAR_TOOL.run(out, err, "ufe", jarFileName, "Bye");
834b7539ada3 8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents: 30820
diff changeset
    79
        check(status == 0);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        checkManifest(jarFileName, "Bye");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    static void testManifestContents() throws Throwable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        // Create some strings we expect to find in the updated manifest
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        final String animal =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
            "Name: animal/marsupial";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        final String specTitle =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
            "Specification-Title: Wombat";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        // Create a text file with manifest entries
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        File manifestOrig = File.createTempFile("manifestOrig", ".txt");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        if (!debug) manifestOrig.deleteOnExit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        PrintWriter pw = new PrintWriter(manifestOrig);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        pw.println("Manifest-Version: 1.0");
6883
bbd0cba11983 6984046: java/jar jar/pack source needs vendor rebranding changes (jdk7 only)
sherman
parents: 5813
diff changeset
    95
        pw.println("Created-By: 1.7.0-internal (Oracle Corporation)");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        pw.println("");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        pw.println(animal);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        pw.println(specTitle);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        pw.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        File hello = createTextFile("hello");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        // Create a jar file
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        final String jarFileName = "um-test.jar";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        new File(jarFileName).delete(); // remove pre-existing first!
41484
834b7539ada3 8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents: 30820
diff changeset
   106
        int status = JAR_TOOL.run(out, err, "cfm", jarFileName,
834b7539ada3 8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents: 30820
diff changeset
   107
                                  manifestOrig.getPath(), hello.getPath());
834b7539ada3 8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents: 30820
diff changeset
   108
        check(status == 0);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        // Create a new manifest, to use in updating the jar file.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        File manifestUpdate = File.createTempFile("manifestUpdate", ".txt");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        if (!debug) manifestUpdate.deleteOnExit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        pw = new PrintWriter(manifestUpdate);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        final String createdBy =
6883
bbd0cba11983 6984046: java/jar jar/pack source needs vendor rebranding changes (jdk7 only)
sherman
parents: 5813
diff changeset
   115
            "Created-By: 1.7.0-special (Oracle Corporation)";
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        final String specVersion =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
            "Specification-Version: 1.0.0.0";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        pw.println(createdBy); // replaces line in the original
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        pw.println("");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        pw.println(animal);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        pw.println(specVersion); // addition to animal/marsupial section
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        pw.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        // Update jar file with manifest
41484
834b7539ada3 8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents: 30820
diff changeset
   125
        status = JAR_TOOL.run(out, err, "ufm",
834b7539ada3 8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents: 30820
diff changeset
   126
                              jarFileName, manifestUpdate.getPath());
834b7539ada3 8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents: 30820
diff changeset
   127
        check(status == 0);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        // Extract jar, and verify contents of manifest file
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        File f = new File(jarFileName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        if (!debug) f.deleteOnExit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        ZipFile zf = new ZipFile(f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        ZipEntry ze = zf.getEntry("META-INF/MANIFEST.MF");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        BufferedReader r = new BufferedReader(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
            new InputStreamReader(zf.getInputStream(ze)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        r.readLine(); // skip Manifest-Version
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        check(r.readLine().equals(createdBy));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        r.readLine(); // skip blank line
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        check(r.readLine().equals(animal));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        String s = r.readLine();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        if (s.equals(specVersion)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
            check(r.readLine().equals(specTitle));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        } else if (s.equals(specTitle)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
            check(r.readLine().equals(specVersion));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
            fail("did not match specVersion nor specTitle");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        }
5813
8e455cd3e807 6962617: Testcase changes, cleanup of problem list for jdk_tools targets
ohair
parents: 5506
diff changeset
   148
        zf.close();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    // --------------------- Convenience ---------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    static File createTextFile(String name) throws Throwable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        // Create a text file to put in a jar file
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        File rc = File.createTempFile(name, ".txt");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        if (!debug) rc.deleteOnExit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        PrintWriter pw = new PrintWriter(rc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        pw.println("hello, world");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        pw.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        return rc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    static void checkManifest(String jarFileName, String mainClass)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
                throws Throwable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        File f = new File(jarFileName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        if (!debug) f.deleteOnExit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        ZipFile zf = new ZipFile(f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        ZipEntry ze = zf.getEntry("META-INF/MANIFEST.MF");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        BufferedReader r = new BufferedReader(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
            new InputStreamReader(zf.getInputStream(ze)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        String line = r.readLine();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        while (line != null && !(line.startsWith("Main-Class:"))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
            line = r.readLine();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        if (line == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
            fail("Didn't find Main-Class in manifest");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
            check(line.equals("Main-Class: " + mainClass));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        zf.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    // --------------------- Infrastructure ---------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    static volatile int passed = 0, failed = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    static void pass() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        passed++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    static void fail() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        failed++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        Thread.dumpStack();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    static void fail(String msg) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        System.out.println(msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        fail();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    static void unexpected(Throwable t) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        failed++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        t.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    static void check(boolean cond) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        if (cond)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
            pass();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
            fail();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    static void equal(Object x, Object y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        if ((x == null) ? (y == null) : x.equals(y))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
            pass();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
            fail(x + " not equal to " + y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    public static void main(String[] args) throws Throwable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
            realMain(args);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        } catch (Throwable t) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
            unexpected(t);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        System.out.println("\nPassed = " + passed + " failed = " + failed);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        if (failed > 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
            throw new AssertionError("Some tests failed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
}