jdk/test/java/rmi/testlibrary/TestLibrary.java
changeset 21810 47aa8bf866e2
parent 15273 fc0a33508cf7
child 22341 4689530d03b9
equal deleted inserted replaced
21809:8afe7ed13ed9 21810:47aa8bf866e2
     1 /*
     1 /*
     2  * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
   125     }
   125     }
   126     public static void bomb(Exception e) {
   126     public static void bomb(Exception e) {
   127         bomb(null, e);
   127         bomb(null, e);
   128     }
   128     }
   129 
   129 
       
   130     /**
       
   131      * Helper method to determine if registry has started
       
   132      *
       
   133      * @param port The port number to check
       
   134      * @param msTimeout The amount of milliseconds to spend checking
       
   135      */
       
   136 
       
   137     public static boolean checkIfRegistryRunning(int port, int msTimeout) {
       
   138         long stopTime = System.currentTimeMillis() + msTimeout;
       
   139         do {
       
   140             try {
       
   141                 Registry r = LocateRegistry.getRegistry(port);
       
   142                 String[] s = r.list();
       
   143                 // no exception. We're now happy that registry is running
       
   144                 return true;
       
   145             } catch (RemoteException e) {
       
   146                 // problem - not ready ? Try again
       
   147                 try {
       
   148                     Thread.sleep(500);
       
   149                 } catch (InterruptedException ie) {
       
   150                     // not expected
       
   151                 }
       
   152             }
       
   153         } while (stopTime > System.currentTimeMillis());
       
   154         return false;
       
   155     }
       
   156 
   130     public static String getProperty(String property, String defaultVal) {
   157     public static String getProperty(String property, String defaultVal) {
   131         final String prop = property;
   158         final String prop = property;
   132         final String def = defaultVal;
   159         final String def = defaultVal;
   133         return java.security.AccessController.doPrivileged(
   160         return java.security.AccessController.doPrivileged(
   134             new java.security.PrivilegedAction<String>() {
   161             new java.security.PrivilegedAction<String>() {