Author: richard.opalka(a)jboss.com
Date: 2008-09-26 07:19:33 -0400 (Fri, 26 Sep 2008)
New Revision: 8240
Modified:
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/xop/doclit/MTOMEndpointBean.java
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/ScriptTestCase.java
framework/trunk/testsuite/test/java/org/jboss/test/ws/projectGenerator/ProjectGeneratorTestCase.java
Log:
[JBWS-2322] fix tests to be cross platform
Modified:
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/xop/doclit/MTOMEndpointBean.java
===================================================================
---
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/xop/doclit/MTOMEndpointBean.java 2008-09-26
11:18:17 UTC (rev 8239)
+++
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/xop/doclit/MTOMEndpointBean.java 2008-09-26
11:19:33 UTC (rev 8240)
@@ -22,6 +22,7 @@
package org.jboss.test.ws.jaxws.samples.xop.doclit;
import java.io.IOException;
+import java.io.InputStream;
import javax.activation.DataHandler;
import javax.jws.WebService;
@@ -46,7 +47,12 @@
try
{
log.info("Recv " + dataHandler.getContentType());
- log.info("Content is " + dataHandler.getContent());
+ Object dataHandlerContent = dataHandler.getContent();
+ log.info("Content is " + dataHandlerContent);
+ if ( dataHandlerContent instanceof InputStream )
+ {
+ ((InputStream)dataHandlerContent).close();
+ }
}
catch (IOException e)
{
Modified:
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/ScriptTestCase.java
===================================================================
---
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/ScriptTestCase.java 2008-09-26
11:18:17 UTC (rev 8239)
+++
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/ScriptTestCase.java 2008-09-26
11:19:33 UTC (rev 8240)
@@ -125,6 +125,7 @@
private void assertStatusCode(Process p, String s) throws InterruptedException
{
CopyJob job = new CopyJob(p.getInputStream(), System.out);
+ // unfortunately the following thread is needed (otherwise this test will not work
on windows)
new Thread( job ).start();
int status = -1;
try
Modified:
framework/trunk/testsuite/test/java/org/jboss/test/ws/projectGenerator/ProjectGeneratorTestCase.java
===================================================================
---
framework/trunk/testsuite/test/java/org/jboss/test/ws/projectGenerator/ProjectGeneratorTestCase.java 2008-09-26
11:18:17 UTC (rev 8239)
+++
framework/trunk/testsuite/test/java/org/jboss/test/ws/projectGenerator/ProjectGeneratorTestCase.java 2008-09-26
11:19:33 UTC (rev 8240)
@@ -23,6 +23,7 @@
import java.io.BufferedReader;
import java.io.BufferedWriter;
+import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
@@ -33,6 +34,7 @@
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
+import org.jboss.wsf.common.concurrent.CopyJob;
import org.jboss.wsf.test.JBossWSTest;
import org.jboss.wsf.test.JBossWSTestHelper;
@@ -50,6 +52,8 @@
public class ProjectGeneratorTestCase extends JBossWSTest
{
private static final String FS = System.getProperty("file.separator"); //
'/' on unix, '\' on windows
+ private static final String PS = System.getProperty("path.separator"); //
':' on unix, ';' on windows
+ private static final String ANT_SHELL = ":".equals( PS ) ? "ant" :
"ant.bat";
private String jbossHome;
private File workspaceHome;
private File binDistroDir;
@@ -77,7 +81,7 @@
writeUserProjectProperties(userPrjProp);
File distroBuild = new File(binDistroDir, "build.xml");
String integrationTarget =
System.getProperty("jbossws.integration.target");
- assertStatusCode(executeCommand("ant -f " + distroBuild.getAbsolutePath()
+ " -D" + integrationTarget + ".home=" + jbossHome + "
-Djbossws.integration.target="
+ assertStatusCode(executeCommand(ANT_SHELL + " -f " +
distroBuild.getAbsolutePath() + " -D" + integrationTarget + ".home=" +
jbossHome + " -Djbossws.integration.target="
+ integrationTarget + " create-project"), "Error while
creating the user project!");
File projectHomeDir = new File(workspaceHome, projectName);
File packageDir = new File(projectHomeDir.getCanonicalPath() + FS + "src"
+ FS + "main" + FS + "java" + FS + "org" + FS +
"jboss" + FS + "test" + FS + "ws" + FS +
"projectGenerator");
@@ -89,7 +93,7 @@
File projectBuild = new File(projectHomeDir.getCanonicalPath(),
"build.xml");
try
{
- assertStatusCode(executeCommand("ant -f " + projectBuild + "
deploy"), "Error while compiling / deploying the user project!");
+ assertStatusCode(executeCommand(ANT_SHELL + " -f " + projectBuild +
" deploy"), "Error while compiling / deploying the user project!");
//Sleeping 15 sec to let the deployment scanner pick up the user project jar
Thread.sleep(15000);
//Running the actual test
@@ -102,8 +106,8 @@
}
finally
{
- assertStatusCode(executeCommand("ant -f " + projectBuild + "
undeploy"), "Error while undeploying the user project");
- assertStatusCode(executeCommand("ant -f " +
distroBuild.getCanonicalPath() + " delete-project"), "Error while deleting
the user project");
+ assertStatusCode(executeCommand(ANT_SHELL + " -f " + projectBuild +
" undeploy"), "Error while undeploying the user project");
+ assertStatusCode(executeCommand(ANT_SHELL + " -f " +
distroBuild.getCanonicalPath() + " delete-project"), "Error while deleting
the user project");
userPrjProp.delete();
}
}
@@ -203,14 +207,22 @@
}
if (!build.exists())
throw new Exception("Unable to find build.xml!");
- Process p = executeCommand("ant -f " + build.getAbsolutePath() + "
-p");
- p.waitFor();
- BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
- String line;
- while ((line = in.readLine()) != null) {
- if (line.contains("build-bin-dist"))
- return false;
+ Process p = executeCommand(ANT_SHELL + " -f " + build.getAbsolutePath() +
" -p");
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ CopyJob job = new CopyJob(p.getInputStream(), baos);
+ // unfortunately the following thread is needed (otherwise this test will not work
on windows)
+ new Thread( job ).start();
+ try
+ {
+ int status = p.waitFor();
+ System.out.println(new String(baos.toByteArray()));
+ assertTrue("Unexpected exit status code: " + status, status == 0);
}
- return true;
+ finally
+ {
+ job.kill();
+ p.destroy();
+ }
+ return !(new String(baos.toByteArray()).contains("build-bin-dist"));
}
}
Show replies by date