Fix tests according new test events model in SF
https://build.spring.io/browse/INT-MASTER-1479 The `MicrometerCustomMetricsTests` and `MicrometerMetricsTests` close an application explicitly in the test, so we can't handle test events properly any more. Therefore use only `DependencyInjectionTestExecutionListener` excluding all others together with the `EventPublishingTestExecutionListener` The `TcpConfigInboundGatewayTests` don't need to use a static holder for the application context at all and, therefore, there is nothing to close in the `@After` any more There is reason to close an application context in the `StoredProcOutboundChannelAdapterWithinChainTests`. Other tests must take care about clean embedded DB before their start
This commit is contained in:
@@ -31,7 +31,9 @@ import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.config.EnableIntegrationManagement;
|
||||
import org.springframework.integration.support.management.metrics.MetricsCaptor;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.test.context.TestExecutionListeners;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
|
||||
|
||||
import io.micrometer.core.instrument.MeterRegistry;
|
||||
import io.micrometer.core.instrument.search.MeterNotFoundException;
|
||||
@@ -39,11 +41,13 @@ import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
|
||||
|
||||
/**
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
*
|
||||
* @since 5.1
|
||||
*
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@TestExecutionListeners(DependencyInjectionTestExecutionListener.class)
|
||||
public class MicrometerCustomMetricsTests {
|
||||
|
||||
@Autowired
|
||||
@@ -56,7 +60,7 @@ public class MicrometerCustomMetricsTests {
|
||||
private QueueChannel queue;
|
||||
|
||||
@Test
|
||||
public void testSend() throws Exception {
|
||||
public void testSend() {
|
||||
GenericMessage<String> message = new GenericMessage<>("foo");
|
||||
this.queue.send(message);
|
||||
this.queue.receive();
|
||||
@@ -112,6 +116,7 @@ public class MicrometerCustomMetricsTests {
|
||||
public MetricsCaptor captor() {
|
||||
return new CustomMetricsCaptor(meterRegistry());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static class CustomMetricsCaptor extends MicrometerMetricsCaptor {
|
||||
|
||||
@@ -49,7 +49,9 @@ import org.springframework.messaging.MessagingException;
|
||||
import org.springframework.messaging.PollableChannel;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.TestExecutionListeners;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
|
||||
|
||||
import io.micrometer.core.instrument.MeterRegistry;
|
||||
import io.micrometer.core.instrument.search.MeterNotFoundException;
|
||||
@@ -57,12 +59,14 @@ import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
|
||||
|
||||
/**
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
*
|
||||
* @since 5.0.2
|
||||
*
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@DirtiesContext
|
||||
@TestExecutionListeners(DependencyInjectionTestExecutionListener.class)
|
||||
public class MicrometerMetricsTests {
|
||||
|
||||
@Autowired
|
||||
@@ -91,7 +95,7 @@ public class MicrometerMetricsTests {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testSend() throws Exception {
|
||||
public void testSend() {
|
||||
GenericMessage<String> message = new GenericMessage<>("foo");
|
||||
this.channel.send(message);
|
||||
try {
|
||||
@@ -186,15 +190,15 @@ public class MicrometerMetricsTests {
|
||||
|
||||
// Test meter removal
|
||||
registry.get("spring.integration.send")
|
||||
.tag("name", "newChannel")
|
||||
.tag("result", "success")
|
||||
.timer();
|
||||
newChannel.destroy();
|
||||
try {
|
||||
registry.get("spring.integration.send")
|
||||
.tag("name", "newChannel")
|
||||
.tag("result", "success")
|
||||
.timer();
|
||||
newChannel.destroy();
|
||||
try {
|
||||
registry.get("spring.integration.send")
|
||||
.tag("name", "newChannel")
|
||||
.tag("result", "success")
|
||||
.timer();
|
||||
fail("Expected MeterNotFoundException");
|
||||
}
|
||||
catch (MeterNotFoundException e) {
|
||||
|
||||
Reference in New Issue
Block a user