Skip to content

Commit

Permalink
generate Hamcrest compatibility tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bodewig committed May 3, 2020
1 parent cc1a76d commit 68138c8
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 52 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ target
.project
.idea
*.iml
/compat-tests/scratch/
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ addons:
install: true
script:
- mvn install -B
- mvn -f compat-tests/hamcrest-2.x/pom.xml test
- cd compat-tests && ./hamcrest-test.sh 2.6.5-SNAPSHOT 2.2
notifications:
email:
- [email protected]
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

83 changes: 62 additions & 21 deletions compat-tests/hamcrest-2.x/pom.xml → compat-tests/hamcrest-test.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,37 +1,40 @@
<?xml version="1.0"?>
<!--
This file is licensed 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
#!/bin/sh
set -e

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

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.
-->
XMLUNIT_VERSION=$1
HAMCREST_VERSION=$2

SCRATCH_DIR=scratch/hamcrest-${HAMCREST_VERSION}

rm -rf scratch && mkdir -p ${SCRATCH_DIR}/src/test/java/org/xmlunit/

cat > ${SCRATCH_DIR}/pom.xml <<EOF
<?xml version="1.0"?>
<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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.xmlunit</groupId>
<artifactId>xmlunit-parent</artifactId>
<version>2.6.5-SNAPSHOT</version>
<relativePath>../..</relativePath>
<version>${XMLUNIT_VERSION}</version>
<relativePath>../../..</relativePath>
</parent>
<groupId>org.xmlunit</groupId>
<artifactId>xmlunit-compat-tests-hamcrest-2.x</artifactId>
<artifactId>xmlunit-compat-tests-hamcrest-${HAMCREST_VERSION}</artifactId>
<packaging>jar</packaging>
<name>org.xmlunit:xmlunit-compat-tests-hamcrest-2.x</name>
<description>Verifies the Hamcrest Matchers are compatible with the latest version of Hamcrest</description>
<name>org.xmlunit:xmlunit-compat-tests-hamcrest-${HAMCREST_VERSION}</name>
<description>Verifies the Hamcrest Matchers are compatible with Hamcrest ${HAMCREST_VERSION}</description>
<url>https://www.xmlunit.org/</url>
<properties>
<automatic.module.name>${project.groupId}.compat-tests-hamcrest-2.x</automatic.module.name>
<hamcrest.version>2.2</hamcrest.version>
<automatic.module.name>\${project.groupId}.compat-tests-hamcrest-${HAMCREST_VERSION}</automatic.module.name>
<hamcrest.version>${HAMCREST_VERSION}</hamcrest.version>
</properties>
<dependencies>
Expand All @@ -48,13 +51,13 @@
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>${hamcrest.version}</version>
<version>\${hamcrest.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<version>${hamcrest.version}</version>
<version>\${hamcrest.version}</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -69,3 +72,41 @@
</dependency>
</dependencies>
</project>
EOF

cat > ${SCRATCH_DIR}/src/test/java/org/xmlunit/TestResources.java <<'EOF'
/*
This file is licensed 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.
*/
package org.xmlunit;
public final class TestResources {
public static final String TEST_RESOURCE_DIR = "../../../test-resources/";
public static final String ANIMAL_FILE = TEST_RESOURCE_DIR + "test1.xml";
public static final String BLAME_FILE = TEST_RESOURCE_DIR + "test.blame.html";
public static final String ANIMAL_XSL = TEST_RESOURCE_DIR + "animal.xsl";
public static final String DOG_FILE = TEST_RESOURCE_DIR + "testAnimal.xml";
public static final String BOOK_DTD = TEST_RESOURCE_DIR + "Book.dtd";
public static final String BOOK_XSD = TEST_RESOURCE_DIR + "Book.xsd";
private TestResources() { }
}
EOF

cp -r ../xmlunit-matchers/src/test/java/org/xmlunit/bugreports ${SCRATCH_DIR}/src/test/java/org/xmlunit
cp -r ../xmlunit-matchers/src/test/java/org/xmlunit/matchers ${SCRATCH_DIR}/src/test/java/org/xmlunit

mvn -f ${SCRATCH_DIR}/pom.xml test

0 comments on commit 68138c8

Please sign in to comment.