test/java/rmi/Naming/LookupNameWithColon.java
Print this page
*** 23,32 ****
--- 23,35 ----
/* @test
* @bug 4387038
* @summary Ensure that java.rmi.Naming.lookup functions properly for names
* containing embedded ':' characters.
+ *
+ * @library ../testlibrary
+ * @build TestLibrary
*/
import java.rmi.Naming;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
*** 37,52 ****
"fairly:simple", "somewhat:more/complicated",
"multiple:colons:in:name"
};
Registry reg;
try {
! reg = LocateRegistry.createRegistry(Registry.REGISTRY_PORT);
} catch (Exception ex) {
reg = LocateRegistry.getRegistry();
}
for (int i = 0; i < names.length; i++) {
reg.rebind(names[i], reg);
! Naming.lookup("rmi://localhost/" + names[i]);
}
}
}
--- 40,58 ----
"fairly:simple", "somewhat:more/complicated",
"multiple:colons:in:name"
};
Registry reg;
+ int port = -1;
+
try {
! reg = TestLibrary.createRegistryOnUnusedPort();
! port = TestLibrary.getRegistryPort(reg);
} catch (Exception ex) {
reg = LocateRegistry.getRegistry();
}
for (int i = 0; i < names.length; i++) {
reg.rebind(names[i], reg);
! Naming.lookup("rmi://localhost:" + port + "/" + names[i]);
}
}
}