test/java/rmi/server/RMISocketFactory/useSocketFactory/registry/UseCustomSocketFactory.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 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.
@@ -30,10 +30,11 @@
*
* @library ../../../../testlibrary
* @build Hello
* @build HelloImpl
* @build HelloImpl_Stub
+ * @build TestLibrary
* @build UseCustomSocketFactory
* @build Compress
* @run main/othervm/policy=security.policy/timeout=240 UseCustomSocketFactory
*/
@@ -56,31 +57,36 @@
HelloImpl impl = null;
System.out.println("\nRegression test for bug 4148850\n");
TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager");
+ int registryPort = TestLibrary.getUnusedRandomPort();
try {
impl = new HelloImpl();
/* Make sure that the rmiregistry can communicate over a
* custom socket. Ensure that the functionality exists to
* allow the rmiregistry to be secure.
*/
registry = LocateRegistry.
- createRegistry(TestLibrary.REGISTRY_PORT,
+ createRegistry(registryPort,
new Compress.CompressRMIClientSocketFactory(),
new Compress.CompressRMIServerSocketFactory());
registry.rebind("/HelloServer", impl);
checkStub(registry, "RMIServerSocket");
} catch (Exception e) {
TestLibrary.bomb("creating registry", e);
}
- JavaVM serverVM = new JavaVM("HelloImpl", "-Djava.security.policy=" +
- TestParams.defaultPolicy, "");
+ JavaVM serverVM = new JavaVM("HelloImpl",
+ "-Djava.security.policy=" +
+ TestParams.defaultPolicy +
+ " -Drmi.registry.port=" +
+ registryPort,
+ "");
try {
/*
* spawn VM for HelloServer which will download a client socket