INT-1817 added namespace support for object-name-static-properties for IntegrationMBeanExporter

This commit is contained in:
Oleg Zhurakousky
2011-03-09 17:13:13 -05:00
parent 3f06998118
commit 8b53fa1fc7
5 changed files with 47 additions and 12 deletions

View File

@@ -4,19 +4,25 @@
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">
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="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
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<context:mbean-server id="mbs"/>
<si:channel id="testChannel"/>
<jmx:mbean-export id="integratioMbeanExporter" server="mbs" default-domain="tests.MBeanExpoerterParser"/>
<jmx:mbean-export id="integratioMbeanExporter"
server="mbs"
default-domain="tests.MBeanExpoerterParser"
object-name-static-properties-ref="appProperties"/>
<util:properties id="appProperties">
<prop key="foo">foo</prop>
<prop key="bar">bar</prop>
</util:properties>
</beans>

View File

@@ -16,20 +16,27 @@
package org.springframework.integration.jmx.config;
import static org.junit.Assert.assertEquals;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertTrue;
import java.util.Properties;
import javax.management.MBeanServer;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.integration.monitor.IntegrationMBeanExporter;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @author Mark Fisher
* @author Oleg Zhurakousky
* @since 2.0
*/
@ContextConfiguration
@@ -43,6 +50,11 @@ public class MBeanExporterParserTests {
public void testMBeanExporterExists() throws InterruptedException {
IntegrationMBeanExporter exporter = this.context.getBean(IntegrationMBeanExporter.class);
MBeanServer server = this.context.getBean("mbs", MBeanServer.class);
Properties properties = TestUtils.getPropertyValue(exporter, "objectNameStaticProperties", Properties.class);
assertNotNull(properties);
assertEquals(2, properties.size());
assertTrue(properties.containsKey("foo"));
assertTrue(properties.containsKey("bar"));
assertEquals(server, exporter.getServer());
exporter.destroy();
}