View Javadoc

1   /*
2    * $Id$
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, 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.functional;
12  
13  import org.mule.DefaultMuleMessage;
14  import org.mule.api.MuleMessage;
15  import org.mule.module.client.MuleClient;
16  import org.mule.tck.DynamicPortTestCase;
17  
18  import java.util.Map;
19  
20  public class CxfContentTypeTestCase extends DynamicPortTestCase
21  {
22      private static final int TIMEOUT_IN_MILLISECONDS = 500;
23  
24      private static final String requestPayload =
25          "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"\n" +
26              "           xmlns:hi=\"http://example.org/\">\n" +
27              "<soap:Body>\n" +
28              "<hi:sayHi>\n" +
29              "    <arg0>Hello</arg0>\n" +
30              "</hi:sayHi>\n" +
31              "</soap:Body>\n" +
32              "</soap:Envelope>";
33  
34  
35      @Override
36      protected int getNumPortsToFind()
37      {
38          return 1;
39      }
40  
41      @Override
42      protected String getConfigResources()
43      {
44          return "cxf-echo-service-conf.xml";
45      }
46  
47      public void testCxfService() throws Exception
48      {
49          MuleMessage request = new DefaultMuleMessage(requestPayload, (Map<String,Object>)null, muleContext);
50          MuleClient client = new MuleClient(muleContext);
51          MuleMessage received = client.send("http://localhost:" + getPorts().get(0) + "/hello", request);
52          String contentType = received.getInboundProperty("content-type");
53          assertNotNull(contentType);
54          assertTrue(contentType.contains("charset"));
55      }
56  
57      public void testCxfClient() throws Exception
58      {
59          MuleMessage request = new DefaultMuleMessage("hello", (Map<String,Object>)null, muleContext);
60          MuleClient client = new MuleClient(muleContext);
61          MuleMessage received = client.send("vm://helloClient", request);
62          String contentType = received.getInboundProperty("contentType");
63          assertNotNull(contentType);
64          assertTrue(contentType.contains("charset"));
65      }
66  
67  }