JdbcMapper/system-controls/test/webservice/build.xml

460 lines
24 KiB
XML
Raw Normal View History

<?xml version="1.0" ?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
$Header:$
-->
<!--
todo:
- create the following directory structure:
webapps/
serviceControlTestWeb/ (yes, this name is different)
build.xml
src/
web/
tests/
wsdl/
and move the tests requiring a container into this model. Will be a bit of work, but it's nicely
encapsulated and will be easeier to load into IDEA (etc).
- rationalize the build/ directory, ie: what relates to what? encapsulation is a good thing.
- fixup the web application's structure
- add documentation to the tests
- tests use assertEquals rather than assertTrue
- add READMEs to the sub-directories
- decompose /build.xml so that the standalone JUnit and container JUnit tests can be run individually
- convert WEB-INF/src/log4j.properties to WEB-INF/src/log4j.xml
- provide a web application build file
- container tests:
- cleanup source files (optimize and order imports, etc)
- change all "jcx" names to "wsc". "jcx" doesn't mean anything specific
- get the service control tests working in an IDE with JUnit (might not be possible because of the
generated source files, but if they exist, it would be *awesome* if this worked.
- port web service controls onto Controls test infrastructure
- bug: service control needs to hide its own annotations
- create real index.jsp page that finds all of the web services in the web application and displays links to them
-->
<project name="Beehive/Controls/System/WebService/Tests" default="drt" basedir=".">
<property environment="os"/>
<import file="../../systemcontrols-imports.xml"/>
<property file="build.properties"/>
<!-- client properties -->
<property name="build.root.dir" location="build"/>
<property name="client.build" location="${build.root.dir}/client"/>
<property name="build.fetchedwsdl.dir" location="${client.build}/wsdls"/>
<property name="junit-source.dir" location="webapp/tests"/>
<property name="types-source.dir" location="webapp/typesrc"/>
<property name="webapp.build.dir" location="${build.root.dir}/webapp"/>
<property name="client.beansrc" location="${client.build}/beansrc"/>
<property name="client.axisgen" location="${client.build}/axisgen"/>
<property name="client.xmlbeangen" location="${client.build}/xmlbeangen"/>
<property name="client.classes" location="${client.build}/classes"/>
<property name="wsdls.dir" location="webapp/wsdl"/>
<property name="axisgen.wsdls.dir" location="${wsdls.dir}/axisgen"/>
<property name="schematypes.wsdls.dir" location="${wsdls.dir}/schematypes"/>
<property name="pojotypes.wsdls.dir" location="${wsdls.dir}/pojotypes"/>
<property name="xmlbeangen.wsdls.dir" location="${wsdls.dir}/xmlbeangen"/>
<property name="client.wscgensrc" location="${client.build}/wscsrc"/>
<!-- Properties used for server testing -->
<property name="log.dir" location="${build.root.dir}/logs"/>
<property name="context.path" value="ServiceControlDRT"/>
<property name="waitfor.url" value="http://localhost:8080/index.jsp"/>
<property name="webapp.waitfor.url" value="http://localhost:8080/${context.path}"/>
<property name="waitfor.timeout" value="100"/>
<property name="beehive-webservice-control.jar"
location="${beehive.home}/system-controls/build/jars/beehive-webservice-control.jar"/>
<!-- hack to satisfy the WSM dependence for the web service control's build -->
<path id="wsm.dependency.path">
<fileset dir="external/beehive-wsm-snapshot" includes="*.jar"/>
</path>
<path id="client.classpath">
<pathelement path="${client.classes}"/>
<pathelement path="${beehive-webservice-control.jar}"/>
<path refid="wsm.dependency.path"/>
<path refid="axis.dependency.path"/>
<path refid="saaj.dependency.path"/>
<path refid="jaxrpc.dependency.path"/>
<path refid="wsdl4j.dependency.path"/>
<path refid="controls.dependency.path"/>
<path refid="junit.dependency.path"/>
<path refid="xbean.dependency.path"/>
<path refid="log4j.dependency.path"/>
<path refid="velocity.dependency.path"/>
<path refid="commons-logging.dependency.path"/>
<path refid="commons-discovery.dependency.path"/>
<pathelement location="${activation.jar}"/>
<pathelement location="${mailapi.jar}"/>
</path>
<!-- =================================================================== -->
<!-- drt - run the webservice control DRTs -->
<!-- =================================================================== -->
<target name="drt" description="Clean, build, and run the web service control drts.">
<antcall target="clean"/>
<antcall target="test.junit"/>
<antcall target="build.webapp"/>
<antcall target="test.server"/>
</target>
<target name="test.junit" description="Run the WSC JUnit tests">
<echo message="--------------------------------------------------"/>
<echo message="| Start WSC JUnit tests |"/>
<echo message="--------------------------------------------------"/>
<ant dir="junit" target="drt" inheritAll="false"/>
<echo message="--------------------------------------------------"/>
<echo message="| End WSC JUnit tests |"/>
<echo message="--------------------------------------------------"/>
</target>
<!-- what does this do? -->
<!--
<target name="generate_debug">
<taskdef name="webservice-control-gen"
classname="org.apache.beehive.controls.system.webservice.generator.WebServiceControlGeneratorTask"
classpathref="client.classpath"/>
<webservice-control-gen
srcUrl="http://www.ignyte.com/webservices/ignyte.whatsshowing.webservice/moviefunctions.asmx?wsdl"
copyWsdl="true"
destdir="/tmp/wsdls_out"
destPackageName="foo"/>
</target>
-->
<target name="test.server" description="Run the WSC server tests">
<echo message="--------------------------------------------------"/>
<echo message="| Start WSC Server tests |"/>
<echo message="--------------------------------------------------"/>
<parallel failonany="true">
<start-server shmem="false" javaOptions=""/>
<sequential>
<echo message="Wait for server to start at URL: ${waitfor.url}"/>
<waitfor maxwait="${waitfor.timeout}"
maxwaitunit="second"
timeoutproperty="server.timeout">
<http url="${waitfor.url}"/>
</waitfor>
<fail if="server.timeout" message="Server failed to start up properly at URL: ${waitfor.url}"/>
<antcall target="ensure.deployed"/>
<!-- Validate the wsdls we have against those returned from WSM, fail if any diffs -->
<antcall target="check.wsdls"/>
<!-- wsdls have been validated and we are good to go - build the services controls -->
<antcall target="build.client"/>
<antcall target="server.junit"/>
<antcall target="undeploy"/>
<stop-server/>
</sequential>
</parallel>
<echo message="--------------------------------------------------"/>
<echo message="| End WSC Server tests |"/>
<echo message="--------------------------------------------------"/>
</target>
<!-- =================================================================== -->
<!-- build - build the junit tests and webservice controls -->
<!-- =================================================================== -->
<target name="build.client" description="Build the server-side JUnit tests and web service controls.">
<echo message="--------------------------------------------------"/>
<echo message="| Web service control client build starting |"/>
<echo message="--------------------------------------------------"/>
<antcall target="dirs"/>
<antcall target="gen.wscs"/>
<!-- build webservice controls generated from wsdl files -->
<build-controls srcdir="${client.wscgensrc}"
destdir="${client.classes}"
tempdir="${client.beansrc}"
classpathref="client.classpath"/>
<copy todir="${client.classes}">
<fileset dir="${client.wscgensrc}">
<include name="**/*.wsdl"/>
</fileset>
</copy>
<!-- build the client junit tests, use apt since they may access controls -->
<build-controls srcdir="${junit-source.dir}"
destdir="${client.classes}"
tempdir="${client.beansrc}"
classpathref="client.classpath"/>
<echo message="--------------------------------------------------"/>
<echo message="| Web service control client build ending |"/>
<echo message="--------------------------------------------------"/>
</target>
<target name="server.junit" description="Run the server's JUnit tests">
<echo message="JUnit log files written to: ${log.dir}"/>
<junit failureproperty="drtfailed"
printsummary="on"
tempdir="${client.build}"
fork="yes">
<classpath>
<path refid="client.classpath"/>
</classpath>
<formatter type="plain"/>
<batchtest filtertrace="off" todir="${log.dir}">
<fileset dir="${junit-source.dir}">
<include name="**/*Test.java"/>
<exclude name="**/Image*Test.java"/>
<exclude name="**/DataHandler*Test.java"/>
<exclude name="**/MimeMultipart*Test.java"/>
<exclude name="**/XmlSource*Test.java"/>
</fileset>
</batchtest>
</junit>
<fail if="drtfailed" message="One or more tests in the ServiceControl DRT failed."/>
</target>
<target name="build.webapp" description="Build the webapp for the drts.">
<ant dir="webapp" target="build" inheritAll="false"/>
</target>
<target name="clean.webapp" description="Build the webapp for the drts.">
<ant dir="webapp" target="clean" inheritAll="false"/>
</target>
<target name="gen.wscs" description="Generate wscs for junit tests.">
<!-- First generate the web service controls which do not require any object generation support -->
<taskdef name="webservice-control-gen"
classname="org.apache.beehive.controls.system.webservice.generator.WebServiceControlGeneratorTask"
classpathref="client.classpath"/>
<webservice-control-gen wsdlsrc="${schematypes.wsdls.dir}" destdir="${client.wscgensrc}"
copyWsdl="yes" destPackageName="schematypestest"/>
<!-- now gen the wsc's which require type support from xmlbeans and axis -->
<antcall target="gen.pojo.wscs"/>
<antcall target="gen.xmlbean.wscs"/>
<antcall target="gen.axis.wscs"/>
</target>
<target name="gen.xmlbean.wscs" description="Build wsc's which use XmlBeans type generation.">
<taskdef name="xmlbeanbuild"
classname="org.apache.xmlbeans.impl.tool.XMLBean"
classpathref="xbean.dependency.path"/>
<taskdef name="webservice-control-gen"
classname="org.apache.beehive.controls.system.webservice.generator.WebServiceControlGeneratorTask"
classpathref="client.classpath"/>
<xmlbeanbuild classpathref="xbean.dependency.path" classgendir="${client.classes}" failonerror="true"
ignoreDuplicatesInNamespaces="http://complextypes.beehive.apache.org">
<fileset dir="${xmlbeangen.wsdls.dir}">
<include name="ComplexTypesRpcLitXmlbeangen.wsdl"/>
<include name="ComplexTypesDocLitWrappedXmlbeangen.wsdl"/>
</fileset>
</xmlbeanbuild>
<webservice-control-gen wsdlsrc="${xmlbeangen.wsdls.dir}" destdir="${client.wscgensrc}"
copyWsdl="yes" destPackageName="xmlbeangentest"/>
</target>
<target name="gen.axis.wscs" description="Build wsc's which use Axis type generation.">
<taskdef name="axisbeanbuild"
classname="org.apache.beehive.controls.system.jaxrpc.AxisTypeGeneratorTask"
classpathref="client.classpath"/>
<!-- currently, rpc encoded must be generated from the axis bean generator -->
<axisbeanbuild wsdlsrc="${axisgen.wsdls.dir}" outputdir="${client.axisgen}"/>
<javac srcdir="${client.axisgen}" destdir="${client.classes}" classpathref="client.classpath" debug="true"/>
<webservice-control-gen wsdlsrc="${axisgen.wsdls.dir}" destdir="${client.wscgensrc}"
copyWsdl="true" destPackageName="axisgentest"/>
</target>
<target name="gen.pojo.wscs" description="Build wsc's which use pre-existing java classes generation.">
<javac srcdir="${types-source.dir}" destdir="${client.classes}" classpathref="client.classpath" debug="true"/>
<webservice-control-gen wsdlsrc="${pojotypes.wsdls.dir}" destdir="${client.wscgensrc}"
copyWsdl="yes" destPackageName="pojotypetest"/>
</target>
<!-- =================================================================== -->
<!-- Verify that the webservice generates an identical wsdl to the DRT -->
<!-- wsdl we keep a copy of. -->
<!-- =================================================================== -->
<target name="check.wsdls" description="Verify that the webservice wsdl matches our DRT wsdl.">
<mkdir dir="${build.fetchedwsdl.dir}"/>
<check-wsdl webservicePath="attachments/images" webserviceName="ImagesDocLitWrapped" drtWsdlDir="${schematypes.wsdls.dir}"/>
<check-wsdl webservicePath="attachments/images" webserviceName="ImagesRpcLit" drtWsdlDir="${schematypes.wsdls.dir}"/>
<check-wsdl webservicePath="attachments/images" webserviceName="ImagesRpcEnc" drtWsdlDir="${schematypes.wsdls.dir}"/>
<check-wsdl webservicePath="attachments/datahandler" webserviceName="DataHandlerDocLitWrapped" drtWsdlDir="${schematypes.wsdls.dir}"/>
<check-wsdl webservicePath="attachments/datahandler" webserviceName="DataHandlerRpcLit" drtWsdlDir="${schematypes.wsdls.dir}"/>
<check-wsdl webservicePath="attachments/datahandler" webserviceName="DataHandlerRpcEnc" drtWsdlDir="${schematypes.wsdls.dir}"/>
<check-wsdl webservicePath="attachments/mimemultipart" webserviceName="MimeMultipartDocLitWrapped" drtWsdlDir="${schematypes.wsdls.dir}"/>
<check-wsdl webservicePath="attachments/mimemultipart" webserviceName="MimeMultipartRpcLit" drtWsdlDir="${schematypes.wsdls.dir}"/>
<check-wsdl webservicePath="attachments/mimemultipart" webserviceName="MimeMultipartRpcEnc" drtWsdlDir="${schematypes.wsdls.dir}"/>
<check-wsdl webservicePath="attachments/xml" webserviceName="XmlSourceDocLitWrapped" drtWsdlDir="${schematypes.wsdls.dir}"/>
<check-wsdl webservicePath="attachments/xml" webserviceName="XmlSourceRpcLit" drtWsdlDir="${schematypes.wsdls.dir}"/>
<check-wsdl webservicePath="attachments/xml" webserviceName="XmlSourceRpcEnc" drtWsdlDir="${schematypes.wsdls.dir}"/>
<check-wsdl webservicePath="complextypes/doclitwrapped/pojo" webserviceName="ComplexTypesDocLitWrapped" drtWsdlDir="${pojotypes.wsdls.dir}"/>
<check-wsdl webservicePath="complextypes/doclitwrapped/axisgen" webserviceName="ComplexTypesDocLitWrappedAxisgen" drtWsdlDir="${axisgen.wsdls.dir}"/>
<check-wsdl webservicePath="complextypes/doclitwrapped/xmlbeangen" webserviceName="ComplexTypesDocLitWrappedXmlbeangen" drtWsdlDir="${xmlbeangen.wsdls.dir}"/>
<check-wsdl webservicePath="complextypes/rpclit/pojo" webserviceName="ComplexTypesRpcLit" drtWsdlDir="${pojotypes.wsdls.dir}"/>
<check-wsdl webservicePath="complextypes/rpclit/axisgen" webserviceName="ComplexTypesRpcLitAxisgen" drtWsdlDir="${axisgen.wsdls.dir}"/>
<check-wsdl webservicePath="complextypes/rpclit/xmlbeangen" webserviceName="ComplexTypesRpcLitXmlbeangen" drtWsdlDir="${xmlbeangen.wsdls.dir}"/>
<check-wsdl webservicePath="complextypes/rpcenc/axisgen" webserviceName="ComplexTypesRpcEncAxisgen" drtWsdlDir="${axisgen.wsdls.dir}"/>
<check-wsdl webservicePath="handlers" webserviceName="HandlerDocLitEndpoint" drtWsdlDir="${schematypes.wsdls.dir}"/>
<check-wsdl webservicePath="handlers" webserviceName="HandlerRpcLitEndpoint" drtWsdlDir="${schematypes.wsdls.dir}"/>
<check-wsdl webservicePath="handlers" webserviceName="HandlerRpcEncEndpoint" drtWsdlDir="${schematypes.wsdls.dir}"/>
<check-wsdl webservicePath="header" webserviceName="HeaderDocLitEndpoint" drtWsdlDir="${schematypes.wsdls.dir}"/>
<check-wsdl webservicePath="header" webserviceName="HeaderObjectDocLitEndpoint" drtWsdlDir="${pojotypes.wsdls.dir}"/>
<check-wsdl webservicePath="header" webserviceName="HeaderRpcLitEndpoint" drtWsdlDir="${schematypes.wsdls.dir}"/>
<check-wsdl webservicePath="header" webserviceName="HeaderObjectRpcLitEndpoint" drtWsdlDir="${pojotypes.wsdls.dir}"/>
<check-wsdl webservicePath="header" webserviceName="HeaderRpcEncEndpoint" drtWsdlDir="${schematypes.wsdls.dir}"/>
<check-wsdl webservicePath="header" webserviceName="HeaderObjectRpcEncEndpoint" drtWsdlDir="${axisgen.wsdls.dir}"/>
<check-wsdl webservicePath="soapMarshalling" webserviceName="SoapMarshallingDocLitWrapped" drtWsdlDir="${schematypes.wsdls.dir}"/>
<check-wsdl webservicePath="soapMarshalling" webserviceName="SoapMarshallingDocLitWrappedArrayTypes" drtWsdlDir="${schematypes.wsdls.dir}"/>
<check-wsdl webservicePath="soapMarshalling" webserviceName="SoapMarshallingDocLitBare" drtWsdlDir="${schematypes.wsdls.dir}"/>
<check-wsdl webservicePath="soapMarshalling" webserviceName="SoapMarshallingDocLitBareArrayTypes" drtWsdlDir="${schematypes.wsdls.dir}"/>
<check-wsdl webservicePath="soapMarshalling" webserviceName="SoapMarshallingRpcLit" drtWsdlDir="${schematypes.wsdls.dir}"/>
<check-wsdl webservicePath="soapMarshalling" webserviceName="SoapMarshallingRpcLitArrayTypes" drtWsdlDir="${schematypes.wsdls.dir}"/>
<check-wsdl webservicePath="soapMarshalling" webserviceName="SoapMarshallingRpcEnc" drtWsdlDir="${schematypes.wsdls.dir}"/>
<check-wsdl webservicePath="soapMarshalling" webserviceName="SoapMarshallingRpcEncArrayTypes" drtWsdlDir="${schematypes.wsdls.dir}"/>
</target>
<!-- =================================================================== -->
<!-- clean -->
<!-- =================================================================== -->
<target name="clean">
<delete dir="${build.root.dir}"/>
<ant dir="webapp" target="clean" inheritAll="false"/>
</target>
<!-- =================================================================== -->
<!-- create directories for the build -->
<!-- =================================================================== -->
<target name="dirs">
<mkdir dir="${client.build}"/>
<mkdir dir="${client.beansrc}"/>
<mkdir dir="${client.classes}"/>
<mkdir dir="${client.xmlbeangen}"/>
<mkdir dir="${client.axisgen}"/>
<mkdir dir="${client.wscgensrc}"/>
<mkdir dir="${build.fetchedwsdl.dir}"/>
<mkdir dir="${webapp.build.dir}"/>
<mkdir dir="${log.dir}"/>
</target>
<!-- ================================================================ -->
<!-- -->
<!-- Targets for running the web service control drts on tomcat -->
<!-- -->
<!-- ================================================================ -->
<target name="ensure.deployed" description="Deploy webapp for the test recorder">
<echo>Ensuring that the webapp ${context.path} is deployed on a running server at the url
${webapp.waitfor.url}</echo>
<waitfor maxwait="5" maxwaitunit="second" timeoutproperty="unavailable">
<http url="${webapp.waitfor.url}"/>
</waitfor>
<antcall target="do.deploy"/>
<antcall target="do.redeploy"/>
<fail if="still.unavailable" message="Couldn't find webapp with path ${webapp.waitfor.url}"/>
</target>
<target name="do.deploy" if="unavailable">
<echo>Webapp is not deployed; deploying</echo>
<antcall target="deploy"/>
<echo>...deploy complete</echo>
<waitfor maxwait="120" maxwaitunit="second" timeoutproperty="still.unavailable">
<http url="${webapp.waitfor.url}"/>
</waitfor>
</target>
<target name="do.redeploy" unless="unavailable">
<echo>Webapp is deployed; undeploy and redeploy</echo>
<antcall target="undeploy"/>
<echo>...undeploy complete</echo>
<antcall target="deploy"/>
<echo>...deploy complete</echo>
<waitfor maxwait="120" maxwaitunit="second" timeoutproperty="still.unavailable">
<http url="${webapp.waitfor.url}"/>
</waitfor>
</target>
<target name="deploy" description="Deploy webapp">
<echo message="Deploying ${webapp.build.dir} to ${context.path}"/>
<deploy-webapp webappDir="${webapp.build.dir}" contextPath="${context.path}"/>
</target>
<target name="undeploy" description="Undeploy webapp">
<undeploy-webapp contextPath="${context.path}"/>
</target>
<!-- =================================================================== -->
<!-- Check a DRT wsdl against the one generated from the webservice -->
<!-- =================================================================== -->
<macrodef name="check-wsdl">
<attribute name="webserviceName"/>
<attribute name="webservicePath"/>
<attribute name="drtWsdlDir"/>
<sequential>
<get src="${webapp.waitfor.url}/@{webservicePath}/@{webserviceName}.jws?wsdl"
dest="${build.fetchedwsdl.dir}/@{webserviceName}.wsdl"/>
<!-- based on the platform the generated wsdl may contain CR/LF line endings -->
<fixcrlf srcdir="@{drtWsdlDir}" eol="lf" includes="@{webserviceName}.wsdl"/>
<fixcrlf srcdir="${build.fetchedwsdl.dir}" eol="lf" includes="**/@{webserviceName}.wsdl"/>
<fail message="ERROR: WSDL generated by webservice, ${build.fetchedwsdl.dir}/@{webserviceName}.wsdl, does not match DRT WSDL @{drtWsdlDir}/@{webserviceName}.wsdl !">
<condition>
<not>
<filesmatch file1="@{drtWsdlDir}/@{webserviceName}.wsdl"
file2="${build.fetchedwsdl.dir}/@{webserviceName}.wsdl"/>
</not>
</condition>
</fail>
</sequential>
</macrodef>
</project>