1
2
3
4
5
6
7
8
9
10
11 package org.mule.routing.outbound;
12
13 import org.mule.api.MuleEvent;
14 import org.mule.api.construct.FlowConstruct;
15 import org.mule.api.endpoint.OutboundEndpoint;
16 import org.mule.tck.MuleTestUtils;
17
18 import com.mockobjects.dynamic.AnyConstraintMatcher;
19 import com.mockobjects.dynamic.Mock;
20
21 public class RouterTestUtils
22 {
23 private RouterTestUtils()
24 {
25 super();
26 }
27
28
29 public static Mock getMockEndpoint(OutboundEndpoint toMock)
30 {
31 Mock mockEndpoint = MuleTestUtils.getMockOutboundEndpoint();
32 mockEndpoint.matchAndReturn("getEndpointURI", toMock.getEndpointURI());
33 mockEndpoint.matchAndReturn("getAddress", toMock.getEndpointURI().getUri().toString());
34 mockEndpoint.matchAndReturn("toString", toMock.toString());
35 mockEndpoint.matchAndReturn("getExchangePattern", toMock.getExchangePattern());
36 mockEndpoint.matchAndReturn("getProperties", toMock.getProperties());
37 mockEndpoint.matchAndReturn("getFilter", toMock.getFilter());
38 mockEndpoint.matchAndReturn("getName", toMock.getName());
39 mockEndpoint.matchAndReturn("getResponseTransformers", toMock.getResponseTransformers());
40 mockEndpoint.matchAndReturn("hashCode", System.identityHashCode(mockEndpoint));
41 return mockEndpoint;
42 }
43
44
45 public static AnyConstraintMatcher getArgListCheckerMuleEvent()
46 {
47 return new AnyConstraintMatcher()
48 {
49 @Override
50 public boolean matches(Object[] args)
51 {
52 return args.length == 1 && args[0] instanceof MuleEvent;
53 }
54 };
55 }
56
57
58 public static AnyConstraintMatcher getArgListCheckerFlowConstruct()
59 {
60 return new AnyConstraintMatcher()
61 {
62 @Override
63 public boolean matches(Object[] args)
64 {
65 return args.length == 1 && (args[0] == null || args[0] instanceof FlowConstruct);
66 }
67 };
68 }
69 }