jdk/test/java/net/NetworkInterface/NetworkInterfaceStreamTest.java
author xiaofeya
Mon, 28 Dec 2015 19:03:18 -0800
changeset 34834 8baf154e0db4
parent 34722 1d23e916f189
child 35705 5c3998b1b7ea
permissions -rw-r--r--
8146209: java/net/NetworkInterface/NetworkInterfaceStreamTest.java still fails after fix JDK-8131155 Reviewed-by: chegar Contributed-by: 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
/*
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
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
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 {
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    54
                return NetworkInterface.networkInterfaces();
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
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    61
        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
    62
        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
    63
                .stream(s -> s)
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    64
                .expectedResult(expected)
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    65
                .exercise();
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    66
    }
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
    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
    70
        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
    71
        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
    72
            getAllSubNetworkInterfaces(ni, anis);
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
        return anis;
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    75
    }
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
    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
    78
        if (isIncluded(ni)) {
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
    79
            result.add(ni);
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
    80
        }
31469
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
        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
    83
            getAllSubNetworkInterfaces(sni, result);
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    84
        }
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
    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
    88
        return NetworkInterface.networkInterfaces()
8baf154e0db4 8146209: java/net/NetworkInterface/NetworkInterfaceStreamTest.java still fails after fix JDK-8131155
xiaofeya
parents: 34722
diff changeset
    89
                .filter(ni -> isIncluded(ni))
8baf154e0db4 8146209: java/net/NetworkInterface/NetworkInterfaceStreamTest.java still fails after fix JDK-8131155
xiaofeya
parents: 34722
diff changeset
    90
                .flatMap(this::allSubNetworkInterfaces);
31469
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
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    93
    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
    94
        return Stream.concat(
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
    95
                Stream.of(ni),
34834
8baf154e0db4 8146209: java/net/NetworkInterface/NetworkInterfaceStreamTest.java still fails after fix JDK-8131155
xiaofeya
parents: 34722
diff changeset
    96
                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
    97
    }
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
    @Test
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   100
    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
   101
        Supplier<Stream<NetworkInterface>> ss = () -> {
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   102
            try {
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   103
                return allNetworkInterfaces();
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   104
            }
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   105
            catch (SocketException e) {
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   106
                throw new RuntimeException(e);
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   107
            }
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
        Collection<NetworkInterface> expected = getAllNetworkInterfaces();
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   111
        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
   112
                .stream(s -> s)
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   113
                .expectedResult(expected)
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   114
                .exercise();
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   115
    }
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
    @Test
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   119
    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
   120
        Supplier<Stream<InetAddress>> ss = () -> {
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   121
            try {
34722
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
   122
                return NetworkInterface.networkInterfaces()
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
   123
                        .filter(ni -> isIncluded(ni))
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
   124
                        .flatMap(NetworkInterface::inetAddresses);
31469
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   125
            }
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   126
            catch (SocketException e) {
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   127
                throw new RuntimeException(e);
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   128
            }
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
        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
   132
        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
   133
        for (NetworkInterface ni : nis) {
34834
8baf154e0db4 8146209: java/net/NetworkInterface/NetworkInterfaceStreamTest.java still fails after fix JDK-8131155
xiaofeya
parents: 34722
diff changeset
   134
            if (isIncluded(ni)) {
8baf154e0db4 8146209: java/net/NetworkInterface/NetworkInterfaceStreamTest.java still fails after fix JDK-8131155
xiaofeya
parents: 34722
diff changeset
   135
                expected.addAll(Collections.list(ni.getInetAddresses()));
8baf154e0db4 8146209: java/net/NetworkInterface/NetworkInterfaceStreamTest.java still fails after fix JDK-8131155
xiaofeya
parents: 34722
diff changeset
   136
            }
31469
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   137
        }
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   138
        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
   139
                .stream(s -> s)
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   140
                .expectedResult(expected)
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   141
                .exercise();
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
34722
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
   144
    /**
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
   145
     * 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
   146
     * "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
   147
     *
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
   148
     * @param ni a network interace
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
   149
     * @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
   150
     */
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
   151
    private boolean isIncluded(NetworkInterface ni) {
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
   152
        if (!IS_WINDOWS) {
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
   153
            return true;
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
   154
        }
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
        String dName = ni.getDisplayName();
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
   157
        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
   158
    }
31469
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   159
92cc72d2a11a 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods
psandoz
parents:
diff changeset
   160
}
34722
1d23e916f189 8131155: java/net/NetworkInterface/NetworkInterfaceStreamTest.java failed because of Teredo Tunneling Pseudo-Interface
xiaofeya
parents: 33830
diff changeset
   161