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