< prev index next >

test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/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  */


  38  */
  39 
  40 import java.io.IOException;
  41 import java.net.MalformedURLException;
  42 import java.rmi.*;
  43 import java.rmi.registry.*;
  44 
  45 public class UseCustomSocketFactory {
  46 
  47     public static void main(String[] args) {
  48 
  49         int registryPort = -1;
  50 
  51         String[] protocols = new String[] { "", "compress", "xor" };
  52 
  53         System.out.println("\nRegression test for bug 4127826\n");
  54 
  55         TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager");
  56 
  57         try {
  58             Registry registry = TestLibrary.createRegistryOnUnusedPort();
  59             registryPort = TestLibrary.getRegistryPort(registry);
  60         } catch (RemoteException e) {
  61             TestLibrary.bomb("creating registry", e);
  62         }
  63         for (String protocol : protocols) {
  64             System.err.println("test policy: " +
  65                     TestParams.defaultPolicy);
  66             JavaVM serverVM = new JavaVM("EchoImpl", "-Djava.security.policy=" +
  67                     TestParams.defaultPolicy +
  68                     " -Drmi.registry.port=" +
  69                     registryPort, protocol);
  70             System.err.println("\nusing protocol: " +
  71                     ("".equals(protocol) ? "none" : protocol));
  72             try {
  73                 /* spawn VM for EchoServer */
  74                 serverVM.start();
  75 
  76                 /* lookup server */
  77                 Echo obj = null;
  78                 // 16 seconds timeout


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


  38  */
  39 
  40 import java.io.IOException;
  41 import java.net.MalformedURLException;
  42 import java.rmi.*;
  43 import java.rmi.registry.*;
  44 
  45 public class UseCustomSocketFactory {
  46 
  47     public static void main(String[] args) {
  48 
  49         int registryPort = -1;
  50 
  51         String[] protocols = new String[] { "", "compress", "xor" };
  52 
  53         System.out.println("\nRegression test for bug 4127826\n");
  54 
  55         TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager");
  56 
  57         try {
  58             Registry registry = TestLibrary.createRegistryOnEphemeralPort();
  59             registryPort = TestLibrary.getRegistryPort(registry);
  60         } catch (RemoteException e) {
  61             TestLibrary.bomb("creating registry", e);
  62         }
  63         for (String protocol : protocols) {
  64             System.err.println("test policy: " +
  65                     TestParams.defaultPolicy);
  66             JavaVM serverVM = new JavaVM("EchoImpl", "-Djava.security.policy=" +
  67                     TestParams.defaultPolicy +
  68                     " -Drmi.registry.port=" +
  69                     registryPort, protocol);
  70             System.err.println("\nusing protocol: " +
  71                     ("".equals(protocol) ? "none" : protocol));
  72             try {
  73                 /* spawn VM for EchoServer */
  74                 serverVM.start();
  75 
  76                 /* lookup server */
  77                 Echo obj = null;
  78                 // 16 seconds timeout


< prev index next >