1
2
3
4
5
6
7
8
9
10
11 package org.mule.test.components;
12
13 import org.mule.api.MuleMessage;
14 import org.mule.message.DefaultExceptionPayload;
15 import org.mule.module.client.MuleClient;
16 import org.mule.tck.FunctionalTestCase;
17
18 import java.util.HashMap;
19
20
21
22
23 public class EntryPointResolverCacheTestCase extends FunctionalTestCase
24 {
25 @Override
26 protected String getConfigResources()
27 {
28 return "org/mule/test/components/entry-point-resolver-cache.xml";
29 }
30
31 public void testCache() throws Exception
32 {
33 MuleClient clt = new MuleClient(muleContext);
34
35 MuleMessage response = null;
36 HashMap<String, Object> propertyMap = new HashMap<String, Object>();
37 propertyMap.put("method", "retrieveReferenceData");
38
39 response = clt.send("refOneInbound", "a request", propertyMap);
40 Object payload = response.getPayload();
41
42 assertTrue("should be a string", payload instanceof String );
43 assertEquals("ServiceOne", payload);
44
45 response = clt.send("refTwoInbound", "another request", propertyMap);
46 payload = response.getPayload();
47 if((payload == null) || (response.getExceptionPayload() != null))
48 {
49 DefaultExceptionPayload exPld = (DefaultExceptionPayload)response.getExceptionPayload();
50 if(exPld.getException() != null)
51 {
52 fail(exPld.getException().getMessage());
53 }
54 else
55 {
56 fail(exPld.toString());
57 }
58 }
59 assertTrue("should be a string", payload instanceof String );
60 assertEquals("ServiceTwo", payload);
61
62 }
63
64 public interface ReferenceDataService
65 {
66 String retrieveReferenceData(String refKey);
67 }
68
69 public static class RefDataServiceOne implements ReferenceDataService
70 {
71 public String retrieveReferenceData(String refKey)
72 {
73 return "ServiceOne";
74 }
75 }
76
77 public static class RefDataServiceTwo implements ReferenceDataService
78 {
79 public String retrieveReferenceData(String refKey)
80 {
81 return "ServiceTwo";
82 }
83
84 }
85 }