test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/UseCustomSocketFactory.java
Print this page
*** 44,61 ****
public class UseCustomSocketFactory {
public static void main(String[] args) {
String[] protocol = new String[] { "", "compress", "xor" };
System.out.println("\nRegression test for bug 4127826\n");
TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager");
try {
! LocateRegistry.createRegistry(TestLibrary.REGISTRY_PORT);
} catch (Exception e) {
TestLibrary.bomb("creating registry", e);
}
for (int i = 0; i < protocol.length; i++) {
--- 44,64 ----
public class UseCustomSocketFactory {
public static void main(String[] args) {
+ int registryPort = -1;
+
String[] protocol = new String[] { "", "compress", "xor" };
System.out.println("\nRegression test for bug 4127826\n");
TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager");
try {
! Registry registry = TestLibrary.createRegistryOnUnusedPort();
! registryPort = TestLibrary.getRegistryPort(registry);
} catch (Exception e) {
TestLibrary.bomb("creating registry", e);
}
for (int i = 0; i < protocol.length; i++) {
*** 63,73 ****
System.err.println("test policy: " +
TestParams.defaultPolicy);
JavaVM serverVM = new JavaVM("EchoImpl",
"-Djava.security.policy=" +
! TestParams.defaultPolicy,
protocol[i]);
System.err.println("\nusing protocol: " +
(protocol[i] == "" ? "none" : protocol[i]));
try {
--- 66,78 ----
System.err.println("test policy: " +
TestParams.defaultPolicy);
JavaVM serverVM = new JavaVM("EchoImpl",
"-Djava.security.policy=" +
! TestParams.defaultPolicy +
! " -Drmi.registry.port=" +
! registryPort,
protocol[i]);
System.err.println("\nusing protocol: " +
(protocol[i] == "" ? "none" : protocol[i]));
try {
*** 77,87 ****
/* lookup server */
int tries = 8;
Echo obj = null;
do {
try {
! obj = (Echo) Naming.lookup("//:" + TestLibrary.REGISTRY_PORT +
"/EchoServer");
break;
} catch (NotBoundException e) {
try {
Thread.sleep(2000);
--- 82,92 ----
/* lookup server */
int tries = 8;
Echo obj = null;
do {
try {
! obj = (Echo) Naming.lookup("//:" + registryPort +
"/EchoServer");
break;
} catch (NotBoundException e) {
try {
Thread.sleep(2000);
*** 107,117 ****
TestLibrary.bomb("test failed", e);
} finally {
serverVM.destroy();
try {
! Naming.unbind("//:" + TestLibrary.REGISTRY_PORT +
"/EchoServer");
} catch (Exception e) {
TestLibrary.bomb("unbinding EchoServer", e);
}
--- 112,122 ----
TestLibrary.bomb("test failed", e);
} finally {
serverVM.destroy();
try {
! Naming.unbind("//:" + registryPort +
"/EchoServer");
} catch (Exception e) {
TestLibrary.bomb("unbinding EchoServer", e);
}