18
18
import org .jabref .model .util .DummyFileUpdateMonitor ;
19
19
20
20
import org .junit .jupiter .api .BeforeEach ;
21
- import org .junit .jupiter .api .Disabled ;
22
21
import org .junit .jupiter .api .io .TempDir ;
23
22
import org .junit .jupiter .params .ParameterizedTest ;
24
23
import org .junit .jupiter .params .provider .MethodSource ;
25
24
import org .mockito .Answers ;
26
25
import org .mockito .Mockito ;
26
+ import org .xmlunit .diff .DefaultNodeMatcher ;
27
+ import org .xmlunit .diff .ElementSelectors ;
27
28
29
+ import static org .hamcrest .MatcherAssert .assertThat ;
28
30
import static org .junit .jupiter .api .Assertions .assertEquals ;
29
31
import static org .mockito .Mockito .mock ;
32
+ import static org .xmlunit .matchers .CompareMatcher .isSimilarTo ;
30
33
31
34
public class ModsExportFormatTestFiles {
32
35
@@ -66,7 +69,6 @@ public void setUp(@TempDir Path testFolder) throws Exception {
66
69
67
70
@ ParameterizedTest
68
71
@ MethodSource ("fileNames" )
69
- @ Disabled ("Ordering of XML elements changed 2019-08-25" )
70
72
public final void testPerformExport (String filename ) throws Exception {
71
73
importFile = Paths .get (ModsExportFormatTestFiles .class .getResource (filename ).toURI ());
72
74
String xmlFileName = filename .replace (".bib" , ".xml" );
@@ -75,9 +77,16 @@ public final void testPerformExport(String filename) throws Exception {
75
77
76
78
exporter .export (databaseContext , tempFile , charset , entries );
77
79
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 )));
81
90
}
82
91
83
92
@ ParameterizedTest
0 commit comments