[jbossws-commits] JBossWS SVN: r9648 - in framework/trunk/testsuite/test: resources/jaxws/smoke/tools and 1 other directories.
jbossws-commits at lists.jboss.org
jbossws-commits at lists.jboss.org
Mon Mar 23 09:12:39 EDT 2009
Author: richard.opalka at jboss.com
Date: 2009-03-23 09:12:39 -0400 (Mon, 23 Mar 2009)
New Revision: 9648
Added:
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSRunClientTestCase.java
framework/trunk/testsuite/test/resources/jaxws/smoke/tools/wsrunclient/
framework/trunk/testsuite/test/resources/jaxws/smoke/tools/wsrunclient/jars.txt
framework/trunk/testsuite/test/resources/jaxws/smoke/tools/wsrunclient/properties.txt
framework/trunk/testsuite/test/resources/jaxws/smoke/tools/wsrunclient/tests.txt
Log:
[JBWS-2327] providing test case
Added: framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSRunClientTestCase.java
===================================================================
--- framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSRunClientTestCase.java (rev 0)
+++ framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSRunClientTestCase.java 2009-03-23 13:12:39 UTC (rev 9648)
@@ -0,0 +1,173 @@
+package org.jboss.test.ws.jaxws.smoke.tools;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.jboss.wsf.test.JBossWSTest;
+
+/**
+ * [JBWS-2327] Provide tests for wsrunclient shell script
+ *
+ * @author richard.opalka at jboss.com
+ */
+public final class WSRunClientTestCase extends JBossWSTest
+{
+
+ private static final String FS = System.getProperty("file.separator");
+ private static final String PS = System.getProperty("path.separator");
+ private static final String SP = " ";
+ private static final String EXT = ":".equals( PS ) ? ".sh" : ".bat";
+ private List<String> integrationJars;
+ private String commandLineProperties;
+ private String additionalClasspath;
+ private List<String> testsToExecute;
+ private String jbossHome = System.getProperty("jboss.home");
+
+ /**
+ * Initialization
+ */
+ public void setUp() throws Exception
+ {
+ List<String> properties = getContent("jaxws/smoke/tools/wsrunclient/properties.txt");
+ assertTrue(properties.size() > 0);
+ this.commandLineProperties = prepareEnvProperties(properties);
+ this.testsToExecute = getContent("jaxws/smoke/tools/wsrunclient/tests.txt");
+ assertTrue(this.testsToExecute.size() > 0);
+ this.integrationJars = getContent("jaxws/smoke/tools/wsrunclient/jars.txt");
+ assertTrue(this.integrationJars.size() > 0);
+ this.additionalClasspath = prepareAdditionalClasspath();
+ }
+
+ /**
+ * Executing wsrunclient commandline script
+ * @throws Exception if any error occurs
+ */
+ public void test() throws Exception
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.append(jbossHome).append(FS).append("bin").append(FS).append("wsrunclient").append(EXT);
+ sb.append(SP).append("-classpath").append(SP).append(additionalClasspath);
+ sb.append(SP).append(commandLineProperties);
+ sb.append(SP).append("junit.textui.TestRunner").append(SP);
+ String commandWithoutTestParam = sb.toString();
+ String testOutput = null;
+ for (String test : testsToExecute)
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ executeCommand(commandWithoutTestParam + test, baos, "wsrunclient");
+ System.out.println("Test output: " + new String(baos.toByteArray()));
+ // There's no need to verify the test output.
+ // If test that is executed fails executeCommand will fail (because of SC != 0)
+ // The same applies to wrongly configured wsrunclient classpath.
+ }
+ }
+
+ /**
+ * Cleanup
+ */
+ public void tearDown() throws Exception
+ {
+ this.additionalClasspath = null;
+ this.commandLineProperties = null;
+ this.jbossHome = null;
+ this.testsToExecute = null;
+ this.integrationJars = null;
+ }
+
+ private String prepareAdditionalClasspath()
+ {
+ StringBuilder sb = new StringBuilder();
+
+ // setup test classes dir
+ sb.append(PS).append(System.getProperty("test.classes.directory"));
+
+ // setup junit lib
+ sb.append(PS).append(System.getProperty("basedir"));
+ sb.append(FS).append("target").append(FS).append("junit-libs").append(FS).append("junit.jar");
+
+ // setup jbossws integration jars
+ String jbossClientDir = System.getProperty("jboss.home") + FS + "client" + FS;
+ for (String jar : this.integrationJars)
+ {
+ sb.append(PS).append(jbossClientDir).append(jar);
+ }
+
+ return sb.toString();
+ }
+
+ /**
+ * Prepares properties list for commandline execution
+ * @param properties to be configured
+ * @return commandline ready list of properties
+ */
+ private String prepareEnvProperties(List<String> properties)
+ {
+ StringBuilder sb = new StringBuilder();
+
+ for (String key : properties)
+ {
+ String value = System.getProperty(key);
+ if (value != null)
+ {
+ assertFalse("Space found in property '" + key + "'", value.contains(SP));
+ sb.append("-D").append(key).append("=").append(value).append(SP);
+ }
+ }
+
+ return sb.toString();
+ }
+
+ /**
+ * Prepares test list to be executed via wsrunclient
+ * @param tests tests list
+ * @return test list ready for commandline execution
+ */
+ private String prepareTests(List<String> tests)
+ {
+ StringBuilder sb = new StringBuilder();
+
+ for (String test : tests)
+ {
+ sb.append(SP).append(test);
+ }
+
+ return sb.toString();
+ }
+
+ /**
+ * Returns content of text file
+ * @param resource to be parsed
+ * @return list of values
+ * @throws Exception if any I/O error ocurs
+ */
+ private List<String> getContent(String resource) throws Exception
+ {
+ File f = this.getResourceFile(resource);
+ assertTrue(f.exists());
+ List<String> retVal = new LinkedList<String>();
+ BufferedReader br = null;
+ try
+ {
+ br = new BufferedReader(new FileReader(f));
+ String line = null;
+ while ((line = br.readLine()) != null)
+ {
+ retVal.add(line.trim());
+ }
+ }
+ finally
+ {
+ if (br != null)
+ {
+ br.close();
+ }
+ }
+
+ return retVal;
+ }
+
+}
Added: framework/trunk/testsuite/test/resources/jaxws/smoke/tools/wsrunclient/jars.txt
===================================================================
--- framework/trunk/testsuite/test/resources/jaxws/smoke/tools/wsrunclient/jars.txt (rev 0)
+++ framework/trunk/testsuite/test/resources/jaxws/smoke/tools/wsrunclient/jars.txt 2009-03-23 13:12:39 UTC (rev 9648)
@@ -0,0 +1,7 @@
+jbossws-jboss423.jar
+jbossws-jboss50.jar
+jbossws-jboss500.jar
+jbossws-jboss501.jar
+jbossws-jboss510.jar
+jbossws-jboss60.jar
+jbossws-jboss600.jar
Added: framework/trunk/testsuite/test/resources/jaxws/smoke/tools/wsrunclient/properties.txt
===================================================================
--- framework/trunk/testsuite/test/resources/jaxws/smoke/tools/wsrunclient/properties.txt (rev 0)
+++ framework/trunk/testsuite/test/resources/jaxws/smoke/tools/wsrunclient/properties.txt 2009-03-23 13:12:39 UTC (rev 9648)
@@ -0,0 +1,9 @@
+java.naming.provider.url
+jboss.bind.address
+jboss.home
+jbossws.integration.target
+log4j.output.dir
+test.classes.directory
+test.resources.directory
+test.archive.directory
+wsdl.publish.location
Added: framework/trunk/testsuite/test/resources/jaxws/smoke/tools/wsrunclient/tests.txt
===================================================================
--- framework/trunk/testsuite/test/resources/jaxws/smoke/tools/wsrunclient/tests.txt (rev 0)
+++ framework/trunk/testsuite/test/resources/jaxws/smoke/tools/wsrunclient/tests.txt 2009-03-23 13:12:39 UTC (rev 9648)
@@ -0,0 +1,20 @@
+org.jboss.test.ws.jaxws.samples.oneway.OneWayTestCase
+org.jboss.test.ws.jaxws.samples.webparam.WebParamTestCase
+org.jboss.test.ws.jaxws.samples.webmethod.WebMethodTestCase
+org.jboss.test.ws.jaxws.samples.webresult.WebResultTestCase
+org.jboss.test.ws.jaxws.samples.asynchronous.AsynchronousDispatchTestCase
+org.jboss.test.ws.jaxws.samples.asynchronous.AsynchronousProxyTestCase
+org.jboss.test.ws.jaxws.samples.context.WebServiceContextEJBTestCase
+org.jboss.test.ws.jaxws.samples.context.WebServiceContextJSETestCase
+org.jboss.test.ws.jaxws.samples.eardeployment.EarTestCase
+org.jboss.test.ws.jaxws.samples.exception.ExceptionEJB3TestCase
+org.jboss.test.ws.jaxws.samples.exception.ExceptionTestCase
+org.jboss.test.ws.jaxws.samples.logicalhandler.LogicalHandlerJAXBTestCase
+org.jboss.test.ws.jaxws.samples.logicalhandler.LogicalHandlerSourceTestCase
+org.jboss.test.ws.jaxws.samples.provider.ProviderJAXBTestCase
+org.jboss.test.ws.jaxws.samples.provider.ProviderMessageTestCase
+org.jboss.test.ws.jaxws.samples.provider.ProviderPayloadTestCase
+org.jboss.test.ws.jaxws.samples.swaref.SWARefTestCase
+org.jboss.test.ws.jaxws.samples.webservice.WebServiceJSETestCase
+org.jboss.test.ws.jaxws.samples.webservice.WebServiceEJB3TestCase
+org.jboss.test.ws.jaxws.samples.advanced.retail.RetailSampleTestCase
More information about the jbossws-commits
mailing list