jdk/test/java/net/NetworkInterface/NetworkInterfaceStreamTest.java
author xiaofeya
Tue, 19 Apr 2016 01:40:13 -0700
changeset 37537 0af4cc7d6f54
parent 36511 9d0388c6b336
child 37588 e672a494cce9
permissions -rw-r--r--
8146758: NetworkInterfaceStreamTest.java fails intermittently at comparing network interfaces Reviewed-by: chegar Contributed-by: Felix Yang <felix.yang@oracle.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
31469
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
     1
/*
35705
5c3998b1b7ea 8149003: Mark more jdk_core tests as intermittently failing
amlu
parents: 34834
diff changeset
     2
 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
31469
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
     4
 *
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
     7
 * published by the Free Software Foundation.
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
     8
 *
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    13
 * accompanied this code).
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    14
 *
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    18
 *
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    21
 * questions.
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    22
 */
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    23
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    24
/* @test
34722
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
    25
 * @bug 8081678 8131155
31469
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    26
 * @summary Tests for stream returning methods
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35705
diff changeset
    27
 * @library ../../util/stream/bootlib
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35705
diff changeset
    28
 * @build java.base/java.util.stream.OpTestCase
31469
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    29
 * @run testng/othervm NetworkInterfaceStreamTest
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    30
 * @run testng/othervm -Djava.net.preferIPv4Stack=true NetworkInterfaceStreamTest
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    31
 */
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    32
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    33
import org.testng.annotations.Test;
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    34
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    35
import java.net.InetAddress;
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    36
import java.net.NetworkInterface;
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    37
import java.net.SocketException;
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    38
import java.util.ArrayList;
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    39
import java.util.Collection;
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    40
import java.util.Collections;
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    41
import java.util.function.Supplier;
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    42
import java.util.stream.OpTestCase;
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    43
import java.util.stream.Stream;
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    44
import java.util.stream.TestData;
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    45
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    46
public class NetworkInterfaceStreamTest extends OpTestCase {
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    47
34722
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
    48
    private final static boolean IS_WINDOWS = System.getProperty("os.name").startsWith("Windows");
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
    49
31469
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    50
    @Test
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    51
    public void testNetworkInterfaces() throws SocketException {
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    52
        Supplier<Stream<NetworkInterface>> ss = () -> {
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    53
            try {
37537
0af4cc7d6f54 8146758: NetworkInterfaceStreamTest.java fails intermittently at comparing network interfaces
xiaofeya
parents: 36511
diff changeset
    54
                return allNetworkInterfaces();
31469
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    55
            }
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    56
            catch (SocketException e) {
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    57
                throw new RuntimeException(e);
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    58
            }
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    59
        };
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    60
37537
0af4cc7d6f54 8146758: NetworkInterfaceStreamTest.java fails intermittently at comparing network interfaces
xiaofeya
parents: 36511
diff changeset
    61
        Collection<NetworkInterface> enums = Collections.list(NetworkInterface.getNetworkInterfaces());
0af4cc7d6f54 8146758: NetworkInterfaceStreamTest.java fails intermittently at comparing network interfaces
xiaofeya
parents: 36511
diff changeset
    62
        Collection<NetworkInterface> expected = new ArrayList<>();
0af4cc7d6f54 8146758: NetworkInterfaceStreamTest.java fails intermittently at comparing network interfaces
xiaofeya
parents: 36511
diff changeset
    63
        enums.forEach(ni -> {
0af4cc7d6f54 8146758: NetworkInterfaceStreamTest.java fails intermittently at comparing network interfaces
xiaofeya
parents: 36511
diff changeset
    64
            if (isIncluded(ni)) {
0af4cc7d6f54 8146758: NetworkInterfaceStreamTest.java fails intermittently at comparing network interfaces
xiaofeya
parents: 36511
diff changeset
    65
                expected.add(ni);
0af4cc7d6f54 8146758: NetworkInterfaceStreamTest.java fails intermittently at comparing network interfaces
xiaofeya
parents: 36511
diff changeset
    66
            }
0af4cc7d6f54 8146758: NetworkInterfaceStreamTest.java fails intermittently at comparing network interfaces
xiaofeya
parents: 36511
diff changeset
    67
        });
31469
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    68
        withData(TestData.Factory.ofSupplier("Top-level network interfaces", ss))
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    69
                .stream(s -> s)
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    70
                .expectedResult(expected)
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    71
                .exercise();
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    72
    }
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    73
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    74
    private Collection<NetworkInterface> getAllNetworkInterfaces() throws SocketException {
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    75
        Collection<NetworkInterface> anis = new ArrayList<>();
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    76
        for (NetworkInterface ni : Collections.list(NetworkInterface.getNetworkInterfaces())) {
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    77
            getAllSubNetworkInterfaces(ni, anis);
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    78
        }
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    79
        return anis;
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    80
    }
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    81
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    82
    private void getAllSubNetworkInterfaces(NetworkInterface ni, Collection<NetworkInterface> result) {
34722
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
    83
        if (isIncluded(ni)) {
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
    84
            result.add(ni);
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
    85
        }
31469
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    86
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    87
        for (NetworkInterface sni : Collections.list(ni.getSubInterfaces())) {
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    88
            getAllSubNetworkInterfaces(sni, result);
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    89
        }
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    90
    }
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    91
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    92
    private Stream<NetworkInterface> allNetworkInterfaces() throws SocketException {
34834
8baf154e0db4 8146209: java/net/NetworkInterface/NetworkInterfaceStreamTest.java still fails after fix JDK-8131155
xiaofeya
parents: 34722
diff changeset
    93
        return NetworkInterface.networkInterfaces()
8baf154e0db4 8146209: java/net/NetworkInterface/NetworkInterfaceStreamTest.java still fails after fix JDK-8131155
xiaofeya
parents: 34722
diff changeset
    94
                .filter(ni -> isIncluded(ni))
8baf154e0db4 8146209: java/net/NetworkInterface/NetworkInterfaceStreamTest.java still fails after fix JDK-8131155
xiaofeya
parents: 34722
diff changeset
    95
                .flatMap(this::allSubNetworkInterfaces);
31469
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    96
    }
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    97
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    98
    private Stream<NetworkInterface> allSubNetworkInterfaces(NetworkInterface ni) {
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    99
        return Stream.concat(
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   100
                Stream.of(ni),
34834
8baf154e0db4 8146209: java/net/NetworkInterface/NetworkInterfaceStreamTest.java still fails after fix JDK-8131155
xiaofeya
parents: 34722
diff changeset
   101
                ni.subInterfaces().filter(sni -> isIncluded(sni)).flatMap(this::allSubNetworkInterfaces));
31469
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   102
    }
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   103
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   104
    @Test
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   105
    public void testSubNetworkInterfaces() throws SocketException {
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   106
        Supplier<Stream<NetworkInterface>> ss = () -> {
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   107
            try {
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   108
                return allNetworkInterfaces();
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   109
            }
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   110
            catch (SocketException e) {
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   111
                throw new RuntimeException(e);
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   112
            }
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   113
        };
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   114
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   115
        Collection<NetworkInterface> expected = getAllNetworkInterfaces();
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   116
        withData(TestData.Factory.ofSupplier("All network interfaces", ss))
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   117
                .stream(s -> s)
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   118
                .expectedResult(expected)
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   119
                .exercise();
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   120
    }
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   121
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   122
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   123
    @Test
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   124
    public void testInetAddresses() throws SocketException {
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   125
        Supplier<Stream<InetAddress>> ss = () -> {
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   126
            try {
34722
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
   127
                return NetworkInterface.networkInterfaces()
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
   128
                        .filter(ni -> isIncluded(ni))
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
   129
                        .flatMap(NetworkInterface::inetAddresses);
31469
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   130
            }
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   131
            catch (SocketException e) {
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   132
                throw new RuntimeException(e);
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   133
            }
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   134
        };
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   135
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   136
        Collection<NetworkInterface> nis = Collections.list(NetworkInterface.getNetworkInterfaces());
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   137
        Collection<InetAddress> expected = new ArrayList<>();
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   138
        for (NetworkInterface ni : nis) {
34834
8baf154e0db4 8146209: java/net/NetworkInterface/NetworkInterfaceStreamTest.java still fails after fix JDK-8131155
xiaofeya
parents: 34722
diff changeset
   139
            if (isIncluded(ni)) {
8baf154e0db4 8146209: java/net/NetworkInterface/NetworkInterfaceStreamTest.java still fails after fix JDK-8131155
xiaofeya
parents: 34722
diff changeset
   140
                expected.addAll(Collections.list(ni.getInetAddresses()));
8baf154e0db4 8146209: java/net/NetworkInterface/NetworkInterfaceStreamTest.java still fails after fix JDK-8131155
xiaofeya
parents: 34722
diff changeset
   141
            }
31469
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   142
        }
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   143
        withData(TestData.Factory.ofSupplier("All inet addresses", ss))
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   144
                .stream(s -> s)
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   145
                .expectedResult(expected)
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   146
                .exercise();
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   147
    }
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   148
34722
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
   149
    /**
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
   150
     * Check if the input network interface should be included in the test. It is necessary to exclude
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
   151
     * "Teredo Tunneling Pseudo-Interface" whose configuration can be variable during a test run.
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
   152
     *
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
   153
     * @param ni a network interace
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
   154
     * @return false if it is a "Teredo Tunneling Pseudo-Interface", otherwise true.
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
   155
     */
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
   156
    private boolean isIncluded(NetworkInterface ni) {
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
   157
        if (!IS_WINDOWS) {
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
   158
            return true;
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
   159
        }
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
   160
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
   161
        String dName = ni.getDisplayName();
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
   162
        return dName == null || !dName.contains("Teredo");
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
   163
    }
31469
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   164
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   165
}
34722
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
   166