1
2
3
4
5
6
7
8
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.junit4.FunctionalTestCase;
17 import org.mule.tck.junit4.rule.DynamicPort;
18
19 import java.util.Map;
20
21 import org.junit.Rule;
22 import org.junit.Test;
23
24 import static org.junit.Assert.assertNotNull;
25 import static org.junit.Assert.assertTrue;
26
27 public class CxfContentTypeTestCase extends FunctionalTestCase
28 {
29 private static final String requestPayload =
30 "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"\n" +
31 " xmlns:hi=\"http://example.org/\">\n" +
32 "<soap:Body>\n" +
33 "<hi:sayHi>\n" +
34 " <arg0>Hello</arg0>\n" +
35 "</hi:sayHi>\n" +
36 "</soap:Body>\n" +
37 "</soap:Envelope>";
38
39 @Rule
40 public DynamicPort dynamicPort = new DynamicPort("port1");
41
42 @Override
43 protected String getConfigResources()
44 {
45 return "cxf-echo-service-conf.xml";
46 }
47
48 @Test
49 public void testCxfService() throws Exception
50 {
51 MuleMessage request = new DefaultMuleMessage(requestPayload, (Map<String,Object>)null, muleContext);
52 MuleClient client = new MuleClient(muleContext);
53 MuleMessage received = client.send("http://localhost:" + dynamicPort.getNumber() + "/hello", request);
54 String contentType = received.getInboundProperty("content-type");
55 assertNotNull(contentType);
56 assertTrue(contentType.contains("charset"));
57 }
58
59 @Test
60 public void testCxfClient() throws Exception
61 {
62 MuleMessage request = new DefaultMuleMessage("hello", (Map<String,Object>)null, muleContext);
63 MuleClient client = new MuleClient(muleContext);
64 MuleMessage received = client.send("vm://helloClient", request);
65 String contentType = received.getInboundProperty("contentType");
66 assertNotNull(contentType);
67 assertTrue(contentType.contains("charset"));
68 }
69
70 }