test/java/rmi/Naming/UnderscoreHost.java

Print this page

        

@@ -1,7 +1,7 @@
-/*
- * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
+ /*
+  * Copyright (c) 2005, 2012, 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.

@@ -19,11 +19,11 @@
  * 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.
  */
 
-/*
+ /*
  * @test
  * @bug 5083594
  * @summary Ensure that Naming.java correctly parses host names with '_' in
  * them.
  * @author Vinod Johnson

@@ -75,15 +75,16 @@
     public static void main(String args[]) {
         UnderscoreHost t = null;
         try {
             HostVerifyingSocketFactory hvf = new HostVerifyingSocketFactory();
             RMISocketFactory.setSocketFactory(hvf);
-            Registry r = LocateRegistry.createRegistry(Registry.REGISTRY_PORT);
+            Registry r = TestLibrary.createRegistryOnUnusedPort();
+            int port = TestLibrary.getRegistryPort(r);
             t = new UnderscoreHost();
             r.rebind(NAME, t);
             Naming.lookup("rmi://" + HOSTNAME +
-                          ":" + Registry.REGISTRY_PORT + "/" + NAME);
+                          ":" + port + "/" + NAME);
             /*
              * This test is coded to pass whether java.net.URI obeys
              * RFC 2396 or RFC 3986 (see 5085902, 6394131, etc.).
              *
              * If java.net.URI obeys RFC 3986, so host names may