summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Clayton <alex.clayton@isode.com>2018-07-19 12:40:16 (GMT)
committerAlex Clayton <alex.clayton@isode.com>2018-08-09 12:46:43 (GMT)
commite906d1c46a854de703017cbb05e1adde5babe417 (patch)
tree55516b842367b0d9cb53ed796b2dc9c2892c924a
parent17a1e7662102eea20ddc104133e2e30a70fefdc1 (diff)
downloadstroke-master.zip
stroke-master.tar.bz2
Update stroke's junit testsHEADmaster
Update stroke junit tests so it can cope with the latest version of Junit 4 (4.12) which no requires both Junit and Hamcrest to be on the classpath. This is done using a method similar to how JUNIT is currently set. The make file passes a new HAMCREST enviroment variable to the ant script as HAMCREST_JAR which ant then adds to the tests classpath. So to run the tests with the new JUNIT will need to set JUNIT to point to junit.jar and HAMCREST to the hamcrest jar, then run Make test. Also make use of ant's junitreport task to create a html version of the junit test's results, which makes diagnosing failures easier. Test-information: After setting HAMCREST and JUNIT then running Make Test on OSX and Unix all tests pass and HTML output is generated. If HAMCREST is not set but JUNIT points to latest junit.jar (i.e one that requires hamcrest on class path) tests fail with error about not being able to find hamcrest classes. If HAMCREST not set but JUNIT points to an older junit.jar then tests run correctly. On Windows got the unit tests to run by calling ant directly, again with HAMCREST and JUNIT set tests run correctly. Change-Id: I272b1dbe1bde05593df15f22814b7882a494f2c8
-rw-r--r--Makefile2
-rw-r--r--build.xml15
2 files changed, 15 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index e642806..b9c4d82 100644
--- a/Makefile
+++ b/Makefile
@@ -1,58 +1,58 @@
all: dist/lib/stroke.jar
DEFINES = -Dxpp-dir=third-party/xpp -Djzlib-dir=third-party/jzlib -Dicu4j-dir=third-party/ -Dstax2-dir=third-party/stax2/ -Daalto-dir=third-party/aalto/ -Ddnsjava-dir=third-party/dnsjava
JUNIT ?= /usr/share/junit/junit.jar
.PHONY : clean
clean:
ant clean
.PHONY : distclean
distclean: clean
ant distclean
rm -rf third-party
.PHONY : dist/lib/stroke.jar
dist/lib/stroke.jar: third-party/jzlib/jzlib.jar third-party/icu4j.jar third-party/aalto/aalto-xml.jar third-party/stax2/stax2-api.jar third-party/dnsjava/dnsjava.jar
ant ${DEFINES}
FINDBUGS_VERSION=3.0.1
.PHONY : test
test: dist/lib/stroke.jar third-party/cobertura/cobertura.jar third-party/findbugs-$(FINDBUGS_VERSION)/lib/findbugs.jar third-party/pmd/lib/pmd-5.0.0.jar
- ant ${DEFINES} -DJUNIT_JAR=${JUNIT} -Dcobertura-jar=third-party/cobertura/cobertura.jar -Djakarta-oro-jar=third-party/cobertura/lib/jakarta-oro-2.0.8.jar -Dlog4j-jar=third-party/cobertura/lib/log4j-1.2.9.jar -Dasm-jar=third-party/cobertura/lib/asm-3.0.jar -Dasm-tree-jar=third-party/cobertura/lib/asm-tree-3.0.jar -Dicu4j-jar=third-party/icu4j.jar -Dfindbugs.home=third-party/findbugs-$(FINDBUGS_VERSION) -Dpmd.home=third-party/pmd test
+ ant ${DEFINES} -DJUNIT_JAR=${JUNIT} -DHAMCREST_JAR=${HAMCREST} -Dcobertura-jar=third-party/cobertura/cobertura.jar -Djakarta-oro-jar=third-party/cobertura/lib/jakarta-oro-2.0.8.jar -Dlog4j-jar=third-party/cobertura/lib/log4j-1.2.9.jar -Dasm-jar=third-party/cobertura/lib/asm-3.0.jar -Dasm-tree-jar=third-party/cobertura/lib/asm-tree-3.0.jar -Dicu4j-jar=third-party/icu4j.jar -Dfindbugs.home=third-party/findbugs-$(FINDBUGS_VERSION) -Dpmd.home=third-party/pmd test
third-party/aalto/aalto-xml.jar:
mkdir -p third-party/aalto
curl http://repo2.maven.org/maven2/com/fasterxml/aalto-xml/0.9.8/aalto-xml-0.9.8.jar -o third-party/aalto/aalto-xml.jar
third-party/stax2/stax2-api.jar:
mkdir -p third-party/stax2
curl http://repo.maven.apache.org/maven2/org/codehaus/woodstox/stax2-api/3.0.3/stax2-api-3.0.3.jar -o third-party/stax2/stax2-api.jar
third-party/jzlib/jzlib.jar:
mkdir -p third-party
curl http://www.jcraft.com/jzlib/jzlib-1.0.7.tar.gz -o third-party/jzlib-1.0.7.tar.gz
tar -xvzf third-party/jzlib-1.0.7.tar.gz -C third-party/
mv third-party/jzlib-1.0.7 third-party/jzlib
cp build-jzlib.xml third-party/jzlib/build.xml
ant -f third-party/jzlib/build.xml
third-party/icu4j.jar:
mkdir -p third-party
curl http://download.icu-project.org/files/icu4j/4.8.1/icu4j-4_8_1.jar -o third-party/icu4j.jar
third-party/dnsjava/dnsjava.jar:
mkdir -p third-party/dnsjava
curl http://www.dnsjava.org/download/dnsjava-2.1.6.jar -o third-party/dnsjava/dnsjava.jar
third-party/cobertura/cobertura.jar:
mkdir -p third-party
curl -L 'http://sourceforge.net/projects/cobertura/files/cobertura/1.9.4.1/cobertura-1.9.4.1-bin.tar.bz2/download' -o third-party/cobertura-1.9.4.1-bin.tar.bz2
tar -xvjf third-party/cobertura-1.9.4.1-bin.tar.bz2 -C third-party/
mv third-party/cobertura-1.9.4.1 third-party/cobertura
third-party/findbugs-$(FINDBUGS_VERSION)/lib/findbugs.jar:
mkdir -p third-party
curl -L 'http://prdownloads.sourceforge.net/findbugs/findbugs-$(FINDBUGS_VERSION).tar.gz?download' -o third-party/findbugs-$(FINDBUGS_VERSION).tar.gz
tar -xvzf third-party/findbugs-$(FINDBUGS_VERSION).tar.gz -C third-party/
diff --git a/build.xml b/build.xml
index fe123bb..00f098e 100644
--- a/build.xml
+++ b/build.xml
@@ -85,162 +85,175 @@
unless="noexamples">
<mkdir dir="${dist}/lib"/>
<jar jarfile="${jar}" basedir="${build}">
<manifest>
<attribute name="Main-Class" value="${main-class}"/>
</manifest>
</jar>
</target>
<target name="-dist-without-examples" depends="-compile-without-examples"
description="generate the distribution excluding examples"
if="noexamples">
<mkdir dir="${dist}/lib"/>
<jar jarfile="${jar}" basedir="${build}">
</jar>
</target>
<target name="compile-tests" depends="dist"
description="compile the test sources " >
<depend
srcdir="${src.tests}"
classpath="${jar}"
destdir="${src.tests}"
closure="yes"/>
<javac srcdir="${src.tests}" destdir="${src.tests}"
debug="${compile.debug}"
source="1.6"
target="1.6">
<compilerarg line="-encoding utf-8"/>
<classpath>
<pathelement location="${jar}"/>
<pathelement location="${JUNIT_JAR}"/>
+ <pathelement location="${HAMCREST_JAR}"/>
<fileset dir="${icu4j-dir}" includes="icu4j.jar"/>
</classpath>
</javac>
</target>
<target name="instrument" if="cobertura-jar" depends="compile-tests">
<delete dir="${cobertura.dir}"/>
<mkdir dir="${cobertura.dir}"/>
<cobertura-instrument todir="${cobertura.dir}">
<fileset dir="test">
<include name="**/*.class"/>
</fileset>
</cobertura-instrument>
</target>
<target name="run-tests" depends="compile-tests">
<delete dir="${test.results}"/>
<mkdir dir="${test.results}"/>
<junit fork="yes">
<formatter type="xml"/>
<classpath>
<pathelement location="${cobertura.dir}"/>
<path refid="cobertura.classpath"/>
</classpath>
<classpath>
<pathelement location="${JUNIT_JAR}"/>
+ <pathelement location="${HAMCREST_JAR}"/>
<pathelement location="${jar}"/>
<pathelement location="${src.tests}"/>
<path refid="classpath"/>
</classpath>
<batchtest todir="${test.results}">
<fileset dir="${src.tests}">
<include name="**/*Test.java"/>
<!--<exclude name="**/AllTests.java"/>-->
</fileset>
</batchtest>
</junit>
</target>
<target name="coverage" if="cobertura-jar" depends="instrument, run-tests">
<delete dir="${coveragereport.dir}"/>
<mkdir dir="${coveragereport.dir}"/>
<cobertura-report format="xml" destdir="${coveragereport.dir}">
<fileset dir="${src}">
<include name="**/*.java"/>
</fileset>
<fileset dir="${src.tests}">
<include name="**/*.java"/>
</fileset>
</cobertura-report>
</target>
<target name="findbugs" if="findbugs.home" depends="dist">
<path id="findbugs-jar">
<pathelement path="${findbugs.home}/lib/findbugs-ant.jar" />
</path>
<taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpathref="findbugs-jar" />
<findbugs home="${findbugs.home}"
output="xml"
outputFile="findbugs.xml" >
<auxClasspath>
<path refid="classpath" />
</auxClasspath>
<sourcePath path="${src}" />
<class location="${jar}" />
</findbugs>
</target>
<target name="pmd">
<path id="pmd-jar">
<fileset dir="${pmd.home}/lib">
<include name="*.jar" />
</fileset>
</path>
<taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask" classpathref="pmd-jar"/>
<pmd shortFilenames="true">
<ruleset>pmd-ruleset.xml</ruleset>
<formatter type="xml" toFile="pmd.xml" />
<fileset dir="${src}">
<include name="**/*.java"/>
</fileset>
</pmd>
</target>
- <target name="test" depends="compile-tests, instrument, run-tests, coverage, findbugs, pmd">
+ <target name="test" depends="compile-tests, instrument, run-tests, coverage, findbugs, pmd, report-junit-tests">
</target>
<target name="clean"
description="clean up" >
<delete dir="${build}"/>
<delete dir="${test.results}"/>
<delete dir="${dist}"/>
<delete dir="${doc}"/>
<delete dir="${coveragereport.dir}"/>
<delete dir="${cobertura.dir}"/>
<delete>
<fileset dir="${src.tests}">
<include name="**/*.class"/>
</fileset>
</delete>
</target>
<target name="javadoc" depends="init">
<!-- Note that this may stall if no network connection is available
to the Oracle website -->
<javadoc packagenames="com.isode.**.**"
sourcepath="${src}"
destdir="${doc}"
windowtitle="Stroke">
<!--<classpath>
<fileset dir="${xpp-dir}" includes="xpp.jar"/>
</classpath>-->
<link href="http://docs.oracle.com/javase/6/docs/api/"/>
</javadoc>
</target>
<target name="run" description="Run the demo" depends="dist">
<java fork="true" classname="${main-class}">
<classpath>
<path refid="classpath"/>
<path location="${jar}"/>
</classpath>
</java>
</target>
+
+ <target name="report-junit-tests" depends="run-tests">
+ <mkdir dir="${test.results}/html"/>
+ <junitreport todir="${test.results}">
+ <fileset dir="${test.results}">
+ <include name="TEST-*.xml"/>
+ </fileset>
+ <report todir="${test.results}/html"/>
+ </junitreport>
+ </target>
+
</project>