Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/test/java/com/rabbitmq/client/AbstractJsonRpcTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ public void init() throws Exception {
clientChannel = clientConnection.createChannel();
serverConnection = TestUtils.connectionFactory().newConnection();
serverChannel = serverConnection.createChannel();
serverChannel.queueDeclare(queue, false, false, false, null);
serverChannel.queueDelete(queue);
serverChannel.queueDeclare(queue, true, false, false, null);
server = new JsonRpcServer(serverChannel, queue, RpcService.class, new DefaultRpcservice(), createMapper());
new Thread(() -> {
try {
Expand Down
10 changes: 6 additions & 4 deletions src/test/java/com/rabbitmq/client/test/BrokerTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,14 @@ protected void declareDurableQueue(String q) throws IOException {
channel.queueDeclare(q, true, false, false, null);
}

protected void declareTransientQueue(String q) throws IOException {
channel.queueDeclare(q, false, false, false, null);
protected void deleteAndDeclareQueue(String q) throws IOException {
channel.queueDelete(q);
channel.queueDeclare(q, true, false, false, null);
}

protected void declareTransientQueue(String q, Map<String, Object> args) throws IOException {
channel.queueDeclare(q, false, false, false, args);
protected void deleteAndDeclareQueue(String q, Map<String, Object> args) throws IOException {
channel.queueDelete(q);
channel.queueDeclare(q, true, false, false, args);
}

protected void declareDurableTopicExchange(String x) throws IOException {
Expand Down
3 changes: 2 additions & 1 deletion src/test/java/com/rabbitmq/client/test/Bug20004Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ public void bug20004() throws InterruptedException {
() -> {
try {
synchronized (channel) {
channel.queueDeclare("Bug20004Test", false, false, false, null);
channel.queueDelete("Bug20004Test");
channel.queueDeclare("Bug20004Test", true, false, false, null);
testInstance.created = true;
}
} catch (Exception e) {
Expand Down
8 changes: 7 additions & 1 deletion src/test/java/com/rabbitmq/client/test/CloseInMainLoop.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ public void closeWithFaultyConsumer() throws Exception {
SpecialConnection connection = new SpecialConnection();
Channel channel = connection.createChannel();
channel.exchangeDeclare(x, "direct");
channel.queueDeclare(q, false, false, false, null);
channel.queueDelete(q);
channel.queueDeclare(q, true, false, false, null);
channel.queueBind(q, x, "k");

channel.basicConsume(
Expand All @@ -128,5 +129,10 @@ public void handleDelivery(

assertTrue(closeLatch.await(1000, TimeUnit.MILLISECONDS));
assertTrue(connection.hadValidShutdown());

Channel cleanupCh = this.connection.createChannel();
cleanupCh.queueDelete(q);
cleanupCh.exchangeDelete(x);
cleanupCh.close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private static void safeClose(Connection c) {
@Override
protected void createResources() throws IOException, TimeoutException {
q = generateQueueName();
declareTransientQueue(q);
deleteAndDeclareQueue(q);
super.createResources();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

package com.rabbitmq.client.test;

import java.io.IOException;
import java.util.concurrent.atomic.AtomicReference;

import org.junit.jupiter.api.Test;
Expand All @@ -28,15 +29,22 @@ public class MultiThreadedChannel extends BrokerTestCase {

private static final String DUMMY_EXCHANGE_NAME = "dummy.exchange";

@Override
protected void releaseResources() throws IOException {
channel.queueDelete(DUMMY_QUEUE_NAME);
channel.exchangeDelete(DUMMY_EXCHANGE_NAME);
}

@Test public void interleavedRpcs() throws Throwable {
channel.queueDelete(DUMMY_QUEUE_NAME);

final AtomicReference<Throwable> throwableRef = new AtomicReference<Throwable>(null);

Thread queueDeclare = new Thread(new Runnable() {
public void run() {
try {
for (int x = 0; x < 100; x++) {
channel.queueDeclare(DUMMY_QUEUE_NAME, false, false, true, null);
channel.queueDeclare(DUMMY_QUEUE_NAME, true, false, true, null);
}
} catch (Throwable e) {
throwableRef.set(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public class NoAutoRecoveryWhenTcpWindowIsFullTest {
private AutorecoveringChannel consumingChannel;

private CountDownLatch consumerOkLatch;
private String testQueue;

@BeforeEach
public void setUp() throws Exception {
Expand Down Expand Up @@ -115,16 +116,22 @@ public void configure(Socket socket) throws IOException {
}

@AfterEach
public void tearDown() throws IOException {
public void tearDown() throws Exception {
closeConnectionIfOpen(consumingConnection);
closeConnectionIfOpen(producingConnection);

if (testQueue != null) {
ConnectionFactory cf = TestUtils.connectionFactory();
try (Connection c = cf.newConnection(); Channel ch = c.createChannel()) {
ch.queueDelete(testQueue);
}
}
executorService.shutdownNow();
}

@Test
public void failureAndRecovery() throws IOException, InterruptedException {
final String queue = UUID.randomUUID().toString();
this.testQueue = queue;

final CountDownLatch recoveryLatch = new CountDownLatch(1);

Expand Down Expand Up @@ -161,7 +168,8 @@ private void closeConnectionIfOpen(Connection connection) throws IOException {

private void declareQueue(final Channel channel, final String queue) throws IOException {
final Map<String, Object> queueArguments = new HashMap<String, Object>();
channel.queueDeclare(queue, false, false, false, queueArguments);
channel.queueDelete(queue);
channel.queueDeclare(queue, true, false, false, queueArguments);
}

private void produceMessagesInBackground(final Channel channel, final String queue) throws IOException {
Expand Down
3 changes: 2 additions & 1 deletion src/test/java/com/rabbitmq/client/test/RpcTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ public void init() throws Exception {
clientChannel = clientConnection.createChannel();
serverConnection = TestUtils.connectionFactory().newConnection();
serverChannel = serverConnection.createChannel();
serverChannel.queueDeclare(queue, false, false, false, null);
serverChannel.queueDelete(queue);
serverChannel.queueDeclare(queue, true, false, false, null);
}

@AfterEach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ public void handleReturn(int replyCode,

@Override protected void createResources() throws IOException {
for (String q : resources) {
channel.queueDeclare(q, false, false, false, null);
channel.queueDelete(q);
channel.queueDeclare(q, true, false, false, null);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ protected static String randomString() {

protected void createQueueAndBindToExchange(Binding binding, boolean durable) throws IOException {
channel.exchangeDeclare(binding.x, "direct", durable);
channel.queueDeclare(binding.q, durable, false, false, null);
channel.queueDelete(binding.q);
channel.queueDeclare(binding.q, true, false, false, null);
channel.queueBind(binding.q, binding.x, binding.k);
}

Expand All @@ -77,13 +78,13 @@ protected void doAutoDelete(boolean durable, int queues) throws IOException, Tim
List<String> queueNames = new ArrayList<>();
Binding binding = Binding.randomBinding();
channel.exchangeDeclare(binding.x, "direct", durable, true, null);
channel.queueDeclare(binding.q, durable, false, true, null);
channel.queueDeclare(binding.q, durable, !durable, true, null);
channel.queueBind(binding.q, binding.x, binding.k);
if (queues > 1) {
int j = queues - 1;
for (int i = 0; i < j; i++) {
queueNames.add(randomString());
channel.queueDeclare(queueNames.get(i), durable, false, false, null);
channel.queueDeclare(queueNames.get(i), durable, !durable, false, null);
channel.queueBind(queueNames.get(i), binding.x, binding.k);
channel.basicConsume(queueNames.get(i), true, new QueueingConsumer(channel));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public class CcRoutes extends BrokerTestCase {
.collect(Collectors.toList())
.toArray(new String[]{});
for (String q : queues) {
channel.queueDeclare(q, false, false, true, null);
channel.queueDeclare(q, true, false, true, null);
}
channel.exchangeDeclare(exDirect, "direct", false, true, null);
channel.exchangeDeclare(exTopic, "topic", false, true, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private boolean clustered(Connection c1, Connection c2) throws IOException {
Channel ch1 = c1.createChannel();
Channel ch2 = c2.createChannel();
// autodelete but not exclusive
String q = ch1.queueDeclare("", false, false, true, null).getQueue();
String q = ch1.queueDeclare("", true, false, true, null).getQueue();

try {
ch2.queueDeclarePassive(q);
Expand Down
Loading
Loading