Skip to content

Commit

Permalink
more tests affected by message changes in AssertJ 3.19.0
Browse files Browse the repository at this point in the history
see #212
  • Loading branch information
bodewig committed Feb 4, 2021
1 parent f7d5a28 commit db2ff6c
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 16 deletions.
4 changes: 4 additions & 0 deletions RELEASE_NOTES.md
Expand Up @@ -2,6 +2,10 @@

## XMLUnit for Java 2.8.3 - /not released, yet/

* adjusted unit tests so they pass when AssertJ 3.19.0 is used.
[#212](https://github.com/xmlunit/xmlunit/pull/212) by
[mmathesius](https://github.com/mmathesius)

## XMLUnit for Java 2.8.2 - /Released 2020-12-21/

* `CompareAssert` inside the AssertJ3 module swapped the expected and
Expand Down
Expand Up @@ -43,17 +43,17 @@ public void testAssertThat_withNull_shouldFailed() {
}

@Test
public void testNodesByXPath_withNull_shouldFailed() {
public void testNodesByXPath_withNull_shouldFail() {

thrown.expectAssertionError(format("%nExpecting not blank but was:<null>"));
thrown.expectAssertionErrorPattern(format("%nExpecting not blank but was:(<| )null>?"));

assertThat("<a><b></b><c/></a>").nodesByXPath(null);
}

@Test
public void testNodesByXPath_withWhitespacesOnly_shouldFailed() {
public void testNodesByXPath_withWhitespacesOnly_shouldFail() {

thrown.expectAssertionError(format("%nExpecting not blank but was:<\" \n \t\">"));
thrown.expectAssertionErrorPattern(format("%nExpecting not blank but was:(<| )\" \n \t\">?"));

assertThat("<a><b></b><c/></a>").nodesByXPath(" \n \t");
}
Expand Down
Expand Up @@ -31,17 +31,17 @@ public class XmlAssertValueByXPathTest {
public static SetEnglishLocaleRule locale = new SetEnglishLocaleRule();

@Test
public void testValueByXPath_withNull_shouldFailed() {
public void testValueByXPath_withNull_shouldFail() {

thrown.expectAssertionError(format("%nExpecting not blank but was:<null>"));
thrown.expectAssertionErrorPattern(format("%nExpecting not blank but was:(<| )null>?"));

assertThat("<a><b></b><c/></a>").valueByXPath(null);
}

@Test
public void testValueByXPath_withWhitespacesOnly_shouldFailed() {
public void testValueByXPath_withWhitespacesOnly_shouldFail() {

thrown.expectAssertionError(format("%nExpecting not blank but was:<\" \n \t\">"));
thrown.expectAssertionErrorPattern(format("%nExpecting not blank but was:(<| )\" \n \t\">?"));

assertThat("<a><b></b><c/></a>").valueByXPath(" \n \t");
}
Expand Down
Expand Up @@ -24,6 +24,7 @@
import java.io.ByteArrayInputStream;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.regex.Pattern;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
Expand Down Expand Up @@ -263,7 +264,13 @@ public void testIsEqualTo_withAttributeValueExpression_shouldPass() {
@Test
public void testIsEqualTo_withAttributeValueExpression_shouldFailed() {

thrown.expectAssertionError("expected:<\"[something]\"> but was:<\"[abc]\">");
thrown.expectAssertionErrorPattern(".*("
// AssertJ 3.18.1
+ Pattern.quote("expected:<\"[something]\"> but was:<\"[abc]\">")
+ "|"
// AssertJ 3.19.0+
+ Pattern.quote("Expecting:\n <\"abc\">\nto be equal to:\n <\"something\">\nbut was not.")
+ ")");

String xml = "<a><b attr=\"abc\"></b></a>";

Expand Down
Expand Up @@ -43,17 +43,17 @@ public void testAssertThat_withNull_shouldFailed() {
}

@Test
public void testNodesByXPath_withNull_shouldFailed() {
public void testNodesByXPath_withNull_shouldFail() {

thrown.expectAssertionError(format("%nExpecting not blank but was:<null>"));
thrown.expectAssertionErrorPattern(format("%nExpecting not blank but was:(<| )null>?"));

assertThat("<a><b></b><c/></a>").nodesByXPath(null);
}

@Test
public void testNodesByXPath_withWhitespacesOnly_shouldFailed() {
public void testNodesByXPath_withWhitespacesOnly_shouldFail() {

thrown.expectAssertionError(format("%nExpecting not blank but was:<\" \n \t\">"));
thrown.expectAssertionErrorPattern(format("%nExpecting not blank but was:(<| )\" \n \t\">?"));

assertThat("<a><b></b><c/></a>").nodesByXPath(" \n \t");
}
Expand Down
Expand Up @@ -31,17 +31,17 @@ public class XmlAssertValueByXPathTest {
public static SetEnglishLocaleRule locale = new SetEnglishLocaleRule();

@Test
public void testValueByXPath_withNull_shouldFailed() {
public void testValueByXPath_withNull_shouldFail() {

thrown.expectAssertionError(format("%nExpecting not blank but was:<null>"));
thrown.expectAssertionErrorPattern(format("%nExpecting not blank but was:(<| )null>?"));

assertThat("<a><b></b><c/></a>").valueByXPath(null);
}

@Test
public void testValueByXPath_withWhitespacesOnly_shouldFailed() {

thrown.expectAssertionError(format("%nExpecting not blank but was:<\" \n \t\">"));
thrown.expectAssertionErrorPattern(format("%nExpecting not blank but was:(<| )\" \n \t\">?"));

assertThat("<a><b></b><c/></a>").valueByXPath(" \n \t");
}
Expand Down

0 comments on commit db2ff6c

Please sign in to comment.