Skip to content

Commit

Permalink
RabbitMQ: Support declaring an exchange within a vhost (testcontainer…
Browse files Browse the repository at this point in the history
  • Loading branch information
dangets authored and quincy committed May 28, 2020
1 parent dd8cfef commit c32098f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
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

0 comments on commit c32098f

Please sign in to comment.