Author: richard.opalka(a)jboss.com
Date: 2008-09-26 13:08:21 -0400 (Fri, 26 Sep 2008)
New Revision: 8253
Modified:
framework/trunk/testsuite/test/ant-import/build-testsuite.xml
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] final refactoring
Modified: framework/trunk/testsuite/test/ant-import/build-testsuite.xml
===================================================================
--- framework/trunk/testsuite/test/ant-import/build-testsuite.xml 2008-09-26 17:01:24 UTC
(rev 8252)
+++ framework/trunk/testsuite/test/ant-import/build-testsuite.xml 2008-09-26 17:08:21 UTC
(rev 8253)
@@ -81,7 +81,7 @@
<property name="node0.hajndi.url"
value="jnp://${node0}:1100"/>
<mkdir dir="${tests.output.dir}"/>
- <delete file="${tests.output.dir}/test.log"/>
+ <delete file="${tests.output.dir}/test.log"
failonerror="false"/>
<property name="jboss.client"
value="${jboss.home}/client"/>
<property name="jboss.lib" value="${jboss.home}/lib"/>
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
17:01:24 UTC (rev 8252)
+++
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/ScriptTestCase.java 2008-09-26
17:08:21 UTC (rev 8253)
@@ -21,9 +21,7 @@
*/
package org.jboss.test.ws.jaxws.smoke.tools;
-import java.io.*;
-
-import org.jboss.wsf.common.concurrent.CopyJob;
+import java.io.File;
import org.jboss.wsf.test.JBossWSTest;
/**
@@ -47,10 +45,8 @@
private String ENDPOINT_CLASS =
"org.jboss.test.ws.jaxws.smoke.tools.CalculatorBean";
private String JBOSS_HOME;
- private String JAVA_HOME;
private String CLASSES_DIR;
private String TEST_DIR;
- private String OS;
private String origJavaHome;
@@ -62,7 +58,6 @@
CLASSES_DIR = System.getProperty("test.classes.directory");
TEST_DIR = createResourceFile("..").getAbsolutePath();
origJavaHome = System.getProperty("java.home");
- OS = System.getProperty("os.name").toLowerCase();
// the script requires the system JAVA_HOME, which points to the JDK not the JRE
@@ -70,11 +65,9 @@
{
String JDK_HOME = origJavaHome.substring(0, origJavaHome.indexOf(FS +
"jre"));
System.setProperty("java.home", JDK_HOME);
- JAVA_HOME= JDK_HOME;
}
}
-
protected void tearDown() throws Exception
{
// reset surefire's JAVA_HOME
@@ -86,89 +79,19 @@
// use absolute path for the output to be re-usable
String absWsdlLoc = getResourceFile(WSDL_LOCATION).getAbsolutePath();
String absOutput = new File(TEST_DIR, "wsconsume" + FS +
"java").getAbsolutePath();
-
String command = JBOSS_HOME + FS + "bin" + FS + "wsconsume" +
EXT + " -v -k -o " + absOutput + " " + absWsdlLoc;
- Process p = executeCommand(command);
-
- // check status code
- assertStatusCode(p, "wsconsume");
-
+ executeCommand(command, "wsconsume");
File javaSource = new File(TEST_DIR, "wsconsume" + FS + "java"
+ FS + "org" + FS + "openuri" + FS + "_2004" + FS +
"_04" + FS + "helloworld" + FS + "EndpointInterface.java");
-
assertTrue("Service endpoint interface not generated",
javaSource.exists());
}
public void testWSProvideFromCommandLine() throws Exception
{
String absOutput = new File(TEST_DIR, "wsprovide" + FS +
"java").getAbsolutePath();
-
String command = JBOSS_HOME + FS + "bin" + FS + "wsprovide" +
EXT + " -k -w -o " + absOutput + " --classpath " + CLASSES_DIR +
" " + ENDPOINT_CLASS;
- Process p = executeCommand(command);
-
- // check status code
- assertStatusCode(p, "wsprovide");
-
+ executeCommand(command, "wsprovide");
File javaSource = new File(TEST_DIR, "wsprovide" + FS + "java"
+ FS + "org" + FS + "jboss" + FS + "test" + FS +
"ws" + FS + "jaxws" + FS + "smoke" + FS + "tools"
+ FS + "jaxws" + FS + "AddResponse.java");
-
assertTrue("Response wrapper not generated", javaSource.exists());
}
- private Process executeCommand(String command) throws IOException
- {
- // be verbose
- System.out.println("cmd: " + command);
-
- Process p = Runtime.getRuntime().exec(command, new String[] {
"JBOSS_HOME=" + JBOSS_HOME, "JAVA_HOME=" + JAVA_HOME });
- return p;
- }
-
- 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
- {
- status = p.waitFor();
- }
- finally
- {
- job.kill();
- p.destroy();
- }
-
- // check status code
- if (status != 0)
- {
- System.out.println("Error stream");
- dumpStream(p.getErrorStream());
- }
- assertTrue(s + " did exit with status " + status, status == 0);
- }
-
- private void dumpStream(InputStream in)
- {
- try
- {
- BufferedInputStream bin = new BufferedInputStream (in);
- StringBuffer out = new StringBuffer();
- byte[] b = new byte[4096];
- for (int n; (n = bin.read(b)) != -1;)
- {
- out.append(new String(b, 0, n));
- }
-
- System.out.println(out.toString());
- }
- catch (IOException e)
- {
- throw new RuntimeException("", e);
- }
- }
-
- private boolean isWindowsOS()
- {
- return ((OS.indexOf("nt") > -1) || (OS.indexOf("windows")
> -1));
- }
}
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
17:01:24 UTC (rev 8252)
+++
framework/trunk/testsuite/test/java/org/jboss/test/ws/projectGenerator/ProjectGeneratorTestCase.java 2008-09-26
17:08:21 UTC (rev 8253)
@@ -21,20 +21,15 @@
*/
package org.jboss.test.ws.projectGenerator;
-import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
import java.net.URL;
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;
@@ -65,7 +60,7 @@
protected void setUp() throws Exception
{
super.setUp();
- jbossHome = System.getProperty("jboss.home");
+ jbossHome = System.getProperty("jboss.home").replace('\\',
'/');
workspaceHome = new File(".");
binDistroDir = new File("..");
}
@@ -81,8 +76,8 @@
writeUserProjectProperties(userPrjProp);
File distroBuild = new File(binDistroDir, "build.xml");
String integrationTarget =
System.getProperty("jbossws.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!");
+ 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");
packageDir.mkdirs();
@@ -93,8 +88,8 @@
File projectBuild = new File(projectHomeDir.getCanonicalPath(),
"build.xml");
try
{
- 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
+ executeCommand(ANT_SHELL + " -f " + projectBuild + "
deploy", "Error while compiling / deploying the user project!");
+ System.out.println("Sleeping 15 sec to let the deployment scanner pick up
the user project jar");
Thread.sleep(15000);
//Running the actual test
URL wsdlURL = new URL(endpointURL + "?wsdl");
@@ -106,8 +101,8 @@
}
finally
{
- 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");
+ executeCommand(ANT_SHELL + " -f " + projectBuild + "
undeploy", "Error while undeploying the user project");
+ executeCommand(ANT_SHELL + " -f " + distroBuild.getCanonicalPath() +
" delete-project", "Error while deleting the user project");
userPrjProp.delete();
}
}
@@ -159,44 +154,12 @@
sb.append("project.jboss.home=" + jbossHome + "\n");
sb.append("project.type=jar\n");
sb.append("project.jboss.conf=default\n");
- sb.append("workspace.home=" + workspaceHome.getCanonicalPath() +
"\n");
+ sb.append("workspace.home=" +
workspaceHome.getCanonicalPath().replace('\\', '/') + "\n");
BufferedWriter out = new BufferedWriter(new FileWriter(file));
out.write(sb.toString());
out.close();
}
- private Process executeCommand(String command) throws IOException
- {
- // be verbose
- System.out.println("cmd: " + command);
-
- Process p = Runtime.getRuntime().exec(command);
- return p;
- }
-
- private void assertStatusCode(Process p, String error) throws Exception
- {
- // check status code
- int status = p.waitFor();
- if (p.exitValue() != 0)
- {
- printStream(p.getInputStream());
- printStream(p.getErrorStream());
- }
- assertTrue(error, status == 0);
- }
-
- private void printStream(InputStream is) throws IOException
- {
- BufferedReader in = new BufferedReader(new InputStreamReader(is));
- StringBuffer buffer = new StringBuffer();
- String line;
- while ((line = in.readLine()) != null) {
- buffer.append(line + "\n");
- }
- System.out.println(buffer.toString() + "\n");
- }
-
private boolean isDistroTest() throws Exception
{
File build = new File(".." + FS + "build.xml");
@@ -207,22 +170,9 @@
}
if (!build.exists())
throw new Exception("Unable to find build.xml!");
- 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);
- }
- finally
- {
- job.kill();
- p.destroy();
- }
+ executeCommand(ANT_SHELL + " -f " + build.getAbsolutePath() + "
-p", baos);
return !(new String(baos.toByteArray()).contains("build-bin-dist"));
}
}