diff --git a/org.springframework.integration.jmx/src/test/java/org/springframework/integration/jmx/config/AttributePollingChannelAdapterParserTests-context.xml b/org.springframework.integration.jmx/src/test/java/org/springframework/integration/jmx/config/AttributePollingChannelAdapterParserTests-context.xml new file mode 100644 index 0000000000..5381afcfe2 --- /dev/null +++ b/org.springframework.integration.jmx/src/test/java/org/springframework/integration/jmx/config/AttributePollingChannelAdapterParserTests-context.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + diff --git a/org.springframework.integration.jmx/src/test/java/org/springframework/integration/jmx/config/AttributePollingChannelAdapterParserTests.java b/org.springframework.integration.jmx/src/test/java/org/springframework/integration/jmx/config/AttributePollingChannelAdapterParserTests.java new file mode 100644 index 0000000000..4d28c0aea6 --- /dev/null +++ b/org.springframework.integration.jmx/src/test/java/org/springframework/integration/jmx/config/AttributePollingChannelAdapterParserTests.java @@ -0,0 +1,59 @@ +/* + * 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. + */ + +package org.springframework.integration.jmx.config; + +import static org.junit.Assert.assertEquals; +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.integration.channel.PollableChannel; +import org.springframework.integration.core.Message; +import org.springframework.integration.endpoint.SourcePollingChannelAdapter; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +/** + * @author Mark Fisher + * @since 2.0 + */ +@ContextConfiguration +@RunWith(SpringJUnit4ClassRunner.class) +public class AttributePollingChannelAdapterParserTests { + + @Autowired + private PollableChannel channel; + + @Autowired + private SourcePollingChannelAdapter adapter; + + @Autowired + private TestBean testBean; + + + @Test + public void pollForAttribute() throws Exception { + testBean.test("foo"); + adapter.start(); + Message result = channel.receive(1000); + assertNotNull(result); + assertEquals("foo", result.getPayload()); + } + +} diff --git a/org.springframework.integration.jmx/src/test/java/org/springframework/integration/jmx/config/TestBean.java b/org.springframework.integration.jmx/src/test/java/org/springframework/integration/jmx/config/TestBean.java index 676ef235ee..538f84c71d 100644 --- a/org.springframework.integration.jmx/src/test/java/org/springframework/integration/jmx/config/TestBean.java +++ b/org.springframework.integration.jmx/src/test/java/org/springframework/integration/jmx/config/TestBean.java @@ -19,6 +19,7 @@ package org.springframework.integration.jmx.config; import java.util.ArrayList; import java.util.List; +import org.springframework.jmx.export.annotation.ManagedAttribute; import org.springframework.jmx.export.annotation.ManagedOperation; import org.springframework.jmx.export.annotation.ManagedResource; @@ -31,6 +32,11 @@ public class TestBean { final List messages = new ArrayList(); + @ManagedAttribute + public String getFirstMessage() { + return (messages.size() > 0) ? messages.get(0) : null; + } + @ManagedOperation public void test(String text) { this.messages.add(text);