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.module.cxf;
8   
9   import org.mule.api.MuleMessage;
10  import org.mule.module.client.MuleClient;
11  import org.mule.tck.junit4.FunctionalTestCase;
12  import org.mule.tck.junit4.rule.DynamicPort;
13  import org.mule.transport.http.HttpConstants;
14  
15  import java.util.HashMap;
16  import java.util.Map;
17  
18  import org.junit.ClassRule;
19  import org.junit.Test;
20  
21  import static org.junit.Assert.assertEquals;
22  import static org.junit.Assert.assertFalse;
23  
24  public class Http10TestCase extends FunctionalTestCase
25  {
26  
27      @ClassRule
28      public static DynamicPort dynamicPort = new DynamicPort("port1");
29  
30      public Http10TestCase()
31      {
32          setDisposeContextPerClass(true);
33      }
34  
35      @Override
36      protected String getConfigResources()
37      {
38          return "http-10-conf.xml";
39      }
40  
41      @Test
42      public void testHttp10TransformerNotOnProtocol() throws Exception
43      {
44          MuleClient client = new MuleClient(muleContext);
45          Map<String,String> props = new HashMap<String, String>();
46          
47          MuleMessage result = client.send("cxfOutbound", "Dan", props);
48          assertEquals("Hello Dan", result.getPayload());
49          
50          result = client.request("vm://out", 1000);
51          assertFalse("chunked".equals(result.getOutboundProperty(HttpConstants.HEADER_TRANSFER_ENCODING)));
52      }
53  
54      @Test
55      public void testHttp10TransformerOnProtocol() throws Exception
56      {
57          MuleClient client = new MuleClient(muleContext);
58          Map<String,String> props = new HashMap<String, String>();
59          
60          MuleMessage result = client.send("cxfOutbound2", "Dan", props);
61          assertEquals("Hello Dan", result.getPayload());
62          
63          result = client.request("vm://out", 1000);
64          assertFalse("chunked".equals(result.getOutboundProperty(HttpConstants.HEADER_TRANSFER_ENCODING)));
65      }
66  }