Fix broker cleanup after tests

- `RabbitBinderTests` automatically clean up but remove declaration of an unused queue
- `RabbitBinderModuleTests` didn't clean up properly.

Resolves #138
This commit is contained in:
Gary Russell
2018-03-08 14:34:16 -05:00
committed by Oleg Zhurakousky
parent 79a42e33ae
commit 4b36d1cb0d
2 changed files with 7 additions and 14 deletions

View File

@@ -19,7 +19,6 @@ package org.springframework.cloud.stream.binder.rabbit;
import java.lang.reflect.Constructor;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
@@ -993,14 +992,6 @@ public class RabbitBinderTests extends
@Test
public void testAutoBindDLQwithRepublish() throws Exception {
// pre-declare the queue with dead-lettering, users can also use a policy
RabbitAdmin admin = new RabbitAdmin(this.rabbitAvailableRule.getResource());
Map<String, Object> args = new HashMap<String, Object>();
args.put("x-dead-letter-exchange", TEST_PREFIX + "DLX");
args.put("x-dead-letter-routing-key", TEST_PREFIX + "dlqpubtest.default");
Queue queue = new Queue(TEST_PREFIX + "dlqpubtest.default", true, false, false, args);
admin.declareQueue(queue);
RabbitTestBinder binder = getBinder();
ExtendedConsumerProperties<RabbitConsumerProperties> consumerProperties = createConsumerProperties();
consumerProperties.getExtension().setPrefix(TEST_PREFIX);

View File

@@ -19,6 +19,7 @@ package org.springframework.cloud.stream.binder.rabbit.integration;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.junit.After;
import org.junit.ClassRule;
@@ -87,10 +88,8 @@ public class RabbitBinderModuleTests {
context = null;
}
RabbitAdmin admin = new RabbitAdmin(rabbitTestSupport.getResource());
admin.deleteQueue("binder.input.default");
admin.deleteQueue("binder.output.default");
admin.deleteExchange("binder.input");
admin.deleteExchange("binder.output");
admin.deleteExchange("input");
admin.deleteExchange("output");
}
@Test
@@ -132,6 +131,7 @@ public class RabbitBinderModuleTests {
ConnectionNameStrategy cns = TestUtils.getPropertyValue(cf, "connectionNameStrategy",
ConnectionNameStrategy.class);
assertThat(cns.obtainNewConnectionName(cf)).isEqualTo("foo#2");
new RabbitAdmin(rabbitTestSupport.getResource()).deleteExchange("checkPF");
}
@Test
@@ -240,7 +240,8 @@ public class RabbitBinderModuleTests {
.getPropertyValue("indicators");
assertThat(healthIndicators).containsKey("custom");
assertThat(healthIndicators.get("custom").health().getStatus()).isEqualTo(Status.UP);
Binding<MessageChannel> binding = binder.bindProducer("foo", new DirectChannel(),
String name = UUID.randomUUID().toString();
Binding<MessageChannel> binding = binder.bindProducer(name, new DirectChannel(),
new ExtendedProducerProperties<>(new RabbitProducerProperties()));
RetryTemplate template = TestUtils.getPropertyValue(binding, "lifecycle.amqpTemplate.retryTemplate",
RetryTemplate.class);
@@ -253,6 +254,7 @@ public class RabbitBinderModuleTests {
assertThat(backOff.getMultiplier()).isEqualTo(1.1);
assertThat(backOff.getMaxInterval()).isEqualTo(3000L);
binding.unbind();
new RabbitAdmin(rabbitTestSupport.getResource()).deleteExchange(name);
context.close();
}