< prev index next >

test/java/rmi/activation/Activatable/forceLogSnapshot/ForceLogSnapshot.java

Print this page




   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  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 4173960
  26  * @summary synopsis: Activatable objects cannot be restarted.
  27  * @author Laird Dornin
  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  *     ActivateMe ForceLogSnapshot_Stub
  36  * @run main/othervm/policy=security.policy/timeout=640 ForceLogSnapshot
  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.*;
  45 
  46 public class ForceLogSnapshot
  47         implements ActivateMe
  48 {
  49     /** how many activatable remote objects to create to test rmid */
  50     final public static int HOW_MANY = 50;
  51     final public static int NUM_GROUPS = 4;
  52     /** cause RMID to generate a snapshot every 10th activated object */
  53     final public static int SNAPSHOT_INTERVAL = 10;
  54 
  55     private ActivationID id;
  56     private Vector responders = new Vector();
  57 
  58     private static final String RESTARTABLE = "restartable";
  59     private static final String ACTIVATABLE = "activatable";


 111         System.exit(0);
 112     }
 113 
 114     public ActivationID getID() {
 115         return id;
 116     }
 117 
 118     public static void main(String[] args) {
 119 
 120         System.out.println("\nRegression test for bug 4173960\n");
 121 
 122         TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager");
 123 
 124         RMID rmid = null;
 125         ForceLogSnapshot[] unicastObjs = new ForceLogSnapshot[HOW_MANY];
 126 
 127         try {
 128             String option = " -Dsun.rmi.activation.snapshotInterval=" +
 129                 SNAPSHOT_INTERVAL;
 130 

 131             RMID.removeLog();
 132             rmid = RMID.createRMID();
 133             rmid.addOptions(new String[] {option, "-Djava.compiler="});

 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                   TestParams.defaultSecurityManager);
 146 
 147             Object[][] stuff = new Object[HOW_MANY][];
 148             MarshalledObject restartMobj = null;
 149             ActivationGroupDesc groupDesc = null;
 150             MarshalledObject activateMobj = null;
 151             ActivationGroupID[] groupIDs = new ActivationGroupID[NUM_GROUPS];
 152             ActivationDesc restartableDesc = null;
 153             ActivationDesc activatableDesc = null;
 154             ActivateMe[] restartableObj = new ActivateMe[HOW_MANY];




   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  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 4173960 8085192
  26  * @summary synopsis: Activatable objects cannot be restarted.
  27  * @author Laird Dornin
  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  *     ActivateMe ForceLogSnapshot_Stub
  36  * @run main/othervm/policy=security.policy/timeout=640 ForceLogSnapshot
  37  */
  38 
  39 import java.io.*;
  40 import java.net.BindException;
  41 import java.rmi.*;
  42 import java.rmi.activation.*;
  43 import java.rmi.server.*;
  44 import java.rmi.registry.*;
  45 import java.util.*;
  46 
  47 public class ForceLogSnapshot
  48         implements ActivateMe
  49 {
  50     /** how many activatable remote objects to create to test rmid */
  51     final public static int HOW_MANY = 50;
  52     final public static int NUM_GROUPS = 4;
  53     /** cause RMID to generate a snapshot every 10th activated object */
  54     final public static int SNAPSHOT_INTERVAL = 10;
  55 
  56     private ActivationID id;
  57     private Vector responders = new Vector();
  58 
  59     private static final String RESTARTABLE = "restartable";
  60     private static final String ACTIVATABLE = "activatable";


 112         System.exit(0);
 113     }
 114 
 115     public ActivationID getID() {
 116         return id;
 117     }
 118 
 119     public static void main(String[] args) {
 120 
 121         System.out.println("\nRegression test for bug 4173960\n");
 122 
 123         TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager");
 124 
 125         RMID rmid = null;
 126         ForceLogSnapshot[] unicastObjs = new ForceLogSnapshot[HOW_MANY];
 127 
 128         try {
 129             String option = " -Dsun.rmi.activation.snapshotInterval=" +
 130                 SNAPSHOT_INTERVAL;
 131 
 132             for (int i = 0; i < 20; i++) {
 133                 RMID.removeLog();
 134                 rmid = RMID.createRMID();
 135                 rmid.addOptions(new String[] {option, "-Djava.compiler="});
 136                 try {
 137                     rmid.start();
 138                     break;
 139                 } catch (BindException ex) {
 140                     System.err.format("%ncatch BindException(%s), "
 141                             + "continue to launch rmid again...%n%n", ex.getMessage());
 142                     continue;
 143                 }
 144             }
 145 
 146             /* Cause activation groups to have a security policy that will
 147              * allow security managers to be downloaded and installed
 148              */
 149             Properties p = new Properties();
 150             // this test must always set policies/managers in its
 151             // activation groups
 152             p.put("java.security.policy",
 153                   TestParams.defaultGroupPolicy);
 154             p.put("java.security.manager",
 155                   TestParams.defaultSecurityManager);
 156 
 157             Object[][] stuff = new Object[HOW_MANY][];
 158             MarshalledObject restartMobj = null;
 159             ActivationGroupDesc groupDesc = null;
 160             MarshalledObject activateMobj = null;
 161             ActivationGroupID[] groupIDs = new ActivationGroupID[NUM_GROUPS];
 162             ActivationDesc restartableDesc = null;
 163             ActivationDesc activatableDesc = null;
 164             ActivateMe[] restartableObj = new ActivateMe[HOW_MANY];


< prev index next >