< prev index next >

test/tools/wsgen/MultiReleaseJarTest.java

Print this page
rev 17272 : 8181391: remove explicit @build actions for the top level testlibary classes
Reviewed-by: duke


  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @summary Test Multi-Release jar support in wsgen tool
  27  * @library /test/lib
  28  * @library /lib/testlibrary
  29  * @modules jdk.compiler java.xml.ws
  30  * @build jdk.test.lib.JDKToolFinder jdk.test.lib.JDKToolLauncher
  31  *        jdk.test.lib.process.OutputAnalyzer
  32  *        jdk.test.lib.process.ProcessTools
  33  *        jdk.test.lib.Utils
  34  *        CompilerUtils MultiReleaseJarTest
  35  * @run testng MultiReleaseJarTest
  36  */
  37 
  38 import jdk.test.lib.JDKToolLauncher;
  39 import jdk.test.lib.Utils;
  40 import jdk.test.lib.process.OutputAnalyzer;
  41 import jdk.test.lib.process.ProcessTools;
  42 import org.testng.annotations.BeforeClass;
  43 import org.testng.annotations.DataProvider;
  44 import org.testng.annotations.Test;
  45 
  46 import java.io.IOException;
  47 import java.nio.file.Files;
  48 import java.nio.file.Path;
  49 import java.nio.file.Paths;
  50 import java.util.stream.Stream;
  51 
  52 import static org.testng.Assert.assertTrue;
  53 
  54 public class MultiReleaseJarTest {


 101         return new String(Files.readAllBytes(file)).contains(pattern);
 102     }
 103 
 104     private OutputAnalyzer jar(String... args) throws Throwable {
 105         JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jar");
 106         Stream.of(args).forEach(launcher::addToolArg);
 107         return ProcessTools.executeCommand(launcher.getCommand());
 108     }
 109 
 110     private void compile() throws Throwable {
 111         String[] vers = {"base", "v9", "v10"};
 112         for (String ver : vers) {
 113             Path classes = Paths.get("classes", ver);
 114             Files.createDirectories(classes);
 115             Path source = Paths.get(Utils.TEST_SRC,"data", "mr", ver);
 116             assertTrue(CompilerUtils.compile(source, classes,
 117                     "--add-modules", "java.xml.ws"));
 118         }
 119     }
 120 }



  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @summary Test Multi-Release jar support in wsgen tool
  27  * @library /test/lib
  28  * @library /lib/testlibrary
  29  * @modules jdk.compiler java.xml.ws
  30  * @build CompilerUtils




  31  * @run testng MultiReleaseJarTest
  32  */
  33 
  34 import jdk.test.lib.JDKToolLauncher;
  35 import jdk.test.lib.Utils;
  36 import jdk.test.lib.process.OutputAnalyzer;
  37 import jdk.test.lib.process.ProcessTools;
  38 import org.testng.annotations.BeforeClass;
  39 import org.testng.annotations.DataProvider;
  40 import org.testng.annotations.Test;
  41 
  42 import java.io.IOException;
  43 import java.nio.file.Files;
  44 import java.nio.file.Path;
  45 import java.nio.file.Paths;
  46 import java.util.stream.Stream;
  47 
  48 import static org.testng.Assert.assertTrue;
  49 
  50 public class MultiReleaseJarTest {


  97         return new String(Files.readAllBytes(file)).contains(pattern);
  98     }
  99 
 100     private OutputAnalyzer jar(String... args) throws Throwable {
 101         JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jar");
 102         Stream.of(args).forEach(launcher::addToolArg);
 103         return ProcessTools.executeCommand(launcher.getCommand());
 104     }
 105 
 106     private void compile() throws Throwable {
 107         String[] vers = {"base", "v9", "v10"};
 108         for (String ver : vers) {
 109             Path classes = Paths.get("classes", ver);
 110             Files.createDirectories(classes);
 111             Path source = Paths.get(Utils.TEST_SRC,"data", "mr", ver);
 112             assertTrue(CompilerUtils.compile(source, classes,
 113                     "--add-modules", "java.xml.ws"));
 114         }
 115     }
 116 }
 117 
< prev index next >