5266N/A * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * @author Adrian Colley 0N/A * @author Laird Dornin 0N/A * @author Peter Jones 0N/A * @author Ann Wollrath 0N/A * The rmi library directory contains a set of simple utiltity classes 0N/A * for use in rmi regression tests. 0N/A * NOTE: The JavaTest group has recommended that regression tests do 0N/A * not make use of packages. 0N/A * the writing and maintainance of rmi regression tests. 5266N/A * RMI tests are run concurrently and port conflicts result when a single 5266N/A * port number is used by multiple tests. When needing a port, use 5266N/A * getUnusedRandomPort() wherever possible. If getUnusedRandomPort() cannot 5266N/A * be used, reserve and specify a port to use for your test here. This 5266N/A * will ensure there are no port conflicts amongst the RMI tests. The 5266N/A * port numbers specified here may also be specified in the respective 5266N/A * tests. Do not change the reserved port numbers here without also 5266N/A * changing the port numbers in the respective tests. 5266N/A * When needing an instance of the RMIRegistry, use 5266N/A * createRegistryOnUnusedPort wherever possible to prevent port conflicts. 5266N/A * Reserved port range: FIXED_PORT_MIN to FIXED_PORT_MAX (inclusive) for 5266N/A * tests which cannot use a random port. If new fixed ports are added below 5266N/A * FIXED_PORT_MIN or above FIXED_PORT_MAX, then adjust 0N/A * Routines that enable rmi tests to fail in a uniformly 0N/A * informative fashion. 0N/A * Routines to print out a test's properties environment. 0N/A * Routine that "works-around" a limitation in jtreg. 0N/A * Currently it is not possible for a test to specify that the 0N/A * test harness should build a given source file and install the 0N/A * resulting class in a location that is not accessible from the 0N/A * test's classpath. This method enables a test to move a 0N/A * compiled test class file from the test's class directory into a 0N/A * given "codebase" directory. As a result the test can only 0N/A * access the class file for <code>className</code>if the test loads 0N/A * it from a classloader (e.g. RMIClassLoader). 0N/A * Tests that use this routine must have the following permissions 0N/A * getProperty user.dir 0N/A * and the codebase must be a relative path (it's created relative 0N/A * to the working directory). 0N/A * Specify the file to contain the class definition. Make sure 0N/A * that the codebase directory exists (underneath the working 0N/A "could not create codebase directory");
0N/A * Obtain the URL for the codebase. 0N/A * Specify where we will copy the class definition from, if 0N/A * necessary. After the test is built, the class file can be 0N/A * found in the "test.classes" directory. 0N/A * If the class definition is not already located at the codebase, 0N/A * copy it there from the test build area. 0N/A "could not find class file to install in codebase " +
0N/A "could not install class file in codebase");
0N/A * After the class definition is successfully installed at the 0N/A * codebase, delete it from the test's CLASSPATH, so that it will 0N/A * not be found there first before the codebase is searched. 0N/A "could not delete duplicate class file in CLASSPATH");
0N/A /** routine to unexport an object */ 0N/A * Allow test framework to control the security manager set in 0N/A * @param managerClassName The class name of the security manager 0N/A * to be instantiated and set if no security 0N/A * manager has already been set. 0N/A bomb(
"Security manager could not be found: " +
0N/A bomb(
"Error creating security manager. ", e);
5266N/A * Creates an RMI {@link Registry} on a random, un-reserved port. 5266N/A * @returns an RMI Registry, using a random port. 5266N/A * @throws RemoteException if there was a problem creating a Registry. 5266N/A * Returns the port number the RMI {@link Registry} is running on. 5266N/A * @param registry the registry to find the port of. 5266N/A * @return the port number the registry is using. 5266N/A * @throws RuntimeException if there was a problem getting the port number. 5266N/A * Returns an unused random port number which is not a reserved port. Will 5266N/A * try up to 10 times to get a random port before giving up and throwing a 5266N/A * @return an unused random port number. 5266N/A * @throws RuntimeException if there was a problem getting a port. 5673N/A // temporarily print stack trace here until we find out why 5673N/A +
" ServerSocket(0) returned the reserved port " 5673N/A +
" in TestLibrary.getUnusedRandomPort() ");
5266N/A // If we're here, then either an exception was thrown or the port is 5673N/A +
" last port returned by ServerSocket(0) was a reserved port");
5266N/A * Determines if a port is one of the reserved port numbers. 5266N/A * @param port the port to test. 5266N/A * @return {@code true} if the port is a reserved port, otherwise 0N/A * Method to capture the stack trace of an exception and return it 0N/A /** extra properties */ 0N/A * Returns extra test properties. Looks for the file "../../test.props" 0N/A * and reads it in as a Properties file. Assuming the working directory 0N/A * Returns an extra test property. Looks for the file "../../test.props" 0N/A * and reads it in as a Properties file. Assuming the working directory 0N/A * If the property isn't found, defaultVal is returned.