8146758: NetworkInterfaceStreamTest.java fails intermittently at comparing network interfaces
authorxiaofeya
Tue, 19 Apr 2016 01:40:13 -0700
changeset 37537 0af4cc7d6f54
parent 37536 dcd80bbbb686
child 37538 feed20ba7a0c
8146758: NetworkInterfaceStreamTest.java fails intermittently at comparing network interfaces Reviewed-by: chegar Contributed-by: Felix Yang <felix.yang@oracle.com>
jdk/test/java/net/NetworkInterface/NetworkInterfaceStreamTest.java
--- a/jdk/test/java/net/NetworkInterface/NetworkInterfaceStreamTest.java	Mon Apr 18 22:12:52 2016 -0700
+++ b/jdk/test/java/net/NetworkInterface/NetworkInterfaceStreamTest.java	Tue Apr 19 01:40:13 2016 -0700
@@ -28,7 +28,6 @@
  * @build java.base/java.util.stream.OpTestCase
  * @run testng/othervm NetworkInterfaceStreamTest
  * @run testng/othervm -Djava.net.preferIPv4Stack=true NetworkInterfaceStreamTest
- * @key intermittent
  */
 
 import org.testng.annotations.Test;
@@ -52,21 +51,26 @@
     public void testNetworkInterfaces() throws SocketException {
         Supplier<Stream<NetworkInterface>> ss = () -> {
             try {
-                return NetworkInterface.networkInterfaces();
+                return allNetworkInterfaces();
             }
             catch (SocketException e) {
                 throw new RuntimeException(e);
             }
         };
 
-        Collection<NetworkInterface> expected = Collections.list(NetworkInterface.getNetworkInterfaces());
+        Collection<NetworkInterface> enums = Collections.list(NetworkInterface.getNetworkInterfaces());
+        Collection<NetworkInterface> expected = new ArrayList<>();
+        enums.forEach(ni -> {
+            if (isIncluded(ni)) {
+                expected.add(ni);
+            }
+        });
         withData(TestData.Factory.ofSupplier("Top-level network interfaces", ss))
                 .stream(s -> s)
                 .expectedResult(expected)
                 .exercise();
     }
 
-
     private Collection<NetworkInterface> getAllNetworkInterfaces() throws SocketException {
         Collection<NetworkInterface> anis = new ArrayList<>();
         for (NetworkInterface ni : Collections.list(NetworkInterface.getNetworkInterfaces())) {