View Javadoc

1   /*
2    * $Id: HttpEncodingFunctionalTestCase.java 19191 2010-08-25 21:05:23Z tcarlson $
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.functional;
12  
13  import org.mule.api.MuleMessage;
14  import org.mule.module.client.MuleClient;
15  import org.mule.transport.http.HttpConnector;
16  import org.mule.transport.http.HttpConstants;
17  
18  import java.util.HashMap;
19  import java.util.Map;
20  
21  public class HttpEncodingFunctionalTestCase extends HttpFunctionalTestCase
22  {
23      protected static String TEST_MESSAGE = "Test Http Request (R�dgr�d), 57 = \u06f7\u06f5 in Arabic";
24  
25      @Override
26      protected String getConfigResources()
27      {
28          return "http-encoding-test.xml";
29      }
30  
31      @Override
32      public void testSend() throws Exception
33      {
34          MuleClient client = new MuleClient(muleContext);
35          
36          Map<String, Object> messageProperties = new HashMap<String, Object>();
37          messageProperties.put(HttpConstants.HEADER_CONTENT_TYPE, getSendEncoding());
38          
39          MuleMessage reply = client.send("clientEndpoint", TEST_MESSAGE, messageProperties);
40          assertNotNull(reply);
41          assertEquals("200", reply.getInboundProperty(HttpConnector.HTTP_STATUS_PROPERTY));
42          assertEquals("text/baz;charset=UTF-16BE", reply.<String>getInboundProperty(HttpConstants.HEADER_CONTENT_TYPE));
43          assertEquals("UTF-16BE", reply.getEncoding());
44          assertEquals(TEST_MESSAGE + " Received", reply.getPayloadAsString());
45      }
46  
47      protected String getSendEncoding()
48      {
49          return "text/plain;charset=UTF-8";
50      }
51  }