test/java/rmi/activation/Activatable/inactiveGroup/InactiveGroup.java

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


  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 4116082
  26  *
  27  * @summary synopsis: rmid should not destroy group when it reports
  28  * inactiveGroup
  29  * @author Ann Wollrath
  30  *
  31  * @library ../../../testlibrary
  32  * @modules java.rmi/sun.rmi.registry
  33  *          java.rmi/sun.rmi.server
  34  *          java.rmi/sun.rmi.transport
  35  *          java.rmi/sun.rmi.transport.tcp
  36  * @build TestLibrary RMID ActivationLibrary ActivateMe InactiveGroup_Stub

  37  * @run main/othervm/policy=security.policy/timeout=240 InactiveGroup
  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.Properties;
  46 
  47 public class InactiveGroup
  48         implements ActivateMe, Runnable
  49 {
  50 
  51     private ActivationID id;
  52 
  53     public InactiveGroup(ActivationID id, MarshalledObject obj)
  54         throws ActivationException, RemoteException
  55     {
  56         this.id = id;


  84      * Thread to deactivate object. First attempts to make object
  85      * inactive (via the inactive method).  If that fails (the
  86      * object may still have pending/executing calls), then
  87      * unexport the object forcibly.
  88      */
  89     public void run()
  90     {
  91         ActivationLibrary.deactivate(this, getID());
  92     }
  93 
  94     public static void main(String[] args) {
  95 
  96         System.out.println("\nRegression test for bug 4116082\n");
  97 
  98         TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager");
  99 
 100         RMID rmid = null;
 101 
 102         try {
 103             RMID.removeLog();
 104             rmid = RMID.createRMID();
 105             rmid.start();
 106 
 107             /* Cause activation groups to have a security policy that will
 108              * allow security managers to be downloaded and installed
 109              */
 110             Properties p = new Properties();
 111             // this test must always set policies/managers in its
 112             // activation groups
 113             p.put("java.security.policy",
 114                   TestParams.defaultGroupPolicy);
 115             p.put("java.security.manager",
 116                   TestParams.defaultSecurityManager);
 117 
 118             /*
 119              * Create descriptor and activate object in a separate VM.
 120              */
 121             System.err.println("Creating descriptor");
 122             ActivationGroupDesc groupDesc =
 123                 new ActivationGroupDesc(p, null);
 124             ActivationGroupID groupID =




  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 4116082
  26  *
  27  * @summary synopsis: rmid should not destroy group when it reports
  28  * inactiveGroup
  29  * @author Ann Wollrath
  30  *
  31  * @library ../../../testlibrary
  32  * @modules java.rmi/sun.rmi.registry
  33  *          java.rmi/sun.rmi.server
  34  *          java.rmi/sun.rmi.transport
  35  *          java.rmi/sun.rmi.transport.tcp
  36  *          java.base/sun.nio.ch
  37  * @build TestLibrary RMID RMIDSelectorProvider ActivationLibrary ActivateMe InactiveGroup_Stub
  38  * @run main/othervm/policy=security.policy/timeout=240 InactiveGroup
  39  */
  40 
  41 import java.io.*;
  42 import java.rmi.*;
  43 import java.rmi.activation.*;
  44 import java.rmi.server.*;
  45 import java.rmi.registry.*;
  46 import java.util.Properties;
  47 
  48 public class InactiveGroup
  49         implements ActivateMe, Runnable
  50 {
  51 
  52     private ActivationID id;
  53 
  54     public InactiveGroup(ActivationID id, MarshalledObject obj)
  55         throws ActivationException, RemoteException
  56     {
  57         this.id = id;


  85      * Thread to deactivate object. First attempts to make object
  86      * inactive (via the inactive method).  If that fails (the
  87      * object may still have pending/executing calls), then
  88      * unexport the object forcibly.
  89      */
  90     public void run()
  91     {
  92         ActivationLibrary.deactivate(this, getID());
  93     }
  94 
  95     public static void main(String[] args) {
  96 
  97         System.out.println("\nRegression test for bug 4116082\n");
  98 
  99         TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager");
 100 
 101         RMID rmid = null;
 102 
 103         try {
 104             RMID.removeLog();
 105             rmid = RMID.createRMIDOnEphemeralPort();
 106             rmid.start();
 107 
 108             /* Cause activation groups to have a security policy that will
 109              * allow security managers to be downloaded and installed
 110              */
 111             Properties p = new Properties();
 112             // this test must always set policies/managers in its
 113             // activation groups
 114             p.put("java.security.policy",
 115                   TestParams.defaultGroupPolicy);
 116             p.put("java.security.manager",
 117                   TestParams.defaultSecurityManager);
 118 
 119             /*
 120              * Create descriptor and activate object in a separate VM.
 121              */
 122             System.err.println("Creating descriptor");
 123             ActivationGroupDesc groupDesc =
 124                 new ActivationGroupDesc(p, null);
 125             ActivationGroupID groupID =