Skip to content

Commit 86827c2

Browse files
committed
Fix test
Relying on the name of the metadata host does not work when the broker advertised_host setting is set.
1 parent 018cfb8 commit 86827c2

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -901,13 +901,15 @@ void methodsShouldThrowExceptionWhenConsumerIsClosed() {
901901
@Test
902902
void creationShouldFailWithDetailsWhenUnknownHost() {
903903
Address localhost = localhost();
904+
// first connection is locator
905+
AtomicInteger connectionCount = new AtomicInteger(0);
904906
EnvironmentBuilder builder =
905907
environmentBuilder()
906908
.host(localhost.host())
907909
.port(localhost.port())
908910
.addressResolver(
909911
n ->
910-
n.equals(localhost)
912+
connectionCount.getAndIncrement() == 0
911913
? n
912914
: new Address(UUID.randomUUID().toString(), Client.DEFAULT_PORT));
913915
try (Environment env = builder.build()) {

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,13 +644,15 @@ void methodsShouldThrowExceptionWhenProducerIsClosed() throws InterruptedExcepti
644644
@Test
645645
void creationShouldFailWithDetailsWhenUnknownHost() {
646646
Address localhost = localhost();
647+
// first connection is locator
648+
AtomicInteger connectionCount = new AtomicInteger(0);
647649
EnvironmentBuilder builder =
648650
environmentBuilder()
649651
.host(localhost.host())
650652
.port(localhost.port())
651653
.addressResolver(
652654
n ->
653-
n.equals(localhost)
655+
connectionCount.getAndIncrement() == 0
654656
? n
655657
: new Address(UUID.randomUUID().toString(), Client.DEFAULT_PORT));
656658
try (Environment env = builder.build()) {

0 commit comments

Comments
 (0)