View Javadoc

1   /*
2    * $Id: Http10TestCase.java 22924 2011-09-12 22:08:33Z pablo.kraan $
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.module.cxf;
12  
13  import static org.junit.Assert.assertEquals;
14  import static org.junit.Assert.assertFalse;
15  
16  import org.mule.api.MuleMessage;
17  import org.mule.module.client.MuleClient;
18  import org.mule.tck.AbstractServiceAndFlowTestCase;
19  import org.mule.tck.junit4.rule.DynamicPort;
20  import org.mule.transport.http.HttpConstants;
21  
22  import java.util.Arrays;
23  import java.util.Collection;
24  import java.util.HashMap;
25  import java.util.Map;
26  
27  import org.junit.ClassRule;
28  import org.junit.Test;
29  import org.junit.runners.Parameterized.Parameters;
30  
31  public class Http10TestCase extends AbstractServiceAndFlowTestCase
32  {
33  
34      @ClassRule
35      public static DynamicPort dynamicPort = new DynamicPort("port1");
36  
37      public Http10TestCase(ConfigVariant variant, String configResources)
38      {
39          super(variant, configResources);
40          setDisposeContextPerClass(true);
41      }
42  
43      @Parameters
44      public static Collection<Object[]> parameters()
45      {
46          return Arrays.asList(new Object[][]{
47              {ConfigVariant.SERVICE, "http-10-conf-service.xml"},
48              {ConfigVariant.FLOW, "http-10-conf-flow.xml"}
49          });
50      }      
51  
52      @Test
53      public void testHttp10TransformerNotOnProtocol() throws Exception
54      {
55          MuleClient client = new MuleClient(muleContext);
56          Map<String,String> props = new HashMap<String, String>();
57          
58          MuleMessage result = client.send("cxfOutbound", "Dan", props);
59          assertEquals("Hello Dan", result.getPayload());
60          
61          result = client.request("vm://out", 1000);
62          assertFalse("chunked".equals(result.getOutboundProperty(HttpConstants.HEADER_TRANSFER_ENCODING)));
63      }
64  
65      @Test
66      public void testHttp10TransformerOnProtocol() throws Exception
67      {
68          MuleClient client = new MuleClient(muleContext);
69          Map<String,String> props = new HashMap<String, String>();
70          
71          MuleMessage result = client.send("cxfOutbound2", "Dan", props);
72          assertEquals("Hello Dan", result.getPayload());
73          
74          result = client.request("vm://out", 1000);
75          assertFalse("chunked".equals(result.getOutboundProperty(HttpConstants.HEADER_TRANSFER_ENCODING)));
76      }
77  }