Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RabbitMQ: Support declaring an exchange within a vhost #2362

Merged
merged 2 commits into from
May 7, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,17 @@ public RabbitMQContainer withExchange(String name, String type) {

public RabbitMQContainer withExchange(String name, String type, boolean autoDelete, boolean internal, boolean durable, Map<String, Object> arguments) {
values.add(asList("rabbitmqadmin", "declare", "exchange",
"name=" + name,
"type=" + type,
"auto_delete=" + autoDelete,
"internal=" + internal,
"durable=" + durable,
"arguments=" + toJson(arguments)));
return self();
}

public RabbitMQContainer withExchange(String vhost, String name, String type, boolean autoDelete, boolean internal, boolean durable, Map<String, Object> arguments) {
values.add(asList("rabbitmqadmin", "--vhost=" + vhost, "declare", "exchange",
"name=" + name,
"type=" + type,
"auto_delete=" + autoDelete,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.security.NoSuchAlgorithmException;
import java.security.UnrecoverableKeyException;
import java.security.cert.CertificateException;
import java.util.Collections;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManagerFactory;
Expand Down Expand Up @@ -91,6 +92,20 @@ public void shouldCreateRabbitMQContainerWithExchange() throws IOException, Inte
}
}

@Test
public void shouldCreateRabbitMQContainerWithExchangeInVhost() throws IOException, InterruptedException
{
try (RabbitMQContainer container = new RabbitMQContainer()) {
container.withVhost("test-vhost");
container.withExchange("test-vhost", "test-exchange", "direct", false, false, false, Collections.emptyMap());

container.start();

assertThat(container.execInContainer("rabbitmqctl", "list_exchanges", "-p", "test-vhost").getStdout())
.containsPattern("test-exchange\\s+direct");
}
}

@Test
public void shouldCreateRabbitMQContainerWithQueues() throws IOException, InterruptedException
{
Expand Down