< prev index next >

jdk/test/tools/jar/InputFilesTest.java

Print this page

        

*** 27,37 **** * @summary test several jar tool input file scenarios with variations on -C * options with/without a --release option. Some input files are * duplicates that sometimes cause exceptions and other times do not, * demonstrating identical behavior to JDK 8 jar tool. * @library /lib/testlibrary ! * @modules jdk.jartool/sun.tools.jar * @build jdk.testlibrary.FileUtils * @run testng InputFilesTest */ import org.testng.Assert; --- 27,37 ---- * @summary test several jar tool input file scenarios with variations on -C * options with/without a --release option. Some input files are * duplicates that sometimes cause exceptions and other times do not, * demonstrating identical behavior to JDK 8 jar tool. * @library /lib/testlibrary ! * @modules jdk.jartool * @build jdk.testlibrary.FileUtils * @run testng InputFilesTest */ import org.testng.Assert;
*** 45,60 **** --- 45,66 ---- import java.io.UncheckedIOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Arrays; + import java.util.spi.ToolProvider; import java.util.stream.Stream; import java.util.zip.ZipException; import jdk.testlibrary.FileUtils; public class InputFilesTest { + private static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar") + .orElseThrow(() -> + new RuntimeException("jar tool not found") + ); + private final String nl = System.lineSeparator(); private final ByteArrayOutputStream baos = new ByteArrayOutputStream(); private final PrintStream out = new PrintStream(baos); private Runnable onCompletion;
*** 193,205 **** // 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); ! boolean ok = new sun.tools.jar.Main(out, err, "jar").run(cmdline.split(" +")); System.setErr(saveErr); ! if (!ok) { String s = baes.toString(); if (s.startsWith("java.util.zip.ZipException: duplicate entry: ")) { throw new ZipException(s); } throw new IOException(s); --- 199,211 ---- // 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: ")) { throw new ZipException(s); } throw new IOException(s);
< prev index next >