< prev index next >

jdk/test/java/net/Inet6Address/B6558853.java

Print this page
rev 17203 : 8180644: move jdk.testlibrary.NetworkConfiguration to the top level test library
Reviewed-by: duke


   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @bug 6558853
  27  * @summary  getHostAddress() on connections using IPv6 link-local addrs should have zone id
  28  * @library /lib/testlibrary
  29  * @build jdk.testlibrary.NetworkConfiguration
  30  * @run main B6558853
  31  */
  32 
  33 import java.io.IOException;
  34 import java.io.InputStream;
  35 import java.io.OutputStream;
  36 import java.net.*;
  37 import java.util.Optional;
  38 import jdk.testlibrary.NetworkConfiguration;
  39 
  40 public class B6558853 implements Runnable {
  41     private InetAddress addr = null;
  42     private int port = 0;
  43 
  44     public static void main(String[] args) throws Exception {
  45         Optional<Inet6Address> oaddr = NetworkConfiguration.probe()
  46                 .ip6Addresses()
  47                 .filter(a -> a.isLinkLocalAddress())
  48                 .findFirst();
  49 
  50         if (!oaddr.isPresent()) {
  51             System.out.println("No suitable interface found. Exiting.");
  52             return;
  53         }
  54 
  55         Inet6Address dest = oaddr.get();
  56         System.out.println("Using " + dest);
  57 
  58         try (ServerSocket ss = new ServerSocket(0)) {




   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @bug 6558853
  27  * @summary  getHostAddress() on connections using IPv6 link-local addrs should have zone id
  28  * @library /test/lib

  29  * @run main B6558853
  30  */
  31 
  32 import java.io.IOException;
  33 import java.io.InputStream;
  34 import java.io.OutputStream;
  35 import java.net.*;
  36 import java.util.Optional;
  37 import jdk.test.lib.NetworkConfiguration;
  38 
  39 public class B6558853 implements Runnable {
  40     private InetAddress addr = null;
  41     private int port = 0;
  42 
  43     public static void main(String[] args) throws Exception {
  44         Optional<Inet6Address> oaddr = NetworkConfiguration.probe()
  45                 .ip6Addresses()
  46                 .filter(a -> a.isLinkLocalAddress())
  47                 .findFirst();
  48 
  49         if (!oaddr.isPresent()) {
  50             System.out.println("No suitable interface found. Exiting.");
  51             return;
  52         }
  53 
  54         Inet6Address dest = oaddr.get();
  55         System.out.println("Using " + dest);
  56 
  57         try (ServerSocket ss = new ServerSocket(0)) {


< prev index next >