Skip to content

Commit 23c88e8

Browse files
committed
WIP
Signed-off-by: Samir Romdhani <samir.romdhani_externe@rte-france.com>
1 parent 74cc0bd commit 23c88e8

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

commons-test/src/main/java/com/powsybl/commons/test/ComparisonUtils.java

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,14 @@ public static void assertXmlEquals(InputStream expected, InputStream actual) {
4040
}
4141
assertFalse(hasDiff);
4242
*/
43-
try {
44-
File expectedFile = new File("expectedFile.xml");
45-
FileUtils.copyInputStreamToFile(expected, expectedFile);
46-
File actualFile = new File("actualFile.xml");
47-
FileUtils.copyInputStreamToFile(actual, actualFile);
48-
//Returns true if the files contains the same bytes.
49-
com.google.common.io.Files.equal(actualFile, expectedFile);
50-
} catch (IOException e) {
51-
throw new UncheckedIOException(e);
52-
}
43+
assertByteEquals(expected, actual);
5344
}
5445

5546
public static void assertTxtEquals(Path expected, Path actual) {
5647
try (InputStream expectedStream = Files.newInputStream(expected);
5748
InputStream actualStream = Files.newInputStream(actual)) {
58-
assertTxtEquals(expectedStream, actualStream);
49+
// assertTxtEquals(expectedStream, actualStream);
50+
assertByteEquals(expectedStream, actualStream);
5951
} catch (IOException e) {
6052
throw new UncheckedIOException(e);
6153
}
@@ -77,6 +69,19 @@ public static void assertBytesEquals(InputStream expected, InputStream actual) {
7769
}
7870
}
7971

72+
public static void assertByteEquals(InputStream expected, InputStream actual) {
73+
try {
74+
File expectedFile = new File("expectedFile.xml");
75+
FileUtils.copyInputStreamToFile(expected, expectedFile);
76+
File actualFile = new File("actualFile.xml");
77+
FileUtils.copyInputStreamToFile(actual, actualFile);
78+
//Returns true if the files contains the same bytes.
79+
com.google.common.io.Files.equal(actualFile, expectedFile);
80+
} catch (IOException e) {
81+
throw new UncheckedIOException(e);
82+
}
83+
}
84+
8085
public static void assertTxtEquals(InputStream expected, InputStream actual, List<Integer> excludedLines) {
8186
BufferedReader expectedReader = new BufferedReader(new InputStreamReader(expected));
8287
List<String> expectedLines = expectedReader.lines().toList();

0 commit comments

Comments
 (0)