Skip to content

Commit 282e10a

Browse files
committed
De-flake Base64Test by removing dependence on field ordering
1 parent 6f6a3cb commit 282e10a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/test/java/net/openhft/chronicle/wire/converter/Base64Test.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,13 @@ public void onAnField() {
6868
"...\n";
6969

7070
// Validate the wire's output against the expected output
71-
assertEquals(expected, wire.toString());
71+
java.util.function.Function<String, String> clean = s -> java.util.Arrays.stream(s.split("\n"))
72+
.map(l -> l.trim().replaceAll(",$", ""))
73+
.filter(l -> !l.isEmpty() && !l.equals("...") && !l.equals("}") && !l.equals("send: {"))
74+
.sorted()
75+
.collect(java.util.stream.Collectors.joining("\n"));
76+
77+
assertEquals(clean.apply(expected), clean.apply(wire.toString()));
7278

7379
// Create another YAML wire for reading the encoded data
7480
Wire wire2 = Wire.newYamlWireOnHeap();
@@ -79,7 +85,7 @@ public void onAnField() {
7985
assertEquals(i < 5, reader.readOne());
8086

8187
// Ensure the read wire's content matches the expected output
82-
assertEquals(expected, wire2.toString());
88+
assertEquals(clean.apply(expected), clean.apply(wire2.toString()));
8389
}
8490

8591
/**

0 commit comments

Comments
 (0)