1
2
3
4
5
6
7
8
9
10
11 package org.mule.test.integration.construct;
12
13 import org.mule.module.client.MuleClient;
14 import org.mule.tck.AbstractServiceAndFlowTestCase;
15 import org.mule.tck.junit4.rule.DynamicPort;
16 import org.mule.test.integration.tck.WeatherForecaster;
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.Parameters;
24
25 import static org.junit.Assert.assertEquals;
26 import static org.junit.Assert.assertTrue;
27
28 public class WSProxyTestCase extends AbstractServiceAndFlowTestCase
29 {
30 @Rule
31 public DynamicPort port1 = new DynamicPort("port1");
32
33 @Rule
34 public DynamicPort port2 = new DynamicPort("port2");
35
36 private MuleClient muleClient;
37
38 @Parameters
39 public static Collection<Object[]> parameters()
40 {
41 return Arrays.asList(new Object[][]{{ConfigVariant.SERVICE,
42 "org/mule/test/integration/construct/ws-proxy-config.xml"}
43
44 });
45 }
46
47 public WSProxyTestCase(ConfigVariant variant, String configResources)
48 {
49 super(variant, configResources);
50 }
51
52 @Override
53 protected void doSetUp() throws Exception
54 {
55 super.doSetUp();
56 muleClient = new MuleClient(muleContext);
57 }
58
59 @Test
60 public void testDynamicWsdl() throws Exception
61 {
62 testWsdlAndWebServiceRequests(0);
63 }
64
65 @Test
66 public void testFileContentsWsdl() throws Exception
67 {
68 testWsdlAndWebServiceRequests(1);
69 }
70
71 @Test
72 public void testStaticUriWsdl() throws Exception
73 {
74 testWsdlAndWebServiceRequests(2);
75 }
76
77 @Test
78 public void testGlobalEndpoints() throws Exception
79 {
80 testWsdlAndWebServiceRequests(3);
81 }
82
83 @Test
84 public void testTransformers() throws Exception
85 {
86 testWsdlAndWebServiceRequests(4);
87 }
88
89 @Test
90 public void testExceptionStrategy() throws Exception
91 {
92 testWsdlAndWebServiceRequests(5);
93 }
94
95 @Test
96 public void testInheritance() throws Exception
97 {
98 testWsdlAndWebServiceRequests(6);
99 }
100
101 @Test
102 public void testEndpointChildren() throws Exception
103 {
104 testWsdlAndWebServiceRequests(7);
105 }
106
107 @Test
108 public void testInheritanceAndEndpointChildren() throws Exception
109 {
110 testWsdlAndWebServiceRequests(8);
111 }
112
113 @Test
114 public void testExpressionEndpoint() throws Exception
115 {
116 testWsdlAndWebServiceRequests(9);
117 }
118
119 private void testWsdlAndWebServiceRequests(final int proxyId) throws Exception
120 {
121 testWsdlRequest(proxyId);
122 testWebServiceRequest(proxyId);
123 }
124
125 private void testWsdlRequest(final int proxyId) throws Exception
126 {
127 final String wsdl = muleClient.request(
128 "http://localhost:" + port1.getNumber() + "/weather-forecast/" + proxyId + "?wsdl",
129 getTestTimeoutSecs() * 1000L).getPayloadAsString();
130 assertTrue(wsdl.contains("GetWeatherByZipCode"));
131 }
132
133 private void testWebServiceRequest(final int proxyId) throws Exception
134 {
135 final String weatherForecast = muleClient.send(
136 "wsdl-cxf:http://localhost:" + port1.getNumber() + "/weather-forecast/" + proxyId
137 + "?wsdl&method=GetWeatherByZipCode", "95050", null, getTestTimeoutSecs() * 1000)
138 .getPayloadAsString();
139
140 assertEquals(new WeatherForecaster().getByZipCode("95050"), weatherForecast);
141 }
142 }