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.transport.http.functional;
8   
9   import org.mule.api.ExceptionPayload;
10  import org.mule.api.MuleMessage;
11  import org.mule.tck.junit4.FunctionalTestCase;
12  import org.mule.tck.junit4.rule.DynamicPort;
13  
14  import org.junit.Rule;
15  import org.junit.Test;
16  
17  import static org.hamcrest.core.IsInstanceOf.instanceOf;
18  import static org.hamcrest.core.IsNull.notNullValue;
19  import static org.junit.Assert.assertThat;
20  
21  public class HttpExceptionStrategyTestCase extends FunctionalTestCase
22  {
23      public static final int TIMEOUT = 3000;
24  
25      @Rule
26      public DynamicPort port1 = new DynamicPort("port1");
27  
28      @Override
29      protected String getConfigResources()
30      {
31          return "http-exception-strategy-config.xml";
32      }
33  
34      @Test
35      public void testInExceptionDoRollbackHttpSync() throws Exception
36      {
37          String url = String.format("http://localhost:%d/flowWithoutExceptionStrategySync", port1.getNumber());
38          MuleMessage response = muleContext.getClient().send(url, TEST_MESSAGE, null, TIMEOUT);
39          assertThat(response, notNullValue());
40          assertThat(response.getExceptionPayload(), notNullValue()); //to be fixed
41          assertThat(response.getExceptionPayload(), instanceOf(ExceptionPayload.class)); //to be review/fixed
42      }
43  }