1
2
3
4
5
6
7
8
9
10
11 package org.mule.endpoint.inbound;
12
13 import org.mule.api.MuleEvent;
14 import org.mule.api.MuleMessage;
15 import org.mule.api.endpoint.InboundEndpoint;
16 import org.mule.api.processor.MessageProcessor;
17 import org.mule.context.notification.EndpointMessageNotification;
18 import org.mule.endpoint.AbstractMessageProcessorTestCase;
19
20 import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit;
21
22 public class InboundNotificationMessageProcessorTestCase extends AbstractMessageProcessorTestCase
23 {
24
25 public void testProcess() throws Exception
26 {
27 TestEndpointMessageNotificationListener listener = new TestEndpointMessageNotificationListener();
28 muleContext.registerListener(listener);
29
30 InboundEndpoint endpoint = createTestInboundEndpoint(null, null);
31 MessageProcessor mp = new InboundNotificationMessageProcessor(endpoint);
32 MuleEvent event = createTestInboundEvent(endpoint);
33 mp.process(event);
34
35 assertTrue(listener.latch.await(RECEIVE_TIMEOUT, TimeUnit.MILLISECONDS));
36 assertEquals(EndpointMessageNotification.MESSAGE_RECEIVED, listener.messageNotification.getAction());
37 assertEquals(endpoint.getEndpointURI().getUri().toString(),
38 listener.messageNotification.getEndpoint());
39 assertTrue(listener.messageNotification.getSource() instanceof MuleMessage);
40 assertEquals(event.getMessage().getPayload(),
41 ((MuleMessage) listener.messageNotification.getSource()).getPayload());
42 }
43
44 }