< prev index next >

test/java/rmi/activation/Activatable/elucidateNoSuchMethod/ElucidateNoSuchMethod.java

Print this page
rev 15876 : 8085192: java/rmi/activation/Activatable tests fail intermittently due to "Port already in use"
Reviewed-by: rriggs, mli


  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 /* @test
  25  * @bug 4128620
  26  * @summary synopsis: NoSuchMethodError should be elucidated
  27  * @author Laird Dornin
  28  *
  29  * @library ../../../testlibrary
  30  * @modules java.rmi/sun.rmi.registry
  31  *          java.rmi/sun.rmi.server
  32  *          java.rmi/sun.rmi.transport
  33  *          java.rmi/sun.rmi.transport.tcp
  34  * @build TestLibrary RMID ActivateMe ElucidateNoSuchMethod_Stub

  35  * @run main/othervm/policy=security.policy/timeout=240 ElucidateNoSuchMethod
  36  */
  37 
  38 import java.io.*;
  39 import java.rmi.*;
  40 import java.rmi.activation.*;
  41 import java.rmi.server.*;
  42 import java.rmi.registry.*;
  43 import java.util.Properties;
  44 
  45 public class ElucidateNoSuchMethod
  46         extends Activatable
  47         implements ActivateMe, Runnable
  48 {
  49 
  50     /**
  51      *  provide a constructor that alllows this object to be made
  52      *  activatable, or at least registered.
  53      */
  54     ElucidateNoSuchMethod(ActivationID id, int port)


  74     /**
  75      * Thread to deactivate object. First attempts to make object
  76      * inactive (via the inactive method).  If that fails (the
  77      * object may still have pending/executing calls), then
  78      * unexport the object forcibly.
  79      */
  80     public void run() {
  81         ActivationLibrary.deactivate(this, getID());
  82     }
  83 
  84     public static void main(String[] args) {
  85 
  86         System.out.println("\nRegression test for 4128620 \n");
  87 
  88         TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager");
  89 
  90         RMID rmid = null;
  91 
  92         try {
  93             RMID.removeLog();
  94             rmid = RMID.createRMID();
  95             rmid.start();
  96 
  97             /* Cause activation groups to have a security policy that will
  98              * allow security managers to be downloaded and installed
  99              */
 100             Properties p = new Properties();
 101             // this test must always set policies/managers in its
 102             // activation groups
 103             p.put("java.security.policy",
 104                   TestParams.defaultGroupPolicy);
 105             p.put("java.security.manager",
 106                   TestParams.defaultSecurityManager);
 107 
 108             System.err.println("Create activation group in this VM");
 109             ActivationGroupDesc groupDesc =
 110                 new ActivationGroupDesc(p, null);
 111             ActivationSystem system = ActivationGroup.getSystem();
 112             ActivationGroupID groupID = system.registerGroup(groupDesc);
 113             ActivationGroup.createGroup(groupID, groupDesc, 0);
 114 




  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 /* @test
  25  * @bug 4128620
  26  * @summary synopsis: NoSuchMethodError should be elucidated
  27  * @author Laird Dornin
  28  *
  29  * @library ../../../testlibrary
  30  * @modules java.rmi/sun.rmi.registry
  31  *          java.rmi/sun.rmi.server
  32  *          java.rmi/sun.rmi.transport
  33  *          java.rmi/sun.rmi.transport.tcp
  34  *          java.base/sun.nio.ch
  35  * @build TestLibrary RMID RMIDSelectorProvider ActivateMe ElucidateNoSuchMethod_Stub
  36  * @run main/othervm/policy=security.policy/timeout=240 ElucidateNoSuchMethod
  37  */
  38 
  39 import java.io.*;
  40 import java.rmi.*;
  41 import java.rmi.activation.*;
  42 import java.rmi.server.*;
  43 import java.rmi.registry.*;
  44 import java.util.Properties;
  45 
  46 public class ElucidateNoSuchMethod
  47         extends Activatable
  48         implements ActivateMe, Runnable
  49 {
  50 
  51     /**
  52      *  provide a constructor that alllows this object to be made
  53      *  activatable, or at least registered.
  54      */
  55     ElucidateNoSuchMethod(ActivationID id, int port)


  75     /**
  76      * Thread to deactivate object. First attempts to make object
  77      * inactive (via the inactive method).  If that fails (the
  78      * object may still have pending/executing calls), then
  79      * unexport the object forcibly.
  80      */
  81     public void run() {
  82         ActivationLibrary.deactivate(this, getID());
  83     }
  84 
  85     public static void main(String[] args) {
  86 
  87         System.out.println("\nRegression test for 4128620 \n");
  88 
  89         TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager");
  90 
  91         RMID rmid = null;
  92 
  93         try {
  94             RMID.removeLog();
  95             rmid = RMID.createRMIDOnEphemeralPort();
  96             rmid.start();
  97 
  98             /* Cause activation groups to have a security policy that will
  99              * allow security managers to be downloaded and installed
 100              */
 101             Properties p = new Properties();
 102             // this test must always set policies/managers in its
 103             // activation groups
 104             p.put("java.security.policy",
 105                   TestParams.defaultGroupPolicy);
 106             p.put("java.security.manager",
 107                   TestParams.defaultSecurityManager);
 108 
 109             System.err.println("Create activation group in this VM");
 110             ActivationGroupDesc groupDesc =
 111                 new ActivationGroupDesc(p, null);
 112             ActivationSystem system = ActivationGroup.getSystem();
 113             ActivationGroupID groupID = system.registerGroup(groupDesc);
 114             ActivationGroup.createGroup(groupID, groupDesc, 0);
 115 


< prev index next >