< prev index next >

test/java/rmi/reliability/juicer/AppleUserImpl.java

Print this page


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


 296                     usage();
 297                 }
 298             }
 299             if (durationString == null) {
 300                 durationString = testDuration + " milliseconds";
 301             }
 302         } catch (Throwable t) {
 303             usage();
 304             throw new RuntimeException("TEST FAILED: Bad argument");
 305         }
 306 
 307         AppleUserImpl user = null;
 308         long startTime = 0;
 309         Thread server = null;
 310         int exitValue = 0;
 311         try {
 312             user = new AppleUserImpl();
 313 
 314             synchronized (user) {
 315                 // create new registry and bind new AppleUserImpl in registry
 316                 Registry registry = TestLibrary.createRegistryOnUnusedPort();
 317                 registryPort = TestLibrary.getRegistryPort(registry);
 318                 LocateRegistry.getRegistry(registryPort).rebind("AppleUser",
 319                                                                  user);
 320 
 321                 // start the other server if applicable
 322                 if (othervm) {
 323                     // the other server must be running in a separate process
 324                     logger.log(Level.INFO, "Application server must be " +
 325                         "started in separate process");
 326                 } else {
 327                     Class app = Class.forName("ApplicationServer");
 328                     java.lang.reflect.Constructor appConstructor =
 329                             app.getDeclaredConstructor(new Class[] {Integer.TYPE});
 330                     server = new Thread((Runnable) appConstructor.newInstance(registryPort));
 331                     logger.log(Level.INFO, "Starting application server " +
 332                         "in same process");
 333                     server.start();
 334                 }
 335 
 336                 // wait for other server to call startTest method


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


 296                     usage();
 297                 }
 298             }
 299             if (durationString == null) {
 300                 durationString = testDuration + " milliseconds";
 301             }
 302         } catch (Throwable t) {
 303             usage();
 304             throw new RuntimeException("TEST FAILED: Bad argument");
 305         }
 306 
 307         AppleUserImpl user = null;
 308         long startTime = 0;
 309         Thread server = null;
 310         int exitValue = 0;
 311         try {
 312             user = new AppleUserImpl();
 313 
 314             synchronized (user) {
 315                 // create new registry and bind new AppleUserImpl in registry
 316                 Registry registry = TestLibrary.createRegistryOnEphemeralPort();
 317                 registryPort = TestLibrary.getRegistryPort(registry);
 318                 LocateRegistry.getRegistry(registryPort).rebind("AppleUser",
 319                                                                  user);
 320 
 321                 // start the other server if applicable
 322                 if (othervm) {
 323                     // the other server must be running in a separate process
 324                     logger.log(Level.INFO, "Application server must be " +
 325                         "started in separate process");
 326                 } else {
 327                     Class app = Class.forName("ApplicationServer");
 328                     java.lang.reflect.Constructor appConstructor =
 329                             app.getDeclaredConstructor(new Class[] {Integer.TYPE});
 330                     server = new Thread((Runnable) appConstructor.newInstance(registryPort));
 331                     logger.log(Level.INFO, "Starting application server " +
 332                         "in same process");
 333                     server.start();
 334                 }
 335 
 336                 // wait for other server to call startTest method


< prev index next >