Skip to content

Commit 68138c8

Browse files
committed
generate Hamcrest compatibility tests
1 parent cc1a76d commit 68138c8

File tree

6 files changed

+64
-52
lines changed

6 files changed

+64
-52
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ target
55
.project
66
.idea
77
*.iml
8+
/compat-tests/scratch/

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ addons:
2323
install: true
2424
script:
2525
- mvn install -B
26-
- mvn -f compat-tests/hamcrest-2.x/pom.xml test
26+
- cd compat-tests && ./hamcrest-test.sh 2.6.5-SNAPSHOT 2.2
2727
notifications:
2828
email:
2929

compat-tests/hamcrest-2.x/src/test/java/org/xmlunit/TestResources.java

-28
This file was deleted.

compat-tests/hamcrest-2.x/src/test/java/org/xmlunit/bugreports

-1
This file was deleted.

compat-tests/hamcrest-2.x/src/test/java/org/xmlunit/matchers

-1
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,40 @@
1-
<?xml version="1.0"?>
2-
<!--
3-
This file is licensed to You under the Apache License, Version 2.0
4-
(the "License"); you may not use this file except in compliance with
5-
the License. You may obtain a copy of the License at
1+
#!/bin/sh
2+
set -e
63

7-
http://www.apache.org/licenses/LICENSE-2.0
4+
if [ "$#" -ne 2 ]; then
5+
echo "Usage: hamcrest-test.sh XMLUNIT_VERSION HAMCREST_VERSION"
6+
exit 1
7+
fi
88

9-
Unless required by applicable law or agreed to in writing, software
10-
distributed under the License is distributed on an "AS IS" BASIS,
11-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
See the License for the specific language governing permissions and
13-
limitations under the License.
14-
-->
9+
XMLUNIT_VERSION=$1
10+
HAMCREST_VERSION=$2
11+
12+
SCRATCH_DIR=scratch/hamcrest-${HAMCREST_VERSION}
13+
14+
rm -rf scratch && mkdir -p ${SCRATCH_DIR}/src/test/java/org/xmlunit/
15+
16+
cat > ${SCRATCH_DIR}/pom.xml <<EOF
17+
<?xml version="1.0"?>
1518
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
1619
<modelVersion>4.0.0</modelVersion>
1720
1821
<parent>
1922
<groupId>org.xmlunit</groupId>
2023
<artifactId>xmlunit-parent</artifactId>
21-
<version>2.6.5-SNAPSHOT</version>
22-
<relativePath>../..</relativePath>
24+
<version>${XMLUNIT_VERSION}</version>
25+
<relativePath>../../..</relativePath>
2326
</parent>
2427
2528
<groupId>org.xmlunit</groupId>
26-
<artifactId>xmlunit-compat-tests-hamcrest-2.x</artifactId>
29+
<artifactId>xmlunit-compat-tests-hamcrest-${HAMCREST_VERSION}</artifactId>
2730
<packaging>jar</packaging>
28-
<name>org.xmlunit:xmlunit-compat-tests-hamcrest-2.x</name>
29-
<description>Verifies the Hamcrest Matchers are compatible with the latest version of Hamcrest</description>
31+
<name>org.xmlunit:xmlunit-compat-tests-hamcrest-${HAMCREST_VERSION}</name>
32+
<description>Verifies the Hamcrest Matchers are compatible with Hamcrest ${HAMCREST_VERSION}</description>
3033
<url>https://www.xmlunit.org/</url>
3134
3235
<properties>
33-
<automatic.module.name>${project.groupId}.compat-tests-hamcrest-2.x</automatic.module.name>
34-
<hamcrest.version>2.2</hamcrest.version>
36+
<automatic.module.name>\${project.groupId}.compat-tests-hamcrest-${HAMCREST_VERSION}</automatic.module.name>
37+
<hamcrest.version>${HAMCREST_VERSION}</hamcrest.version>
3538
</properties>
3639
3740
<dependencies>
@@ -48,13 +51,13 @@
4851
<dependency>
4952
<groupId>org.hamcrest</groupId>
5053
<artifactId>hamcrest-core</artifactId>
51-
<version>${hamcrest.version}</version>
54+
<version>\${hamcrest.version}</version>
5255
<scope>test</scope>
5356
</dependency>
5457
<dependency>
5558
<groupId>org.hamcrest</groupId>
5659
<artifactId>hamcrest-library</artifactId>
57-
<version>${hamcrest.version}</version>
60+
<version>\${hamcrest.version}</version>
5861
<scope>test</scope>
5962
</dependency>
6063
<dependency>
@@ -69,3 +72,41 @@
6972
</dependency>
7073
</dependencies>
7174
</project>
75+
EOF
76+
77+
cat > ${SCRATCH_DIR}/src/test/java/org/xmlunit/TestResources.java <<'EOF'
78+
/*
79+
This file is licensed to You under the Apache License, Version 2.0
80+
(the "License"); you may not use this file except in compliance with
81+
the License. You may obtain a copy of the License at
82+
83+
http://www.apache.org/licenses/LICENSE-2.0
84+
85+
Unless required by applicable law or agreed to in writing, software
86+
distributed under the License is distributed on an "AS IS" BASIS,
87+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
88+
See the License for the specific language governing permissions and
89+
limitations under the License.
90+
*/
91+
package org.xmlunit;
92+
93+
public final class TestResources {
94+
public static final String TEST_RESOURCE_DIR = "../../../test-resources/";
95+
96+
public static final String ANIMAL_FILE = TEST_RESOURCE_DIR + "test1.xml";
97+
public static final String BLAME_FILE = TEST_RESOURCE_DIR + "test.blame.html";
98+
public static final String ANIMAL_XSL = TEST_RESOURCE_DIR + "animal.xsl";
99+
public static final String DOG_FILE = TEST_RESOURCE_DIR + "testAnimal.xml";
100+
101+
public static final String BOOK_DTD = TEST_RESOURCE_DIR + "Book.dtd";
102+
public static final String BOOK_XSD = TEST_RESOURCE_DIR + "Book.xsd";
103+
104+
private TestResources() { }
105+
}
106+
EOF
107+
108+
cp -r ../xmlunit-matchers/src/test/java/org/xmlunit/bugreports ${SCRATCH_DIR}/src/test/java/org/xmlunit
109+
cp -r ../xmlunit-matchers/src/test/java/org/xmlunit/matchers ${SCRATCH_DIR}/src/test/java/org/xmlunit
110+
111+
mvn -f ${SCRATCH_DIR}/pom.xml test
112+

0 commit comments

Comments
 (0)