/* * Copyright (c) 2002, 2022, 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions.
*/
/* * Lookup/reverse lookup class for regression test 4773521 * @test * @bug 4773521 * @summary Test that reverse lookups of IPv4 addresses work when IPv6 * is enabled * @library /test/lib * @build jdk.test.lib.Utils * jdk.test.lib.Asserts * jdk.test.lib.JDKToolFinder * jdk.test.lib.JDKToolLauncher * jdk.test.lib.Platform * jdk.test.lib.process.* * Lookup * @run main Lookup root *
*/ import java.io.IOException; import java.net.InetAddress; import java.net.UnknownHostException; import java.util.List; import java.util.stream.Stream; import java.util.stream.Collectors;
// check that the reverse lookup of the IPv4 address // will succeed with the IPv4 only stack
tmp = reverseWithIPv4Prefer(addr);
System.out.println("IPv4 reverse lookup results: [" + tmp + "]"); if (SKIP.equals(tmp)) {
System.out.println(addr + " can't be resolved with preferIPv4 - test skipped."); return;
}
strs = tmp.split(":");
ipv4Reversed = strs[1];
// Now check that a reverse lookup will succeed with the dual stack.
InetAddress ia = InetAddress.getByName(addr);
String name = ia.getHostName();
System.out.println("(default) " + addr + "--> " + name
+ " (reversed IPv4: " + ipv4Reversed + ")"); if (!ipv4Name.equals(name)) { // adding some diagnosting
System.err.println("name=" + name + " doesn't match expected=" + ipv4Name);
System.err.println("Listing all adresses:"); for (InetAddress any : InetAddress.getAllByName(HOST)) {
System.err.println("\t[" + any + "] address=" + any.getHostAddress()
+ ", host=" + any.getHostName());
} // make the test fail... thrownew RuntimeException("Mismatch between default"
+ " and java.net.preferIPv4Stack=true results");
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.