1
2
3
4
5
6
7
8
9
10
11 package org.mule.module.cxf;
12
13 import org.mule.api.MuleMessage;
14 import org.mule.api.client.MuleClient;
15 import org.mule.tck.AbstractServiceAndFlowTestCase;
16 import org.mule.tck.junit4.rule.DynamicPort;
17
18 import java.util.Arrays;
19 import java.util.Collection;
20
21 import org.junit.Rule;
22 import org.junit.Test;
23 import org.junit.runners.Parameterized;
24
25 import static org.junit.Assert.assertTrue;
26
27 public class ProxySoapVersionTestCase extends AbstractServiceAndFlowTestCase
28 {
29 String doGoogleSearch = "<urn:doGoogleSearch xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:urn=\"urn:GoogleSearch\">";
30
31
32 String msgWithComment = "<soap12:Envelope xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\">"
33 + "<!-- comment 1 -->"
34 + "<soap12:Header>"
35 + "<!-- comment 2 -->"
36 + "</soap12:Header>"
37 + "<!-- comment 3 -->"
38 + "<soap12:Body>"
39 + "<!-- comment 4 -->"
40 + doGoogleSearch
41 + "<!-- this comment breaks it -->"
42 + "<key>1</key>"
43 + "<!-- comment 5 -->"
44 + "<q>a</q>"
45 + "<start>0</start>"
46 + "<maxResults>1</maxResults>"
47 + "<filter>false</filter>"
48 + "<restrict>a</restrict>"
49 + "<safeSearch>true</safeSearch>"
50 + "<lr>a</lr>"
51 + "<ie>b</ie>"
52 + "<oe>c</oe>"
53 + "</urn:doGoogleSearch>"
54 + "<!-- comment 6 -->"
55 + "</soap12:Body>"
56 + "<!-- comment 7 -->"
57 + "</soap12:Envelope>";
58
59 public ProxySoapVersionTestCase(ConfigVariant variant, String configResources)
60 {
61 super(variant, configResources);
62 }
63
64 @Rule
65 public DynamicPort dynamicPort = new DynamicPort("port1");
66
67 @Parameterized.Parameters
68 public static Collection<Object[]> parameters()
69 {
70 return Arrays.asList(new Object[][] {
71 {AbstractServiceAndFlowTestCase.ConfigVariant.SERVICE, "proxy-soap-version-conf-service.xml"},
72 {AbstractServiceAndFlowTestCase.ConfigVariant.FLOW, "proxy-soap-version-conf-flow.xml"}
73 });
74 }
75
76 @Test
77 public void testProxyWithCommentInRequest() throws Exception
78 {
79 MuleClient client = muleContext.getClient();
80 MuleMessage result = client.send("http://localhost:" + dynamicPort.getNumber() + "/services/proxy-soap-version", msgWithComment, null);
81 String resString = result.getPayloadAsString();
82 assertTrue(resString.contains(doGoogleSearch));
83 }
84 }