View Javadoc

1   /*
2    * $Id: WsProxyConfigurationIssuesTestCase.java 19191 2010-08-25 21:05:23Z tcarlson $
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.module.ws.construct;
12  
13  import java.net.URI;
14  import java.util.concurrent.Callable;
15  
16  import org.mule.MessageExchangePattern;
17  import org.mule.api.construct.FlowConstructInvalidException;
18  import org.mule.tck.AbstractMuleTestCase;
19  import org.mule.tck.MuleTestUtils;
20  
21  public class WsProxyConfigurationIssuesTestCase extends AbstractMuleTestCase
22  {
23      public void testNullMessageSource()
24      {
25          runTestFailingWithExpectedFlowConstructInvalidException(new Callable<WSProxy>()
26          {
27              public WSProxy call() throws Exception
28              {
29                  return new WSProxy("testNullMessageSource", muleContext, null,
30                      MuleTestUtils.getTestOutboundEndpoint(MessageExchangePattern.REQUEST_RESPONSE,
31                          muleContext));
32              }
33          });
34      }
35  
36      public void testNullOutboundEndpoint()
37      {
38          runTestFailingWithExpectedFlowConstructInvalidException(new Callable<WSProxy>()
39          {
40              public WSProxy call() throws Exception
41              {
42                  return new WSProxy("testNullOutboundEndpoint", muleContext,
43                      getTestInboundEndpoint(MessageExchangePattern.REQUEST_RESPONSE), null);
44              }
45          });
46      }
47  
48      public void testNullOutboundEndpointWithWsdl()
49      {
50          runTestFailingWithExpectedFlowConstructInvalidException(new Callable<WSProxy>()
51          {
52              public WSProxy call() throws Exception
53              {
54                  return new WSProxy("testNullOutboundEndpointWithWsdl", muleContext,
55                      getTestInboundEndpoint(MessageExchangePattern.REQUEST_RESPONSE), null, "fake_wsdl");
56              }
57          });
58      }
59  
60      public void testBlankWsdlContents()
61      {
62          runTestFailingWithExpectedFlowConstructInvalidException(new Callable<WSProxy>()
63          {
64              public WSProxy call() throws Exception
65              {
66                  return new WSProxy("testBlankWsdlContents", muleContext,
67                      getTestInboundEndpoint(MessageExchangePattern.REQUEST_RESPONSE),
68                      MuleTestUtils.getTestOutboundEndpoint(MessageExchangePattern.REQUEST_RESPONSE,
69                          muleContext), "");
70              }
71          });
72      }
73  
74      public void testNullWsdlUri()
75      {
76          runTestFailingWithExpectedFlowConstructInvalidException(new Callable<WSProxy>()
77          {
78              public WSProxy call() throws Exception
79              {
80                  return new WSProxy("testNullWsdlUrl", muleContext,
81                      getTestInboundEndpoint(MessageExchangePattern.REQUEST_RESPONSE),
82                      MuleTestUtils.getTestOutboundEndpoint(MessageExchangePattern.REQUEST_RESPONSE,
83                          muleContext), (URI) null);
84              }
85          });
86      }
87  
88      public void testOneWayInboundEndpoint()
89      {
90          runTestFailingWithExpectedFlowConstructInvalidException(new Callable<WSProxy>()
91          {
92              public WSProxy call() throws Exception
93              {
94                  return new WSProxy("testOneWayInboundEndpoint", muleContext,
95                      getTestInboundEndpoint(MessageExchangePattern.ONE_WAY),
96                      MuleTestUtils.getTestOutboundEndpoint(MessageExchangePattern.REQUEST_RESPONSE,
97                          muleContext));
98              }
99          });
100     }
101 
102     public void testOneWayOutboundEndpoint()
103     {
104         runTestFailingWithExpectedFlowConstructInvalidException(new Callable<WSProxy>()
105         {
106             public WSProxy call() throws Exception
107             {
108                 return new WSProxy("testOneWayOutboundEndpoint", muleContext,
109                     getTestInboundEndpoint(MessageExchangePattern.REQUEST_RESPONSE),
110                     MuleTestUtils.getTestOutboundEndpoint(MessageExchangePattern.ONE_WAY, muleContext));
111             }
112         });
113     }
114 
115     private void runTestFailingWithExpectedFlowConstructInvalidException(Callable<WSProxy> failingStatement)
116     {
117         try
118         {
119             failingStatement.call().validateConstruct();
120             fail("should have got a FlowConstructInvalidException");
121         }
122         catch (final Exception e)
123         {
124             assertTrue(e instanceof FlowConstructInvalidException);
125         }
126     }
127 }