View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.endpoint.inbound;
8   
9   import org.mule.api.MuleEvent;
10  import org.mule.api.endpoint.InboundEndpoint;
11  import org.mule.api.processor.MessageProcessor;
12  import org.mule.endpoint.AbstractMessageProcessorTestCase;
13  import org.mule.message.DefaultExceptionPayload;
14  
15  import org.junit.Test;
16  
17  import static org.junit.Assert.assertEquals;
18  import static org.junit.Assert.assertNotNull;
19  
20  public class InboundExceptionDetailsProcessorTestCase extends AbstractMessageProcessorTestCase
21  {
22  
23      @Test
24      public void testProcess() throws Exception
25      {
26          InboundEndpoint endpoint = createTestInboundEndpoint(null, null);
27          MessageProcessor mp = new InboundExceptionDetailsMessageProcessor(endpoint.getConnector());
28  
29          MuleEvent event = createTestInboundEvent(endpoint);
30          event.getMessage().setExceptionPayload(new DefaultExceptionPayload(new RuntimeException()));
31  
32          MuleEvent result = mp.process(event);
33  
34          assertNotNull(result);
35          final int status = result.getMessage().getOutboundProperty("status", 0);
36          assertEquals(500, status);
37      }
38  }