1818import org .jabref .model .util .DummyFileUpdateMonitor ;
1919
2020import org .junit .jupiter .api .BeforeEach ;
21- import org .junit .jupiter .api .Disabled ;
2221import org .junit .jupiter .api .io .TempDir ;
2322import org .junit .jupiter .params .ParameterizedTest ;
2423import org .junit .jupiter .params .provider .MethodSource ;
2524import org .mockito .Answers ;
2625import org .mockito .Mockito ;
26+ import org .xmlunit .diff .DefaultNodeMatcher ;
27+ import org .xmlunit .diff .ElementSelectors ;
2728
29+ import static org .hamcrest .MatcherAssert .assertThat ;
2830import static org .junit .jupiter .api .Assertions .assertEquals ;
2931import static org .mockito .Mockito .mock ;
32+ import static org .xmlunit .matchers .CompareMatcher .isSimilarTo ;
3033
3134public class ModsExportFormatTestFiles {
3235
@@ -66,7 +69,6 @@ public void setUp(@TempDir Path testFolder) throws Exception {
6669
6770 @ ParameterizedTest
6871 @ MethodSource ("fileNames" )
69- @ Disabled ("Ordering of XML elements changed 2019-08-25" )
7072 public final void testPerformExport (String filename ) throws Exception {
7173 importFile = Paths .get (ModsExportFormatTestFiles .class .getResource (filename ).toURI ());
7274 String xmlFileName = filename .replace (".bib" , ".xml" );
@@ -75,9 +77,16 @@ public final void testPerformExport(String filename) throws Exception {
7577
7678 exporter .export (databaseContext , tempFile , charset , entries );
7779
78- assertEquals (
79- String .join ("\n " , Files .readAllLines (xmlFile )),
80- String .join ("\n " , Files .readAllLines (tempFile )));
80+ String expected = String .join ("\n " , Files .readAllLines (xmlFile ));
81+ String actual = String .join ("\n " , Files .readAllLines (tempFile ));
82+
83+ // The order of elements changes from Windows to Travis environment somehow
84+ // The order does not really matter, so we ignore it.
85+ // Source: https://stackoverflow.com/a/16540679/873282
86+ assertThat (expected , isSimilarTo (expected )
87+ .ignoreWhitespace ()
88+ .normalizeWhitespace ()
89+ .withNodeMatcher (new DefaultNodeMatcher (ElementSelectors .byNameAndText )));
8190 }
8291
8392 @ ParameterizedTest
0 commit comments