Base for the taskx - the verification infrastructure
authorJaroslav Tulach <jaroslav.tulach@apidesign.org>
Mon, 29 Sep 2008 06:31:19 +0200
changeset 14d907b216f8a1
parent 13 1ca35892ef26
child 15 a861bd02a1d2
Base for the taskx - the verification infrastructure
taskx/common.properties
taskx/common.xml
taskx/jtulach/against-solutionXY/build.xml
taskx/jtulach/against-solutionXY/nbproject/project.xml
taskx/jtulach/against-solutionXY/project.properties
taskx/jtulach/against-solutionXY/test/apifest/CurrencyTest.java
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/taskx/common.properties	Mon Sep 29 06:31:19 2008 +0200
     1.3 @@ -0,0 +1,5 @@
     1.4 +
     1.5 +# location to root of the repository with apifest projects
     1.6 +apifest=${ant.file.common}/../../
     1.7 +# and where is junit?
     1.8 +junit.jar=${apifest}/libs/junit-4.4.jar
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/taskx/common.xml	Mon Sep 29 06:31:19 2008 +0200
     2.3 @@ -0,0 +1,105 @@
     2.4 +<?xml version="1.0" encoding="UTF-8"?>
     2.5 +<!-- this is a template file to test  -->
     2.6 +<project name="common" default="run" basedir=".">
     2.7 +    <description>Builds the test against first version and runs them against two</description>
     2.8 +
     2.9 +    <loadproperties srcfile="${ant.file.common}/../common.properties"/>
    2.10 +    <loadproperties srcfile="project.properties"/>
    2.11 +    
    2.12 +    <target name="make-sure-projects-are-compiled">
    2.13 +        <ant dir="${taskA}/${apitotest}" target="compile"/>
    2.14 +        <ant dir="${taskB}/${apitotest}" target="compile"/>
    2.15 +    </target>
    2.16 +    
    2.17 +    <target name="compile" depends="make-sure-projects-are-compiled">
    2.18 +        <mkdir dir="build/tests"/>
    2.19 +        <echo level="info" message="Compiling the tests against old version of the API"/>
    2.20 +        <javac destdir="build/tests" srcdir="test">
    2.21 +            <classpath>
    2.22 +                <pathelement location="${apiA}"/>
    2.23 +                <pathelement location="${junit.jar}"/>
    2.24 +            </classpath>
    2.25 +        </javac>
    2.26 +    </target>
    2.27 +    
    2.28 +    <target name="run" depends="-run-binary-check,-run-source-check">
    2.29 +        <fail message="The test shall either compile against A and not B or run on A and fail on B, nothing like that happened">
    2.30 +            <condition>
    2.31 +                <not><or>
    2.32 +                    <isset property="execution.failed"/>
    2.33 +                    <isset property="compilation.failed"/>
    2.34 +                </or></not>
    2.35 +            </condition>
    2.36 +        </fail>
    2.37 +    </target>
    2.38 +        
    2.39 +    <target name="-run-binary-check" depends="compile">
    2.40 +        <mkdir dir="build/testresultA"/>
    2.41 +
    2.42 +        <echo level="info" message="Running the tests against old version of the API"/>
    2.43 +        <junit dir="build/tests" failureproperty="run.on.A.shall.succeed" fork="true">
    2.44 +            <batchtest todir="build/testresultA">
    2.45 +                <fileset dir="test" includes="**/*.java"/>
    2.46 +            </batchtest>
    2.47 +            <formatter type="brief" usefile="false"/>
    2.48 +            <formatter type="xml"/>
    2.49 +            <classpath>
    2.50 +                <pathelement location="${apiA}"/>
    2.51 +                <pathelement location="${junit.jar}"/>
    2.52 +                <pathelement location="build/tests"/>
    2.53 +            </classpath>
    2.54 +        </junit>
    2.55 +        
    2.56 +        <mkdir dir="build/testresultB"/>
    2.57 +        <echo level="info" message="Running the same tests against new version of the API, this should fail, if there is binary or functional incompatibility"/>
    2.58 +        <junit dir="build/tests" failureproperty="run.on.B.shall.fail" fork="true">
    2.59 +            <batchtest todir="build/testresultB">
    2.60 +                <fileset dir="test" includes="**/*.java"/>
    2.61 +            </batchtest>
    2.62 +            <formatter type="brief" usefile="false"/>
    2.63 +            <formatter type="xml"/>
    2.64 +            <classpath>
    2.65 +                <pathelement location="${apiB}"/>
    2.66 +                <pathelement location="${junit.jar}"/>
    2.67 +                <pathelement location="build/tests"/>
    2.68 +            </classpath>
    2.69 +        </junit>
    2.70 +        
    2.71 +        <condition property="execution.failed">
    2.72 +            <and>
    2.73 +                <isset property="run.on.B.shall.fail"/>
    2.74 +                <not><isset property="run.on.A.shall.succeed"/></not>
    2.75 +            </and>
    2.76 +        </condition>
    2.77 +    </target>
    2.78 +    
    2.79 +    <target name="-run-source-check" depends="compile" unless="execution.failed">
    2.80 +        
    2.81 +        <property name="build.b" location="build/verifyitbuildsagainstB"/>
    2.82 +        <delete dir="${build.b}"/>
    2.83 +        <mkdir dir="${build.b}"/>
    2.84 +
    2.85 +        
    2.86 +        <echo level="info" message="Verifying source compatibility: Compiling the tests against new version of the API"/>
    2.87 +        <javac destdir="${build.b}" srcdir="test" failonerror="false" fork="true">
    2.88 +            <classpath>
    2.89 +                <pathelement location="${apiB}"/>
    2.90 +                <pathelement location="${junit.jar}"/>
    2.91 +            </classpath>
    2.92 +        </javac>
    2.93 +
    2.94 +        
    2.95 +        <uptodate property="compilation.failed">
    2.96 +            <srcfiles dir="${build.b}" includes="**/*.class"/>
    2.97 +            <mapper type="glob" from="*" to="build/tests/*"/>
    2.98 +        </uptodate>
    2.99 +        
   2.100 +
   2.101 +    </target>
   2.102 +    
   2.103 +    <target name="test" depends="run"/>
   2.104 +    
   2.105 +    <target name="clean">
   2.106 +        <delete dir="build"/>
   2.107 +    </target>
   2.108 +</project>    
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/taskx/jtulach/against-solutionXY/build.xml	Mon Sep 29 06:31:19 2008 +0200
     3.3 @@ -0,0 +1,5 @@
     3.4 +<?xml version="1.0" encoding="UTF-8"?>
     3.5 +<!-- this is a template file to test  -->
     3.6 +<project name="testing-template" default="run" basedir=".">
     3.7 +    <import file="../../common.xml"/>
     3.8 +</project>    
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/taskx/jtulach/against-solutionXY/nbproject/project.xml	Mon Sep 29 06:31:19 2008 +0200
     4.3 @@ -0,0 +1,82 @@
     4.4 +<?xml version="1.0" encoding="UTF-8"?>
     4.5 +<project xmlns="http://www.netbeans.org/ns/project/1">
     4.6 +    <type>org.netbeans.modules.ant.freeform</type>
     4.7 +    <configuration>
     4.8 +        <general-data xmlns="http://www.netbeans.org/ns/freeform-project/1">
     4.9 +            <!-- Do not use Project Properties customizer when editing this file manually. -->
    4.10 +            <name>testing template</name>
    4.11 +            <properties>
    4.12 +                <property name="ant.script">build.xml</property>
    4.13 +                <property name="apifest">../../../</property>
    4.14 +                <property-file>project.properties</property-file>
    4.15 +                <property-file>${apifest}/taskx/common.properties</property-file>
    4.16 +            </properties>
    4.17 +            <folders>
    4.18 +                <source-folder>
    4.19 +                    <label>test</label>
    4.20 +                    <type>java</type>
    4.21 +                    <location>test</location>
    4.22 +                </source-folder>
    4.23 +            </folders>
    4.24 +            <ide-actions>
    4.25 +                <action name="build">
    4.26 +                    <script>${ant.script}</script>
    4.27 +                    <target>compile</target>
    4.28 +                </action>
    4.29 +                <action name="clean">
    4.30 +                    <script>${ant.script}</script>
    4.31 +                    <target>clean</target>
    4.32 +                </action>
    4.33 +                <action name="run">
    4.34 +                    <script>${ant.script}</script>
    4.35 +                    <target>test</target>
    4.36 +                </action>
    4.37 +                <action name="test">
    4.38 +                    <script>${ant.script}</script>
    4.39 +                    <target>test</target>
    4.40 +                </action>
    4.41 +                <action name="rebuild">
    4.42 +                    <script>${ant.script}</script>
    4.43 +                    <target>clean</target>
    4.44 +                    <target>compile</target>
    4.45 +                </action>
    4.46 +            </ide-actions>
    4.47 +            <export>
    4.48 +                <type>folder</type>
    4.49 +                <location>build/tests</location>
    4.50 +                <script>${ant.script}</script>
    4.51 +                <build-target>compile</build-target>
    4.52 +            </export>
    4.53 +            <view>
    4.54 +                <items>
    4.55 +                    <source-folder style="packages">
    4.56 +                        <label>test</label>
    4.57 +                        <location>test</location>
    4.58 +                    </source-folder>
    4.59 +                    <source-file>
    4.60 +                        <location>${ant.script}</location>
    4.61 +                    </source-file>
    4.62 +                    <source-file>
    4.63 +                        <location>project.properties</location>
    4.64 +                    </source-file>
    4.65 +                </items>
    4.66 +                <context-menu>
    4.67 +                    <ide-action name="build"/>
    4.68 +                    <ide-action name="clean"/>
    4.69 +                    <ide-action name="run"/>
    4.70 +                    <ide-action name="test"/>
    4.71 +                    <ide-action name="rebuild"/>
    4.72 +                </context-menu>
    4.73 +            </view>
    4.74 +            <subprojects/>
    4.75 +        </general-data>
    4.76 +        <java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/1">
    4.77 +            <compilation-unit>
    4.78 +                <package-root>test</package-root>
    4.79 +                <classpath mode="compile">${apiA}:${junit.jar}</classpath>
    4.80 +                <built-to>build/tests</built-to>
    4.81 +                <source-level>1.5</source-level>
    4.82 +            </compilation-unit>
    4.83 +        </java-data>
    4.84 +    </configuration>
    4.85 +</project>
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/taskx/jtulach/against-solutionXY/project.properties	Mon Sep 29 06:31:19 2008 +0200
     5.3 @@ -0,0 +1,16 @@
     5.4 +
     5.5 +# name of a project to test
     5.6 +#apitotest=todo:specify_this_property_in:project.properties
     5.7 +#for example use:
     5.8 +apitotest=solution01
     5.9 +
    5.10 +# the test shall expose a problem between two versions
    5.11 +# of one API. select the first version - taskA and a second
    5.12 +# version of the of the API taskB
    5.13 +taskA=${apifest}/task1
    5.14 +taskB=${apifest}/task2
    5.15 +
    5.16 +# usual locations of API classes for each version
    5.17 +apiA=${taskA}/${apitotest}/build/classes/
    5.18 +apiB=${taskB}/${apitotest}/build/classes/
    5.19 +
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/taskx/jtulach/against-solutionXY/test/apifest/CurrencyTest.java	Mon Sep 29 06:31:19 2008 +0200
     6.3 @@ -0,0 +1,17 @@
     6.4 +package apifest;
     6.5 +
     6.6 +import junit.framework.TestCase;
     6.7 +import org.apidesign.apifest08.currency.Convertor;
     6.8 +
     6.9 +
    6.10 +/** Write a test that works with version from task A and fails with version B.
    6.11 + */
    6.12 +public class CurrencyTest extends TestCase {
    6.13 +    public CurrencyTest(String n) {
    6.14 +        super(n);
    6.15 +    }
    6.16 +    
    6.17 +    public void testCompatibility() throws Exception {
    6.18 +        Convertor c = null;
    6.19 +    }
    6.20 +}