You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I changend \R to (\r\n?|\n) for assertj module and saved \R for assertj3 module because it's always run on Java 8.
Now all works correctly both on Windows + Java 8 and Linux + Java 7+.
Is it necessary to replace the %n sequence in expectAssertionError? Doesn't the format string help with the platform sensitivity? I'm really just asking here as I must admit I haven't tried to build XMLUnit on Windows for quite some time now.
Is it necessary to replace the %n sequence in expectAssertionError? Doesn't the format string help with the platform sensitivity?
In this case format() can't help because javax.xml.parsers.DocumentBuilder always parse \r\n as \n.
Let's look at this test case tightly: we have a test XML
which one will be format in Windows to "<a>\r\nx <b/>\r\n</a>".
After that this model will be parsed by javax.xml.parsers.DocumentBuilder in org.xmlunit.util.Convert#toDocument(javax.xml.transform.Source, javax.xml.parsers.DocumentBuilderFactory) method. DocumentBuilder always parse both \r\n and \n as \n. So we will have Document with two nodes with values \nx and \n (I checked this by debugging). DiffBuilder will find difference between \nx in actual document and x in expected document and throw out comparison result with message "Expected text value 'x' but was '\nx '".
If we will expect formatted line "Expected text value 'x' but was '%nx '" than %n will be convert to \r\n and assertion will fail.
That's why we should use \n instead of %n in ExpectedException configuration.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Linked issue: #252