changeset 35400:d1d4726300d3

8076458: java/util/stream/test/org/openjdk/tests/java/util/stream/FlatMapOpTest.java timeout Reviewed-by: psandoz Contributed-by: huaming.li@oracle.com
author amlu
date Mon, 01 Feb 2016 09:38:08 +0800
parents babca4eef83f
children f57a51dbcc50
files jdk/test/java/util/stream/bootlib/java.base/java/util/stream/DoubleStreamTestDataProvider.java jdk/test/java/util/stream/bootlib/java.base/java/util/stream/IntStreamTestDataProvider.java jdk/test/java/util/stream/bootlib/java.base/java/util/stream/LongStreamTestDataProvider.java jdk/test/java/util/stream/bootlib/java.base/java/util/stream/StreamTestDataProvider.java jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/FlatMapOpTest.java
diffstat 5 files changed, 74 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/DoubleStreamTestDataProvider.java	Sun Jan 31 22:30:35 2016 +0100
+++ b/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/DoubleStreamTestDataProvider.java	Mon Feb 01 09:38:08 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, 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
@@ -41,6 +41,7 @@
     private static final double[] pseudoRandom;
 
     private static final Object[][] testData;
+    private static final Object[][] testSmallData;
     private static final Object[][] spliteratorTestData;
 
     static {
@@ -78,11 +79,15 @@
 
     static {
         {
-            List<Object[]> list = new ArrayList<>();
+            List<Object[]> listSmall = new ArrayList<>();
+            List<Object[]> list1000 = new ArrayList<>();
+            List<Object[]> list = null;
             for (Object[] data : arrays) {
                 final Object name = data[0];
                 final double[] doubles = (double[]) data[1];
 
+                list = doubles.length >= 1000 ? list1000 : listSmall;
+
                 list.add(new Object[]{"array:" + name,
                         TestData.Factory.ofArray("array:" + name, doubles)});
 
@@ -93,7 +98,9 @@
                 list.add(new Object[]{"SpinedList:" + name,
                         TestData.Factory.ofSpinedBuffer("SpinedList:" + name, isl)});
             }
-            testData = list.toArray(new Object[0][]);
+            testSmallData = listSmall.toArray(new Object[0][]);
+            list1000.addAll(listSmall);
+            testData = list1000.toArray(new Object[0][]);
         }
 
         {
@@ -136,6 +143,11 @@
         return testData;
     }
 
+    @DataProvider(name = "DoubleStreamTestData.small")
+    public static Object[][] makeSmallDoubleStreamTestData() {
+        return testSmallData;
+    }
+
     // returns an array of (String name, Supplier<PrimitiveSpliterator<Double>>)
     @DataProvider(name = "DoubleSpliterator")
     public static Object[][] spliteratorProvider() {
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/IntStreamTestDataProvider.java	Sun Jan 31 22:30:35 2016 +0100
+++ b/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/IntStreamTestDataProvider.java	Mon Feb 01 09:38:08 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, 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
@@ -41,6 +41,7 @@
     private static final int[] pseudoRandom;
 
     private static final Object[][] testData;
+    private static final Object[][] testSmallData;
     private static final Object[][] spliteratorTestData;
 
     static {
@@ -78,11 +79,15 @@
 
     static {
         {
-            List<Object[]> list = new ArrayList<>();
+            List<Object[]> listSmall = new ArrayList<>();
+            List<Object[]> list1000 = new ArrayList<>();
+            List<Object[]> list = null;
             for (Object[] data : arrays) {
                 final Object name = data[0];
                 final int[] ints = (int[]) data[1];
 
+                list = ints.length >= 1000 ? list1000 : listSmall;
+
                 list.add(new Object[]{"array:" +
                                       name, TestData.Factory.ofArray("array:" + name, ints)});
 
@@ -98,7 +103,9 @@
                 list.add(streamDataDescr("IntStream.rangeClosed(0,l): " + ints.length,
                                          () -> IntStream.rangeClosed(0, ints.length)));
             }
-            testData = list.toArray(new Object[0][]);
+            testSmallData = listSmall.toArray(new Object[0][]);
+            list1000.addAll(listSmall);
+            testData = list1000.toArray(new Object[0][]);
         }
 
         {
@@ -150,6 +157,11 @@
         return testData;
     }
 
+    @DataProvider(name = "IntStreamTestData.small")
+    public static Object[][] makeSmallIntStreamTestData() {
+        return testSmallData;
+    }
+
     // returns an array of (String name, Supplier<PrimitiveSpliterator<Integer>>)
     @DataProvider(name = "IntSpliterator")
     public static Object[][] spliteratorProvider() {
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/LongStreamTestDataProvider.java	Sun Jan 31 22:30:35 2016 +0100
+++ b/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/LongStreamTestDataProvider.java	Mon Feb 01 09:38:08 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, 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
@@ -41,6 +41,7 @@
     private static final long[] pseudoRandom;
 
     private static final Object[][] testData;
+    private static final Object[][] testSmallData;
     private static final Object[][] spliteratorTestData;
 
     static {
@@ -78,11 +79,15 @@
 
     static {
         {
-            List<Object[]> list = new ArrayList<>();
+            List<Object[]> listSmall = new ArrayList<>();
+            List<Object[]> list1000 = new ArrayList<>();
+            List<Object[]> list = null;
             for (Object[] data : arrays) {
                 final Object name = data[0];
                 final long[] longs = (long[]) data[1];
 
+                list = longs.length >= 1000 ? list1000 : listSmall;
+
                 list.add(new Object[]{"array:" + name,
                         TestData.Factory.ofArray("array:" + name, longs)});
 
@@ -98,7 +103,9 @@
                 list.add(streamDataDescr("LongStream.longRangeClosed(0,l): " + longs.length,
                                          () -> LongStream.rangeClosed(0, longs.length)));
             }
-            testData = list.toArray(new Object[0][]);
+            testSmallData = listSmall.toArray(new Object[0][]);
+            list1000.addAll(listSmall);
+            testData = list1000.toArray(new Object[0][]);
         }
 
         {
@@ -150,6 +157,11 @@
         return testData;
     }
 
+    @DataProvider(name = "LongStreamTestData.small")
+    public static Object[][] makeSmallLongStreamTestData() {
+        return testSmallData;
+    }
+
     // returns an array of (String name, Supplier<PrimitiveSpliterator<Long>>)
     @DataProvider(name = "LongSpliterator")
     public static Object[][] spliteratorProvider() {
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/StreamTestDataProvider.java	Sun Jan 31 22:30:35 2016 +0100
+++ b/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/StreamTestDataProvider.java	Mon Feb 01 09:38:08 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, 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
@@ -46,6 +46,7 @@
     private static final Integer[] pseudoRandom;
 
     private static final Object[][] testData;
+    private static final Object[][] testSmallData;
     private static final Object[][] withNullTestData;
     private static final Object[][] spliteratorTestData;
 
@@ -84,12 +85,16 @@
 
     static {
         {
-            List<Object[]> list = new ArrayList<>();
+            List<Object[]> listSmall = new ArrayList<>();
+            List<Object[]> list1000 = new ArrayList<>();
+            List<Object[]> list = null;
             for (Object[] data : arrays) {
                 final Object name = data[0];
                 final Integer[] ints = (Integer[])data[1];
                 final List<Integer> intsAsList = Arrays.asList(ints);
 
+                list = ints.length >= 1000 ? list1000 : listSmall;
+
                 list.add(arrayDataDescr("array:" + name, ints));
                 list.add(collectionDataDescr("ArrayList.asList:" + name, intsAsList));
                 list.add(collectionDataDescr("ArrayList:" + name, new ArrayList<>(intsAsList)));
@@ -114,7 +119,9 @@
 
                 // @@@ Add more
             }
-            testData = list.toArray(new Object[0][]);
+            testSmallData = listSmall.toArray(new Object[0][]);
+            list1000.addAll(listSmall);
+            testData = list1000.toArray(new Object[0][]);
         }
 
         // Simple combination of numbers and null values, probably excessive but may catch
@@ -192,6 +199,11 @@
         return testData;
     }
 
+    @DataProvider(name = "StreamTestData<Integer>.small")
+    public static Object[][] makeSmallStreamTestData() {
+        return testSmallData;
+    }
+
     @DataProvider(name = "withNull:StreamTestData<Integer>")
     public static Object[][] makeStreamWithNullTestData() {
         return withNullTestData;
--- a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/FlatMapOpTest.java	Sun Jan 31 22:30:35 2016 +0100
+++ b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/FlatMapOpTest.java	Mon Feb 01 09:38:08 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, 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
@@ -24,7 +24,7 @@
 /*
  * @test
  * @summary flat-map operations
- * @bug 8044047
+ * @bug 8044047 8076458
  */
 
 package org.openjdk.tests.java.util.stream;
@@ -140,7 +140,10 @@
 
         result = exerciseOps(data, s-> s.flatMap(e -> Stream.empty()));
         assertEquals(0, result.size());
+    }
 
+    @Test(dataProvider = "StreamTestData<Integer>.small", dataProviderClass = StreamTestDataProvider.class)
+    public void testOpsX(String name, TestData.OfRef<Integer> data) {
         exerciseOps(data, s -> s.flatMap(mfLt));
         exerciseOps(data, s -> s.flatMap(integerRangeMapper));
         exerciseOps(data, s -> s.flatMap((Integer e) -> IntStream.range(0, e).boxed().limit(10)));
@@ -156,7 +159,10 @@
 
         result = exerciseOps(data, s -> s.flatMap(i -> IntStream.empty()));
         assertEquals(0, result.size());
+    }
 
+    @Test(dataProvider = "IntStreamTestData.small", dataProviderClass = IntStreamTestDataProvider.class)
+    public void testIntOpsX(String name, TestData.OfInt data) {
         exerciseOps(data, s -> s.flatMap(e -> IntStream.range(0, e)));
         exerciseOps(data, s -> s.flatMap(e -> IntStream.range(0, e).limit(10)));
     }
@@ -171,7 +177,10 @@
 
         result = exerciseOps(data, s -> LongStream.empty());
         assertEquals(0, result.size());
+    }
 
+    @Test(dataProvider = "LongStreamTestData.small", dataProviderClass = LongStreamTestDataProvider.class)
+    public void testLongOpsX(String name, TestData.OfLong data) {
         exerciseOps(data, s -> s.flatMap(e -> LongStream.range(0, e)));
         exerciseOps(data, s -> s.flatMap(e -> LongStream.range(0, e).limit(10)));
     }
@@ -186,7 +195,10 @@
 
         result = exerciseOps(data, s -> DoubleStream.empty());
         assertEquals(0, result.size());
+    }
 
+    @Test(dataProvider = "DoubleStreamTestData.small", dataProviderClass = DoubleStreamTestDataProvider.class)
+    public void testDoubleOpsX(String name, TestData.OfDouble data) {
         exerciseOps(data, s -> s.flatMap(e -> IntStream.range(0, (int) e).asDoubleStream()));
         exerciseOps(data, s -> s.flatMap(e -> IntStream.range(0, (int) e).limit(10).asDoubleStream()));
     }