Author: ropalka
Date: 2012-02-29 10:11:24 -0500 (Wed, 29 Feb 2012)
New Revision: 15790
Modified:
shared-testsuite/trunk/src/main/java/org/jboss/wsf/test/JBossWSTestHelper.java
Log:
[JBWS-3435] resuscitate Process.waitFor() call for now
Modified: shared-testsuite/trunk/src/main/java/org/jboss/wsf/test/JBossWSTestHelper.java
===================================================================
---
shared-testsuite/trunk/src/main/java/org/jboss/wsf/test/JBossWSTestHelper.java 2012-02-29
13:43:01 UTC (rev 15789)
+++
shared-testsuite/trunk/src/main/java/org/jboss/wsf/test/JBossWSTestHelper.java 2012-02-29
15:11:24 UTC (rev 15790)
@@ -80,6 +80,7 @@
private static String testArchiveDir;
private static String testResourcesDir;
private static Process appclientProcess;
+ private static OutputStream appclientOutput;
private static synchronized Deployer getDeployer()
{
@@ -127,7 +128,7 @@
final String appclientName = archive.substring(sharpIndex + 1);
final String appclientFullName = getArchiveFile(earName).getParent() + FS +
archive;
final String touchFile = JBOSS_HOME + FS + "bin" + FS + appclientName
+ ".kill";
- final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ appclientOutput = new ByteArrayOutputStream();
if (appclientOS == null)
{
appclientProcess = new ProcessBuilder().command(appclientScript,
appclientFullName, touchFile).start();
@@ -145,7 +146,7 @@
appclientProcess = new ProcessBuilder().command(args).start();
}
final CopyJob inputStreamJob = new CopyJob(appclientProcess.getInputStream(),
- appclientOS == null ? new TeeOutputStream(baos, System.out) : new
TeeOutputStream(baos, System.out, appclientOS));
+ appclientOS == null ? new TeeOutputStream(appclientOutput, System.out) :
new TeeOutputStream(appclientOutput, System.out, appclientOS));
final CopyJob errorStreamJob = new CopyJob(appclientProcess.getErrorStream(),
System.err);
// unfortunately the following threads are needed because of Windows behavior
System.out.println("Appclient output stream:");
@@ -153,7 +154,7 @@
new Thread(errorStreamJob).start();
int countOfAttempts = 0;
final int maxCountOfAttempts = 30; // max wait time: 30 seconds
- while (!baos.toString().contains("Deployed \"" + earName +
"\""))
+ while (!appclientOutput.toString().contains("Deployed \"" +
earName + "\""))
{
Thread.sleep(1000);
if (countOfAttempts++ == maxCountOfAttempts)
@@ -176,7 +177,19 @@
final int sharpIndex = archive.indexOf('#');
final File touchFile = new File(JBOSS_HOME + FS + "bin" + FS +
archive.substring(sharpIndex + 1) + ".kill");
touchFile.createNewFile();
- Thread.sleep(200);
+ appclientProcess.waitFor();
+ /*
+ int countOfAttempts = 0;
+ final int maxCountOfAttempts = 30; // max wait time: 30 seconds
+ while (!appclientOutput.toString().contains("stopped in"))
+ {
+ Thread.sleep(1000);
+ if (countOfAttempts++ == maxCountOfAttempts)
+ {
+ throw new RuntimeException("Cannot stop appclient");
+ }
+ }
+ */
appclientProcess = null;
touchFile.delete();
System.out.println("appclient stopped");