/* * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions.
*/
/* * @test * @bug 8276764 * @summary test that the jar content ordering is sorted * @library /test/lib * @modules jdk.jartool * @build jdk.test.lib.Platform * jdk.test.lib.util.FileUtils * @run testng ContentOrder
*/
// Test that the jar content ordering when processing a single directory is sorted
@Test publicvoid testSingleDir() throws IOException {
mkdir("testjar/Ctest1", "testjar/Btest2/subdir1", "testjar/Atest3");
touch("testjar/Ctest1/testfile1", "testjar/Ctest1/testfile2", "testjar/Ctest1/testfile3");
touch("testjar/Btest2/subdir1/testfileC", "testjar/Btest2/subdir1/testfileB", "testjar/Btest2/subdir1/testfileA");
touch("testjar/Atest3/fileZ", "testjar/Atest3/fileY", "testjar/Atest3/fileX");
// Test that when specifying multiple directories or releases that the sort // ordering is done on each directory and release, reserving the order of // the directories/releases specified on the command line
@Test publicvoid testMultiDirWithReleases() throws IOException {
mkdir("testjar/foo/classes", "testjar/foo11/classes/Zclasses", "testjar/foo11/classes/Yclasses", "testjar/foo17/classes/Bclasses", "testjar/foo17/classes/Aclasses");
touch("testjar/foo/classes/testfile1", "testjar/foo/classes/testfile2");
touch("testjar/foo11/classes/Zclasses/testfile1", "testjar/foo11/classes/Zclasses/testfile2");
touch("testjar/foo11/classes/Yclasses/testfileA", "testjar/foo11/classes/Yclasses/testfileB");
touch("testjar/foo17/classes/Bclasses/testfile1", "testjar/foo17/classes/Bclasses/testfile2");
touch("testjar/foo17/classes/Aclasses/testfileA", "testjar/foo17/classes/Aclasses/testfileB");
// the run method catches IOExceptions, we need to expose them
ByteArrayOutputStream baes = new ByteArrayOutputStream();
PrintStream err = new PrintStream(baes);
PrintStream saveErr = System.err;
System.setErr(err); int rc = JAR_TOOL.run(out, err, cmdline.split(" +"));
System.setErr(saveErr); if (rc != 0) {
String s = baes.toString(); if (s.startsWith("java.util.zip.ZipException: duplicate entry: ")) { thrownew ZipException(s);
} thrownew IOException(s);
}
}
}
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.