/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
*
*/
/**
* Utility class that creates an instance of rmid with a policy
* file of name <code>TestParams.defaultPolicy</code>.
*
* Activation groups should run with the same security manager as the
* test.
*/
/** Test port for rmid */
private final int port;
/** Initial log name */
/** rmid's logfile directory; currently must be "." */
}
/** make test options and arguments */
// +
//" -Djava.compiler= ";
// if test params set, want to propagate them
}
//if (!TestParams.testClasses.equals("")) {
// options += " -Dtest.classes=" + TestParams.testClasses + " ";
//}
+
" -Djava.rmi.server.logLevel=v ";
// +
// " -Djava.security.debug=all ";
return options;
}
// rmid will run with a security manager set, but no policy
// file - it should not need one.
} else {
}
// getAbsolutePath requires permission to read user.dir
if (includePortArg) {
}
// +
// " -C-Djava.compiler= ";
// if test params set, want to propagate them
}
}
args += " -C-Djava.rmi.server.useCodebaseOnly=false ";
return args;
}
/**
* Routine that creates an rmid that will run with or without a
* policy file.
*/
}
}
}
boolean debugExec)
{
}
boolean debugExec, boolean includePortArg,
int port)
{
return rmid;
}
/**
* Test RMID should be created with the createRMID method.
*/
{
}
public static void removeLog() {
/*
* Remove previous log file directory before
* starting up rmid.
*/
if (f.exists()) {
mesg("removing rmid's old log file...");
}
}
if (f.delete() != true) {
}
}
}
/**
* This method is used for adding arguments to rmid (not its VM)
* for passing as VM options to its child group VMs.
* Returns the extra command line arguments required
* to turn on jcov code coverage analysis for rmid child VMs.
*/
}
start(10000);
}
start(60000);
}
// if rmid is already running, then the test will fail with
// a well recognized exception (port already in use...).
super.start();
int slopFactor = 1;
try {
} catch (NumberFormatException ignore) {}
// We check several times (as many as provides passed waitTime) to
// see if Rmid is currently running. Waiting steps last 100 msecs.
final long rmidStartSleepTime = 100;
do {
// Sleeping for another rmidStartSleepTime time slice.
try {
} catch (InterruptedException ie) {
mesg("Thread interrupted while checking for start of Activation System. Giving up check.");
mesg("Activation System state unknown");
return;
}
// Checking if rmid is present
/**
* We need to set the java.rmi.activation.port value as the
* activation system will use the property to determine the
* port #. The activation system will use this value if set.
* If it isn't set, the activation system will set it to an
* incorrect value.
*/
mesg("finished starting rmid.");
return;
}
else {
mesg("rmid still not started");
}
} while (waitTime > 0);
}
destroy();
start();
}
/**
* Ask rmid to shutdown gracefully using a remote method call.
* catch any errors that might occur from rmid not being present
* at time of shutdown invocation.
*
* Shutdown does not nullify possible references to the rmid
* process object (destroy does though).
*/
try {
try {
mesg("getting a reference to the activation system");
port +
"/java.rmi.activation.ActivationSystem");
mesg("obtained a reference to the activation system");
} catch (RemoteException re) {
mesg("could not contact registry while trying to shutdown activation system");
}
}
} catch (RemoteException re) {
mesg("shutting down the activation daemon failed");
} catch (Exception e) {
mesg("caught exception trying to shutdown rmid");
mesg(e.getMessage());
e.printStackTrace();
}
mesg("testlibrary finished shutting down rmid");
}
/**
* Ask rmid to shutdown gracefully but then destroy the rmid
* process if it does not exit by itself. This method only works
* if rmid is a child process of the current VM.
*/
public void destroy() {
// attempt graceful shutdown of the activation system
try {
/* Waiting for distant RMID process to shutdown.
* Waiting is bounded at a hardcoded max of 60 secs (1 min).
* Waiting by steps of 200 msecs, thus at most 300 such attempts
* for termination of distant RMID process. If process is not
* known to be terminated properly after that time,
* we give up for a gracefull termination, and thus go for
* forcibly destroying the process.
*/
boolean vmEnded = false;
int waitingTrials = 0;
final int maxTrials = 300;
final long vmProcessEndWaitInterval = 200;
int vmExitValue;
do {
try {
mesg("rmid exited on shutdown request");
vmEnded = true;
} catch (IllegalThreadStateException illegal) {
mesg("RMID's process still not terminated after more than " +
}
}
while (!vmEnded &&
(waitingTrials < maxTrials));
if (waitingTrials >= maxTrials) {
mesg("RMID's process still not terminated after more than " +
"Givinp up gracefull termination...");
mesg("destroying RMID's process using Process.destroy()");
super.destroy();
}
} catch (InterruptedException ie) {
mesg("Thread interrupted while checking for termination of distant rmid vm. Giving up check.");
} catch (Exception e) {
mesg("caught unexpected exception trying to destroy rmid: " +
e.getMessage());
e.printStackTrace();
}
// rmid will not restart if its process is not null
}
}
}