Skip to content

Commit 3b90b9a

Browse files
committed
test for api
1 parent 069b62a commit 3b90b9a

2 files changed

Lines changed: 64 additions & 7 deletions

File tree

‎build.xml‎

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
</target>
1717

1818
<target name="generator" description="Build code generator tool">
19-
<java-to-jar srcdir="hamcrest-generator/src/main/java"
20-
modulename="hamcrest-generator-nodeps"
21-
classpath="lib/generator/qdox-1.12.jar"/>
19+
<path id="cp-hamcrest-generator-main" path="lib/generator/qdox-1.12.jar"/>
20+
<path id="cp-hamcrest-generator-test" path="lib/integration/junit-dep-4.10.jar"/>
21+
<compile-module modulename="hamcrest-generator"/>
2222

2323
<!-- Bundle QDox classes in hamcrest-generator.jar using JarJar to place classes under a different package -->
2424
<taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask" classpath="lib/generator/jarjar-1.3.jar"/>
@@ -30,10 +30,35 @@
3030
<copy file="build/hamcrest-generator-nodeps-${version}-sources.jar" tofile="build/hamcrest-generator-${version}-sources.jar"/>
3131
</target>
3232

33-
<target name="core" depends="api,generator" description="Build core Hamcrest library">
34-
<java-to-jar srcdir="hamcrest-core/src/main/java"
35-
modulename="hamcrest-core-nodeps"
36-
classpath="build/hamcrest-api-${version}.jar"/>
33+
<macrodef name="compile-module">
34+
<attribute name="modulename" description="Name of the module to jar"/>
35+
<attribute name="classpathref" description="Anything additional to add on the classpath" default=""/>
36+
37+
<sequential>
38+
<mkdir dir="build/temp/@{modulename}-${version}.jar.contents"/>
39+
<javac srcdir="@{modulename}/src/main/java"
40+
destdir="build/temp/@{modulename}-${version}.jar.contents"
41+
debug="${debug}" source="1.5" target="1.5" includeantruntime="false">
42+
<classpath refid="cp-@{modulename}-main"/>
43+
</javac>
44+
<copy file="LICENSE.txt" todir="build/temp/@{modulename}-${version}.jar.contents/META-INF"/>
45+
<make-manifest modulename="@{modulename}"/>
46+
<jar jarfile="build/@{modulename}-${version}.jar" manifest="build/temp/@{modulename}-${version}.jar.manifest/MANIFEST.MF">
47+
<fileset dir="build/temp/@{modulename}-${version}.jar.contents"/>
48+
</jar>
49+
50+
<mkdir dir="build/temp/@{modulename}-${version}-test.jar.contents"/>
51+
<javac srcdir="@{modulename}/src/test/java"
52+
destdir="build/temp/@{modulename}-${version}-test.jar.contents"
53+
debug="${debug}" source="1.5" target="1.5" includeantruntime="false">
54+
<classpath refid="cp-@{modulename}-test"/>
55+
<classpath path="build/@{modulename}-${version}.jar"/>
56+
</javac>
57+
</sequential>
58+
</macrodef>
59+
60+
<target name="core" depends="generator" description="Build core Hamcrest library">
61+
<java-to-jar srcdir="hamcrest-core/src/main/java" modulename="hamcrest-core"/>
3762

3863
<!-- Generate one class with all static imports -->
3964
<mkdir dir="build/temp/hamcrest-core/generated-code"/>
@@ -261,6 +286,20 @@
261286
</jar>
262287
</target>
263288

289+
<macrodef name="make-manifest">
290+
<attribute name="modulename" description="Name of the module"/>
291+
<sequential>
292+
<mkdir dir="build/temp/@{modulename}-${version}.jar.manifest"/>
293+
<manifest file="build/temp/@{modulename}-${version}.jar.manifest/MANIFEST.MF">
294+
<attribute name="Implementation-Title" value="@{modulename}"/>
295+
<attribute name="Implementation-Vendor" value="hamcrest.org"/>
296+
<attribute name="Implementation-Version" value="${version}"/>
297+
<attribute name="Built-By" value="${user.name}"/>
298+
<attribute name="Built-Date" value="${build.timestamp}"/>
299+
</manifest>
300+
</sequential>
301+
</macrodef>
302+
264303
<macrodef name="java-to-jar" description="Compile Java source for a module and build a Jar">
265304
<attribute name="srcdir" description="Directory containg Java source"/>
266305
<attribute name="modulename" description="Name of the module to jar"/>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package org.hamcrest;
2+
3+
import static org.junit.Assert.*;
4+
5+
import org.hamcrest.Description.NullDescription;
6+
import org.junit.Test;
7+
8+
public final class NullDescriptionTest {
9+
10+
private final NullDescription nullDescription = new Description.NullDescription();
11+
12+
@Test public void
13+
isUnchangedByAppendedText() {
14+
nullDescription.appendText("myText");
15+
assertEquals("", nullDescription.toString());
16+
}
17+
18+
}

0 commit comments

Comments
 (0)