Skip to content

Commit

Permalink
8078219: Verify lack of @test tag in files in java/net test directory
Browse files Browse the repository at this point in the history
Reviewed-by: alanb
  • Loading branch information
pconcannon authored and AlekseiEfimov committed Aug 22, 2019
1 parent 7d0d71d commit a9f92be
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 75 deletions.
130 changes: 60 additions & 70 deletions test/jdk/java/net/MulticastSocket/MulticastAddresses.java
@@ -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
Expand All @@ -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<multicasts.length; i++) {
for (int i = 0; i < multicasts.length; i++) {
InetAddress ia = InetAddress.getByName(multicasts[i]);
if (ia instanceof Inet6Address && !ipv6_available) {
continue;
}

System.out.println("Test: " + ia);

System.out.println("Test: " + ia + " " + " ni: " + ni);
try {

System.out.print(" joinGroup(InetAddress) ");
Expand All @@ -100,8 +56,8 @@ public static void main(String args[]) throws Exception {
System.out.println(" Passed.");

System.out.print(" joinGroup(InetAddress,NetworkInterface) ");
s.joinGroup(new InetSocketAddress(ia,0), ni);
s.leaveGroup(new InetSocketAddress(ia,0), ni);
s.joinGroup(new InetSocketAddress(ia, 0), ni);
s.leaveGroup(new InetSocketAddress(ia, 0), ni);
System.out.println(" Passed.");
} catch (IOException e) {
failures++;
Expand All @@ -111,13 +67,8 @@ public static void main(String args[]) throws Exception {
}

/* test non-multicast addresses */

for (int i=0; i<non_multicasts.length; i++) {
InetAddress ia = InetAddress.getByName(non_multicasts[i]);
if (ia instanceof Inet6Address && !ipv6_available) {
continue;
}

for (int i = 0; i < nonMulticasts.length; i++) {
InetAddress ia = InetAddress.getByName(nonMulticasts[i]);
boolean failed = false;

System.out.println("Test: " + ia + " ");
Expand All @@ -130,20 +81,59 @@ public static void main(String args[]) throws Exception {
} catch (IOException e) {
System.out.println(" Passed: " + e.getMessage());
}

if (failed) {
s.leaveGroup(ia);
failures++;
}
}

/* done */

s.close();

if (failures > 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);
}
}
}
7 changes: 6 additions & 1 deletion test/jdk/java/net/MulticastSocket/Reuse.java
@@ -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
Expand All @@ -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;
Expand Down
13 changes: 9 additions & 4 deletions test/jdk/java/net/URLClassLoader/GetURLsTest.java
@@ -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
Expand All @@ -25,19 +25,24 @@
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());
URL u = ucl.getResource("GetURLsTest.java");
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);
Expand Down

2 comments on commit a9f92be

@jmtd
Copy link

@jmtd jmtd commented on a9f92be Sep 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport openjdk/jdk11u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on a9f92be Sep 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jmtd the backport was successfully created on the branch jmtd-backport-a9f92bec in my personal fork of openjdk/jdk11u-dev. To create a pull request with this backport targeting openjdk/jdk11u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

this pull request contains a backport of commit a9f92bec from the openjdk/jdk repository.

The commit being backported was authored by Patrick Concannon on 22 Aug 2019 and was reviewed by Alan Bateman.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk11u-dev:

$ git fetch https://github.com/openjdk-bots/jdk11u-dev jmtd-backport-a9f92bec:jmtd-backport-a9f92bec
$ git checkout jmtd-backport-a9f92bec
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk11u-dev jmtd-backport-a9f92bec

Please sign in to comment.