changeset 16863:6bb7ec151fd4

8176296: Test sun/security/krb5/auto/Basic.java faling after adding module declaration into TEST.properties. Reviewed-by: valeriep
author weijun
date Wed, 15 Mar 2017 08:09:43 +0800
parents 2e09a4e9a954
children 8ac762a3d4a4
files test/ProblemList.txt test/sun/security/krb5/auto/Basic.java
diffstat 2 files changed, 39 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/test/ProblemList.txt	Tue Mar 14 16:43:59 2017 -0700
+++ b/test/ProblemList.txt	Wed Mar 15 08:09:43 2017 +0800
@@ -215,9 +215,8 @@
 javax/net/ssl/DTLS/PacketLossRetransmission.java                8169086 macosx-x64
 javax/net/ssl/DTLS/RespondToRetransmit.java                     8169086 macosx-x64
 
-sun/security/krb5/auto/Basic.java                               8176296 generic-all
+sun/security/ssl/X509KeyManager/PreferredKey.java               8176354 generic-all
 
-sun/security/ssl/X509KeyManager/PreferredKey.java               8176354 generic-all
 ############################################################################
 
 # jdk_sound
--- a/test/sun/security/krb5/auto/Basic.java	Tue Mar 14 16:43:59 2017 -0700
+++ b/test/sun/security/krb5/auto/Basic.java	Wed Mar 15 08:09:43 2017 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2017, 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
@@ -25,19 +25,48 @@
  * @test
  * @bug 7152176 8164437
  * @summary More krb5 tests
+ * @library /test/lib
  * @compile -XDignore.symbol.file Basic.java
- * @run main/othervm
- *      Basic jdk.security.jgss
- * @run main/othervm --limit-modules java.security.jgss,jdk.security.auth
- *      Basic java.security.jgss
+ * @run main/othervm Basic
  */
 
+import jdk.test.lib.process.ProcessTools;
 import sun.security.jgss.GSSUtil;
 
-// The basic krb5 test skeleton you can copy from
+import java.util.List;
+import java.util.stream.Stream;
+
 public class Basic {
 
-    public static void main(String[] args) throws Exception {
+    public static void main(String[] args) throws Throwable {
+
+        if (args.length == 0) { // jtreg launched here
+
+            // With all modules
+            test("jdk.security.jgss");
+
+            // With limited modules
+            List<String> cmd = ProcessTools.createJavaProcessBuilder().command();
+            Stream.of(jdk.internal.misc.VM.getRuntimeArguments())
+                    .filter(arg -> arg.startsWith("--add-exports=") ||
+                            arg.startsWith("--add-opens="))
+                    .forEach(cmd::add);
+            cmd.addAll(List.of(
+                    "-Dtest.src=" + System.getProperty("test.src"),
+                    "--add-modules",
+                        "java.base,java.security.jgss,jdk.security.auth",
+                    "--limit-modules",
+                        "java.security.jgss,jdk.security.auth",
+                    "Basic",
+                    "launched-limited"));
+            ProcessTools.executeCommand(cmd.toArray(new String[cmd.size()]))
+                    .shouldHaveExitValue(0);
+        } else { // Launched by ProcessTools above, with limited modules.
+            test("java.security.jgss");
+        }
+    }
+
+    static void test(String expected) throws Exception {
 
         new OneKDC(null).writeJAASConf();
 
@@ -66,8 +95,8 @@
 
         // Bonus test for 8164437.
         String moduleName = c.x().getClass().getModule().getName();
-        if (!moduleName.equals(args[0])) {
-            throw new Exception("Expected: " + args[0]
+        if (!moduleName.equals(expected)) {
+            throw new Exception("Expected: " + expected
                     + ". Actual: " + moduleName);
         }
     }