test/java/rmi/activation/Activatable/restartService/RestartService.java

Print this page
rev 15773 : 8085192: java/rmi/activation/Activatable tests fail intermittently due to "Port already in use"
Reviewed-by:


  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /* @test
  25  * @bug 4095165 4321151
  26  * @key intermittent
  27  * @summary synopsis: activator should restart daemon services
  28  * @author Ann Wollrath
  29  *
  30  * @library ../../../testlibrary
  31  * @modules java.rmi/sun.rmi.registry
  32  *          java.rmi/sun.rmi.server
  33  *          java.rmi/sun.rmi.transport
  34  *          java.rmi/sun.rmi.transport.tcp
  35  * @build TestLibrary RMID ActivationLibrary ActivateMe RestartService_Stub

  36  * @run main/othervm/policy=security.policy/timeout=240 RestartService
  37  */
  38 
  39 import java.io.*;
  40 import java.rmi.*;
  41 import java.rmi.activation.*;
  42 import java.rmi.server.*;
  43 import java.rmi.registry.*;
  44 import java.util.Vector;
  45 import java.util.Properties;
  46 
  47 public class RestartService
  48         implements ActivateMe, Runnable
  49 {
  50 
  51     private ActivationID id;
  52     private static Object lock = new Object();
  53     private Vector responders = new Vector();
  54 
  55     private static final String RESTARTABLE = "restartable";


 112      * Thread to deactivate object. First attempts to make object
 113      * inactive (via the inactive method).  If that fails (the
 114      * object may still have pending/executing calls), then
 115      * unexport the object forcibly.
 116      */
 117     public void run() {
 118 
 119     }
 120 
 121     public static void main(String[] args) {
 122 
 123         System.out.println("\nRegression test for bug 4095165\n");
 124 
 125         TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager");
 126 
 127         RMID rmid = null;
 128         RestartService unicastObj = null;
 129 
 130         try {
 131             RMID.removeLog();
 132             rmid = RMID.createRMID();
 133             rmid.start();
 134 
 135             /* Cause activation groups to have a security policy that will
 136              * allow security managers to be downloaded and installed
 137              */
 138             Properties p = new Properties();
 139             // this test must always set policies/managers in its
 140             // activation groups
 141             p.put("java.security.policy",
 142                   TestParams.defaultGroupPolicy);
 143             p.put("java.security.manager",  "");
 144 
 145             /*
 146              * Create unicast object to be contacted when service is activated.
 147              */
 148             unicastObj = new RestartService();
 149             /*
 150              * Create and register descriptors for a restartable and
 151              * non-restartable service (respectively) in a group other than
 152              * this VM's group.




  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /* @test
  25  * @bug 4095165 4321151
  26  * @key intermittent
  27  * @summary synopsis: activator should restart daemon services
  28  * @author Ann Wollrath
  29  *
  30  * @library ../../../testlibrary
  31  * @modules java.rmi/sun.rmi.registry
  32  *          java.rmi/sun.rmi.server
  33  *          java.rmi/sun.rmi.transport
  34  *          java.rmi/sun.rmi.transport.tcp
  35  *          java.base/sun.nio.ch
  36  * @build TestLibrary RMID RMIDSelectorProvider ActivationLibrary ActivateMe RestartService_Stub
  37  * @run main/othervm/policy=security.policy/timeout=240 RestartService
  38  */
  39 
  40 import java.io.*;
  41 import java.rmi.*;
  42 import java.rmi.activation.*;
  43 import java.rmi.server.*;
  44 import java.rmi.registry.*;
  45 import java.util.Vector;
  46 import java.util.Properties;
  47 
  48 public class RestartService
  49         implements ActivateMe, Runnable
  50 {
  51 
  52     private ActivationID id;
  53     private static Object lock = new Object();
  54     private Vector responders = new Vector();
  55 
  56     private static final String RESTARTABLE = "restartable";


 113      * Thread to deactivate object. First attempts to make object
 114      * inactive (via the inactive method).  If that fails (the
 115      * object may still have pending/executing calls), then
 116      * unexport the object forcibly.
 117      */
 118     public void run() {
 119 
 120     }
 121 
 122     public static void main(String[] args) {
 123 
 124         System.out.println("\nRegression test for bug 4095165\n");
 125 
 126         TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager");
 127 
 128         RMID rmid = null;
 129         RestartService unicastObj = null;
 130 
 131         try {
 132             RMID.removeLog();
 133             rmid = RMID.createRMIDOnEphemeralPort();
 134             rmid.start();
 135 
 136             /* Cause activation groups to have a security policy that will
 137              * allow security managers to be downloaded and installed
 138              */
 139             Properties p = new Properties();
 140             // this test must always set policies/managers in its
 141             // activation groups
 142             p.put("java.security.policy",
 143                   TestParams.defaultGroupPolicy);
 144             p.put("java.security.manager",  "");
 145 
 146             /*
 147              * Create unicast object to be contacted when service is activated.
 148              */
 149             unicastObj = new RestartService();
 150             /*
 151              * Create and register descriptors for a restartable and
 152              * non-restartable service (respectively) in a group other than
 153              * this VM's group.