1
2
3
4
5
6
7
8
9
10
11 package org.mule.module.cxf;
12
13 import static org.junit.Assert.assertEquals;
14 import static org.junit.Assert.assertNotNull;
15
16 import java.util.Arrays;
17 import java.util.Collection;
18 import java.util.Properties;
19
20 import org.junit.Rule;
21 import org.junit.Test;
22 import org.junit.runners.Parameterized.Parameters;
23 import org.mule.DefaultMuleMessage;
24 import org.mule.api.MuleMessage;
25 import org.mule.module.client.MuleClient;
26 import org.mule.tck.AbstractServiceAndFlowTestCase;
27 import org.mule.tck.junit4.rule.DynamicPort;
28
29 public class WebServiceWrapperWithCxfTestCase extends AbstractServiceAndFlowTestCase
30 {
31
32 private String testString = "test";
33
34 @Rule
35 public DynamicPort dynamicPort = new DynamicPort("port1");
36
37 public WebServiceWrapperWithCxfTestCase(ConfigVariant variant, String configResources)
38 {
39 super(variant, configResources);
40 }
41
42 @Parameters
43 public static Collection<Object[]> parameters()
44 {
45 return Arrays.asList(new Object[][]{
46 {ConfigVariant.SERVICE, "mule-ws-wrapper-config-service.xml"},
47 {ConfigVariant.FLOW, "mule-ws-wrapper-config-flow.xml"}
48 });
49 }
50
51 @Test
52 public void testWsCall() throws Exception
53 {
54 MuleClient client = new MuleClient(muleContext);
55 MuleMessage result = client.send("vm://testin", new DefaultMuleMessage(testString, muleContext));
56 assertNotNull(result.getPayload());
57 assertEquals("Payload", testString, result.getPayloadAsString());
58 }
59
60 @Test
61 public void testWsCallWithUrlFromMessage() throws Exception
62 {
63 MuleClient client = new MuleClient(muleContext);
64 Properties props = new Properties();
65 props.setProperty("ws.service.url", "http://localhost:" + dynamicPort.getNumber()
66 + "/services/TestUMO?method=onReceive");
67 MuleMessage result = client.send("vm://testin2", testString, props);
68 assertNotNull(result.getPayload());
69 assertEquals("Payload", testString, result.getPayloadAsString());
70 }
71 }