View Javadoc

1   /*
2    * $Id: InboundNotificationMessageProcessorTestCase.java 22391 2011-07-12 12:00:48Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
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 java.util.concurrent.TimeUnit;
21  
22  import org.junit.Test;
23  
24  import static org.junit.Assert.assertEquals;
25  import static org.junit.Assert.assertTrue;
26  
27  public class InboundNotificationMessageProcessorTestCase extends AbstractMessageProcessorTestCase
28  {
29      @Test
30      public void testProcess() throws Exception
31      {
32          TestEndpointMessageNotificationListener listener = new TestEndpointMessageNotificationListener();
33          muleContext.registerListener(listener);
34  
35          InboundEndpoint endpoint = createTestInboundEndpoint(null, null);
36          MessageProcessor mp = new InboundNotificationMessageProcessor(endpoint);
37          MuleEvent event = createTestInboundEvent(endpoint);
38          mp.process(event);
39  
40          assertTrue(listener.latch.await(RECEIVE_TIMEOUT, TimeUnit.MILLISECONDS));
41          assertEquals(EndpointMessageNotification.MESSAGE_RECEIVED, listener.messageNotification.getAction());
42          assertEquals(endpoint.getEndpointURI().getUri().toString(),
43              listener.messageNotification.getEndpoint());
44          assertTrue(listener.messageNotification.getSource() instanceof MuleMessage);
45          assertEquals(event.getMessage().getPayload(),
46              listener.messageNotification.getSource().getPayload());
47      }
48  }