test/java/rmi/activation/Activatable/restartLatecomer/RestartLatecomer.java

Print this page




  14  *
  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 4526514
  26  * @summary rmid does not handle group restart for latecomer objects
  27  * @author Ann Wollrath
  28  *
  29  * @library ../../../testlibrary
  30  * @modules java.rmi/sun.rmi.registry
  31  *          java.rmi/sun.rmi.server
  32  *          java.rmi/sun.rmi.transport
  33  *          java.rmi/sun.rmi.transport.tcp

  34  * @build TestLibrary RMID ActivationLibrary
  35  *     RestartLatecomer RestartLatecomer_Stub
  36  * @run main/othervm/policy=security.policy/timeout=240 RestartLatecomer
  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 RestartLatecomer
  48         implements ActivateMe, Runnable
  49 {
  50 
  51     private ActivationID id;
  52     private static Object lock = new Object();
  53     private Vector responders = new Vector();


 149      * Thread to deactivate object. First attempts to make object
 150      * inactive (via the inactive method).  If that fails (the
 151      * object may still have pending/executing calls), then
 152      * unexport the object forcibly.
 153      */
 154     public void run() {
 155         System.exit(0);
 156     }
 157 
 158     public static void main(String[] args) {
 159 
 160         System.out.println("\nRegression test for bug 4526514\n");
 161 
 162         TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager");
 163 
 164         RMID rmid = null;
 165         RestartLatecomer callbackObj = null;
 166 
 167         try {
 168             RMID.removeLog();
 169             rmid = RMID.createRMID();
 170             rmid.start();
 171 
 172             /* Cause activation groups to have a security policy that will
 173              * allow security managers to be downloaded and installed
 174              */
 175             Properties p = new Properties();
 176             // this test must always set policies/managers in its
 177             // activation groups
 178             p.put("java.security.policy",
 179                   TestParams.defaultGroupPolicy);
 180             p.put("java.security.manager",
 181                   TestParams.defaultSecurityManager);
 182 
 183             /*
 184              * Create unicast object to be contacted when service is activated.
 185              */
 186             callbackObj = new RestartLatecomer();
 187             /*
 188              * Create and register descriptors for a restartable and
 189              * non-restartable service (respectively) in a group other than




  14  *
  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 4526514
  26  * @summary rmid does not handle group restart for latecomer objects
  27  * @author Ann Wollrath
  28  *
  29  * @library ../../../testlibrary
  30  * @modules java.rmi/sun.rmi.registry
  31  *          java.rmi/sun.rmi.server
  32  *          java.rmi/sun.rmi.transport
  33  *          java.rmi/sun.rmi.transport.tcp
  34  *          java.base/sun.nio.ch
  35  * @build TestLibrary RMID ActivationLibrary
  36  *     RestartLatecomer RestartLatecomer_Stub
  37  * @run main/othervm/policy=security.policy/timeout=240 RestartLatecomer
  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 RestartLatecomer
  49         implements ActivateMe, Runnable
  50 {
  51 
  52     private ActivationID id;
  53     private static Object lock = new Object();
  54     private Vector responders = new Vector();


 150      * Thread to deactivate object. First attempts to make object
 151      * inactive (via the inactive method).  If that fails (the
 152      * object may still have pending/executing calls), then
 153      * unexport the object forcibly.
 154      */
 155     public void run() {
 156         System.exit(0);
 157     }
 158 
 159     public static void main(String[] args) {
 160 
 161         System.out.println("\nRegression test for bug 4526514\n");
 162 
 163         TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager");
 164 
 165         RMID rmid = null;
 166         RestartLatecomer callbackObj = null;
 167 
 168         try {
 169             RMID.removeLog();
 170             rmid = RMID.createRMIDOnEphemeralPort();
 171             rmid.start();
 172 
 173             /* Cause activation groups to have a security policy that will
 174              * allow security managers to be downloaded and installed
 175              */
 176             Properties p = new Properties();
 177             // this test must always set policies/managers in its
 178             // activation groups
 179             p.put("java.security.policy",
 180                   TestParams.defaultGroupPolicy);
 181             p.put("java.security.manager",
 182                   TestParams.defaultSecurityManager);
 183 
 184             /*
 185              * Create unicast object to be contacted when service is activated.
 186              */
 187             callbackObj = new RestartLatecomer();
 188             /*
 189              * Create and register descriptors for a restartable and
 190              * non-restartable service (respectively) in a group other than