changeset 12417:8e6b0b4fc31b

8157896: TestDSAGenParameterSpec.java test fails with timeout Reviewed-by: xuelei
author igerasim
date Fri, 08 Sep 2017 10:42:46 -0700
parents d205ce402f46
children 3cf154021626
files test/sun/security/provider/NSASuiteB/TestDSAGenParameterSpec.java
diffstat 1 files changed, 30 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/test/sun/security/provider/NSASuiteB/TestDSAGenParameterSpec.java	Fri Sep 08 10:41:02 2017 -0700
+++ b/test/sun/security/provider/NSASuiteB/TestDSAGenParameterSpec.java	Fri Sep 08 10:42:46 2017 -0700
@@ -31,19 +31,20 @@
 import java.security.spec.DSAGenParameterSpec;
 import java.security.spec.DSAParameterSpec;
 import java.security.spec.InvalidParameterSpecException;
-import java.util.Arrays;
-import java.util.List;
-import java.util.stream.Collectors;
 
 /*
  * @test
  * @bug 8075286
  * @summary Verify that DSAGenParameterSpec can and can only be used to generate
  *          DSA within some certain range of key sizes as described in the class
- *          specification (L, N) as (1024, 160), (2048, 224), (2048, 256) and
- *          (3072, 256) should be OK for DSAGenParameterSpec.
- * @run main TestDSAGenParameterSpec 2048,256,true 2048,224,true 1024,160,true 4096,256 3072,224 2048,160 1024,224 512,160
- * @run main TestDSAGenParameterSpec 3072,256,true
+ *          specification (L, N) as (1024, 160), (2048, 224) and (2048, 256)
+ *          should be OK for DSAGenParameterSpec.
+ * @run main TestDSAGenParameterSpec 512 160
+ * @run main TestDSAGenParameterSpec 1024 160 true
+ * @run main TestDSAGenParameterSpec 1024 224
+ * @run main TestDSAGenParameterSpec 2048 160
+ * @run main/timeout=300 TestDSAGenParameterSpec 2048 224 true
+ * @run main/timeout=300 TestDSAGenParameterSpec 2048 256 true
  */
 public class TestDSAGenParameterSpec {
 
@@ -56,8 +57,8 @@
         System.out.printf("Test case: primePLen=%d, " + "subprimeQLen=%d%n",
                 dataTuple.primePLen, dataTuple.subprimeQLen);
 
-        AlgorithmParameterGenerator apg =
-                AlgorithmParameterGenerator.getInstance(ALGORITHM_NAME,
+        AlgorithmParameterGenerator apg
+                = AlgorithmParameterGenerator.getInstance(ALGORITHM_NAME,
                         PROVIDER_NAME);
 
         DSAGenParameterSpec genParamSpec = createGenParameterSpec(dataTuple);
@@ -79,8 +80,8 @@
 
     private static void checkParam(AlgorithmParameters param,
             DSAGenParameterSpec genParam) throws InvalidParameterSpecException,
-                    NoSuchAlgorithmException, NoSuchProviderException,
-                    InvalidAlgorithmParameterException {
+            NoSuchAlgorithmException, NoSuchProviderException,
+            InvalidAlgorithmParameterException {
         String algorithm = param.getAlgorithm();
         if (!algorithm.equalsIgnoreCase(ALGORITHM_NAME)) {
             throw new RuntimeException(
@@ -138,21 +139,25 @@
     }
 
     public static void main(String[] args) throws Exception {
-        List<DataTuple> dataTuples = Arrays.stream(args)
-                .map(arg -> arg.split(",")).map(params -> {
-                    int primePLen = Integer.valueOf(params[0]);
-                    int subprimeQLen = Integer.valueOf(params[1]);
-                    boolean isDSASpecSupported = false;
-                    if (params.length == 3) {
-                        isDSASpecSupported = Boolean.valueOf(params[2]);
-                    }
-                    return new DataTuple(primePLen, subprimeQLen,
-                            isDSASpecSupported);
-                }).collect(Collectors.toList());
+        if (args == null || args.length < 2) {
+            throw new RuntimeException("Invalid number of arguments to generate"
+                    + " DSA parameter.");
+        }
+        DataTuple dataTuple = null;
+        switch (args.length) {
+            case 3:
+                dataTuple = new DataTuple(Integer.valueOf(args[0]),
+                        Integer.valueOf(args[1]), Boolean.valueOf(args[2]));
+                break;
+            case 2:
+                dataTuple = new DataTuple(Integer.valueOf(args[0]),
+                        Integer.valueOf(args[1]), false);
+                break;
+            default:
+                throw new RuntimeException("Unsupported arguments found.");
+        }
+        testDSAGenParameterSpec(dataTuple);
 
-        for (DataTuple dataTuple : dataTuples) {
-            testDSAGenParameterSpec(dataTuple);
-        }
     }
 
     private static class DataTuple {
@@ -169,4 +174,3 @@
         }
     }
 }
-