Author: heiko.braun(a)jboss.com
Date: 2007-08-02 12:13:55 -0400 (Thu, 02 Aug 2007)
New Revision: 4112
Added:
spi/trunk/ant-import/build-testsuite.xml
spi/trunk/src/test/
spi/trunk/src/test/java/
spi/trunk/src/test/java/org/
spi/trunk/src/test/java/org/jboss/
spi/trunk/src/test/java/org/jboss/test/
spi/trunk/src/test/java/org/jboss/test/wsf/
spi/trunk/src/test/java/org/jboss/test/wsf/spi/
spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/
spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTestCase.java
spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTracker.java
spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTrackerFactory.java
spi/trunk/src/test/resources/
spi/trunk/src/test/resources/smoke/
spi/trunk/src/test/resources/smoke/tools/
Modified:
spi/trunk/ant-import/build-thirdparty.xml
spi/trunk/build.xml
spi/trunk/version.properties
Log:
Initial SPI test suite. Added tools test
Added: spi/trunk/ant-import/build-testsuite.xml
===================================================================
--- spi/trunk/ant-import/build-testsuite.xml (rev 0)
+++ spi/trunk/ant-import/build-testsuite.xml 2007-08-02 16:13:55 UTC (rev 4112)
@@ -0,0 +1,156 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ============================================================ -->
+<!-- JBoss, the OpenSource J2EE webOS -->
+<!-- Distributable under LGPL license. -->
+<!-- See terms of license at
http://www.gnu.org. -->
+<!-- ============================================================ -->
+
+<!-- $Id$ -->
+
+<project>
+
+ <property environment="env"/>
+
+ <!-- ================================================================== -->
+ <!-- Setup -->
+ <!-- ================================================================== -->
+
+ <!-- Use -Ddebug=true for remote debugging -->
+ <condition property="remote.debug.line" value="-Xdebug -Xnoagent
-Djava.compiler=NONE
-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005">
+ <isset property="debug"/>
+ </condition>
+ <condition property="remote.debug.line" value="">
+ <not>
+ <isset property="debug"/>
+ </not>
+ </condition>
+
+ <!-- ================================================================== -->
+ <!-- Initialization -->
+ <!-- ================================================================== -->
+
+ <target name="tests-init">
+ <mkdir dir="${spi.test.output.dir}"/>
+ <mkdir dir="${spi.test.output.dir}/log"/>
+
+ <delete file="${spi.test.output.dir}/log/test.log"/>
+
+ <path id="test.classpath">
+ <path refid="spi.thirdparty.classpath"/>
+ <pathelement location="${spi.output.lib.dir}/jbossws-spi.jar"/>
+ </path>
+
+ </target>
+
+ <target name="tests-compile" depends="init, jars,
tests-init">
+ <macro-compile-classes srcdir="${spi.test.java.dir}"/>
+ </target>
+
+ <!-- ================================================================== -->
+ <!-- Compiling -->
+ <!-- ================================================================== -->
+
+ <macrodef name="macro-compile-classes">
+ <attribute name="srcdir"/>
+ <sequential>
+ <mkdir dir="${spi.test.output.dir}/classes" />
+
+ <javac destdir="${spi.test.output.dir}/classes"
debug="${javac.debug}" encoding="utf-8"
verbose="${javac.verbose}" deprecation="${javac.deprecation}"
+ failonerror="${javac.fail.onerror}">
+ <src path="@{srcdir}"/>
+ <classpath refid="test.classpath"/>
+ </javac>
+ </sequential>
+ </macrodef>
+
+ <!-- ================================================================== -->
+ <!-- Testing -->
+ <!-- ================================================================== -->
+
+ <!-- Run all unit tests and generate a report -->
+ <target name="tests" depends="tests-compile"
description="Run all unit tests and generate a report">
+ <antcall target="tests-run-internal">
+ <param name="include.wildcard"
value="org/jboss/test/wsf/**/*TestCase.class"/>
+ <param name="exclude.wildcard"
value="no-wildcard-exclude-see-excludesfile"/>
+ <param name="haltonfailure" value="true"/>
+ </antcall>
+ </target>
+
+ <target name="test" depends="tests-compile" if="test"
description="Execute SPI testsuite">
+ <antcall target="tests-run-internal">
+ <param name="include.wildcard"
value="org/jboss/test/wsf/${test}/**/*TestCase.class"/>
+ <param name="exclude.wildcard"
value="no-wildcard-exclude-see-excludesfile"/>
+ <param name="haltonfailure" value="false"/>
+ </antcall>
+ </target>
+
+ <target name="tests-main" >
+ <antcall target="tests-compile"/>
+ </target>
+
+ <!-- Common test target -->
+ <target name="tests-run-internal" depends="tests-init">
+ <mkdir dir="${spi.test.output.dir}/reports"/>
+ <junit printsummary="yes" showoutput="yes"
dir="${spi.test.output.dir}" haltonfailure="${haltonfailure}">
+ <!--jvmarg value="-Djava.security.manager"/-->
+ <sysproperty key="build.testlog"
value="${spi.test.output.dir}/log"/>
+ <classpath>
+ <path refid="test.classpath"/>
+ <pathelement location="${spi.test.output.dir}/classes"/>
+ </classpath>
+ <formatter type="plain" usefile="true"/>
+ <formatter type="xml" usefile="true"/>
+ <batchtest todir="${spi.test.output.dir}/reports"
fork="true">
+ <fileset dir="${spi.test.output.dir}/classes"
includes="${include.wildcard}" excludes="${exclude.wildcard}"/>
+ </batchtest>
+ </junit>
+ </target>
+
+ <!--
+ Run a single unit test.
+ ant -Dtest=org.jboss.test.ws.jaxws.samples.provider.ProviderPayloadTestCase
one-test
+ -->
+ <target name="one-test" depends="tests-init"
if="test">
+ <mkdir dir="${spi.test.output.dir}/reports"/>
+ <junit printsummary="yes" showoutput="yes"
dir="${spi.test.output.dir}">
+ <jvmarg line="${remote.debug.line}"/>
+ <jvmarg value="-Djava.security.manager"/>
+ <sysproperty key="build.testlog"
value="${spi.test.output.dir}/log"/>
+ <classpath>
+ <path refid="test.classpath"/>
+ <pathelement location="${spi.test.output.dir}/classes"/>
+ </classpath>
+ <formatter type="plain" usefile="true"/>
+ <formatter type="xml" usefile="true"/>
+ <test todir="${spi.test.output.dir}/reports" name="${test}"
fork="true"/>
+ </junit>
+ </target>
+
+ <!-- ================================================================== -->
+ <!-- Reporting -->
+ <!-- ================================================================== -->
+
+ <!-- Build the tests report -->
+ <target name="tests-report" depends="tests-init">
+ <mkdir dir="${spi.test.output.dir}/reports"/>
+ <junitreport todir="${spi.test.output.dir}/reports">
+ <fileset dir="${spi.test.output.dir}/reports">
+ <include name="TEST-*.xml"/>
+ </fileset>
+ <report format="frames"
todir="${spi.test.output.dir}/reports/html"/>
+ </junitreport>
+ <zip destfile="${spi.test.output.dir}/test-report-${build.id}.zip">
+ <fileset dir="${spi.test.output.dir}"
includes="reports/**"/>
+ </zip>
+ </target>
+
+ <!-- ================================================================== -->
+ <!-- Cleaning -->
+ <!-- ================================================================== -->
+
+ <target name="tests-clean" description="Delete all generated test
files.">
+ <delete dir="${spi.test.output.dir}"/>
+ </target>
+
+</project>
Property changes on: spi/trunk/ant-import/build-testsuite.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: spi/trunk/ant-import/build-thirdparty.xml
===================================================================
--- spi/trunk/ant-import/build-thirdparty.xml 2007-08-02 16:05:43 UTC (rev 4111)
+++ spi/trunk/ant-import/build-thirdparty.xml 2007-08-02 16:13:55 UTC (rev 4112)
@@ -38,6 +38,7 @@
<target name="thirdparty-get" depends="thirdparty-init"
if="force.thirdparty" description="Gets the thirdparty libraries">
<mkdir dir="${thirdparty.dir}"/>
+ <get src="${jboss.repository}/junit/${junit}/lib/junit.jar"
dest="${thirdparty.dir}/junit.jar" usetimestamp="true"
verbose="true"/>
<get src="${jboss.repository}/apache-ant/${apache-ant}/lib/ant.jar"
dest="${thirdparty.dir}/ant.jar" usetimestamp="true"
verbose="true"/>
<get src="${jboss.repository}/gnu-getopt/${gnu-getopt}/lib/getopt.jar"
dest="${thirdparty.dir}/getopt.jar" usetimestamp="true"
verbose="true"/>
<get src="${jboss.repository}/dom4j/${dom4j}/lib/dom4j.jar"
dest="${thirdparty.dir}/dom4j.jar" usetimestamp="true"
verbose="true"/>
@@ -77,6 +78,7 @@
<pathelement location="${thirdparty.dir}/jaxb-api.jar"/>
<pathelement location="${thirdparty.dir}/jaxrpc-api.jar"/>
<pathelement location="${thirdparty.dir}/servlet-api.jar"/>
+ <pathelement location="${thirdparty.dir}/junit.jar"/>
</path>
</target>
Modified: spi/trunk/build.xml
===================================================================
--- spi/trunk/build.xml 2007-08-02 16:05:43 UTC (rev 4111)
+++ spi/trunk/build.xml 2007-08-02 16:13:55 UTC (rev 4112)
@@ -16,6 +16,7 @@
<import file="${basedir}/ant-import/build-setup.xml"/>
<import file="${basedir}/ant-import/build-release.xml"/>
<import file="${basedir}/ant-import/build-thirdparty.xml"/>
+ <import file="${basedir}/ant-import/build-testsuite.xml"/>
<!-- ================================================================== -->
<!-- Setup -->
@@ -25,7 +26,14 @@
<property name="spi.etc.dir" value="${spi.src.dir}/etc"/>
<property name="spi.java.dir" value="${spi.src.dir}/java"/>
<property name="spi.resources.dir"
value="${spi.src.dir}/resources"/>
+ <property name="spi.java.dir" value="${spi.src.dir}/java"/>
<property name="spi.output.dir" value="${spi.dir}/output"/>
+
+ <property name="spi.test.dir" value="${spi.dir}/src/test"/>
+ <property name="spi.test.java.dir"
value="${spi.test.dir}/java"/>
+ <property name="spi.test.resources.dir"
value="${spi.test.dir}/resources"/>
+ <property name="spi.test.output.dir"
value="${spi.output.dir}/test"/>
+
<property name="spi.output.apidocs.dir"
value="${spi.output.dir}/apidocs"/>
<property name="spi.output.etc.dir"
value="${spi.output.dir}/etc"/>
<property name="spi.output.classes.dir"
value="${spi.output.dir}/classes"/>
@@ -111,7 +119,7 @@
</zip>
</target>
-
+
<!-- ================================================================== -->
<!-- Documentation -->
<!-- ================================================================== -->
Added: spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTestCase.java
===================================================================
--- spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTestCase.java
(rev 0)
+++
spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTestCase.java 2007-08-02
16:13:55 UTC (rev 4112)
@@ -0,0 +1,167 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.test.wsf.spi.tools;
+
+import org.jboss.wsf.spi.tools.cmd.WSConsume;
+
+import java.security.Permission;
+
+import junit.framework.TestCase;
+
+/**
+ * Test the command line interface to WSConsume.
+ *
+ * @author Heiko.Braun(a)jboss.com
+ * @version $Revision$
+ */
+public class CmdConsumeTestCase extends TestCase
+{
+
+ SecurityManager systemDefault = System.getSecurityManager();
+ SecurityManager interceptor = new InterceptedSecurity();
+
+ class InterceptedSecurity extends SecurityManager
+ {
+ private final SecurityManager parent = systemDefault;
+
+ public void checkPermission(Permission perm)
+ {
+ if (parent != null)
+ {
+ parent.checkPermission(perm);
+ }
+ }
+
+ public void checkExit(int status)
+ {
+ String msg = (status == 0) ? "WSConsume did exit without errors" :
"WSConsume did exit with an error";
+ throw new InterceptedExit(msg, status);
+ }
+ }
+
+ class InterceptedExit extends SecurityException
+ {
+ private int exitCode;
+
+ public InterceptedExit(String s, int code)
+ {
+ super(s);
+ this.exitCode = code;
+ }
+
+
+ public int getExitCode()
+ {
+ return exitCode;
+ }
+ }
+
+ private void swapSecurityManager()
+ {
+ if(System.getSecurityManager() instanceof InterceptedSecurity)
+ System.setSecurityManager(systemDefault);
+ else
+ System.setSecurityManager(interceptor);
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ // enforce loading of the tracker implemenation
+ System.setProperty(
+ "org.jboss.wsf.spi.tools.ConsumerFactoryImpl",
+ "org.jboss.test.wsf.spi.tools.CmdConsumeTrackerFactory"
+ );
+ }
+
+ /*
+ new LongOpt("binding", LongOpt.REQUIRED_ARGUMENT, null, 'b'),
+ new LongOpt("catalog", LongOpt.REQUIRED_ARGUMENT, null, 'c'),
+ new LongOpt("package", LongOpt.REQUIRED_ARGUMENT, null, 'p'),
+ new LongOpt("wsdlLocation", LongOpt.REQUIRED_ARGUMENT, null,
'w'),
+ new LongOpt("output", LongOpt.REQUIRED_ARGUMENT, null, 'o'),
+ new LongOpt("source", LongOpt.REQUIRED_ARGUMENT, null, 's'),
+ new LongOpt("target", LongOpt.REQUIRED_ARGUMENT, null, 't'),
+ new LongOpt("keep", LongOpt.NO_ARGUMENT, null, 'k'),
+ new LongOpt("help", LongOpt.NO_ARGUMENT, null, 'h'),
+ new LongOpt("quiet", LongOpt.NO_ARGUMENT, null, 'q'),
+ new LongOpt("verbose", LongOpt.NO_ARGUMENT, null, 'v'),
+ new LongOpt("load-consumer", LongOpt.NO_ARGUMENT, null, 'l'),
+
+ */
+
+ public void testInvalidBindingOption() throws Exception
+ {
+ executeCmd("-b", true);
+ }
+
+ public void testValidBindingOption() throws Exception
+ {
+ executeCmd("-b binding-file.xml Service.wsdl", false);
+ assertEquals(CmdConsumeTracker.LAST_EVENT, "setBindingFiles");
+ }
+
+ public void testMissingOptions() throws Exception
+ {
+ executeCmd("", false); // strange, shouldn't this exit(1) ?
+ }
+
+ // TODO: add arbitrary combinations on a case by case basis
+
+ /**
+ * Pass a number of arguments to WSConsume and specify if
+ * you expect this to cause an exception.
+ *
+ * @param arguments
+ * @param expectedException
+ * @throws Exception
+ */
+ private void executeCmd(String arguments, boolean expectedException) throws
Exception
+ {
+ swapSecurityManager();
+
+ String[] args = arguments.split("\\s");
+ try
+ {
+ WSConsume.main(args);
+ if(expectedException)
+ fail("Did expect exception on args: " +args);
+ }
+ catch (InterceptedExit e)
+ {
+ boolean positivStatus = (e.getExitCode() == 0);
+ if( (expectedException && positivStatus)
+ || (!expectedException && !positivStatus) )
+ {
+ String s = expectedException ? "Did expect an exception, but " :
"Did not expect an exception, but ";
+ String s2 = positivStatus ? "status was positiv" : "status was
negativ";
+ throw new Exception(s+s2);
+ }
+
+ }
+ finally
+ {
+ swapSecurityManager();
+ }
+ }
+}
Property changes on:
spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTracker.java
===================================================================
--- spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTracker.java
(rev 0)
+++ spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTracker.java 2007-08-02
16:13:55 UTC (rev 4112)
@@ -0,0 +1,93 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.test.wsf.spi.tools;
+
+import org.jboss.wsf.spi.tools.WSContractConsumer;
+
+import java.io.File;
+import java.io.PrintStream;
+import java.util.List;
+import java.net.URL;
+
+/**
+ * @author Heiko.Braun(a)jboss.com
+ * @version $Revision$
+ */
+public class CmdConsumeTracker extends WSContractConsumer
+{
+ public static String LAST_EVENT = "";
+
+ public void setBindingFiles(List<File> bindingFiles)
+ {
+ CmdConsumeTracker.LAST_EVENT = "setBindingFiles";
+ }
+
+ public void setCatalog(File catalog)
+ {
+ CmdConsumeTracker.LAST_EVENT = "setCatalog";
+ }
+
+ public void setOutputDirectory(File directory)
+ {
+ CmdConsumeTracker.LAST_EVENT = "setOutputDirectory";
+ }
+
+ public void setSourceDirectory(File directory)
+ {
+ CmdConsumeTracker.LAST_EVENT = "setSourceDirectory";
+ }
+
+ public void setGenerateSource(boolean generateSource)
+ {
+ CmdConsumeTracker.LAST_EVENT = "setGenerateSource";
+ }
+
+ public void setTargetPackage(String targetPackage)
+ {
+ CmdConsumeTracker.LAST_EVENT = "setTargetPackage";
+ }
+
+ public void setWsdlLocation(String wsdlLocation)
+ {
+ CmdConsumeTracker.LAST_EVENT = "setWsdlLocation";
+ }
+
+ public void setMessageStream(PrintStream messageStream)
+ {
+ CmdConsumeTracker.LAST_EVENT = "setMessageStream";
+ }
+
+ public void setAdditionalCompilerClassPath(List<String> classPath)
+ {
+ CmdConsumeTracker.LAST_EVENT = "setAdditionalCompilerClassPath";
+ }
+
+ public void setTarget(String target)
+ {
+ CmdConsumeTracker.LAST_EVENT = "setTarget";
+ }
+
+ public void consume(URL wsdl)
+ {
+
+ }
+}
Property changes on:
spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTracker.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTrackerFactory.java
===================================================================
--- spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTrackerFactory.java
(rev 0)
+++
spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTrackerFactory.java 2007-08-02
16:13:55 UTC (rev 4112)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.test.wsf.spi.tools;
+
+import org.jboss.wsf.spi.tools.WSContractConsumerFactory;
+import org.jboss.wsf.spi.tools.WSContractConsumer;
+
+/**
+ * @author Heiko.Braun(a)jboss.com
+ * @version $Revision$
+ */
+public class CmdConsumeTrackerFactory implements WSContractConsumerFactory
+{
+
+ public WSContractConsumer createConsumer()
+ {
+ return new CmdConsumeTracker();
+ }
+}
Property changes on:
spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTrackerFactory.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: spi/trunk/version.properties
===================================================================
--- spi/trunk/version.properties 2007-08-02 16:05:43 UTC (rev 4111)
+++ spi/trunk/version.properties 2007-08-02 16:13:55 UTC (rev 4112)
@@ -28,3 +28,4 @@
sun-jaxrpc=1.1
sun-jaxws=2.1.1
sun-servlet=2.5
+junit=3.8.1