< prev index next >

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

Print this page


   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  */


  41 import java.rmi.*;
  42 import java.rmi.server.*;
  43 import java.rmi.registry.*;
  44 
  45 /**
  46  * Test ensures that the rmiregistry is capable of running over customx
  47  * (i.e. compression) client and server socket factories.
  48  */
  49 public class UseCustomSocketFactory {
  50 
  51     Hello hello = null;
  52 
  53     public static void main(String[] args) {
  54 
  55         Registry registry = null;
  56         HelloImpl impl = null;
  57 
  58         System.out.println("\nRegression test for bug 4148850\n");
  59 
  60         TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager");
  61         int registryPort = TestLibrary.getUnusedRandomPort();
  62 
  63         try {
  64             impl = new HelloImpl();
  65 
  66             /* Make sure that the rmiregistry can communicate over a
  67              * custom socket.  Ensure that the functionality exists to
  68              * allow the rmiregistry to be secure.
  69              */
  70             registry = LocateRegistry.
  71                 createRegistry(registryPort,
  72                                new Compress.CompressRMIClientSocketFactory(),
  73                                new Compress.CompressRMIServerSocketFactory());

  74             registry.rebind("/HelloServer", impl);
  75             checkStub(registry, "RMIServerSocket");
  76 
  77         } catch (Exception e) {
  78             TestLibrary.bomb("creating registry", e);
  79         }
  80 
  81         JavaVM serverVM = new JavaVM("HelloImpl",
  82                                      "-Djava.security.policy=" +
  83                                      TestParams.defaultPolicy +
  84                                      " -Drmi.registry.port=" +
  85                                      registryPort,
  86                                      "");
  87 
  88         try {
  89 
  90             /*
  91              * spawn VM for HelloServer which will download a client socket
  92              * factory
  93              */


   1 /*
   2  * Copyright (c) 1998, 2016, 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  */


  41 import java.rmi.*;
  42 import java.rmi.server.*;
  43 import java.rmi.registry.*;
  44 
  45 /**
  46  * Test ensures that the rmiregistry is capable of running over customx
  47  * (i.e. compression) client and server socket factories.
  48  */
  49 public class UseCustomSocketFactory {
  50 
  51     Hello hello = null;
  52 
  53     public static void main(String[] args) {
  54 
  55         Registry registry = null;
  56         HelloImpl impl = null;
  57 
  58         System.out.println("\nRegression test for bug 4148850\n");
  59 
  60         TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager");
  61         int registryPort = -1;
  62 
  63         try {
  64             impl = new HelloImpl();
  65 
  66             /* Make sure that the rmiregistry can communicate over a
  67              * custom socket.  Ensure that the functionality exists to
  68              * allow the rmiregistry to be secure.
  69              */
  70             registry = LocateRegistry.
  71                 createRegistry(0,
  72                                new Compress.CompressRMIClientSocketFactory(),
  73                                new Compress.CompressRMIServerSocketFactory());
  74             registryPort = TestLibrary.getRegistryPort(registry);
  75             registry.rebind("/HelloServer", impl);
  76             checkStub(registry, "RMIServerSocket");
  77 
  78         } catch (Exception e) {
  79             TestLibrary.bomb("creating registry", e);
  80         }
  81 
  82         JavaVM serverVM = new JavaVM("HelloImpl",
  83                                      "-Djava.security.policy=" +
  84                                      TestParams.defaultPolicy +
  85                                      " -Drmi.registry.port=" +
  86                                      registryPort,
  87                                      "");
  88 
  89         try {
  90 
  91             /*
  92              * spawn VM for HelloServer which will download a client socket
  93              * factory
  94              */


< prev index next >