JBossWS SVN: r8255 - common/branches/jbossws-common-1.0.0.GA_JBPAPP-1216/src/main/java/org/jboss/wsf/common.
by jbossws-commits@lists.jboss.org
Author: darran.lofthouse(a)jboss.com
Date: 2008-09-26 13:24:29 -0400 (Fri, 26 Sep 2008)
New Revision: 8255
Modified:
common/branches/jbossws-common-1.0.0.GA_JBPAPP-1216/src/main/java/org/jboss/wsf/common/DOMUtils.java
Log:
[JBPAPP-1216] Allow OwnerDocument to be set by caller.
Modified: common/branches/jbossws-common-1.0.0.GA_JBPAPP-1216/src/main/java/org/jboss/wsf/common/DOMUtils.java
===================================================================
--- common/branches/jbossws-common-1.0.0.GA_JBPAPP-1216/src/main/java/org/jboss/wsf/common/DOMUtils.java 2008-09-26 17:11:30 UTC (rev 8254)
+++ common/branches/jbossws-common-1.0.0.GA_JBPAPP-1216/src/main/java/org/jboss/wsf/common/DOMUtils.java 2008-09-26 17:24:29 UTC (rev 8255)
@@ -552,6 +552,17 @@
return (parent instanceof Element ? (Element)parent : null);
}
+ /** Peek at the owner document without creating a new one if not set. */
+ public static Document peekOwnerDocument()
+ {
+ return documentThreadLocal.get();
+ }
+
+ public static void setOwnerDocument(Document doc)
+ {
+ documentThreadLocal.set(doc);
+ }
+
/** Get the owner document that is associated with the current thread */
public static Document getOwnerDocument()
{
15 years, 7 months
JBossWS SVN: r8254 - in stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws: tools/scripts and 1 other directory.
by jbossws-commits@lists.jboss.org
Author: richard.opalka(a)jboss.com
Date: 2008-09-26 13:11:30 -0400 (Fri, 26 Sep 2008)
New Revision: 8254
Modified:
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws771/JBWS771TestCase.java
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/tools/scripts/ScriptTestCase.java
Log:
[JBWS-2322] final refactoring
Modified: stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws771/JBWS771TestCase.java
===================================================================
--- stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws771/JBWS771TestCase.java 2008-09-26 17:08:21 UTC (rev 8253)
+++ stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws771/JBWS771TestCase.java 2008-09-26 17:11:30 UTC (rev 8254)
@@ -21,11 +21,7 @@
*/
package org.jboss.test.ws.jaxws.jbws771;
-import java.io.BufferedReader;
import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
import java.net.URL;
import java.util.List;
@@ -43,7 +39,6 @@
import junit.framework.Test;
-import org.jboss.wsf.common.concurrent.CopyJob;
import org.jboss.wsf.test.JBossWSTest;
import org.jboss.wsf.test.JBossWSTestSetup;
@@ -57,7 +52,6 @@
{
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 LS = System.getProperty("line.separator"); // '\n' on unix, '\r\n' on windows
private static final String EXT = ":".equals( PS ) ? ".sh" : ".bat";
private static final String TARGET_NAMESPACE = "http://jbws771.jaxws.ws.test.jboss.org/";
@@ -65,9 +59,7 @@
private static IWebsvc port;
private String JBOSS_HOME;
- private String JDK_HOME;
private String RESOURCES_DIR;
- private String OS;
public static Test suite()
{
@@ -88,8 +80,6 @@
JBOSS_HOME = System.getProperty("jboss.home");
RESOURCES_DIR = createResourceFile(".").getPath();
- JDK_HOME = System.getProperty("java.home") + FS + "..";
- OS = System.getProperty("os.name").toLowerCase();
}
public void testSubmit() throws Exception
@@ -159,11 +149,7 @@
// use absolute path for the output to be re-usable
String absOutput = createResourceFile("wsconsume" + FS + "java").getAbsolutePath();
String command = JBOSS_HOME + FS + "bin" + FS + "wsconsume" + EXT + " -k -o " + absOutput + " --extension --binding=" + RESOURCES_DIR + FS + "jaxws" + FS + "jbws771" + FS + "binding.xml " + wsdlURL.toExternalForm();
- Process p = executeCommand(command);
-
- // check status code
- checkStatusCode(p, "wsconsume");
-
+ executeCommand(command);
File javaSource = getResourceFile("wsconsume" + FS + "java" + FS + "org" + FS + "jboss" + FS + "test" + FS + "ws" + FS + "jaxws" + FS + "jbws771" + FS + "JBWS771Service.java");
assertTrue("Service endpoint interface not generated", javaSource.exists());
}
@@ -176,53 +162,4 @@
Definition definition = wsdlReader.readWSDL(null, wsdlLocation);
return definition;
}
-
- private Process executeCommand(String command) throws IOException
- {
- // be verbose
- System.out.println("cmd: " + command);
- System.out.println("resources dir: " + RESOURCES_DIR);
-
- Process p = Runtime.getRuntime().exec(command, new String[] { "JBOSS_HOME=" + JBOSS_HOME, "JAVA_HOME=" + JDK_HOME });
- return p;
- }
-
- private void checkStatusCode(Process p, String s) throws InterruptedException, IOException
- {
- 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");
- printStream(p.getErrorStream());
- }
- assertTrue(s + " did exit with status " + status, status == 0);
- }
-
- private void printStream(InputStream is) throws IOException
- {
- System.out.println();
- BufferedReader in = new BufferedReader(new InputStreamReader(is));
- StringBuffer buffer = new StringBuffer();
- String line;
- while ((line = in.readLine()) != null) {
- buffer.append(line + LS);
- }
- System.out.println(buffer.toString());
- System.out.println();
- System.out.println();
- }
}
Modified: stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/tools/scripts/ScriptTestCase.java
===================================================================
--- stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/tools/scripts/ScriptTestCase.java 2008-09-26 17:08:21 UTC (rev 8253)
+++ stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/tools/scripts/ScriptTestCase.java 2008-09-26 17:11:30 UTC (rev 8254)
@@ -21,14 +21,8 @@
*/
package org.jboss.test.ws.tools.scripts;
-import java.io.BufferedReader;
import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-
import org.jboss.wsf.test.JBossWSTest;
-import org.jboss.wsf.common.concurrent.CopyJob;
/**
* JBWS-1793: Provide a test case for the tools scripts that reside under JBOSS_HOME/bin
@@ -39,23 +33,16 @@
{
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 LS = System.getProperty("line.separator"); // '\n' on unix, '\r\n' on windows
private String TOOLS_CONFIG = getResourceFile("tools" + FS + "scripts" + FS + "wstools-config.xml").getAbsolutePath();
private static final String EXT = ":".equals( PS ) ? ".sh" : ".bat";
private String JBOSS_HOME;
- private String JDK_HOME;
- private String TEST_EXEC_DIR;
- private String OS;
protected void setUp() throws Exception
{
super.setUp();
JBOSS_HOME = System.getProperty("jboss.home");
- TEST_EXEC_DIR = createResourceFile(".").getPath();
- JDK_HOME = System.getProperty("java.home");
- OS = System.getProperty("os.name").toLowerCase();
}
public void testWSToolsFromCommandLine() throws Exception
@@ -65,63 +52,11 @@
dest.mkdirs();
String command = JBOSS_HOME + FS + "bin" + FS + "wstools" + EXT + " -config " + TOOLS_CONFIG + " -dest "+ dest.getAbsolutePath();
- Process p = executeCommand(command);
+ executeCommand(command);
- // check status code
- assertStatusCode(p, "wstools");
-
File javaSource = getResourceFile("wstools" + FS + "java" + FS + "org" + FS + "jboss" + FS + "test" + FS + "ws" + FS + "jbws810" + FS + "PhoneBookService.java");
assertTrue("Service endpoint interface not generated", javaSource.exists());
}
- private Process executeCommand(String command) throws IOException
- {
- // be verbose
- System.out.println("cmd: " + command);
- System.out.println("test execution dir: " + TEST_EXEC_DIR);
-
- Process p = Runtime.getRuntime().exec(command, new String[] { "JBOSS_HOME=" + JBOSS_HOME, "JAVA_HOME=" + JDK_HOME });
- return p;
- }
-
- private void assertStatusCode(Process p, String s) throws InterruptedException, IOException
- {
- 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");
- printStream(p.getErrorStream());
- }
- assertTrue(s + " did exit with status " + status, status == 0);
- }
-
- private void printStream(InputStream is) throws IOException
- {
- System.out.println();
- BufferedReader in = new BufferedReader(new InputStreamReader(is));
- StringBuffer buffer = new StringBuffer();
- String line;
- while ((line = in.readLine()) != null) {
- buffer.append(line + LS);
- }
- System.out.println(buffer.toString());
- System.out.println();
- System.out.println();
- }
-
}
15 years, 7 months
JBossWS SVN: r8253 - in framework/trunk/testsuite/test: java/org/jboss/test/ws/jaxws/smoke/tools and 1 other directories.
by jbossws-commits@lists.jboss.org
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"));
}
}
15 years, 7 months
JBossWS SVN: r8252 - common/trunk/src/main/java/org/jboss/wsf/test.
by jbossws-commits@lists.jboss.org
Author: richard.opalka(a)jboss.com
Date: 2008-09-26 13:01:24 -0400 (Fri, 26 Sep 2008)
New Revision: 8252
Modified:
common/trunk/src/main/java/org/jboss/wsf/test/JBossWSTest.java
Log:
[JBWS-2322] final refactoring
Modified: common/trunk/src/main/java/org/jboss/wsf/test/JBossWSTest.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/test/JBossWSTest.java 2008-09-26 16:36:23 UTC (rev 8251)
+++ common/trunk/src/main/java/org/jboss/wsf/test/JBossWSTest.java 2008-09-26 17:01:24 UTC (rev 8252)
@@ -21,7 +21,11 @@
*/
package org.jboss.wsf.test;
+import java.io.BufferedReader;
import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
@@ -38,6 +42,7 @@
import org.jboss.logging.Logger;
import org.jboss.wsf.common.DOMWriter;
+import org.jboss.wsf.common.concurrent.CopyJob;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@@ -63,7 +68,92 @@
{
super(name);
}
+
+ /**
+ * Execute <b>command</b> in separate process.
+ * @param command command to execute
+ * @throws IOException if I/O error occurs
+ */
+ public void executeCommand(String command) throws IOException
+ {
+ this.executeCommand(command, null, null);
+ }
+
+ /**
+ * Execute <b>command</b> in separate process. If process will fail, display custom <b>message</b> in assertion.
+ * @param command command to execute
+ * @param message message to display if assertion fails
+ * @throws IOException if I/O error occurs
+ */
+ public void executeCommand(String command, String message) throws IOException
+ {
+ this.executeCommand(command, null, message);
+ }
+
+ /**
+ * Execute <b>command</b> in separate process, copy process input to <b>os</b>.
+ * @param command command to execute
+ * @param os output stream to copy process input to. If null, <b>System.out</b> will be used
+ * @throws IOException if I/O error occurs
+ */
+ public void executeCommand(String command, OutputStream os) throws IOException
+ {
+ this.executeCommand(command, os, null);
+ }
+ /**
+ * Execute <b>command</b> in separate process, copy process input to <b>os</b>. If process will fail, display custom <b>message</b> in assertion.
+ * @param command command to execute
+ * @param os output stream to copy process input to. If null, <b>System.out</b> will be used
+ * @param message message to display if assertion fails
+ * @throws IOException if I/O error occurs
+ */
+ public void executeCommand(String command, OutputStream os, String message) throws IOException
+ {
+ if ( command == null )
+ throw new NullPointerException( "Command cannot be null" );
+
+ System.out.println("Executing command: " + command);
+
+ Process p = Runtime.getRuntime().exec(command);
+ CopyJob job = new CopyJob(p.getInputStream(), os == null ? System.out : os);
+ // unfortunately the following thread is needed (otherwise it will not work on windows)
+ new Thread( job ).start();
+ int statusCode = -1;
+ try
+ {
+ statusCode = p.waitFor();
+ }
+ catch (InterruptedException ie)
+ {
+ ie.printStackTrace(System.err);
+ }
+ finally
+ {
+ job.kill();
+ p.destroy();
+ }
+
+ // check status code
+ if (statusCode != 0)
+ {
+ System.out.println("Error stream");
+ System.out.println();
+ BufferedReader in = new BufferedReader(new InputStreamReader(p.getErrorStream()));
+ StringBuffer buffer = new StringBuffer();
+ String line;
+ while ((line = in.readLine()) != null) {
+ buffer.append(line + "\n");
+ }
+ System.out.println(buffer.toString());
+ System.out.println();
+ System.out.println();
+ }
+
+ String fallbackMessage = "Process did exit with status " + statusCode;
+ assertTrue(message != null ? message : fallbackMessage, statusCode == 0);
+ }
+
public MBeanServerConnection getServer() throws NamingException
{
return JBossWSTestHelper.getServer();
15 years, 7 months
JBossWS SVN: r8251 - common/branches/jbossws-common-1.0.0.GA_JBPAPP-1216/src/main/java/org/jboss/wsf/common.
by jbossws-commits@lists.jboss.org
Author: darran.lofthouse(a)jboss.com
Date: 2008-09-26 12:36:23 -0400 (Fri, 26 Sep 2008)
New Revision: 8251
Modified:
common/branches/jbossws-common-1.0.0.GA_JBPAPP-1216/src/main/java/org/jboss/wsf/common/DOMUtils.java
Log:
[JBPAPP-1216] Added property 'org.jboss.ws.disable_deferred_node_expansion'
Modified: common/branches/jbossws-common-1.0.0.GA_JBPAPP-1216/src/main/java/org/jboss/wsf/common/DOMUtils.java
===================================================================
--- common/branches/jbossws-common-1.0.0.GA_JBPAPP-1216/src/main/java/org/jboss/wsf/common/DOMUtils.java 2008-09-26 16:18:15 UTC (rev 8250)
+++ common/branches/jbossws-common-1.0.0.GA_JBPAPP-1216/src/main/java/org/jboss/wsf/common/DOMUtils.java 2008-09-26 16:36:23 UTC (rev 8251)
@@ -68,16 +68,25 @@
{
private static Logger log = Logger.getLogger(DOMUtils.class);
+ private static final String DISABLE_DEFERRED_NODE_EXPANSION = "org.jboss.ws.disable_deferred_node_expansion";
+
// All elements created by the same thread are created by the same builder and belong to the same doc
- private static ThreadLocal documentThreadLocal = new ThreadLocal();
- private static ThreadLocal builderThreadLocal = new ThreadLocal() {
- protected Object initialValue()
+ private static ThreadLocal<Document> documentThreadLocal = new ThreadLocal<Document>();
+ private static ThreadLocal<DocumentBuilder> builderThreadLocal = new ThreadLocal<DocumentBuilder>() {
+ protected DocumentBuilder initialValue()
{
try
{
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating(false);
factory.setNamespaceAware(true);
+
+ boolean disableDeferredNodeExpansion = Boolean.getBoolean(DISABLE_DEFERRED_NODE_EXPANSION);
+ if (disableDeferredNodeExpansion == true)
+ {
+ factory.setFeature("http://apache.org/xml/features/dom/defer-node-expansion", false);
+ }
+
DocumentBuilder builder = factory.newDocumentBuilder();
setEntityResolver(builder);
return builder;
@@ -503,6 +512,7 @@
private static Iterator getChildElementsIntern(Node node, QName nodeName)
{
ArrayList list = new ArrayList();
+
NodeList nlist = node.getChildNodes();
for (int i = 0; i < nlist.getLength(); i++)
{
15 years, 7 months
JBossWS SVN: r8250 - common/branches/jbossws-common-1.0.0.GA_JBPAPP-1216/src/main/java/org/jboss/wsf/common.
by jbossws-commits@lists.jboss.org
Author: darran.lofthouse(a)jboss.com
Date: 2008-09-26 12:18:15 -0400 (Fri, 26 Sep 2008)
New Revision: 8250
Modified:
common/branches/jbossws-common-1.0.0.GA_JBPAPP-1216/src/main/java/org/jboss/wsf/common/DOMUtils.java
Log:
Format
Modified: common/branches/jbossws-common-1.0.0.GA_JBPAPP-1216/src/main/java/org/jboss/wsf/common/DOMUtils.java
===================================================================
--- common/branches/jbossws-common-1.0.0.GA_JBPAPP-1216/src/main/java/org/jboss/wsf/common/DOMUtils.java 2008-09-26 16:13:52 UTC (rev 8249)
+++ common/branches/jbossws-common-1.0.0.GA_JBPAPP-1216/src/main/java/org/jboss/wsf/common/DOMUtils.java 2008-09-26 16:18:15 UTC (rev 8250)
@@ -70,8 +70,7 @@
// All elements created by the same thread are created by the same builder and belong to the same doc
private static ThreadLocal documentThreadLocal = new ThreadLocal();
- private static ThreadLocal builderThreadLocal = new ThreadLocal()
- {
+ private static ThreadLocal builderThreadLocal = new ThreadLocal() {
protected Object initialValue()
{
try
15 years, 7 months
JBossWS SVN: r8249 - in stack/native/branches/jbossws-native-2.0.1.SP2_JBPAPP-1216/src/main/java/org/jboss: ws/core/utils and 1 other directories.
by jbossws-commits@lists.jboss.org
Author: darran.lofthouse(a)jboss.com
Date: 2008-09-26 12:13:52 -0400 (Fri, 26 Sep 2008)
New Revision: 8249
Modified:
stack/native/branches/jbossws-native-2.0.1.SP2_JBPAPP-1216/src/main/java/org/jboss/ws/core/jaxws/spi/ProviderImpl.java
stack/native/branches/jbossws-native-2.0.1.SP2_JBPAPP-1216/src/main/java/org/jboss/ws/core/utils/ThreadLocalAssociation.java
stack/native/branches/jbossws-native-2.0.1.SP2_JBPAPP-1216/src/main/java/org/jboss/wsf/stack/jbws/RequestHandlerImpl.java
Log:
[JBPAPP-1216] DOMUtils doesn't clear thread locals.
Modified: stack/native/branches/jbossws-native-2.0.1.SP2_JBPAPP-1216/src/main/java/org/jboss/ws/core/jaxws/spi/ProviderImpl.java
===================================================================
--- stack/native/branches/jbossws-native-2.0.1.SP2_JBPAPP-1216/src/main/java/org/jboss/ws/core/jaxws/spi/ProviderImpl.java 2008-09-26 16:11:37 UTC (rev 8248)
+++ stack/native/branches/jbossws-native-2.0.1.SP2_JBPAPP-1216/src/main/java/org/jboss/ws/core/jaxws/spi/ProviderImpl.java 2008-09-26 16:13:52 UTC (rev 8249)
@@ -38,6 +38,7 @@
import javax.xml.ws.wsaddressing.W3CEndpointReference;
import org.jboss.util.NotImplementedException;
+import org.jboss.wsf.common.DOMUtils;
import org.w3c.dom.Element;
/**
@@ -59,6 +60,7 @@
public ServiceDelegate createServiceDelegate(URL wsdlLocation, QName serviceName, Class serviceClass)
{
ServiceDelegateImpl delegate = new ServiceDelegateImpl(wsdlLocation, serviceName, serviceClass);
+ DOMUtils.clearThreadLocals();
return delegate;
}
Modified: stack/native/branches/jbossws-native-2.0.1.SP2_JBPAPP-1216/src/main/java/org/jboss/ws/core/utils/ThreadLocalAssociation.java
===================================================================
--- stack/native/branches/jbossws-native-2.0.1.SP2_JBPAPP-1216/src/main/java/org/jboss/ws/core/utils/ThreadLocalAssociation.java 2008-09-26 16:11:37 UTC (rev 8248)
+++ stack/native/branches/jbossws-native-2.0.1.SP2_JBPAPP-1216/src/main/java/org/jboss/ws/core/utils/ThreadLocalAssociation.java 2008-09-26 16:13:52 UTC (rev 8249)
@@ -60,7 +60,7 @@
public static void clear()
{
- msgContextAssoc.set(null);
- strTransformAssoc.set(null);
+ msgContextAssoc.remove();
+ strTransformAssoc.remove();
}
}
Modified: stack/native/branches/jbossws-native-2.0.1.SP2_JBPAPP-1216/src/main/java/org/jboss/wsf/stack/jbws/RequestHandlerImpl.java
===================================================================
--- stack/native/branches/jbossws-native-2.0.1.SP2_JBPAPP-1216/src/main/java/org/jboss/wsf/stack/jbws/RequestHandlerImpl.java 2008-09-26 16:11:37 UTC (rev 8248)
+++ stack/native/branches/jbossws-native-2.0.1.SP2_JBPAPP-1216/src/main/java/org/jboss/wsf/stack/jbws/RequestHandlerImpl.java 2008-09-26 16:13:52 UTC (rev 8249)
@@ -91,6 +91,7 @@
import org.jboss.wsf.spi.SPIProviderResolver;
import org.jboss.wsf.spi.SPIProvider;
import org.jboss.wsf.common.DOMWriter;
+import org.jboss.wsf.common.DOMUtils;
import org.w3c.dom.Document;
/**
@@ -316,6 +317,7 @@
// clear thread local storage
ThreadLocalAssociation.clear();
+ DOMUtils.clearThreadLocals();
}
}
15 years, 7 months
JBossWS SVN: r8248 - common/branches/jbossws-common-1.0.0.GA_JBPAPP-1216/src/main/java/org/jboss/wsf/common.
by jbossws-commits@lists.jboss.org
Author: darran.lofthouse(a)jboss.com
Date: 2008-09-26 12:11:37 -0400 (Fri, 26 Sep 2008)
New Revision: 8248
Modified:
common/branches/jbossws-common-1.0.0.GA_JBPAPP-1216/src/main/java/org/jboss/wsf/common/DOMUtils.java
common/branches/jbossws-common-1.0.0.GA_JBPAPP-1216/src/main/java/org/jboss/wsf/common/IOUtils.java
Log:
[JBPAPP-1216] DOMUtils doesn't clear thread locals.
Modified: common/branches/jbossws-common-1.0.0.GA_JBPAPP-1216/src/main/java/org/jboss/wsf/common/DOMUtils.java
===================================================================
--- common/branches/jbossws-common-1.0.0.GA_JBPAPP-1216/src/main/java/org/jboss/wsf/common/DOMUtils.java 2008-09-26 16:03:59 UTC (rev 8247)
+++ common/branches/jbossws-common-1.0.0.GA_JBPAPP-1216/src/main/java/org/jboss/wsf/common/DOMUtils.java 2008-09-26 16:11:37 UTC (rev 8248)
@@ -113,6 +113,12 @@
}
};
+ public static void clearThreadLocals()
+ {
+ documentThreadLocal.remove();
+ builderThreadLocal.remove();
+ }
+
// Hide the constructor
private DOMUtils()
{
Modified: common/branches/jbossws-common-1.0.0.GA_JBPAPP-1216/src/main/java/org/jboss/wsf/common/IOUtils.java
===================================================================
--- common/branches/jbossws-common-1.0.0.GA_JBPAPP-1216/src/main/java/org/jboss/wsf/common/IOUtils.java 2008-09-26 16:03:59 UTC (rev 8247)
+++ common/branches/jbossws-common-1.0.0.GA_JBPAPP-1216/src/main/java/org/jboss/wsf/common/IOUtils.java 2008-09-26 16:11:37 UTC (rev 8248)
@@ -63,27 +63,47 @@
*/
public static void copyStream(OutputStream outs, InputStream ins) throws IOException
{
- byte[] bytes = new byte[1024];
- int r = ins.read(bytes);
- while (r > 0)
+ try
{
- outs.write(bytes, 0, r);
- r = ins.read(bytes);
+ byte[] bytes = new byte[1024];
+ int r = ins.read(bytes);
+ while (r > 0)
+ {
+ outs.write(bytes, 0, r);
+ r = ins.read(bytes);
+ }
}
+ catch (IOException e)
+ {
+ throw e;
+ }
+ finally{
+ ins.close();
+ }
}
/** Copy the reader to the output stream
*/
public static void copyReader(OutputStream outs, Reader reader) throws IOException
{
- OutputStreamWriter writer = new OutputStreamWriter(outs);
- char[] bytes = new char[1024];
- int r = reader.read(bytes);
- while (r > 0)
+ try
{
- writer.write(bytes, 0, r);
- r = reader.read(bytes);
+ OutputStreamWriter writer = new OutputStreamWriter(outs);
+ char[] bytes = new char[1024];
+ int r = reader.read(bytes);
+ while (r > 0)
+ {
+ writer.write(bytes, 0, r);
+ r = reader.read(bytes);
+ }
}
+ catch (IOException e)
+ {
+ throw e;
+ }
+ finally{
+ reader.close();
+ }
}
public static byte[] convertToBytes(DataHandler dh)
@@ -106,17 +126,27 @@
*/
public static InputStream transformReader(Reader reader) throws IOException
{
- int capacity = 1024;
- char[] charBuffer = new char[capacity];
- StringBuffer strBuffer = new StringBuffer(capacity);
+ try
+ {
+ int capacity = 1024;
+ char[] charBuffer = new char[capacity];
+ StringBuffer strBuffer = new StringBuffer(capacity);
- int len = reader.read(charBuffer, 0, capacity);
- while (len > 0)
+ int len = reader.read(charBuffer, 0, capacity);
+ while (len > 0)
+ {
+ strBuffer.append(charBuffer, 0, len);
+ len = reader.read(charBuffer, 0, capacity);
+ }
+ return new ByteArrayInputStream(strBuffer.toString().getBytes());
+ }
+ catch (IOException e)
{
- strBuffer.append(charBuffer, 0, len);
- len = reader.read(charBuffer, 0, capacity);
+ throw e;
}
- return new ByteArrayInputStream(strBuffer.toString().getBytes());
+ finally{
+ reader.close();
+ }
}
public static File createTempDirectory() throws IOException
15 years, 7 months
JBossWS SVN: r8247 - common/branches.
by jbossws-commits@lists.jboss.org
Author: darran.lofthouse(a)jboss.com
Date: 2008-09-26 12:03:59 -0400 (Fri, 26 Sep 2008)
New Revision: 8247
Added:
common/branches/jbossws-common-1.0.0.GA_JBPAPP-1216/
Log:
[JBPAPP-1216] Branch for patch.
Copied: common/branches/jbossws-common-1.0.0.GA_JBPAPP-1216 (from rev 8246, common/tags/jbossws-common-1.0.0.GA)
15 years, 7 months
JBossWS SVN: r8246 - stack/native/branches.
by jbossws-commits@lists.jboss.org
Author: darran.lofthouse(a)jboss.com
Date: 2008-09-26 11:48:37 -0400 (Fri, 26 Sep 2008)
New Revision: 8246
Added:
stack/native/branches/jbossws-native-2.0.1.SP2_JBPAPP-1216/
Log:
[JBPAPP-1216] Branch for patch.
Copied: stack/native/branches/jbossws-native-2.0.1.SP2_JBPAPP-1216 (from rev 8245, stack/native/tags/jbossws-native-2.0.1.SP2)
15 years, 7 months