diff --git a/spring-integration-event/src/test/java/org/springframework/integration/event/config/EventInboundChannelAdapterParserTests-context.xml b/spring-integration-event/src/test/java/org/springframework/integration/event/config/EventInboundChannelAdapterParserTests-context.xml
index 259da42760..e5edd8abcd 100644
--- a/spring-integration-event/src/test/java/org/springframework/integration/event/config/EventInboundChannelAdapterParserTests-context.xml
+++ b/spring-integration-event/src/test/java/org/springframework/integration/event/config/EventInboundChannelAdapterParserTests-context.xml
@@ -7,10 +7,10 @@
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.0.xsd
http://www.springframework.org/schema/integration/event http://www.springframework.org/schema/integration/event/spring-integration-event-2.0.xsd">
-
-
-
-
+
+
+
+
diff --git a/spring-integration-event/src/test/java/org/springframework/integration/event/config/EventInboundChannelAdapterParserTests.java b/spring-integration-event/src/test/java/org/springframework/integration/event/config/EventInboundChannelAdapterParserTests.java
index 8211e1fb84..4e310b95fa 100644
--- a/spring-integration-event/src/test/java/org/springframework/integration/event/config/EventInboundChannelAdapterParserTests.java
+++ b/spring-integration-event/src/test/java/org/springframework/integration/event/config/EventInboundChannelAdapterParserTests.java
@@ -13,53 +13,61 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package org.springframework.integration.event.config;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import junit.framework.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.mockito.Mockito;
+
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationEvent;
+import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.integration.Message;
-import org.springframework.integration.core.MessageHandler;
-import org.springframework.integration.core.SubscribableChannel;
+import org.springframework.integration.core.PollableChannel;
import org.springframework.integration.event.ApplicationEventInboundChannelAdapter;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @author Oleg Zhurakousky
+ * @author Mark Fisher
* @since 2.0
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
public class EventInboundChannelAdapterParserTests {
+
@Autowired
private ApplicationContext context;
-
+
+
@Test
- public void validateEventParser(){
+ public void validateEventParser() {
Object adapter = context.getBean("eventAdapter");
Assert.assertNotNull(adapter);
Assert.assertTrue(adapter instanceof ApplicationEventInboundChannelAdapter);
DirectFieldAccessor adapterAccessor = new DirectFieldAccessor(adapter);
Assert.assertEquals(context.getBean("input"), adapterAccessor.getPropertyValue("outputChannel"));
}
+
@Test
- public void validateUsage(){
- SubscribableChannel channel = context.getBean("input", SubscribableChannel.class);
- MessageHandler handler = Mockito.mock(MessageHandler.class);
- channel.subscribe(handler);
- final ApplicationEvent event = new SampleEvent("hello");
+ public void validateUsage() {
+ PollableChannel channel = context.getBean("input", PollableChannel.class);
+ assertEquals(ContextRefreshedEvent.class, channel.receive(0).getPayload().getClass());
context.publishEvent(new SampleEvent("hello"));
-
- Mockito.verify(handler, Mockito.times(1)).handleMessage(Mockito.any(Message.class));
+ Message> message = channel.receive(0);
+ assertNotNull(message);
+ assertEquals(SampleEvent.class, message.getPayload().getClass());
}
-
+
+
+ @SuppressWarnings("serial")
public static class SampleEvent extends ApplicationEvent {
public SampleEvent(Object source) {
@@ -67,4 +75,5 @@ public class EventInboundChannelAdapterParserTests {
}
}
+
}