Skip to content

Commit

Permalink
WIP AssertJ 3.x specific module in order to address #203
Browse files Browse the repository at this point in the history
Right now this is a repackaged copy of xmlunit-assertj with the
workarounds for #181 and #161 removed.

This is not the final solution, I'll try to extract common APIs (and
tests) for xmlunit-assertj and xmlunit-assertj3 in order to reduce
code duplication later.
  • Loading branch information
bodewig committed Nov 3, 2020
1 parent 2a69e26 commit fe24b75
Show file tree
Hide file tree
Showing 44 changed files with 5,699 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pom.xml
Expand Up @@ -488,6 +488,9 @@
<activeByDefault>false</activeByDefault>
<jdk>[1.8,)</jdk>
</activation>
<modules>
<module>xmlunit-assertj3</module>
</modules>
<properties>
<javadoc.additionalparam>-Xdoclint:html,syntax,accessibility,reference</javadoc.additionalparam>
</properties>
Expand Down
68 changes: 68 additions & 0 deletions xmlunit-assertj3/pom.xml
@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<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/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>xmlunit-parent</artifactId>
<groupId>org.xmlunit</groupId>
<version>2.8.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<properties>
<automatic.module.name>${project.groupId}.assertj3</automatic.module.name>
<maven.compile.source>8</maven.compile.source>
<maven.compile.target>8</maven.compile.target>
</properties>

<artifactId>xmlunit-assertj3</artifactId>
<name>org.xmlunit:xmlunit-assertj3</name>
<description>XMLUnit with AssertJ 3.x fluent API</description>
<url>https://www.xmlunit.org/</url>

<dependencies>
<dependency>
<groupId>org.xmlunit</groupId>
<artifactId>xmlunit-core</artifactId>
</dependency>
<dependency>
<groupId>org.xmlunit</groupId>
<artifactId>xmlunit-core</artifactId>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.18.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
@@ -0,0 +1,67 @@
/*
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.assertj3;

import org.assertj.core.api.AbstractBooleanAssert;
import org.assertj.core.api.AbstractCharSequenceAssert;
import org.assertj.core.api.AbstractDoubleAssert;
import org.assertj.core.api.AbstractIntegerAssert;
import org.assertj.core.api.AbstractObjectArrayAssert;
import org.assertj.core.api.AbstractObjectAssert;
import org.assertj.core.api.BooleanAssert;
import org.assertj.core.api.DoubleAssert;
import org.assertj.core.api.IntegerAssert;
import org.assertj.core.api.ObjectArrayAssert;
import org.assertj.core.api.ObjectAssert;
import org.assertj.core.api.StringAssert;

/**
* Class that is proxy for AssertJ assertions used by org.xmlunit.assertj.*Assert classes.
*
* <p>XMLUnit AssertJ tends to break binary compatibility of the
* assertThat methods from time to time so we shield ourselves from
* these changes a bit.</p>
*
* @see <a href="https://github.com/xmlunit/xmlunit/issues/135">GitHub issue #135</a>
* @since XMLUnit 2.8.1
*/
final class AssertionsAdapter {

private AssertionsAdapter() {
}

static <T> AbstractObjectAssert<?, T> assertThat(T actual) {
return new ObjectAssert<>(actual);
}

static <T> AbstractObjectArrayAssert<?, T> assertThat(T[] actual) {
return new ObjectArrayAssert<>(actual);
}

static AbstractCharSequenceAssert<?, String> assertThat(String actual) {
return new StringAssert(actual);
}

static AbstractIntegerAssert<?> assertThat(int actual) {
return new IntegerAssert(actual);
}

static AbstractDoubleAssert<?> assertThat(double actual) {
return new DoubleAssert(actual);
}

static AbstractBooleanAssert<?> assertThat(boolean actual) {
return new BooleanAssert(actual);
}
}

0 comments on commit fe24b75

Please sign in to comment.