1
2
3
4
5
6
7
8
9
10
11 package org.mule.module.ws.construct;
12
13 import org.mule.MessageExchangePattern;
14 import org.mule.api.construct.FlowConstructInvalidException;
15 import org.mule.api.processor.MessageProcessor;
16 import org.mule.tck.MuleTestUtils;
17 import org.mule.tck.junit4.AbstractMuleContextTestCase;
18
19 import java.net.URI;
20 import java.util.Collections;
21 import java.util.List;
22 import java.util.concurrent.Callable;
23
24 import org.junit.Test;
25
26 import static org.junit.Assert.assertTrue;
27 import static org.junit.Assert.fail;
28
29 public class WsProxyConfigurationIssuesTestCase extends AbstractMuleContextTestCase
30 {
31 private static List<MessageProcessor> noMessageProcessors = Collections.emptyList();
32
33 @Test
34 public void testNullMessageSource()
35 {
36 runTestFailingWithExpectedFlowConstructInvalidException(new Callable<WSProxy>()
37 {
38 @Override
39 public WSProxy call() throws Exception
40 {
41 return new WSProxy("testNullMessageSource", muleContext, null,
42 MuleTestUtils.getTestOutboundEndpoint(MessageExchangePattern.REQUEST_RESPONSE,
43 muleContext), noMessageProcessors, noMessageProcessors);
44 }
45 });
46 }
47
48 @Test
49 public void testNullOutboundEndpoint()
50 {
51 runTestFailingWithExpectedFlowConstructInvalidException(new Callable<WSProxy>()
52 {
53 @Override
54 public WSProxy call() throws Exception
55 {
56 return new WSProxy("testNullOutboundEndpoint", muleContext,
57 getTestInboundEndpoint(MessageExchangePattern.REQUEST_RESPONSE), null,
58 noMessageProcessors, noMessageProcessors);
59 }
60 });
61 }
62
63 @Test
64 public void testNullOutboundEndpointWithWsdl()
65 {
66 runTestFailingWithExpectedFlowConstructInvalidException(new Callable<WSProxy>()
67 {
68 @Override
69 public WSProxy call() throws Exception
70 {
71 return new WSProxy("testNullOutboundEndpointWithWsdl", muleContext,
72 getTestInboundEndpoint(MessageExchangePattern.REQUEST_RESPONSE), null,
73 noMessageProcessors, noMessageProcessors, "fake_wsdl");
74 }
75 });
76 }
77
78 @Test
79 public void testBlankWsdlContents()
80 {
81 runTestFailingWithExpectedFlowConstructInvalidException(new Callable<WSProxy>()
82 {
83 @Override
84 public WSProxy call() throws Exception
85 {
86 return new WSProxy("testBlankWsdlContents", muleContext,
87 getTestInboundEndpoint(MessageExchangePattern.REQUEST_RESPONSE),
88 MuleTestUtils.getTestOutboundEndpoint(MessageExchangePattern.REQUEST_RESPONSE,
89 muleContext), noMessageProcessors, noMessageProcessors, "");
90 }
91 });
92 }
93
94 @Test
95 public void testNullWsdlUri()
96 {
97 runTestFailingWithExpectedFlowConstructInvalidException(new Callable<WSProxy>()
98 {
99 @Override
100 public WSProxy call() throws Exception
101 {
102 return new WSProxy("testNullWsdlUrl", muleContext,
103 getTestInboundEndpoint(MessageExchangePattern.REQUEST_RESPONSE),
104 MuleTestUtils.getTestOutboundEndpoint(MessageExchangePattern.REQUEST_RESPONSE,
105 muleContext), noMessageProcessors, noMessageProcessors, (URI) null);
106 }
107 });
108 }
109
110 @Test
111 public void testOneWayInboundEndpoint()
112 {
113 runTestFailingWithExpectedFlowConstructInvalidException(new Callable<WSProxy>()
114 {
115 @Override
116 public WSProxy call() throws Exception
117 {
118 return new WSProxy("testOneWayInboundEndpoint", muleContext,
119 getTestInboundEndpoint(MessageExchangePattern.ONE_WAY),
120 MuleTestUtils.getTestOutboundEndpoint(MessageExchangePattern.REQUEST_RESPONSE,
121 muleContext), noMessageProcessors, noMessageProcessors);
122 }
123 });
124 }
125
126 @Test
127 public void testOneWayOutboundEndpoint()
128 {
129 runTestFailingWithExpectedFlowConstructInvalidException(new Callable<WSProxy>()
130 {
131 @Override
132 public WSProxy call() throws Exception
133 {
134 return new WSProxy("testOneWayOutboundEndpoint", muleContext,
135 getTestInboundEndpoint(MessageExchangePattern.REQUEST_RESPONSE),
136 MuleTestUtils.getTestOutboundEndpoint(MessageExchangePattern.ONE_WAY, muleContext),
137 noMessageProcessors, noMessageProcessors);
138 }
139 });
140 }
141
142 private void runTestFailingWithExpectedFlowConstructInvalidException(final Callable<WSProxy> failingStatement)
143 {
144 try
145 {
146 failingStatement.call().validateConstruct();
147 fail("should have got a FlowConstructInvalidException");
148 }
149 catch (final Exception e)
150 {
151 assertTrue(e instanceof FlowConstructInvalidException);
152 }
153 }
154 }