test/java/rmi/activation/ActivateFailedException/activateFails/ActivateFails.java

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


  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 4097135
  26  * @summary Need a specific subtype of RemoteException for activation failure.
  27  *          If activation fails to happen during a call to a remote object,
  28  *          then the call should end in an ActivateFailedException. In this
  29  *          test, the actual "activatable" remote object fails to activate
  30  *          since its * "activation" constructor throws an exception.
  31  * @author Ann Wollrath
  32  *
  33  * @library ../../../testlibrary
  34  * @modules java.rmi/sun.rmi.registry
  35  *          java.rmi/sun.rmi.server
  36  *          java.rmi/sun.rmi.transport
  37  *          java.rmi/sun.rmi.transport.tcp
  38  * @build TestLibrary RMID ActivationLibrary

  39  *     ActivateMe ActivateFails_Stub ShutdownThread
  40  * @run main/othervm/java.security.policy=security.policy/timeout=240 ActivateFails
  41  */
  42 
  43 import java.rmi.*;
  44 import java.rmi.server.*;
  45 import java.rmi.activation.*;
  46 import java.io.*;
  47 import java.util.Properties;
  48 
  49 public class ActivateFails
  50         extends Activatable
  51         implements ActivateMe
  52 {
  53 
  54     public ActivateFails(ActivationID id, MarshalledObject obj)
  55         throws ActivationException, RemoteException
  56     {
  57         super(id, 0);
  58 


  76     {
  77         ShutdownThread shutdownThread = new ShutdownThread(this, getID());
  78         shutdownThread.start();
  79         return(shutdownThread);
  80     }
  81 
  82     public static void main(String[] args)
  83     {
  84         RMID rmid = null;
  85         ActivateMe obj1, obj2;
  86         ShutdownThread shutdownThread;
  87 
  88         System.err.println("\nRegression test for bug 4097135\n");
  89         try {
  90             TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager");
  91 
  92             /*
  93              * First run "rmid" and wait for it to start up.
  94              */
  95             RMID.removeLog();
  96             rmid = RMID.createRMID();
  97             rmid.start();
  98 
  99             /* Cause activation groups to have a security policy that will
 100              * allow security managers to be downloaded and installed
 101              */
 102             Properties p = new Properties();
 103             // this test must always set policies/managers in its
 104             // activation groups
 105             p.put("java.security.policy",
 106                   TestParams.defaultGroupPolicy);
 107             p.put("java.security.manager",
 108                   TestParams.defaultSecurityManager);
 109 
 110             /*
 111              * Create activation descriptor...
 112              */
 113             System.err.println("creating activation descriptor...");
 114             ActivationGroupDesc groupDesc =
 115                 new ActivationGroupDesc(p, null);
 116             ActivationGroupID groupID =




  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 4097135
  26  * @summary Need a specific subtype of RemoteException for activation failure.
  27  *          If activation fails to happen during a call to a remote object,
  28  *          then the call should end in an ActivateFailedException. In this
  29  *          test, the actual "activatable" remote object fails to activate
  30  *          since its * "activation" constructor throws an exception.
  31  * @author Ann Wollrath
  32  *
  33  * @library ../../../testlibrary
  34  * @modules java.rmi/sun.rmi.registry
  35  *          java.rmi/sun.rmi.server
  36  *          java.rmi/sun.rmi.transport
  37  *          java.rmi/sun.rmi.transport.tcp
  38  *          java.base/sun.nio.ch
  39  * @build TestLibrary RMID RMIDSelectorProvider ActivationLibrary
  40  *     ActivateMe ActivateFails_Stub ShutdownThread
  41  * @run main/othervm/java.security.policy=security.policy/timeout=240 ActivateFails
  42  */
  43 
  44 import java.rmi.*;
  45 import java.rmi.server.*;
  46 import java.rmi.activation.*;
  47 import java.io.*;
  48 import java.util.Properties;
  49 
  50 public class ActivateFails
  51         extends Activatable
  52         implements ActivateMe
  53 {
  54 
  55     public ActivateFails(ActivationID id, MarshalledObject obj)
  56         throws ActivationException, RemoteException
  57     {
  58         super(id, 0);
  59 


  77     {
  78         ShutdownThread shutdownThread = new ShutdownThread(this, getID());
  79         shutdownThread.start();
  80         return(shutdownThread);
  81     }
  82 
  83     public static void main(String[] args)
  84     {
  85         RMID rmid = null;
  86         ActivateMe obj1, obj2;
  87         ShutdownThread shutdownThread;
  88 
  89         System.err.println("\nRegression test for bug 4097135\n");
  90         try {
  91             TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager");
  92 
  93             /*
  94              * First run "rmid" and wait for it to start up.
  95              */
  96             RMID.removeLog();
  97             rmid = RMID.createRMIDOnEphemeralPort();
  98             rmid.start();
  99 
 100             /* Cause activation groups to have a security policy that will
 101              * allow security managers to be downloaded and installed
 102              */
 103             Properties p = new Properties();
 104             // this test must always set policies/managers in its
 105             // activation groups
 106             p.put("java.security.policy",
 107                   TestParams.defaultGroupPolicy);
 108             p.put("java.security.manager",
 109                   TestParams.defaultSecurityManager);
 110 
 111             /*
 112              * Create activation descriptor...
 113              */
 114             System.err.println("creating activation descriptor...");
 115             ActivationGroupDesc groupDesc =
 116                 new ActivationGroupDesc(p, null);
 117             ActivationGroupID groupID =