INT-3637: JMX Improvements Msg Sources/Handlers
JIRA: https://jira.spring.io/browse/INT-3637 - Message Sources - Message Handlers Polishing; Final Review and PR Comments - avoid second call to System.currentTimeMillis() - fix elapsed time in handler metrics - expose TrackableComponent when available INT-3637: Add @IntergrationManagedResource Prevents beans (channels, etc), which were previously picked up via a proxy, from being exported by a standard context MBeanExporter. I looked at completely eliminating the MBeanExporterHelper, which suppresses o.s.integration beans from being exported by a standard MBeanExporter when there is an IMBE present, but I feel this is too much of a breaking change. There are a number of standard beans (such as WireTap) that are @ManagedResources and these would disappear for users that don't have an IMBE. That said, such beans previously disappear completely when there *is* an IMBE so now they are now annotated with both so that they are exported by at most one of the exporters. Polishing; Use MBE.addExludedBean instead of DFA INT-3639: JMX (AMQP/JMS) Channel Stats JIRA: https://jira.spring.io/browse/INT-3639 Module channels inherit `ChannelSendMetrics`; add `PollableChannelManagement` for polled channels. INT-3638: JMX Initial Stats/Counts Settings JIRA: https://jira.spring.io/browse/INT-3638 Add the ability to specify the initial settings for 'enableStats' and 'enableCounts' for MBeans that support those statistics. Polishing; PR Comments; Add Handler Metrics Test Also found a problem using an inner MessageSource bean in an inbound-channel-adapter - a BeanComponentDefinition was returned instead of a BeanDefinition. Add @DirtiesContext to JMX Tests The new MonitorTests failed with InstanceAlreadyExistsException for the errorChannel. Add @DirtiesContext to all tests using the Spring test runner to avoid caching any contexts after the test class completes. INT-3637: JMX Support Negated Name Match Patterns Note: with negated matches, order matters. Polishing for `MonitorTests` Fix `EnableIntegrationMBeanExport` JavaDocs
This commit is contained in:
committed by
Artem Bilan
parent
b56a56e8e6
commit
09c203dc6d
@@ -64,6 +64,7 @@
|
||||
<value type="java.lang.String">SendCountLong</value>
|
||||
<value type="java.lang.String">SendErrorCount</value>
|
||||
<value type="java.lang.String">SendErrorCountLong</value>
|
||||
<value type="java.lang.String">CountsEnabled</value>
|
||||
<value type="java.lang.String">StatsEnabled</value>
|
||||
</array>
|
||||
</constructor-arg>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013 the original author or authors.
|
||||
* Copyright 2013-2015 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.
|
||||
@@ -31,15 +31,18 @@ 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;
|
||||
|
||||
/**
|
||||
* @author Stuart Williams
|
||||
* @author Gary Russell
|
||||
*
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration
|
||||
@DirtiesContext
|
||||
public class MBeanAttributeFilterTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2015 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.
|
||||
@@ -40,6 +40,7 @@ import org.springframework.integration.util.StackTraceUtils;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@@ -53,6 +54,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@DirtiesContext
|
||||
public class ServiceActivatorDefaultFrameworkMethodTests {
|
||||
|
||||
@Autowired
|
||||
@@ -148,7 +150,7 @@ public class ServiceActivatorDefaultFrameworkMethodTests {
|
||||
// INT-2399
|
||||
@Test
|
||||
public void testMessageProcessor() {
|
||||
Object processor = TestUtils.getPropertyValue(processorTestService, "handler.h.advised.targetSource.target.processor");
|
||||
Object processor = TestUtils.getPropertyValue(processorTestService, "handler.processor");
|
||||
assertSame(testMessageProcessor, processor);
|
||||
|
||||
QueueChannel replyChannel = new QueueChannel();
|
||||
|
||||
@@ -95,7 +95,7 @@ public class UpdateMappingsTests {
|
||||
MessagingTemplate messagingTemplate = new MessagingTemplate();
|
||||
messagingTemplate.setReceiveTimeout(1000);
|
||||
Set<ObjectName> names = this.server.queryNames(ObjectName
|
||||
.getInstance("update.mapping.domain:type=HeaderValueRouter,name=router"),
|
||||
.getInstance("update.mapping.domain:type=MessageHandler,name=router,bean=endpoint"),
|
||||
null);
|
||||
assertEquals(1, names.size());
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2015 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.
|
||||
@@ -22,13 +22,15 @@ import static org.junit.Assert.assertSame;
|
||||
|
||||
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;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.messaging.Message;
|
||||
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 +41,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@DirtiesContext
|
||||
public class AttributePollingChannelAdapterParserTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2015 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
|
||||
@@ -20,18 +20,21 @@ import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.integration.core.MessagingTemplate;
|
||||
import org.springframework.jmx.export.MBeanExporter;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.integration.core.MessagingTemplate;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
* @author Gary Russell
|
||||
* @since 2.0
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@DirtiesContext
|
||||
public class ControlBusParserTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2015 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,14 +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.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
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;
|
||||
@@ -41,6 +42,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@DirtiesContext
|
||||
public class DynamicRouterTests {
|
||||
|
||||
@Autowired
|
||||
@@ -53,15 +55,18 @@ public class DynamicRouterTests {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("processAChannel")
|
||||
private QueueChannel processAChannel;
|
||||
private PollableChannel processAChannel;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("processBChannel")
|
||||
private QueueChannel processBChannel;
|
||||
private PollableChannel processBChannel;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("processCChannel")
|
||||
private QueueChannel processCChannel;
|
||||
private PollableChannel processCChannel;
|
||||
|
||||
@Autowired
|
||||
private MessageChannel nullChannel;
|
||||
|
||||
|
||||
@Test @DirtiesContext
|
||||
@@ -109,4 +114,12 @@ public class DynamicRouterTests {
|
||||
assertEquals("123", processCChannel.receive(0).getPayload());
|
||||
}
|
||||
|
||||
@Test @DirtiesContext @Ignore
|
||||
public void testPerf() throws Exception {
|
||||
for (int i = 0; i < 10000000; i++) {
|
||||
this.nullChannel.send(null);
|
||||
}
|
||||
System.out.println("done");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,9 @@
|
||||
server="mbs"
|
||||
default-domain="tests.MBeanExpoerterParser"
|
||||
object-name-static-properties="appProperties"
|
||||
object-naming-strategy="keyNamer"/>
|
||||
object-naming-strategy="keyNamer"
|
||||
counts-enabled="foo, !baz, ba*"
|
||||
stats-enabled="fiz, buz" />
|
||||
|
||||
<util:properties id="appProperties">
|
||||
<prop key="foo">foo</prop>
|
||||
@@ -28,4 +30,16 @@
|
||||
|
||||
<bean id="keyNamer" class="org.springframework.jmx.export.naming.KeyNamingStrategy" />
|
||||
|
||||
<si:channel id="foo" />
|
||||
|
||||
<si:channel id="bar" />
|
||||
|
||||
<si:channel id="baz" />
|
||||
|
||||
<si:channel id="qux" />
|
||||
|
||||
<si:channel id="fiz" />
|
||||
|
||||
<si:channel id="buz" />
|
||||
|
||||
</beans>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2015 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.
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.integration.jmx.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@@ -30,8 +31,10 @@ import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.integration.channel.management.MessageChannelMetrics;
|
||||
import org.springframework.integration.monitor.IntegrationMBeanExporter;
|
||||
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,10 +42,12 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
* @author Mark Fisher
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Gunnar Hillert
|
||||
* @author Gary Russell
|
||||
* @since 2.0
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@DirtiesContext
|
||||
public class MBeanExporterParserTests {
|
||||
|
||||
@Autowired
|
||||
@@ -59,6 +64,24 @@ public class MBeanExporterParserTests {
|
||||
assertTrue(properties.containsKey("bar"));
|
||||
assertEquals(server, exporter.getServer());
|
||||
assertSame(context.getBean("keyNamer"), TestUtils.getPropertyValue(exporter, "namingStrategy"));
|
||||
MessageChannelMetrics metrics = context.getBean("foo", MessageChannelMetrics.class);
|
||||
assertTrue(metrics.isCountsEnabled());
|
||||
assertFalse(metrics.isStatsEnabled());
|
||||
metrics = context.getBean("bar", MessageChannelMetrics.class);
|
||||
assertTrue(metrics.isCountsEnabled());
|
||||
assertFalse(metrics.isStatsEnabled());
|
||||
metrics = context.getBean("baz", MessageChannelMetrics.class);
|
||||
assertFalse(metrics.isCountsEnabled());
|
||||
assertFalse(metrics.isStatsEnabled());
|
||||
metrics = context.getBean("qux", MessageChannelMetrics.class);
|
||||
assertFalse(metrics.isCountsEnabled());
|
||||
assertFalse(metrics.isStatsEnabled());
|
||||
metrics = context.getBean("fiz", MessageChannelMetrics.class);
|
||||
assertTrue(metrics.isCountsEnabled());
|
||||
assertTrue(metrics.isStatsEnabled());
|
||||
metrics = context.getBean("buz", MessageChannelMetrics.class);
|
||||
assertTrue(metrics.isCountsEnabled());
|
||||
assertTrue(metrics.isStatsEnabled());
|
||||
exporter.destroy();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013 the original author or authors.
|
||||
* Copyright 2013-2015 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
|
||||
@@ -28,6 +28,7 @@ import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jmx.export.naming.KeyNamingStrategy;
|
||||
import org.springframework.jmx.export.naming.ObjectNamingStrategy;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@@ -38,6 +39,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@DirtiesContext
|
||||
public class MBeanRegistrationCustomNamingTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2015 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
|
||||
@@ -30,6 +30,7 @@ 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;
|
||||
|
||||
@@ -40,6 +41,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@DirtiesContext
|
||||
public class MBeanRegistrationTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013 the original author or authors.
|
||||
* Copyright 2013-2015 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.
|
||||
@@ -30,6 +30,7 @@ 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;
|
||||
|
||||
@@ -45,8 +47,9 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
* @author Gary Russell
|
||||
*
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@DirtiesContext
|
||||
public class MBeanTreePollingChannelAdapterParserTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright 2002-2011 the original author or authors.
|
||||
*
|
||||
* Copyright 2002-2015 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
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
|
||||
* 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.
|
||||
@@ -22,21 +22,25 @@ 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;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
* @author Gary Russell
|
||||
* @since 2.0
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@DirtiesContext
|
||||
public class MessageStoreTests {
|
||||
|
||||
@Autowired
|
||||
private MBeanServer server;
|
||||
|
||||
|
||||
@Test
|
||||
public void testHandlerMBeanRegistration() throws Exception {
|
||||
Set<ObjectName> names = server.queryNames(new ObjectName("test.MessageStore:type=SimpleMessageStore,*"), null);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
*
|
||||
* Copyright 2002-2015 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
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
|
||||
* 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.
|
||||
@@ -22,22 +22,26 @@ import javax.management.ObjectName;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessagingException;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.messaging.MessagingException;
|
||||
import org.springframework.messaging.SubscribableChannel;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
* @author Gary Russell
|
||||
* @since 2.0
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@DirtiesContext
|
||||
public class MethodInvokerTests {
|
||||
|
||||
@Autowired
|
||||
@@ -56,6 +60,7 @@ public class MethodInvokerTests {
|
||||
// the router and the error handler...
|
||||
assertEquals(2, names.size());
|
||||
underscores.subscribe(new MessageHandler() {
|
||||
@Override
|
||||
public void handleMessage(Message<?> message) throws MessagingException {
|
||||
assertEquals("foo", message.getPayload());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2015 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.
|
||||
@@ -26,13 +26,15 @@ import javax.management.Notification;
|
||||
|
||||
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.jmx.NotificationListeningMessageProducer;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.messaging.Message;
|
||||
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 +45,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@DirtiesContext
|
||||
public class NotificationListeningChannelAdapterParserTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2015 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.
|
||||
@@ -58,6 +58,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@DirtiesContext
|
||||
public class NotificationPublishingChannelAdapterParserTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2015 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.
|
||||
@@ -23,14 +23,16 @@ import static org.junit.Assert.fail;
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.integration.handler.advice.AbstractRequestHandlerAdvice;
|
||||
import org.springframework.integration.jmx.JmxHeaders;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessagingException;
|
||||
import org.springframework.integration.handler.advice.AbstractRequestHandlerAdvice;
|
||||
import org.springframework.integration.jmx.JmxHeaders;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@@ -38,10 +40,12 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
* @author Mark Fisher
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
* @since 2.0
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@DirtiesContext
|
||||
public class OperationInvokingChannelAdapterParserTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2015 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.
|
||||
@@ -43,6 +43,7 @@ import org.springframework.messaging.MessageHandler;
|
||||
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.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@@ -55,6 +56,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@DirtiesContext
|
||||
public class OperationInvokingOutboundGatewayTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
* Copyright 2002-2015 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
|
||||
@@ -22,16 +22,20 @@ 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;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
* @author Gary Russell
|
||||
* @since 2.0
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@DirtiesContext
|
||||
public class PollingAdapterMBeanTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2015 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
|
||||
@@ -22,9 +22,11 @@ import javax.management.ObjectName;
|
||||
|
||||
import org.junit.Test;
|
||||
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 +37,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@DirtiesContext
|
||||
public class PriorityChannelTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright 2002-2010 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
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
|
||||
* 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.
|
||||
@@ -14,15 +14,11 @@
|
||||
package org.springframework.integration.jmx.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.management.MBeanOperationInfo;
|
||||
import javax.management.MBeanServer;
|
||||
import javax.management.ObjectName;
|
||||
|
||||
@@ -31,6 +27,7 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
/**
|
||||
@@ -40,9 +37,9 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
@RunWith(Parameterized.class)
|
||||
public class RouterMBeanTests {
|
||||
|
||||
private MBeanServer server;
|
||||
private final MBeanServer server;
|
||||
|
||||
private ClassPathXmlApplicationContext context;
|
||||
private final ClassPathXmlApplicationContext context;
|
||||
|
||||
public RouterMBeanTests(String configLocation) {
|
||||
context = new ClassPathXmlApplicationContext(configLocation, getClass());
|
||||
@@ -94,26 +91,6 @@ public class RouterMBeanTests {
|
||||
Set<ObjectName> names = server.queryNames(new ObjectName("test.RouterMBean:type=MessageHandler,name=ptRouter,*"), null);
|
||||
assertEquals(1, names.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRouterMBeanHasTrackableComponent() throws Exception {
|
||||
// System.err.println(server.queryNames(new ObjectName("test.RouterMBean:*"), null));
|
||||
Set<ObjectName> names = server.queryNames(new ObjectName("test.RouterMBean:type=ExpressionEvaluatingRouter,*"), null);
|
||||
Map<String,MBeanOperationInfo> infos = new HashMap<String, MBeanOperationInfo>();
|
||||
for (MBeanOperationInfo info : server.getMBeanInfo(names.iterator().next()).getOperations()) {
|
||||
infos.put(info.getName(), info);
|
||||
}
|
||||
// System.err.println(infos);
|
||||
assertNotNull(infos.get("setShouldTrack"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVanillaRouterMBeanRegistration() throws Exception {
|
||||
// System.err.println(server.queryNames(new ObjectName("test.RouterMBean:*"), null));
|
||||
Set<ObjectName> names = server.queryNames(new ObjectName("test.RouterMBean:type=ExpressionEvaluatingRouter,*"), null);
|
||||
// The router is exposed...
|
||||
assertEquals(1, names.size());
|
||||
}
|
||||
|
||||
public static interface Service {
|
||||
void send(String input);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
*
|
||||
* Copyright 2002-2015 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
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
|
||||
* 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.
|
||||
@@ -22,21 +22,25 @@ 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;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
* @author Gary Russell
|
||||
* @since 2.0
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@DirtiesContext
|
||||
public class RouterMBeanVanillaTests {
|
||||
|
||||
@Autowired
|
||||
private MBeanServer server;
|
||||
|
||||
|
||||
@Test
|
||||
public void testHandlerMBeanRegistration() throws Exception {
|
||||
// System.err.println(server.queryNames(new ObjectName("test.RouterMBeanVanilla:*"), null));
|
||||
|
||||
@@ -75,10 +75,12 @@ public class EnableMBeanExportTests {
|
||||
|
||||
assertSame(this.mBeanServer, this.exporter.getServer());
|
||||
String[] componentNamePatterns = TestUtils.getPropertyValue(this.exporter, "componentNamePatterns", String[].class);
|
||||
for (String componentNamePattern : componentNamePatterns) {
|
||||
assertThat(componentNamePattern, Matchers.isOneOf("input", "in*"));
|
||||
assertThat(componentNamePattern, Matchers.not(Matchers.equalTo("*")));
|
||||
}
|
||||
assertThat(componentNamePatterns, Matchers.arrayContaining("input", "inputX", "in*"));
|
||||
String[] enabledCounts = TestUtils.getPropertyValue(this.exporter, "enabledCountsPatterns", String[].class);
|
||||
assertThat(enabledCounts, Matchers.arrayContaining("foo", "bar", "baz"));
|
||||
String[] enabledStatts = TestUtils.getPropertyValue(this.exporter, "enabledStatsPatterns", String[].class);
|
||||
assertThat(enabledStatts, Matchers.arrayContaining("qux", "!*"));
|
||||
|
||||
Set<ObjectName> names = this.mBeanServer.queryNames(ObjectName.getInstance("FOO:type=MessageChannel,*"), null);
|
||||
// Only one registered (out of >2 available)
|
||||
assertEquals(1, names.size());
|
||||
@@ -102,7 +104,11 @@ public class EnableMBeanExportTests {
|
||||
|
||||
@Configuration
|
||||
@EnableIntegration
|
||||
@EnableIntegrationMBeanExport(server = "#{mbeanServer}", defaultDomain = "${managed.domain}", managedComponents = {"input", "${managed.component}"})
|
||||
@EnableIntegrationMBeanExport(server = "#{mbeanServer}",
|
||||
defaultDomain = "${managed.domain}",
|
||||
managedComponents = {"input", "${managed.component}"},
|
||||
countsEnabled = { "foo", "${count.patterns}" },
|
||||
statsEnabled = { "qux", "!*" })
|
||||
public static class ContextConfiguration {
|
||||
|
||||
@Bean
|
||||
@@ -127,8 +133,9 @@ public class EnableMBeanExportTests {
|
||||
@Override
|
||||
public void initialize(GenericApplicationContext applicationContext) {
|
||||
applicationContext.setEnvironment(new MockEnvironment()
|
||||
.withProperty("managed.component", "input,in*")
|
||||
.withProperty("managed.domain", "FOO"));
|
||||
.withProperty("managed.component", "inputX,in*")
|
||||
.withProperty("managed.domain", "FOO")
|
||||
.withProperty("count.patterns", "bar,baz"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2015 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.
|
||||
@@ -19,18 +19,22 @@ import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Gunnar Hillert
|
||||
* @author Gary Russell
|
||||
*
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@DirtiesContext
|
||||
public class ChainWithMessageProducingHandlersTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright 2009-2010 the original author or authors.
|
||||
*
|
||||
* Copyright 2009-2015 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
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
|
||||
* 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.
|
||||
@@ -17,15 +17,23 @@ import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
* @author Gary Russell
|
||||
* @since 2.0
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@DirtiesContext
|
||||
public class ChannelIntegrationTests {
|
||||
|
||||
@Autowired
|
||||
@@ -39,7 +47,7 @@ public class ChannelIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void testMessageChannelStatistics() throws Exception {
|
||||
|
||||
|
||||
requests.send(new GenericMessage<String>("foo"));
|
||||
|
||||
double rate = messageChannelsMonitor.getChannelSendRate("" + requests).getMean();
|
||||
@@ -47,11 +55,11 @@ public class ChannelIntegrationTests {
|
||||
|
||||
rate = messageChannelsMonitor.getChannelSendRate("" + intermediate).getMean();
|
||||
assertTrue("No statistics for intermediate channel", rate >= 0);
|
||||
|
||||
|
||||
assertNotNull(intermediate.receive(100L));
|
||||
double count = messageChannelsMonitor.getChannelReceiveCount("" + intermediate);
|
||||
assertTrue("No statistics for intermediate channel", count >= 0);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,16 +12,11 @@
|
||||
*/
|
||||
package org.springframework.integration.monitor;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import org.aopalliance.intercept.MethodInterceptor;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.aop.framework.Advised;
|
||||
import org.springframework.aop.framework.ProxyFactory;
|
||||
import org.springframework.aop.support.NameMatchMethodPointcutAdvisor;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
@@ -57,19 +52,6 @@ public class MessageMetricsAdviceTests {
|
||||
handler = new DummyHandler();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void adviceExportedHandler() throws Exception {
|
||||
Advised advised = (Advised) mBeanExporter.postProcessAfterInitialization(handler, "test");
|
||||
|
||||
DummyInterceptor interceptor = new DummyInterceptor();
|
||||
advised.addAdvice(interceptor);
|
||||
|
||||
assertThat(advised.getAdvisors().length, equalTo(2));
|
||||
|
||||
((MessageHandler) advised).handleMessage(MessageBuilder.withPayload("test").build());
|
||||
assertThat(interceptor.invoked, is(true));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void exportAdvisedHandler() throws Exception {
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:int-jmx="http://www.springframework.org/schema/integration/jmx"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
|
||||
http://www.springframework.org/schema/integration/jmx http://www.springframework.org/schema/integration/jmx/spring-integration-jmx.xsd
|
||||
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd">
|
||||
|
||||
<context:mbean-server />
|
||||
|
||||
<int-jmx:mbean-export />
|
||||
|
||||
<int:channel id="input">
|
||||
<int:queue />
|
||||
</int:channel>
|
||||
|
||||
<int:bridge input-channel="input" output-channel="next">
|
||||
<int:poller fixed-delay="500" />
|
||||
</int:bridge>
|
||||
|
||||
<int:service-activator input-channel="next">
|
||||
<bean class="org.springframework.integration.monitor.MonitorTests$TestHandler" />
|
||||
</int:service-activator>
|
||||
|
||||
<int:inbound-channel-adapter channel="pubsub">
|
||||
<bean class="org.springframework.integration.monitor.MonitorTests$TestSource" />
|
||||
<int:poller fixed-delay="500" />
|
||||
</int:inbound-channel-adapter>
|
||||
|
||||
<int:publish-subscribe-channel id="pubsub" />
|
||||
|
||||
<int:bridge input-channel="pubsub" output-channel="nullChannel" />
|
||||
|
||||
<int:bridge input-channel="pubsub" output-channel="output" />
|
||||
|
||||
<int:channel id="output">
|
||||
<int:queue />
|
||||
</int:channel>
|
||||
|
||||
</beans>
|
||||
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Copyright 2015 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on 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.monitor;
|
||||
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
||||
import static org.hamcrest.Matchers.lessThan;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.channel.NullChannel;
|
||||
import org.springframework.integration.channel.PublishSubscribeChannel;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.core.MessagingTemplate;
|
||||
import org.springframework.integration.endpoint.AbstractMessageSource;
|
||||
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* @author Gary Russell
|
||||
* @since 4.2
|
||||
*
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@DirtiesContext
|
||||
public class MonitorTests {
|
||||
|
||||
@Autowired
|
||||
private QueueChannel input;
|
||||
|
||||
@Autowired
|
||||
private DirectChannel next;
|
||||
|
||||
@Autowired
|
||||
private TestHandler handler;
|
||||
|
||||
@Autowired
|
||||
private TestSource source;
|
||||
|
||||
@Autowired
|
||||
private PublishSubscribeChannel pubsub;
|
||||
|
||||
@Autowired
|
||||
private QueueChannel output;
|
||||
|
||||
@Autowired
|
||||
private NullChannel nullChannel;
|
||||
|
||||
|
||||
@Test
|
||||
public void testStats() {
|
||||
Integer active = new MessagingTemplate(this.input).convertSendAndReceive("foo", Integer.class);
|
||||
assertEquals(1, active.intValue());
|
||||
assertEquals(0, this.handler.getActiveCount());
|
||||
assertEquals(1, this.handler.getHandleCount());
|
||||
assertThat(this.handler.getDuration().getMax(), greaterThan(99.0));
|
||||
assertThat(this.handler.getDuration().getMax(), lessThan(10000.0));
|
||||
assertEquals(1, this.input.getSendCount());
|
||||
assertEquals(1, this.input.getReceiveCount());
|
||||
assertEquals(1, this.next.getSendCount());
|
||||
assertThat(this.next.getSendDuration().getMax(), greaterThan(99.0));
|
||||
assertThat(this.next.getSendDuration().getMax(), lessThan(10000.0));
|
||||
Message<?> fromInbound = this.output.receive(10000);
|
||||
assertNotNull(fromInbound);
|
||||
assertEquals(0, fromInbound.getPayload());
|
||||
fromInbound = this.output.receive(10000);
|
||||
assertNotNull(fromInbound);
|
||||
assertEquals(1, fromInbound.getPayload());
|
||||
assertThat(this.source.getMessageCount(), greaterThanOrEqualTo(2));
|
||||
assertThat(this.nullChannel.getSendCount(), greaterThanOrEqualTo(2));
|
||||
assertThat(this.pubsub.getSendCount(), greaterThanOrEqualTo(2));
|
||||
}
|
||||
|
||||
public static class TestHandler extends AbstractReplyProducingMessageHandler {
|
||||
|
||||
@Override
|
||||
protected Object handleRequestMessage(Message<?> requestMessage) {
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
return getActiveCount();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class TestSource extends AbstractMessageSource<Integer> {
|
||||
|
||||
@Override
|
||||
public String getComponentType() {
|
||||
return "foo";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object doReceive() {
|
||||
return getMessageCount();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2015 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.
|
||||
@@ -23,11 +23,13 @@ import javax.management.Notification;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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
|
||||
@@ -97,10 +100,12 @@ public class RemoteMBeanServerTests {
|
||||
|
||||
public static class Tester implements TesterMBean {
|
||||
|
||||
@Override
|
||||
public String getFoo() {
|
||||
return "foo";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String fooBar(String foo) {
|
||||
return "bar";
|
||||
}
|
||||
|
||||
@@ -46,9 +46,9 @@ import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
|
||||
import org.springframework.integration.handler.BridgeHandler;
|
||||
import org.springframework.integration.scattergather.ScatterGatherHandler;
|
||||
import org.springframework.integration.jmx.config.EnableIntegrationMBeanExport;
|
||||
import org.springframework.integration.router.RecipientListRouter;
|
||||
import org.springframework.integration.scattergather.ScatterGatherHandler;
|
||||
import org.springframework.integration.store.SimpleMessageStore;
|
||||
import org.springframework.jmx.support.MBeanServerFactoryBean;
|
||||
import org.springframework.messaging.Message;
|
||||
@@ -63,6 +63,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
* @since 4.1
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@@ -94,6 +95,7 @@ public class ScatterGatherHandlerIntegrationTests {
|
||||
assertThat((Double) payload, lessThan(10D));
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Test
|
||||
public void testAuctionWithGatherChannel() {
|
||||
Message<String> quoteMessage = MessageBuilder.withPayload("testQuote").build();
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
|
||||
|
||||
<int:inbound-channel-adapter channel="toControlBus" auto-startup="false"
|
||||
expression="@integrationMbeanExporter.stopActiveComponents(false, 1000)" />
|
||||
expression="@integrationMbeanExporter.stopActiveComponents(1000)" />
|
||||
|
||||
<int:channel id="toControlBus" />
|
||||
|
||||
|
||||
@@ -54,22 +54,17 @@ public class Int2307Tests {
|
||||
int count = 0;
|
||||
for (ObjectInstance mbean : mbeans) {
|
||||
Thread.sleep(500); //Added in order to pass test with Java 8
|
||||
if (mbean.toString().startsWith("org.springframework.integration.router.RecipientListRouter[test.domain:type=RecipientListRouter,name=rlr,random=")) {
|
||||
bits |= 1;
|
||||
count++;
|
||||
} else if (mbean.toString().startsWith("org.springframework.integration.monitor.LifecycleMessageHandlerMetrics[test.domain:type=MessageHandler,name=rlr,bean=endpoint,random=")) {
|
||||
if (mbean.toString().startsWith("org.springframework.integration.monitor.LifecycleTrackableMessageHandlerMetrics[test.domain:type=MessageHandler,name=rlr,bean=endpoint,random=")) {
|
||||
bits |= 2;
|
||||
count++;
|
||||
} else if (mbean.toString().startsWith("org.springframework.integration.router.HeaderValueRouter[test.domain:type=HeaderValueRouter,name=hvr,random=")) {
|
||||
bits |= 4;
|
||||
count++;
|
||||
} else if (mbean.toString().startsWith("org.springframework.integration.monitor.LifecycleMessageHandlerMetrics[test.domain:type=MessageHandler,name=hvr,bean=endpoint,random=")) {
|
||||
}
|
||||
else if (mbean.toString().startsWith("org.springframework.integration.monitor.TrackableRouterMetrics[test.domain:type=MessageHandler,name=hvr,bean=endpoint,random=")) {
|
||||
bits |= 8;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
assertEquals(0xf, bits);
|
||||
assertEquals(4, count);
|
||||
assertEquals(0xa, bits);
|
||||
assertEquals(2, count);
|
||||
|
||||
Class<?> clazz = Class.forName("org.springframework.integration.jmx.config.MBeanExporterHelper");
|
||||
List<Object> beanPostProcessors = TestUtils.getPropertyValue(context, "beanFactory.beanPostProcessors", List.class);
|
||||
@@ -85,7 +80,7 @@ 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();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
Reference in New Issue
Block a user