test/java/rmi/activation/rmidViaInheritedChannel/InheritedChannelNotServerSocket.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 2005, 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.
--- 1,7 ----
/*
! * 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,40 ****
* @author Peter Jones
*
* @library ../../testlibrary
* @build RMID ActivationLibrary
* @build InheritedChannelNotServerSocket
! * @run main/othervm/timeout=240 -Djava.rmi.activation.port=5398
! * InheritedChannelNotServerSocket
*/
import java.io.IOException;
import java.net.Socket;
import java.net.ProtocolFamily;
--- 29,39 ----
* @author Peter Jones
*
* @library ../../testlibrary
* @build RMID ActivationLibrary
* @build InheritedChannelNotServerSocket
! * @run main/othervm/timeout=240 InheritedChannelNotServerSocket
*/
import java.io.IOException;
import java.net.Socket;
import java.net.ProtocolFamily;
*** 53,64 ****
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() { }
--- 52,61 ----
*** 77,87 ****
}
}
public static void main(String[] args) throws Exception {
System.err.println("\nRegression test for bug 6261402\n");
!
RMID rmid = null;
Callback obj = null;
try {
/*
* Export callback object and bind in registry.
--- 74,85 ----
}
}
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,107 ****
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);
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.addOptions(new String[]{
"-Djava.nio.channels.spi.SelectorProvider=" +
"InheritedChannelNotServerSocket$SP"});
rmid.start();
--- 87,107 ----
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.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,
! TestLibrary.INHERITEDCHANNELNOTSERVERSOCKET_ACTIVATION_PORT);
rmid.addOptions(new String[]{
"-Djava.nio.channels.spi.SelectorProvider=" +
"InheritedChannelNotServerSocket$SP"});
rmid.start();
*** 120,130 ****
System.err.println("TEST PASSED");
} finally {
if (obj != null) {
UnicastRemoteObject.unexportObject(obj, true);
}
! ActivationLibrary.rmidCleanup(rmid, PORT);
}
}
public static class SP extends SelectorProvider {
private final SelectorProvider provider;
--- 120,130 ----
System.err.println("TEST PASSED");
} finally {
if (obj != null) {
UnicastRemoteObject.unexportObject(obj, true);
}
! ActivationLibrary.rmidCleanup(rmid);
}
}
public static class SP extends SelectorProvider {
private final SelectorProvider provider;
*** 173,183 ****
* Notify test that inherited channel was created.
*/
try {
System.err.println("notify test...");
Registry registry =
! LocateRegistry.getRegistry(TestLibrary.REGISTRY_PORT);
Callback obj = (Callback) registry.lookup("Callback");
obj.notifyTest();
} catch (NotBoundException nbe) {
throw (IOException)
new IOException("callback object not bound").
--- 173,183 ----
* Notify test that inherited channel was created.
*/
try {
System.err.println("notify test...");
Registry registry =
! 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").