# HG changeset patch # User aefimov # Date 1566496496 -3600 # Node ID 01d9a1cff83ab125578ec01abfe7306421ce347a # Parent db6829c1cc3a902777217f6a60a2b02751138bd6 8078219: Verify lack of @test tag in files in java/net test directory Reviewed-by: alanb Contributed-by: Patrick Concannon diff -r db6829c1cc3a -r 01d9a1cff83a test/jdk/java/net/MulticastSocket/MulticastAddresses.java --- a/test/jdk/java/net/MulticastSocket/MulticastAddresses.java Thu Aug 22 10:41:07 2019 -0700 +++ b/test/jdk/java/net/MulticastSocket/MulticastAddresses.java Thu Aug 22 18:54:56 2019 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,76 +22,32 @@ */ /* - * + * @test * @bug 4488458 + * @library /test/lib * @summary Test that MutlicastSocket.joinGroup is working for * various multicast and non-multicast addresses. */ + +import jdk.test.lib.NetworkConfiguration; + import java.net.*; -import java.util.Enumeration; import java.io.IOException; +import java.util.stream.Collectors; public class MulticastAddresses { - - public static void main(String args[]) throws Exception { - - boolean ipv6_available = false; - NetworkInterface ni = null; - - /* - * Examine the network interfaces and determine :- - * - * 1. If host has IPv6 support - * 2. Get reference to a non-loopback interface - */ - Enumeration nifs = NetworkInterface.getNetworkInterfaces(); - while (nifs.hasMoreElements()) { - NetworkInterface this_ni = (NetworkInterface)nifs.nextElement(); - - Enumeration addrs = this_ni.getInetAddresses(); - while (addrs.hasMoreElements()) { - InetAddress addr = (InetAddress)addrs.nextElement(); - if (addr instanceof Inet6Address) { - ipv6_available = true; - } - - if (!addr.isLoopbackAddress() && ni == null) { - ni = this_ni; - } - } - - if (ipv6_available) { - break; - } - } - + public static void runTest(NetworkInterface ni, + String[] multicasts, + String[] nonMulticasts) throws Exception { int failures = 0; - String multicasts[] = { - "224.80.80.80", - "ff01::1", - "ff02::1234", - "ff05::a", - "ff0e::1234:a" }; - - String non_multicasts[] = { - "129.1.1.1", - "::1", - "::129.1.1.1", - "fe80::a00:20ff:fee5:bc02" }; - MulticastSocket s = new MulticastSocket(); /* test valid multicast addresses */ - - for (int i=0; i 0) { throw new Exception(failures + " test(s) failed - see log file."); } } + + public static void main(String args[]) throws Exception { + + String[] multicastIPv4 = { + "224.80.80.80", + }; + String[] multicastIPv6 = { + "ff01::1", + "ff02::1234", + "ff05::a", + "ff0e::1234:a"}; + + String[] nonMulticastIPv4 = { + "129.1.1.1" + }; + + String[] nonMulticastIPv6 = { + "::1", + "::129.1.1.1", + "fe80::a00:20ff:fee5:bc02"}; + + /* + * Examine the network interfaces and determine :- + * + * 1. If host has IPv6 support + * 2. Get reference to a non-loopback interface + */ + NetworkConfiguration nc = NetworkConfiguration.probe(); + var ipv6List = nc.ip6MulticastInterfaces(false) + .collect(Collectors.toList()); + + var ipv4List = nc.ip4MulticastInterfaces(false) + .collect(Collectors.toList()); + + if (ipv6List.retainAll(ipv4List)) { + runTest(ipv6List.get(0), multicastIPv4, nonMulticastIPv4); + runTest(ipv6List.get(0), multicastIPv6, nonMulticastIPv6); + } else { + if (!ipv4List.isEmpty()) + runTest(ipv4List.get(0), multicastIPv4, nonMulticastIPv4); + if (!ipv6List.isEmpty()) + runTest(ipv6List.get(0), multicastIPv6, nonMulticastIPv6); + } + } } diff -r db6829c1cc3a -r 01d9a1cff83a test/jdk/java/net/MulticastSocket/Reuse.java --- a/test/jdk/java/net/MulticastSocket/Reuse.java Thu Aug 22 10:41:07 2019 -0700 +++ b/test/jdk/java/net/MulticastSocket/Reuse.java Thu Aug 22 18:54:56 2019 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,11 @@ import java.net.MulticastSocket; import java.net.BindException; +/* + * @test + * @summary Check if MulticastSocket sets SO_REUSEADDR + */ + public class Reuse { public static void main(String[] args) throws Exception { MulticastSocket s1, s2; diff -r db6829c1cc3a -r 01d9a1cff83a test/jdk/java/net/URLClassLoader/GetURLsTest.java --- a/test/jdk/java/net/URLClassLoader/GetURLsTest.java Thu Aug 22 10:41:07 2019 -0700 +++ b/test/jdk/java/net/URLClassLoader/GetURLsTest.java Thu Aug 22 18:54:56 2019 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,11 +25,16 @@ import java.io.*; /* - * Regression test for URLClassLoader getURLs() and addURL() methods. + * @test + * @summary Regression test for URLClassLoader getURLs() and addURL() methods. * See RFE 4102580: Need URLClassLoader.getURLs() method */ -class GetURLsTest { +public class GetURLsTest { + static final String TEST_DIR = System.getProperty("test.src", "."); + public static void main(String[] args) throws Exception { + File testJars = new File(TEST_DIR, "jars"); + MyURLClassLoader ucl = new MyURLClassLoader(new URL[] { new File(".").toURL() }); p("initial urls = ", ucl.getURLs()); @@ -37,7 +42,7 @@ if (u != null) { p("found resource = " + u); } - ucl.addURL(new File("jars", "class_path_test.jar").toURL()); + ucl.addURL(new File(testJars, "class_path_test.jar").toURL()); p("new urls = ", ucl.getURLs()); Class c = ucl.loadClass("Foo"); p("found class = " + c);