INT-3124 Add JMX MBean Tree Inbound Adapter
Add an MBeanTreePollingMessageSource that produces a graph of simple objects representing the JMX tree (INT-3124). The DefaultMBeanObjectConverter converts MBean objects into a graph of Lists, Maps and arrays or primitives. Formatting tidy, per feedback. Feedback incorporated: split setter/attributes, more tests, inner bean constructor, logging changes. Overloaded setter methods with different parameter types are now named separately, the endpoint attributes reflect this and tests are added to reflect this. An inner bean can be supplied to provide an alternative MBeanObjectConverter. Log a warning instead of a more destructive UnsupportedOperationException where there's incomplete parsing in the DefaultMBeanObjectConverter and add a trace level for exception debugging. Minor test change and doc/reference update Added attribute filter interface as suggested. Three implementations are provided 'all', 'named only' and 'not named' actually add notnamedfield filter (doh). Polishing
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
<?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:int-jmx="http://www.springframework.org/schema/integration/jmx"
|
||||
xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.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-export/>
|
||||
|
||||
<context:mbean-server/>
|
||||
|
||||
<int-jmx:mbean-export/>
|
||||
|
||||
<int-jmx:tree-polling-channel-adapter id="adapter"
|
||||
channel="in"
|
||||
query-expression="org.springframework.integration:type=MessageChannel,name=*"
|
||||
auto-startup="false">
|
||||
<int:poller max-messages-per-poll="1" fixed-rate="5000"/>
|
||||
<bean class="org.springframework.integration.jmx.DefaultMBeanObjectConverter">
|
||||
<constructor-arg>
|
||||
<bean class="org.springframework.integration.jmx.NamedFieldsMBeanAttributeFilter">
|
||||
<constructor-arg>
|
||||
<array>
|
||||
<value type="java.lang.String">SendCount</value>
|
||||
<value type="java.lang.String">SendErrorCount</value>
|
||||
</array>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
</int-jmx:tree-polling-channel-adapter>
|
||||
|
||||
<int:channel id="in" />
|
||||
|
||||
<int:service-activator id="pass"
|
||||
input-channel="in"
|
||||
output-channel="out"
|
||||
expression="payload">
|
||||
</int:service-activator>
|
||||
|
||||
<int:channel id="out">
|
||||
<int:queue/>
|
||||
</int:channel>
|
||||
|
||||
<int-jmx:tree-polling-channel-adapter id="adapterNot"
|
||||
channel="in"
|
||||
query-expression="org.springframework.integration:type=MessageChannel,name=*"
|
||||
auto-startup="false">
|
||||
<int:poller max-messages-per-poll="1" fixed-rate="5000"/>
|
||||
<bean class="org.springframework.integration.jmx.DefaultMBeanObjectConverter">
|
||||
<constructor-arg>
|
||||
<bean class="org.springframework.integration.jmx.NotNamedFieldsMBeanAttributeFilter">
|
||||
<constructor-arg>
|
||||
<array>
|
||||
<value type="java.lang.String">SendCount</value>
|
||||
<value type="java.lang.String">SendErrorCount</value>
|
||||
</array>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
</int-jmx:tree-polling-channel-adapter>
|
||||
|
||||
</beans>
|
||||
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Copyright 2013 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.jmx;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
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.Message;
|
||||
import org.springframework.integration.core.PollableChannel;
|
||||
import org.springframework.integration.endpoint.SourcePollingChannelAdapter;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* @author Stuart Williams
|
||||
*
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration
|
||||
public class MBeanAttributeFilterTests {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("out")
|
||||
private PollableChannel channel;
|
||||
|
||||
@Autowired
|
||||
private SourcePollingChannelAdapter adapter;
|
||||
|
||||
@Autowired
|
||||
private SourcePollingChannelAdapter adapterNot;
|
||||
|
||||
private final long testTimeout = 1000L;
|
||||
|
||||
@Test
|
||||
public void testAttributeFilter() {
|
||||
while (channel.receive(0) != null) {
|
||||
;
|
||||
}
|
||||
adapter.start();
|
||||
|
||||
Message<?> result = channel.receive(testTimeout);
|
||||
assertNotNull(result);
|
||||
assertEquals(HashMap.class, result.getPayload().getClass());
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> payload = (Map<String, Object>) result.getPayload();
|
||||
assertEquals(4, payload.size());
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> bean = (Map<String, Object>) payload
|
||||
.get("org.springframework.integration:name=in,type=MessageChannel");
|
||||
|
||||
assertEquals(2, bean.size());
|
||||
assertTrue(bean.containsKey("SendCount"));
|
||||
assertTrue(bean.containsKey("SendErrorCount"));
|
||||
|
||||
adapter.stop();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAttributeFilterNot() {
|
||||
while (channel.receive(0) != null) {
|
||||
;
|
||||
}
|
||||
adapterNot.start();
|
||||
|
||||
Message<?> result = channel.receive(testTimeout);
|
||||
assertNotNull(result);
|
||||
assertEquals(HashMap.class, result.getPayload().getClass());
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> payload = (Map<String, Object>) result.getPayload();
|
||||
assertEquals(4, payload.size());
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> bean = (Map<String, Object>) payload
|
||||
.get("org.springframework.integration:name=in,type=MessageChannel");
|
||||
|
||||
assertEquals(8, bean.size());
|
||||
assertFalse(bean.containsKey("SendCount"));
|
||||
assertFalse(bean.containsKey("SendErrorCount"));
|
||||
|
||||
adapterNot.stop();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* Copyright 2013 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.jmx;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.management.MBeanServer;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.jmx.support.MBeanServerFactoryBean;
|
||||
|
||||
/**
|
||||
* @author Stuart Williams
|
||||
*
|
||||
*/
|
||||
public class MBeanTreePollingMessageSourceTests {
|
||||
|
||||
private MBeanServer server;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
MBeanServerFactoryBean factoryBean = new MBeanServerFactoryBean();
|
||||
factoryBean.setLocateExistingServerIfPossible(true);
|
||||
factoryBean.afterPropertiesSet();
|
||||
this.server = factoryBean.getObject();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultPoll() {
|
||||
|
||||
MBeanObjectConverter converter = new DefaultMBeanObjectConverter();
|
||||
MBeanTreePollingMessageSource source = new MBeanTreePollingMessageSource(converter);
|
||||
source.setServer(server);
|
||||
|
||||
Object received = source.doReceive();
|
||||
|
||||
assertEquals(HashMap.class, received.getClass());
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> beans = (Map<String, Object>) received;
|
||||
|
||||
// test for a couple of MBeans
|
||||
assertTrue(beans.containsKey("java.lang:type=OperatingSystem"));
|
||||
assertTrue(beans.containsKey("java.lang:type=Runtime"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryNameFilteredPoll() {
|
||||
MBeanObjectConverter converter = new DefaultMBeanObjectConverter();
|
||||
MBeanTreePollingMessageSource source = new MBeanTreePollingMessageSource(converter);
|
||||
source.setServer(server);
|
||||
source.setQueryName("java.lang:*");
|
||||
|
||||
Object received = source.doReceive();
|
||||
|
||||
assertEquals(HashMap.class, received.getClass());
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> beans = (Map<String, Object>) received;
|
||||
|
||||
// test for a few MBeans
|
||||
assertTrue(beans.containsKey("java.lang:type=OperatingSystem"));
|
||||
assertTrue(beans.containsKey("java.lang:type=Runtime"));
|
||||
assertFalse(beans.containsKey("java.util.logging:type=Logging"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryExpressionFilteredPoll() {
|
||||
MBeanObjectConverter converter = new DefaultMBeanObjectConverter();
|
||||
MBeanTreePollingMessageSource source = new MBeanTreePollingMessageSource(converter);
|
||||
source.setServer(server);
|
||||
source.setQueryExpression("*:type=Logging");
|
||||
|
||||
Object received = source.doReceive();
|
||||
|
||||
assertEquals(HashMap.class, received.getClass());
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> beans = (Map<String, Object>) received;
|
||||
|
||||
// test for a few MBeans
|
||||
assertFalse(beans.containsKey("java.lang:type=OperatingSystem"));
|
||||
assertFalse(beans.containsKey("java.lang:type=Runtime"));
|
||||
assertTrue(beans.containsKey("java.util.logging:type=Logging"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
<?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:si="http://www.springframework.org/schema/integration"
|
||||
xmlns: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
|
||||
http://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/integration/jmx
|
||||
http://www.springframework.org/schema/integration/jmx/spring-integration-jmx.xsd">
|
||||
|
||||
<context:mbean-export/>
|
||||
<context:mbean-server/>
|
||||
|
||||
<jmx:tree-polling-channel-adapter id="adapter-default"
|
||||
channel="channel1"
|
||||
auto-startup="false">
|
||||
<si:poller max-messages-per-poll="1" fixed-rate="5000"/>
|
||||
</jmx:tree-polling-channel-adapter>
|
||||
|
||||
<si:channel id="channel1">
|
||||
<si:queue/>
|
||||
</si:channel>
|
||||
|
||||
<jmx:tree-polling-channel-adapter id="adapter-inner"
|
||||
channel="channel2"
|
||||
auto-startup="false">
|
||||
<si:poller max-messages-per-poll="1" fixed-rate="5000"/>
|
||||
<bean class="org.springframework.integration.jmx.DefaultMBeanObjectConverter"></bean>
|
||||
</jmx:tree-polling-channel-adapter>
|
||||
|
||||
<si:channel id="channel2">
|
||||
<si:queue/>
|
||||
</si:channel>
|
||||
|
||||
<jmx:tree-polling-channel-adapter id="adapter-query-name"
|
||||
channel="channel3"
|
||||
auto-startup="false"
|
||||
query-name="java.lang:type=Runtime"
|
||||
query-expression="*:type=*">
|
||||
<si:poller max-messages-per-poll="1" fixed-rate="5000"/>
|
||||
</jmx:tree-polling-channel-adapter>
|
||||
|
||||
<si:channel id="channel3">
|
||||
<si:queue/>
|
||||
</si:channel>
|
||||
|
||||
<jmx:tree-polling-channel-adapter id="adapter-query-name-bean"
|
||||
channel="channel4"
|
||||
auto-startup="false"
|
||||
query-name-ref="queryName">
|
||||
<si:poller max-messages-per-poll="1" fixed-rate="5000"/>
|
||||
</jmx:tree-polling-channel-adapter>
|
||||
|
||||
<bean id="queryName" class="javax.management.ObjectName">
|
||||
<constructor-arg>
|
||||
<value type="java.lang.String">java.lang:type=OperatingSystem</value>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
|
||||
<si:channel id="channel4">
|
||||
<si:queue/>
|
||||
</si:channel>
|
||||
|
||||
<jmx:tree-polling-channel-adapter id="adapter-query-expr-bean"
|
||||
channel="channel5"
|
||||
auto-startup="false"
|
||||
query-expression-ref="queryExp">
|
||||
<si:poller max-messages-per-poll="1" fixed-rate="5000"/>
|
||||
</jmx:tree-polling-channel-adapter>
|
||||
|
||||
<bean id="queryExp" class="javax.management.ObjectName">
|
||||
<constructor-arg>
|
||||
<value type="java.lang.String">java.lang:type=Runtime</value>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
|
||||
<si:channel id="channel5">
|
||||
<si:queue/>
|
||||
</si:channel>
|
||||
|
||||
<jmx:tree-polling-channel-adapter id="adapter-converter"
|
||||
channel="channel6" converter="converter"
|
||||
auto-startup="false">
|
||||
<si:poller max-messages-per-poll="1" fixed-rate="5000"/>
|
||||
</jmx:tree-polling-channel-adapter>
|
||||
|
||||
<bean id="converter" class="org.springframework.integration.jmx.DefaultMBeanObjectConverter" />
|
||||
|
||||
<si:channel id="channel6">
|
||||
<si:queue/>
|
||||
</si:channel>
|
||||
|
||||
</beans>
|
||||
@@ -0,0 +1,230 @@
|
||||
/*
|
||||
* Copyright 2013 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.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;
|
||||
|
||||
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.Message;
|
||||
import org.springframework.integration.core.PollableChannel;
|
||||
import org.springframework.integration.endpoint.SourcePollingChannelAdapter;
|
||||
import org.springframework.integration.jmx.MBeanObjectConverter;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* @author Stuart Williams
|
||||
* @author Gary Russell
|
||||
*
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration
|
||||
public class MBeanTreePollingChannelAdapterParserTests {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("channel1")
|
||||
private PollableChannel channel1;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("channel2")
|
||||
private PollableChannel channel2;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("channel3")
|
||||
private PollableChannel channel3;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("channel4")
|
||||
private PollableChannel channel4;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("channel5")
|
||||
private PollableChannel channel5;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("channel6")
|
||||
private PollableChannel channel6;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("adapter-default")
|
||||
private SourcePollingChannelAdapter adapterDefault;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("adapter-inner")
|
||||
private SourcePollingChannelAdapter adapterInner;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("adapter-query-name")
|
||||
private SourcePollingChannelAdapter adapterQueryName;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("adapter-query-name-bean")
|
||||
private SourcePollingChannelAdapter adapterQueryNameBean;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("adapter-query-expr-bean")
|
||||
private SourcePollingChannelAdapter adapterQueryExprBean;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("adapter-converter")
|
||||
private SourcePollingChannelAdapter adapterConverter;
|
||||
|
||||
@Autowired
|
||||
private MBeanObjectConverter converter;
|
||||
|
||||
@Autowired
|
||||
private MBeanServer mbeanServer;
|
||||
|
||||
private final long testTimeout = 2000L;
|
||||
|
||||
@Test
|
||||
public void pollDefaultAdapter() throws Exception {
|
||||
adapterDefault.start();
|
||||
|
||||
Message<?> result = channel1.receive(testTimeout);
|
||||
assertNotNull(result);
|
||||
|
||||
assertEquals(HashMap.class, result.getPayload().getClass());
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> beans = (Map<String, Object>) result.getPayload();
|
||||
|
||||
// test for a couple of MBeans
|
||||
assertTrue(beans.containsKey("java.lang:type=OperatingSystem"));
|
||||
assertTrue(beans.containsKey("java.lang:type=Runtime"));
|
||||
|
||||
adapterDefault.stop();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pollInnerAdapter() throws Exception {
|
||||
adapterInner.start();
|
||||
|
||||
Message<?> result = channel2.receive(testTimeout);
|
||||
assertNotNull(result);
|
||||
|
||||
assertEquals(HashMap.class, result.getPayload().getClass());
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> beans = (Map<String, Object>) result.getPayload();
|
||||
|
||||
// test for a couple of MBeans
|
||||
assertTrue(beans.containsKey("java.lang:type=OperatingSystem"));
|
||||
assertTrue(beans.containsKey("java.lang:type=Runtime"));
|
||||
|
||||
adapterDefault.stop();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pollQueryNameAdapter() throws Exception {
|
||||
adapterQueryName.start();
|
||||
|
||||
ObjectName queryName = TestUtils.getPropertyValue(adapterQueryName, "source.queryName", ObjectName.class);
|
||||
assertEquals("java.lang:type=Runtime", queryName.getCanonicalName());
|
||||
|
||||
QueryExp queryExp = TestUtils.getPropertyValue(adapterQueryName, "source.queryExpression", QueryExp.class);
|
||||
assertTrue(queryExp.apply(new ObjectName("java.lang:type=Runtime")));
|
||||
|
||||
Message<?> result = channel3.receive(testTimeout);
|
||||
assertNotNull(result);
|
||||
|
||||
assertEquals(HashMap.class, result.getPayload().getClass());
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> beans = (Map<String, Object>) result.getPayload();
|
||||
|
||||
// test for a couple of MBeans
|
||||
assertFalse(beans.containsKey("java.lang:type=OperatingSystem"));
|
||||
assertTrue(beans.containsKey("java.lang:type=Runtime"));
|
||||
|
||||
adapterDefault.stop();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pollQueryNameBeanAdapter() throws Exception {
|
||||
adapterQueryNameBean.start();
|
||||
|
||||
Message<?> result = channel4.receive(testTimeout);
|
||||
assertNotNull(result);
|
||||
|
||||
assertEquals(HashMap.class, result.getPayload().getClass());
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> beans = (Map<String, Object>) result.getPayload();
|
||||
|
||||
// test for a couple of MBeans
|
||||
assertTrue(beans.containsKey("java.lang:type=OperatingSystem"));
|
||||
assertFalse(beans.containsKey("java.lang:type=Runtime"));
|
||||
|
||||
adapterDefault.stop();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pollQueryExprBeanAdapter() throws Exception {
|
||||
adapterQueryExprBean.start();
|
||||
|
||||
Message<?> result = channel5.receive(testTimeout);
|
||||
assertNotNull(result);
|
||||
|
||||
assertEquals(HashMap.class, result.getPayload().getClass());
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> beans = (Map<String, Object>) result.getPayload();
|
||||
|
||||
// test for a couple of MBeans
|
||||
assertFalse(beans.containsKey("java.lang:type=OperatingSystem"));
|
||||
assertTrue(beans.containsKey("java.lang:type=Runtime"));
|
||||
|
||||
adapterDefault.stop();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pollConverterAdapter() throws Exception {
|
||||
adapterConverter.start();
|
||||
|
||||
Message<?> result = channel6.receive(testTimeout);
|
||||
assertNotNull(result);
|
||||
|
||||
assertEquals(HashMap.class, result.getPayload().getClass());
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> beans = (Map<String, Object>) result.getPayload();
|
||||
|
||||
// test for a couple of MBeans
|
||||
assertTrue(beans.containsKey("java.lang:type=OperatingSystem"));
|
||||
assertTrue(beans.containsKey("java.lang:type=Runtime"));
|
||||
|
||||
adapterDefault.stop();
|
||||
assertSame(converter, TestUtils.getPropertyValue(adapterConverter, "source.converter"));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user