test/java/rmi/activation/Activatable/shutdownGracefully/ShutdownGracefully.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 4183169 8032050
  26  * @summary Minor problem with the way ReliableLog handles IOExceptions.
  27  *
  28  * @author Laird Dornin; code borrowed from 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

  36  *     TestSecurityManager RegisteringActivatable ShutdownGracefully_Stub
  37  * @run main/othervm/policy=security.policy/timeout=700 ShutdownGracefully
  38  */
  39 
  40 import java.rmi.activation.*;
  41 import java.rmi.*;
  42 import java.util.Properties;
  43 import java.util.concurrent.TimeoutException;
  44 
  45 /**
  46  * The test creates an rmid with a special security manager.  After
  47  * rmid makes two registrations (which is greater than rmid's
  48  * snapshotInterval) the security manager stops allowing rmid to write
  49  * to update and snapshot log files in rmid's log directory.  The Test
  50  * registers an Activatable object twice with different group ids.
  51  * The second registration will cause rmid to have to write to a
  52  * LogFile (it causes a snapshot) and the security manager will not
  53  * allow the file write to happen.  The test makes sure that rmid
  54  * shuts down in a graceful manner without any explicit request to do
  55  * so.  The test will not exit for 400 seconds if rmid does not exit


  59     extends Activatable implements RegisteringActivatable
  60 {
  61     private static RegisteringActivatable registering = null;
  62 
  63     private final static long SHUTDOWN_TIMEOUT = 400 * 1000;
  64 
  65     public static void main(String args[]) {
  66 
  67         RMID rmid = null;
  68 
  69         // Save exception if there is a exception or expected behavior
  70         Exception exception = null;
  71         System.err.println("\nRegression test for bug/rfe 4183169\n");
  72 
  73         try {
  74             TestLibrary.suggestSecurityManager(
  75                 "java.rmi.RMISecurityManager");
  76 
  77             // start an rmid.
  78             RMID.removeLog();
  79             rmid = RMID.createRMID();
  80 
  81             // rmid needs to run with a security manager that
  82             // simulates a log problem; rmid should also snapshot
  83             // quickly.
  84             rmid.addOptions(new String[] {
  85                 "-Djava.security.manager=TestSecurityManager",
  86                 "-Dsun.rmi.activation.snapshotInterval=1"});
  87 
  88             //      rmid.addArguments(new String[] {
  89             //          "-C-Djava.rmi.server.logCalls=true"});
  90 
  91             rmid.start();
  92 
  93             // Ensure that activation groups run with the correct
  94             // security manager.
  95             //
  96             Properties p = new Properties();
  97             p.put("java.security.policy",
  98                   TestParams.defaultGroupPolicy);
  99             p.put("java.security.manager",




  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 4183169 8032050
  26  * @summary Minor problem with the way ReliableLog handles IOExceptions.
  27  *
  28  * @author Laird Dornin; code borrowed from 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
  37  *     TestSecurityManager RegisteringActivatable ShutdownGracefully_Stub
  38  * @run main/othervm/policy=security.policy/timeout=700 ShutdownGracefully
  39  */
  40 
  41 import java.rmi.activation.*;
  42 import java.rmi.*;
  43 import java.util.Properties;
  44 import java.util.concurrent.TimeoutException;
  45 
  46 /**
  47  * The test creates an rmid with a special security manager.  After
  48  * rmid makes two registrations (which is greater than rmid's
  49  * snapshotInterval) the security manager stops allowing rmid to write
  50  * to update and snapshot log files in rmid's log directory.  The Test
  51  * registers an Activatable object twice with different group ids.
  52  * The second registration will cause rmid to have to write to a
  53  * LogFile (it causes a snapshot) and the security manager will not
  54  * allow the file write to happen.  The test makes sure that rmid
  55  * shuts down in a graceful manner without any explicit request to do
  56  * so.  The test will not exit for 400 seconds if rmid does not exit


  60     extends Activatable implements RegisteringActivatable
  61 {
  62     private static RegisteringActivatable registering = null;
  63 
  64     private final static long SHUTDOWN_TIMEOUT = 400 * 1000;
  65 
  66     public static void main(String args[]) {
  67 
  68         RMID rmid = null;
  69 
  70         // Save exception if there is a exception or expected behavior
  71         Exception exception = null;
  72         System.err.println("\nRegression test for bug/rfe 4183169\n");
  73 
  74         try {
  75             TestLibrary.suggestSecurityManager(
  76                 "java.rmi.RMISecurityManager");
  77 
  78             // start an rmid.
  79             RMID.removeLog();
  80             rmid = RMID.createRMIDOnEphemeralPort();
  81 
  82             // rmid needs to run with a security manager that
  83             // simulates a log problem; rmid should also snapshot
  84             // quickly.
  85             rmid.addOptions(new String[] {
  86                 "-Djava.security.manager=TestSecurityManager",
  87                 "-Dsun.rmi.activation.snapshotInterval=1"});
  88 
  89             //      rmid.addArguments(new String[] {
  90             //          "-C-Djava.rmi.server.logCalls=true"});
  91 
  92             rmid.start();
  93 
  94             // Ensure that activation groups run with the correct
  95             // security manager.
  96             //
  97             Properties p = new Properties();
  98             p.put("java.security.policy",
  99                   TestParams.defaultGroupPolicy);
 100             p.put("java.security.manager",