Skip to content

Commit c110d96

Browse files
committed
Add test to check SAC must have a name
References #46, rabbitmq/rabbitmq-server#3753
1 parent d4e3af8 commit c110d96

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/test/java/com/rabbitmq/stream/impl/SacClientTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
1414
package com.rabbitmq.stream.impl;
1515

16+
import static com.rabbitmq.stream.impl.TestUtils.ResponseConditions.ko;
1617
import static com.rabbitmq.stream.impl.TestUtils.ResponseConditions.ok;
18+
import static com.rabbitmq.stream.impl.TestUtils.ResponseConditions.responseCode;
1719
import static com.rabbitmq.stream.impl.TestUtils.b;
1820
import static com.rabbitmq.stream.impl.TestUtils.declareSuperStreamTopology;
1921
import static com.rabbitmq.stream.impl.TestUtils.deleteSuperStreamTopology;
@@ -574,4 +576,17 @@ void superStreamRebalancingShouldWorkWhilePublishing(TestInfo info) throws Excep
574576
deleteSuperStreamTopology(c, superStream, 3);
575577
}
576578
}
579+
580+
@Test
581+
void singleActiveConsumerMustHaveName() {
582+
Client client = cf.get();
583+
Response response =
584+
client.subscribe(
585+
b(0),
586+
stream,
587+
OffsetSpecification.first(),
588+
10,
589+
Collections.singletonMap("single-active-consumer", "true"));
590+
assertThat(response).is(ko()).has(responseCode(Constants.RESPONSE_CODE_PRECONDITION_FAILED));
591+
}
577592
}

src/test/java/com/rabbitmq/stream/impl/TestUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,11 +369,11 @@ static CountDownLatchAssert latchAssert(AtomicReference<CountDownLatch> latchRef
369369
static class ResponseConditions {
370370

371371
static Condition<Response> ok() {
372-
return new Condition<>(Response::isOk, "Response should be OK");
372+
return new Condition<>(Response::isOk, "OK");
373373
}
374374

375375
static Condition<Response> ko() {
376-
return new Condition<>(response -> !response.isOk(), "Response should be OK");
376+
return new Condition<>(response -> !response.isOk(), "KO");
377377
}
378378

379379
static Condition<Response> responseCode(short expectedResponse) {

0 commit comments

Comments
 (0)