test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/UseCustomSocketFactory.java

Print this page
rev 11003 : 8035000: clean up ActivationLibrary.DestroyThread
   1 /*
   2  * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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  */


  40 public class UseCustomSocketFactory {
  41     static final int REGISTRY_PORT = TestLibrary.getUnusedRandomPort();
  42 
  43     static String[] protocol = new String[] { "", "compress", "xor" };
  44 
  45     public static void main(String[] args) {
  46 
  47         System.out.println("\nRegression test for bug 4115696\n");
  48 
  49         TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager");
  50 
  51         try {
  52             LocateRegistry.createRegistry(REGISTRY_PORT);
  53         } catch (RemoteException e) {
  54             TestLibrary.bomb("creating registry", e);
  55         }
  56 
  57         RMID rmid = null;
  58 
  59         try {
  60             rmid = RMID.createRMID(true);
  61             rmid.addArguments(new String[] {
  62                 "-C-Djava.security.policy=" +
  63                     TestParams.defaultGroupPolicy +
  64                     " -C-Djava.security.manager=java.rmi.RMISecurityManager "});
  65             rmid.start();
  66 
  67             Echo[] echo = spawnAndTest(rmid.getPort());
  68             reactivateAndTest(echo);
  69         } catch (IOException e) {
  70             TestLibrary.bomb("creating rmid", e);
  71         } finally {
  72             if (rmid != null)
  73                 rmid.destroy();
  74         }
  75     }
  76 
  77     private static Echo[] spawnAndTest(int rmidPort) {
  78 
  79         System.err.println("\nCreate Test-->");
  80 


   1 /*
   2  * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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  */


  40 public class UseCustomSocketFactory {
  41     static final int REGISTRY_PORT = TestLibrary.getUnusedRandomPort();
  42 
  43     static String[] protocol = new String[] { "", "compress", "xor" };
  44 
  45     public static void main(String[] args) {
  46 
  47         System.out.println("\nRegression test for bug 4115696\n");
  48 
  49         TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager");
  50 
  51         try {
  52             LocateRegistry.createRegistry(REGISTRY_PORT);
  53         } catch (RemoteException e) {
  54             TestLibrary.bomb("creating registry", e);
  55         }
  56 
  57         RMID rmid = null;
  58 
  59         try {
  60             rmid = RMID.createRMID();
  61             rmid.addArguments(new String[] {
  62                 "-C-Djava.security.policy=" +
  63                     TestParams.defaultGroupPolicy +
  64                     " -C-Djava.security.manager=java.rmi.RMISecurityManager "});
  65             rmid.start();
  66 
  67             Echo[] echo = spawnAndTest(rmid.getPort());
  68             reactivateAndTest(echo);
  69         } catch (IOException e) {
  70             TestLibrary.bomb("creating rmid", e);
  71         } finally {
  72             if (rmid != null)
  73                 rmid.destroy();
  74         }
  75     }
  76 
  77     private static Echo[] spawnAndTest(int rmidPort) {
  78 
  79         System.err.println("\nCreate Test-->");
  80