View Javadoc

1   /*
2    * $Id: InboundExceptionDetailsProcessorTestCase.java 22377 2011-07-11 12:41:42Z 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.endpoint.InboundEndpoint;
15  import org.mule.api.processor.MessageProcessor;
16  import org.mule.endpoint.AbstractMessageProcessorTestCase;
17  import org.mule.message.DefaultExceptionPayload;
18  
19  import org.junit.Test;
20  
21  import static org.junit.Assert.assertEquals;
22  import static org.junit.Assert.assertNotNull;
23  
24  public class InboundExceptionDetailsProcessorTestCase extends AbstractMessageProcessorTestCase
25  {
26  
27      @Test
28      public void testProcess() throws Exception
29      {
30          InboundEndpoint endpoint = createTestInboundEndpoint(null, null);
31          MessageProcessor mp = new InboundExceptionDetailsMessageProcessor(endpoint.getConnector());
32  
33          MuleEvent event = createTestInboundEvent(endpoint);
34          event.getMessage().setExceptionPayload(new DefaultExceptionPayload(new RuntimeException()));
35  
36          MuleEvent result = mp.process(event);
37  
38          assertNotNull(result);
39          final int status = result.getMessage().getOutboundProperty("status", 0);
40          assertEquals(500, status);
41      }
42  }