Add @DirtiesContext for some JMX tests
https://build.spring.io/browse/INT-B41X-121/
This commit is contained in:
@@ -31,6 +31,7 @@ import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.integration.endpoint.SourcePollingChannelAdapter;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.PollableChannel;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@@ -40,6 +41,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration
|
||||
@DirtiesContext
|
||||
public class MBeanAttributeFilterTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -96,6 +96,7 @@ public class NotificationListeningMessageProducerTests {
|
||||
assertEquals("foo", notification.getMessage());
|
||||
assertEquals(objectName, notification.getSource());
|
||||
assertNull(message.getHeaders().get(JmxHeaders.NOTIFICATION_HANDBACK));
|
||||
adapter.stop();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -119,6 +120,7 @@ public class NotificationListeningMessageProducerTests {
|
||||
assertEquals("foo", notification.getMessage());
|
||||
assertEquals(objectName, notification.getSource());
|
||||
assertEquals(handback, message.getHeaders().get(JmxHeaders.NOTIFICATION_HANDBACK));
|
||||
adapter.stop();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -148,6 +150,7 @@ public class NotificationListeningMessageProducerTests {
|
||||
assertTrue(message.getPayload() instanceof Notification);
|
||||
Notification notification = (Notification) message.getPayload();
|
||||
assertEquals("okay", notification.getMessage());
|
||||
adapter.stop();
|
||||
}
|
||||
|
||||
|
||||
@@ -176,6 +179,7 @@ public class NotificationListeningMessageProducerTests {
|
||||
Notification notification = new Notification("testType", this, sequence.getAndIncrement(), message);
|
||||
this.notificationPublisher.sendNotification(notification);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -29,6 +29,7 @@ import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.PollableChannel;
|
||||
import org.springframework.integration.endpoint.SourcePollingChannelAdapter;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@@ -39,6 +40,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@DirtiesContext
|
||||
public class AttributePollingChannelAdapterParserTests {
|
||||
|
||||
@Autowired
|
||||
@@ -63,6 +65,7 @@ public class AttributePollingChannelAdapterParserTests {
|
||||
Message<?> result = channel.receive(1000);
|
||||
assertNotNull(result);
|
||||
assertEquals("foo", result.getPayload());
|
||||
adapter.stop();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,16 +21,15 @@ import static org.junit.Assert.assertEquals;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
@@ -38,10 +37,12 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
/**
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
*
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
|
||||
public class DynamicRouterTests {
|
||||
|
||||
@Autowired
|
||||
@@ -65,7 +66,7 @@ public class DynamicRouterTests {
|
||||
private QueueChannel processCChannel;
|
||||
|
||||
|
||||
@Test @DirtiesContext
|
||||
@Test
|
||||
public void testRouteChange() throws Exception {
|
||||
routingChannel.send(new GenericMessage<String>("123"));
|
||||
assertEquals("123", processAChannel.receive(0).getPayload());
|
||||
@@ -78,7 +79,7 @@ public class DynamicRouterTests {
|
||||
assertEquals("123", processCChannel.receive(0).getPayload());
|
||||
}
|
||||
|
||||
@Test @DirtiesContext
|
||||
@Test
|
||||
public void testRouteChangeMap() throws Exception {
|
||||
routingChannel.send(new GenericMessage<String>("123"));
|
||||
assertEquals("123", processAChannel.receive(0).getPayload());
|
||||
@@ -94,8 +95,7 @@ public class DynamicRouterTests {
|
||||
assertEquals("123", processCChannel.receive(0).getPayload());
|
||||
}
|
||||
|
||||
@Test @DirtiesContext
|
||||
@Ignore // Requires Spring 3.2.3 TODO: Remove when minimum SF is >= 3.2.3
|
||||
@Test
|
||||
public void testRouteChangeMapNamedArgs() throws Exception {
|
||||
routingChannel.send(new GenericMessage<String>("123"));
|
||||
assertEquals("123", processAChannel.receive(0).getPayload());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013 the original author or authors.
|
||||
* Copyright 201302017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.jmx.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -24,12 +25,12 @@ import static org.junit.Assert.assertTrue;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.management.MBeanServer;
|
||||
import javax.management.ObjectName;
|
||||
import javax.management.QueryExp;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.integration.endpoint.SourcePollingChannelAdapter;
|
||||
@@ -37,6 +38,7 @@ import org.springframework.integration.jmx.MBeanObjectConverter;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.PollableChannel;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@@ -47,6 +49,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration
|
||||
@DirtiesContext
|
||||
public class MBeanTreePollingChannelAdapterParserTests {
|
||||
|
||||
@Autowired
|
||||
@@ -100,10 +103,7 @@ public class MBeanTreePollingChannelAdapterParserTests {
|
||||
@Autowired
|
||||
private MBeanObjectConverter converter;
|
||||
|
||||
@Autowired
|
||||
private MBeanServer mbeanServer;
|
||||
|
||||
private final long testTimeout = 2000L;
|
||||
private final long testTimeout = 20000L;
|
||||
|
||||
@Test
|
||||
public void pollDefaultAdapter() throws Exception {
|
||||
@@ -140,7 +140,7 @@ public class MBeanTreePollingChannelAdapterParserTests {
|
||||
assertTrue(beans.containsKey("java.lang:type=OperatingSystem"));
|
||||
assertTrue(beans.containsKey("java.lang:type=Runtime"));
|
||||
|
||||
adapterDefault.stop();
|
||||
adapterInner.stop();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -165,7 +165,7 @@ public class MBeanTreePollingChannelAdapterParserTests {
|
||||
assertFalse(beans.containsKey("java.lang:type=OperatingSystem"));
|
||||
assertTrue(beans.containsKey("java.lang:type=Runtime"));
|
||||
|
||||
adapterDefault.stop();
|
||||
adapterQueryName.stop();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -184,7 +184,7 @@ public class MBeanTreePollingChannelAdapterParserTests {
|
||||
assertTrue(beans.containsKey("java.lang:type=OperatingSystem"));
|
||||
assertFalse(beans.containsKey("java.lang:type=Runtime"));
|
||||
|
||||
adapterDefault.stop();
|
||||
adapterQueryNameBean.stop();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -203,7 +203,7 @@ public class MBeanTreePollingChannelAdapterParserTests {
|
||||
assertFalse(beans.containsKey("java.lang:type=OperatingSystem"));
|
||||
assertTrue(beans.containsKey("java.lang:type=Runtime"));
|
||||
|
||||
adapterDefault.stop();
|
||||
adapterQueryExprBean.stop();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -222,7 +222,7 @@ public class MBeanTreePollingChannelAdapterParserTests {
|
||||
assertTrue(beans.containsKey("java.lang:type=OperatingSystem"));
|
||||
assertTrue(beans.containsKey("java.lang:type=Runtime"));
|
||||
|
||||
adapterDefault.stop();
|
||||
adapterConverter.stop();
|
||||
assertSame(converter, TestUtils.getPropertyValue(adapterConverter, "source.converter"));
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.PollableChannel;
|
||||
import org.springframework.integration.jmx.NotificationListeningMessageProducer;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@@ -43,6 +44,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@DirtiesContext
|
||||
public class NotificationListeningChannelAdapterParserTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
@@ -23,6 +23,7 @@ import javax.management.ObjectName;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@@ -32,6 +33,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@DirtiesContext
|
||||
public class PollingAdapterMBeanTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
@@ -25,6 +25,7 @@ import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.integration.channel.QueueChannelOperations;
|
||||
import org.springframework.messaging.PollableChannel;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@@ -35,6 +36,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@DirtiesContext
|
||||
public class PriorityChannelTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.monitor;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -28,6 +29,7 @@ import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.PollableChannel;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@@ -45,6 +47,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@DirtiesContext
|
||||
public class RemoteMBeanServerTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
@@ -10,6 +10,7 @@
|
||||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration_.mbeanexporterhelper;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -85,7 +86,9 @@ public class Int2307Tests {
|
||||
assertTrue(TestUtils.getPropertyValue(mBeanExporterHelper, "siBeanNames", Set.class).contains("zz"));
|
||||
|
||||
// make sure there are no duplicate MBean ObjectNames if 2 contexts loaded from same config
|
||||
new ClassPathXmlApplicationContext("single-config.xml", this.getClass());
|
||||
new ClassPathXmlApplicationContext("single-config.xml", this.getClass()).close();
|
||||
|
||||
context.close();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -110,7 +113,9 @@ public class Int2307Tests {
|
||||
}
|
||||
assertNotNull(mBeanExporterHelper);
|
||||
assertTrue(TestUtils.getPropertyValue(mBeanExporterHelper, "siBeanNames", Set.class).contains("z"));
|
||||
context.close();
|
||||
}
|
||||
|
||||
public static class Foo{}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user