langtools/test/tools/javac/javazip/JavaZipTest.java
changeset 36778 e04318f39f92
parent 36526 3b41f1c69604
equal deleted inserted replaced
36777:28d33fb9097f 36778:e04318f39f92
     1 /*
     1 /*
     2  * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    25  * @test
    25  * @test
    26  * @bug 4098712 6304984 6388453
    26  * @bug 4098712 6304984 6388453
    27  * @summary check that source files inside zip files on the class path are ignored
    27  * @summary check that source files inside zip files on the class path are ignored
    28  * @library /tools/lib
    28  * @library /tools/lib
    29  * @modules jdk.compiler/com.sun.tools.javac.api
    29  * @modules jdk.compiler/com.sun.tools.javac.api
    30  *          jdk.compiler/com.sun.tools.javac.file
       
    31  *          jdk.compiler/com.sun.tools.javac.main
    30  *          jdk.compiler/com.sun.tools.javac.main
    32  *          jdk.jdeps/com.sun.tools.javap
    31  * @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask
    33  * @build ToolBox
       
    34  * @run main JavaZipTest
    32  * @run main JavaZipTest
    35  */
    33  */
    36 
    34 
    37 import java.nio.file.Files;
    35 import java.nio.file.Files;
    38 import java.nio.file.Paths;
    36 import java.nio.file.Paths;
    39 import java.util.Arrays;
    37 import java.util.Arrays;
       
    38 
       
    39 import toolbox.JarTask;
       
    40 import toolbox.JavacTask;
       
    41 import toolbox.Task;
       
    42 import toolbox.ToolBox;
    40 
    43 
    41 // Original test: test/tools/javac/javazip/Test.sh
    44 // Original test: test/tools/javac/javazip/Test.sh
    42 public class JavaZipTest {
    45 public class JavaZipTest {
    43 
    46 
    44     private static final String ASrc =
    47     private static final String ASrc =
    82     private final ToolBox tb = new ToolBox();
    85     private final ToolBox tb = new ToolBox();
    83 
    86 
    84     public void test() throws Exception {
    87     public void test() throws Exception {
    85         createOutputDirAndSourceFiles();
    88         createOutputDirAndSourceFiles();
    86         createZipsAndJars();
    89         createZipsAndJars();
    87         check(ToolBox.Expect.SUCCESS, successfulCompilationArgs);
    90         check(Task.Expect.SUCCESS, successfulCompilationArgs);
    88         check(ToolBox.Expect.FAIL, unsuccessfulCompilationArgs);
    91         check(Task.Expect.FAIL, unsuccessfulCompilationArgs);
    89     }
    92     }
    90 
    93 
    91     void createOutputDirAndSourceFiles() throws Exception {
    94     void createOutputDirAndSourceFiles() throws Exception {
    92         //create output dir
    95         //create output dir
    93         Files.createDirectory(Paths.get("output"));
    96         Files.createDirectory(Paths.get("output"));
    99     }
   102     }
   100 
   103 
   101     void createZipsAndJars() throws Exception {
   104     void createZipsAndJars() throws Exception {
   102         //jar and zip creation
   105         //jar and zip creation
   103         for (String[] args: jarArgs) {
   106         for (String[] args: jarArgs) {
   104             tb.new JarTask().run(args).writeAll();
   107             new JarTask(tb).run(args).writeAll();
   105         }
   108         }
   106     }
   109     }
   107 
   110 
   108     void check(ToolBox.Expect expectedStatus, String[][] theArgs) throws Exception {
   111     void check(Task.Expect expectedStatus, String[][] theArgs) throws Exception {
   109 
   112 
   110 
   113 
   111         for (String[] allArgs: theArgs) {
   114         for (String[] allArgs: theArgs) {
   112             tb.new JavacTask()
   115             new JavacTask(tb)
   113                     .options(opts(allArgs))
   116                     .options(opts(allArgs))
   114                     .files(files(allArgs))
   117                     .files(files(allArgs))
   115                     .run(expectedStatus)
   118                     .run(expectedStatus)
   116                     .writeAll();
   119                     .writeAll();
   117 
   120