View Javadoc

1   /*
2    * $Id: InboundMessageLossAsynchTestCase.java 23284 2011-10-31 23:07:39Z mike.schilling $
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.transport.http.reliability;
12  
13  import org.mule.transport.http.HttpConstants;
14  
15  import org.apache.commons.httpclient.HttpMethodBase;
16  import org.apache.commons.httpclient.methods.PostMethod;
17  
18  /**
19   * Verify that no inbound messages are lost when exceptions occur.  
20   * The message must either make it all the way to the SEDA queue (in the case of 
21   * an asynchronous inbound endpoint), or be restored/rolled back at the source.
22   * 
23   * In the case of the HTTP transport, there is no way to restore the source message
24   * so an exception is simply returned to the client.
25   */
26  public class InboundMessageLossAsynchTestCase extends InboundMessageLossTestCase
27  {
28      @Override
29      protected String getConfigResources()
30      {
31          return "reliability/inbound-message-loss-asynch.xml";
32      }
33  
34      public void testNoException() throws Exception
35      {
36          HttpMethodBase request = createRequest(getBaseUri() + "/noException");
37          int status = httpClient.executeMethod(request);
38          assertEquals(HttpConstants.SC_OK, status);
39      }
40  
41      @Override
42      public void testHandledTransformerException() throws Exception
43      {
44          HttpMethodBase request = createRequest(getBaseUri() + "/handledTransformerException");
45          int status = httpClient.executeMethod(request);
46          assertEquals(HttpConstants.SC_OK, status);    }
47  
48      public void testComponentException() throws Exception
49      {
50          HttpMethodBase request = createRequest(getBaseUri() + "/componentException");
51          int status = httpClient.executeMethod(request);
52          // Component exception occurs after the SEDA queue for an asynchronous request, so from the client's
53          // perspective, the message has been delivered successfully.
54          assertEquals(HttpConstants.SC_OK, status);
55      }    
56  
57      @Override
58      protected HttpMethodBase createRequest(String uri)
59      {
60          return new PostMethod(uri);
61      }    
62  }