View Javadoc

1   /*
2    * $Id: WSProxyTestCase.java 19885 2010-10-12 19:26:00Z ddossot $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, 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.test.integration.construct;
12  
13  import org.mule.module.client.MuleClient;
14  import org.mule.tck.FunctionalTestCase;
15  import org.mule.test.integration.tck.WeatherForecaster;
16  
17  public class WSProxyTestCase extends FunctionalTestCase
18  {
19      private MuleClient muleClient;
20  
21      @Override
22      protected String getConfigResources()
23      {
24          return "org/mule/test/integration/construct/ws-proxy-config.xml";
25      }
26  
27      @Override
28      protected void doSetUp() throws Exception
29      {
30          super.setDisposeManagerPerSuite(true);
31          super.doSetUp();
32          muleClient = new MuleClient(muleContext);
33      }
34  
35      public void testDynamicWsdl() throws Exception
36      {
37          testWsdlAndWebServiceRequests(0);
38      }
39  
40      public void testFileContentsWsdl() throws Exception
41      {
42          testWsdlAndWebServiceRequests(1);
43      }
44  
45      public void testStaticUriWsdl() throws Exception
46      {
47          testWsdlAndWebServiceRequests(2);
48      }
49  
50      public void testGlobalEndpoints() throws Exception
51      {
52          testWsdlAndWebServiceRequests(3);
53      }
54  
55      public void testTransformers() throws Exception
56      {
57          testWsdlAndWebServiceRequests(4);
58      }
59  
60      public void testExceptionStrategy() throws Exception
61      {
62          testWsdlAndWebServiceRequests(5);
63      }
64  
65      public void testInheritance() throws Exception
66      {
67          testWsdlAndWebServiceRequests(6);
68      }
69  
70      public void testEndpointChildren() throws Exception
71      {
72          testWsdlAndWebServiceRequests(7);
73      }
74  
75      public void testInheritanceAndEndpointChildren() throws Exception
76      {
77          testWsdlAndWebServiceRequests(8);
78      }
79  
80      public void testExpressionEndpoint() throws Exception
81      {
82          testWsdlAndWebServiceRequests(9);
83      }
84  
85      private void testWsdlAndWebServiceRequests(int proxyId) throws Exception
86      {
87          testWsdlRequest(proxyId);
88          testWebServiceRequest(proxyId);
89      }
90  
91      private void testWsdlRequest(int proxyId) throws Exception
92      {
93          final String wsdl = muleClient.request("http://localhost:8090/weather-forecast/" + proxyId + "?wsdl",
94              getTestTimeoutSecs() * 1000L).getPayloadAsString();
95          assertTrue(wsdl.contains("GetWeatherByZipCode"));
96      }
97  
98      private void testWebServiceRequest(int proxyId) throws Exception
99      {
100         final String weatherForecast = muleClient.send(
101             "wsdl-cxf:http://localhost:8090/weather-forecast/" + proxyId + "?wsdl&method=GetWeatherByZipCode",
102             "95050", null, getTestTimeoutSecs() * 1000)
103             .getPayloadAsString();
104 
105         assertEquals(new WeatherForecaster().getByZipCode("95050"), weatherForecast);
106     }
107 
108 }