< prev index next >

jdk/test/java/rmi/activation/ActivationGroup/downloadActivationGroup/DownloadActivationGroup.java

Print this page


   1 /*
   2  * Copyright (c) 2002, 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  */
  23 
  24 /*
  25  * @test
  26  * @bug 4510355
  27  * @key intermittent
  28  * @summary ActivationGroup implementations cannot be downloaded by default;
  29  * Creates a custom activation group without setting a security manager
  30  * in activation group's descriptor.  The custom activation group
  31  * implementation should be downloaded when first object within that group
  32  * is activated.
  33  * @author Ann Wollrath
  34  *
  35  * @library ../../../testlibrary
  36  * @modules java.rmi/sun.rmi.registry
  37  *          java.rmi/sun.rmi.server
  38  *          java.rmi/sun.rmi.transport
  39  *          java.rmi/sun.rmi.transport.tcp
  40  * @build TestLibrary RMID ActivationLibrary
  41  *     DownloadActivationGroup MyActivationGroupImpl DownloadActivationGroup_Stub
  42  * @run main/othervm/policy=security.policy/timeout=240 DownloadActivationGroup
  43  */
  44 
  45 import java.net.URL;
  46 import java.rmi.MarshalledObject;
  47 import java.rmi.Remote;


 123             /*
 124              * Start rmid.
 125              */
 126             RMID.removeLog();
 127             rmid = RMID.createRMID();
 128             String execPolicyOption = "-Dsun.rmi.activation.execPolicy=none";
 129             rmid.addOptions(new String[] { execPolicyOption });
 130             rmid.start();
 131 
 132             /*
 133              * Create and register descriptors for custom group and an
 134              * activatable object in that group.
 135              */
 136             System.err.println("register group");
 137 
 138             Properties p = new Properties();
 139             p.put("java.security.policy", TestParams.defaultGroupPolicy);
 140             CommandEnvironment cmd = new ActivationGroupDesc.CommandEnvironment(
 141                     null,
 142                     new String[] {
 143                         "-XaddExports:java.rmi/sun.rmi.registry=ALL-UNNAMED",
 144                         "-XaddExports:java.rmi/sun.rmi.server=ALL-UNNAMED",
 145                         "-XaddExports:java.rmi/sun.rmi.transport=ALL-UNNAMED",
 146                         "-XaddExports:java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED" });
 147 
 148             ActivationGroupDesc groupDesc =
 149                 new ActivationGroupDesc("MyActivationGroupImpl",
 150                                         groupURL.toExternalForm(),
 151                                         null, p, cmd);
 152             ActivationGroupID groupID =
 153                 ActivationGroup.getSystem().registerGroup(groupDesc);
 154 
 155 
 156             System.err.println("register activatable object");
 157             ActivationDesc desc =
 158                 new ActivationDesc(groupID, "DownloadActivationGroup",
 159                                    null, null);
 160             Ping obj = (Ping) Activatable.register(desc);
 161 
 162             /*
 163              * Start group (by calling ping).
 164              */
 165             System.err.println(
 166                 "ping object (forces download of group's class)");
   1 /*
   2  * Copyright (c) 2002, 2015, 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  */
  23 
  24 /*
  25  * @test
  26  * @bug 4510355

  27  * @summary ActivationGroup implementations cannot be downloaded by default;
  28  * Creates a custom activation group without setting a security manager
  29  * in activation group's descriptor.  The custom activation group
  30  * implementation should be downloaded when first object within that group
  31  * is activated.
  32  * @author Ann Wollrath
  33  *
  34  * @library ../../../testlibrary
  35  * @modules java.rmi/sun.rmi.registry
  36  *          java.rmi/sun.rmi.server
  37  *          java.rmi/sun.rmi.transport
  38  *          java.rmi/sun.rmi.transport.tcp
  39  * @build TestLibrary RMID ActivationLibrary
  40  *     DownloadActivationGroup MyActivationGroupImpl DownloadActivationGroup_Stub
  41  * @run main/othervm/policy=security.policy/timeout=240 DownloadActivationGroup
  42  */
  43 
  44 import java.net.URL;
  45 import java.rmi.MarshalledObject;
  46 import java.rmi.Remote;


 122             /*
 123              * Start rmid.
 124              */
 125             RMID.removeLog();
 126             rmid = RMID.createRMID();
 127             String execPolicyOption = "-Dsun.rmi.activation.execPolicy=none";
 128             rmid.addOptions(new String[] { execPolicyOption });
 129             rmid.start();
 130 
 131             /*
 132              * Create and register descriptors for custom group and an
 133              * activatable object in that group.
 134              */
 135             System.err.println("register group");
 136 
 137             Properties p = new Properties();
 138             p.put("java.security.policy", TestParams.defaultGroupPolicy);
 139             CommandEnvironment cmd = new ActivationGroupDesc.CommandEnvironment(
 140                     null,
 141                     new String[] {
 142                         "--add-exports=java.rmi/sun.rmi.registry=ALL-UNNAMED",
 143                         "--add-exports=java.rmi/sun.rmi.server=ALL-UNNAMED",
 144                         "--add-exports=java.rmi/sun.rmi.transport=ALL-UNNAMED",
 145                         "--add-exports=java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED" });
 146 
 147             ActivationGroupDesc groupDesc =
 148                 new ActivationGroupDesc("MyActivationGroupImpl",
 149                                         groupURL.toExternalForm(),
 150                                         null, p, cmd);
 151             ActivationGroupID groupID =
 152                 ActivationGroup.getSystem().registerGroup(groupDesc);
 153 
 154 
 155             System.err.println("register activatable object");
 156             ActivationDesc desc =
 157                 new ActivationDesc(groupID, "DownloadActivationGroup",
 158                                    null, null);
 159             Ping obj = (Ping) Activatable.register(desc);
 160 
 161             /*
 162              * Start group (by calling ping).
 163              */
 164             System.err.println(
 165                 "ping object (forces download of group's class)");
< prev index next >