test/java/rmi/activation/rmidViaInheritedChannel/InheritedChannelNotServerSocket.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2005, 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.
@@ -29,12 +29,11 @@
* @author Peter Jones
*
* @library ../../testlibrary
* @build RMID ActivationLibrary
* @build InheritedChannelNotServerSocket
- * @run main/othervm/timeout=240 -Djava.rmi.activation.port=5398
- * InheritedChannelNotServerSocket
+ * @run main/othervm/timeout=240 InheritedChannelNotServerSocket
*/
import java.io.IOException;
import java.net.Socket;
import java.net.ProtocolFamily;
@@ -53,12 +52,10 @@
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;
public class InheritedChannelNotServerSocket {
-
- private static final int PORT = 5398;
private static final Object lock = new Object();
private static boolean notified = false;
private InheritedChannelNotServerSocket() { }
@@ -77,11 +74,12 @@
}
}
public static void main(String[] args) throws Exception {
System.err.println("\nRegression test for bug 6261402\n");
-
+ System.setProperty("java.rmi.activation.port",
+ Integer.toString(TestLibrary.INHERITEDCHANNELNOTSERVERSOCKET_ACTIVATION_PORT));
RMID rmid = null;
Callback obj = null;
try {
/*
* Export callback object and bind in registry.
@@ -89,19 +87,21 @@
System.err.println("export callback object and bind in registry");
obj = new CallbackImpl();
Callback proxy =
(Callback) UnicastRemoteObject.exportObject(obj, 0);
Registry registry =
- LocateRegistry.createRegistry(TestLibrary.REGISTRY_PORT);
+ LocateRegistry.createRegistry(
+ TestLibrary.INHERITEDCHANNELNOTSERVERSOCKET_REGISTRY_PORT);
registry.bind("Callback", proxy);
/*
* Start rmid.
*/
System.err.println("start rmid with inherited channel");
RMID.removeLog();
- rmid = RMID.createRMID(System.out, System.err, true, true, PORT);
+ rmid = RMID.createRMID(System.out, System.err, true, true,
+ TestLibrary.INHERITEDCHANNELNOTSERVERSOCKET_ACTIVATION_PORT);
rmid.addOptions(new String[]{
"-Djava.nio.channels.spi.SelectorProvider=" +
"InheritedChannelNotServerSocket$SP"});
rmid.start();
@@ -120,11 +120,11 @@
System.err.println("TEST PASSED");
} finally {
if (obj != null) {
UnicastRemoteObject.unexportObject(obj, true);
}
- ActivationLibrary.rmidCleanup(rmid, PORT);
+ ActivationLibrary.rmidCleanup(rmid);
}
}
public static class SP extends SelectorProvider {
private final SelectorProvider provider;
@@ -173,11 +173,11 @@
* Notify test that inherited channel was created.
*/
try {
System.err.println("notify test...");
Registry registry =
- LocateRegistry.getRegistry(TestLibrary.REGISTRY_PORT);
+ LocateRegistry.getRegistry(TestLibrary.INHERITEDCHANNELNOTSERVERSOCKET_REGISTRY_PORT);
Callback obj = (Callback) registry.lookup("Callback");
obj.notifyTest();
} catch (NotBoundException nbe) {
throw (IOException)
new IOException("callback object not bound").