test/jdk/java/net/NetworkConfigurationProbe.java
author igerasim
Wed, 16 Oct 2019 18:47:11 -0700
changeset 58659 4113f16d5109
parent 47216 71c04702a3d5
permissions -rw-r--r--
8231859: Extra dash after the exception name in @throws clause of javadoc Reviewed-by: weijun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
44671
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
     1
/*
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
     2
 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
     4
 *
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
     7
 * published by the Free Software Foundation.
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
     8
 *
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    13
 * accompanied this code).
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    14
 *
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    18
 *
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    21
 * questions.
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    22
 */
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    23
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    24
/**
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    25
 * @test
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    26
 * @summary NOT A TEST. Captures the network interface configuration.
45186
387a39577f09 8180644: move jdk.testlibrary.NetworkConfiguration to the top level test library
iignatyev
parents: 44671
diff changeset
    27
 * @library /test/lib
45467
99c87a16a8e4 8181761: add explicit @build actions for jdk.test.lib classes in all :tier2 tests
iignatyev
parents: 45186
diff changeset
    28
 * @build jdk.test.lib.NetworkConfiguration
99c87a16a8e4 8181761: add explicit @build actions for jdk.test.lib classes in all :tier2 tests
iignatyev
parents: 45186
diff changeset
    29
 *        jdk.test.lib.Utils
99c87a16a8e4 8181761: add explicit @build actions for jdk.test.lib classes in all :tier2 tests
iignatyev
parents: 45186
diff changeset
    30
 *        jdk.test.lib.Asserts
99c87a16a8e4 8181761: add explicit @build actions for jdk.test.lib classes in all :tier2 tests
iignatyev
parents: 45186
diff changeset
    31
 *        jdk.test.lib.JDKToolFinder
99c87a16a8e4 8181761: add explicit @build actions for jdk.test.lib classes in all :tier2 tests
iignatyev
parents: 45186
diff changeset
    32
 *        jdk.test.lib.JDKToolLauncher
99c87a16a8e4 8181761: add explicit @build actions for jdk.test.lib classes in all :tier2 tests
iignatyev
parents: 45186
diff changeset
    33
 *        jdk.test.lib.Platform
99c87a16a8e4 8181761: add explicit @build actions for jdk.test.lib classes in all :tier2 tests
iignatyev
parents: 45186
diff changeset
    34
 *        jdk.test.lib.process.*
44671
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    35
 * @run main NetworkConfigurationProbe
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    36
 */
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    37
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    38
import java.net.Inet4Address;
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    39
import java.net.Inet6Address;
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    40
import java.net.NetworkInterface;
45186
387a39577f09 8180644: move jdk.testlibrary.NetworkConfiguration to the top level test library
iignatyev
parents: 44671
diff changeset
    41
import jdk.test.lib.NetworkConfiguration;
44671
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    42
import static java.util.stream.Collectors.joining;
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    43
import static java.lang.System.out;
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    44
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    45
/**
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    46
 * Not a test. Captures the network interface configuration.
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    47
 */
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    48
public class NetworkConfigurationProbe {
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    49
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    50
    public static void main(String... args) throws Exception {
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    51
        NetworkConfiguration.printSystemConfiguration(out);
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    52
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    53
        NetworkConfiguration nc = NetworkConfiguration.probe();
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    54
        String list;
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    55
        list = nc.ip4MulticastInterfaces()
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    56
                  .map(NetworkInterface::getName)
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    57
                  .collect(joining(" "));
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    58
        out.println("ip4MulticastInterfaces: " +  list);
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    59
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    60
        list = nc.ip4Addresses()
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    61
                  .map(Inet4Address::toString)
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    62
                  .collect(joining(" "));
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    63
        out.println("ip4Addresses: " +  list);
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    64
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    65
        list = nc.ip6MulticastInterfaces()
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    66
                  .map(NetworkInterface::getName)
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    67
                  .collect(joining(" "));
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    68
        out.println("ip6MulticastInterfaces: " +  list);
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    69
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    70
        list = nc.ip6Addresses()
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    71
                  .map(Inet6Address::toString)
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    72
                  .collect(joining(" "));
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    73
        out.println("ip6Addresses: " +  list);
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    74
    }
d1d011d4654d 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
chegar
parents:
diff changeset
    75
}