changeset 14209:9bde86ff09ba

8146758: NetworkInterfaceStreamTest.java fails intermittently at comparing network interfaces Reviewed-by: chegar Contributed-by: Felix Yang <felix.yang@oracle.com>
author xiaofeya
date Tue, 19 Apr 2016 01:40:13 -0700
parents def1edac0ea5
children 79e92af0d115
files test/java/net/NetworkInterface/NetworkInterfaceStreamTest.java
diffstat 1 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/test/java/net/NetworkInterface/NetworkInterfaceStreamTest.java	Mon Apr 18 22:12:52 2016 -0700
+++ b/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())) {