jdk/test/java/net/NetworkInterface/NetworkInterfaceStreamTest.java
author amlu
Thu, 04 Feb 2016 14:38:17 +0800
changeset 35705 5c3998b1b7ea
parent 34834 8baf154e0db4
child 36511 9d0388c6b336
permissions -rw-r--r--
8149003: Mark more jdk_core tests as intermittently failing Reviewed-by: chegar, darcy
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
33830
9f4be4f1c8b6 8143015: 5 tests fail with error "Can't find source for class: java.util.stream.OpTestCase"
weijun
parents: 32835
diff changeset
    27
 * @library ../../util/stream/bootlib/java.base
31469
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    28
 * @build java.util.stream.OpTestCase
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
35705
5c3998b1b7ea 8149003: Mark more jdk_core tests as intermittently failing
amlu
parents: 34834
diff changeset
    31
 * @key intermittent
31469
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
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    34
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
    35
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    36
import java.net.InetAddress;
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    37
import java.net.NetworkInterface;
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    38
import java.net.SocketException;
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    39
import java.util.ArrayList;
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    40
import java.util.Collection;
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    41
import java.util.Collections;
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    42
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
    43
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
    44
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
    45
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
    46
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    47
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
    48
34722
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
    49
    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
    50
31469
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    51
    @Test
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    52
    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
    53
        Supplier<Stream<NetworkInterface>> ss = () -> {
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    54
            try {
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    55
                return NetworkInterface.networkInterfaces();
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    56
            }
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    57
            catch (SocketException e) {
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    58
                throw new RuntimeException(e);
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
        };
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    61
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    62
        Collection<NetworkInterface> expected = Collections.list(NetworkInterface.getNetworkInterfaces());
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    63
        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
    64
                .stream(s -> s)
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    65
                .expectedResult(expected)
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    66
                .exercise();
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    67
    }
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    68
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    69
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    70
    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
    71
        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
    72
        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
    73
            getAllSubNetworkInterfaces(ni, anis);
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    74
        }
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    75
        return anis;
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    76
    }
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    77
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    78
    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
    79
        if (isIncluded(ni)) {
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
    80
            result.add(ni);
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
    81
        }
31469
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    82
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    83
        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
    84
            getAllSubNetworkInterfaces(sni, result);
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    85
        }
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
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    88
    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
    89
        return NetworkInterface.networkInterfaces()
8baf154e0db4 8146209: java/net/NetworkInterface/NetworkInterfaceStreamTest.java still fails after fix JDK-8131155
xiaofeya
parents: 34722
diff changeset
    90
                .filter(ni -> isIncluded(ni))
8baf154e0db4 8146209: java/net/NetworkInterface/NetworkInterfaceStreamTest.java still fails after fix JDK-8131155
xiaofeya
parents: 34722
diff changeset
    91
                .flatMap(this::allSubNetworkInterfaces);
31469
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    92
    }
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    93
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    94
    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
    95
        return Stream.concat(
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    96
                Stream.of(ni),
34834
8baf154e0db4 8146209: java/net/NetworkInterface/NetworkInterfaceStreamTest.java still fails after fix JDK-8131155
xiaofeya
parents: 34722
diff changeset
    97
                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
    98
    }
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    99
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   100
    @Test
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   101
    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
   102
        Supplier<Stream<NetworkInterface>> ss = () -> {
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   103
            try {
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   104
                return allNetworkInterfaces();
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   105
            }
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   106
            catch (SocketException e) {
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   107
                throw new RuntimeException(e);
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   108
            }
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
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   111
        Collection<NetworkInterface> expected = getAllNetworkInterfaces();
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   112
        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
   113
                .stream(s -> s)
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   114
                .expectedResult(expected)
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   115
                .exercise();
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   116
    }
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   117
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   118
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   119
    @Test
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   120
    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
   121
        Supplier<Stream<InetAddress>> ss = () -> {
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   122
            try {
34722
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
   123
                return NetworkInterface.networkInterfaces()
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
   124
                        .filter(ni -> isIncluded(ni))
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
   125
                        .flatMap(NetworkInterface::inetAddresses);
31469
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   126
            }
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   127
            catch (SocketException e) {
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   128
                throw new RuntimeException(e);
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   129
            }
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
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   132
        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
   133
        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
   134
        for (NetworkInterface ni : nis) {
34834
8baf154e0db4 8146209: java/net/NetworkInterface/NetworkInterfaceStreamTest.java still fails after fix JDK-8131155
xiaofeya
parents: 34722
diff changeset
   135
            if (isIncluded(ni)) {
8baf154e0db4 8146209: java/net/NetworkInterface/NetworkInterfaceStreamTest.java still fails after fix JDK-8131155
xiaofeya
parents: 34722
diff changeset
   136
                expected.addAll(Collections.list(ni.getInetAddresses()));
8baf154e0db4 8146209: java/net/NetworkInterface/NetworkInterfaceStreamTest.java still fails after fix JDK-8131155
xiaofeya
parents: 34722
diff changeset
   137
            }
31469
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   138
        }
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   139
        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
   140
                .stream(s -> s)
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   141
                .expectedResult(expected)
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   142
                .exercise();
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   143
    }
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   144
34722
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
   145
    /**
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
   146
     * 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
   147
     * "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
   148
     *
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
   149
     * @param ni a network interace
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
   150
     * @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
   151
     */
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
   152
    private boolean isIncluded(NetworkInterface ni) {
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
   153
        if (!IS_WINDOWS) {
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
   154
            return 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
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
   157
        String dName = ni.getDisplayName();
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
   158
        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
   159
    }
31469
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   160
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   161
}
34722
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
   162