Skip to content

Commit 538dbea

Browse files
mtopolnikclaude
andcommitted
Use the class rejection helper in the SF segment tests
The two storeAndForwardMaxSegmentBytes rejection tests spelled out try/fail/catch inline, 19 lines for what the class already expresses in one call. assertThrows(String, Runnable) is the dominant idiom here, used by roughly twenty other tests in the file, and it produces a better failure message than a bare Assert.fail. The assertion moves from message equality to containment. The expected text is the whole message in both cases, so the check is as strong as it was; a mutation run with both production guards removed fails both tests. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 558a70c commit 538dbea

1 file changed

Lines changed: 4 additions & 19 deletions

File tree

core/src/test/java/io/questdb/client/test/cutlass/qwp/client/LineSenderBuilderWebSocketTest.java

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -649,16 +649,8 @@ public void testStoreAndForwardMaxSegmentBytes() {
649649
public void testStoreAndForwardMaxSegmentBytesRejectsNonPositiveValues() {
650650
long[] rejected = {0L, -1L};
651651
for (long value : rejected) {
652-
try {
653-
Sender.builder(Sender.Transport.WEBSOCKET)
654-
.storeAndForwardMaxSegmentBytes(value);
655-
Assert.fail("expected storeAndForwardMaxSegmentBytes(" + value + ") to fail");
656-
} catch (LineSenderException expected) {
657-
Assert.assertEquals(
658-
"sf_max_segment_bytes must be positive: " + value,
659-
expected.getMessage()
660-
);
661-
}
652+
assertThrows("sf_max_segment_bytes must be positive: " + value,
653+
() -> Sender.builder(Sender.Transport.WEBSOCKET).storeAndForwardMaxSegmentBytes(value));
662654
}
663655
}
664656

@@ -670,15 +662,8 @@ public void testStoreAndForwardMaxSegmentBytesRejectedForNonWebSocketTransports(
670662
Sender.Transport.UDP
671663
};
672664
for (Sender.Transport transport : rejected) {
673-
try {
674-
Sender.builder(transport).storeAndForwardMaxSegmentBytes(64 * 1024L);
675-
Assert.fail("expected " + transport + " to reject storeAndForwardMaxSegmentBytes");
676-
} catch (LineSenderException expected) {
677-
Assert.assertEquals(
678-
"store_and_forward is only supported for WebSocket transport",
679-
expected.getMessage()
680-
);
681-
}
665+
assertThrows("store_and_forward is only supported for WebSocket transport",
666+
() -> Sender.builder(transport).storeAndForwardMaxSegmentBytes(64 * 1024L));
682667
}
683668
}
684669

0 commit comments

Comments
 (0)