1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.rice.ksb.messaging;
18
19 import java.util.List;
20
21 import javax.xml.namespace.QName;
22
23 import org.junit.Test;
24 import org.kuali.rice.core.config.Config;
25 import org.kuali.rice.core.config.ConfigContext;
26 import org.kuali.rice.ksb.messaging.bam.BAMTargetEntry;
27 import org.kuali.rice.ksb.messaging.bam.service.BAMService;
28 import org.kuali.rice.ksb.messaging.service.KSBXMLService;
29 import org.kuali.rice.ksb.service.KSBServiceLocator;
30 import org.kuali.rice.ksb.test.KSBTestCase;
31
32
33
34
35
36
37
38 public class StoreAndForwardTest extends KSBTestCase {
39
40 public boolean startClient1() {
41 return true;
42 }
43
44
45 @Test public void testServiceCall() throws Exception {
46 ConfigContext.getCurrentContextConfig().putProperty(Config.STORE_AND_FORWARD, "true");
47 QName serviceName = new QName("TestCl1", "testXmlAsyncService");
48 KSBXMLService testXmlAsyncService = (KSBXMLService) KSBServiceLocator.getMessageHelper().getServiceAsynchronously(serviceName);
49 testXmlAsyncService.invoke("message content");
50 verifyServiceCalls();
51 }
52
53 private void verifyServiceCalls() throws Exception {
54 BAMService bamService = KSBServiceLocator.getBAMService();
55 List<BAMTargetEntry> bamCalls = bamService.getCallsForService(QName.valueOf("{TestCl1}testXmlAsyncService-forwardHandler"));
56 assertTrue("No service call recorded", bamCalls.size() > 0);
57 boolean foundClientCall = false;
58 boolean foundServiceCall = false;
59 for (BAMTargetEntry bamEntry : bamCalls) {
60 if (bamEntry.getServerInvocation()) {
61 foundServiceCall = true;
62 } else {
63 foundClientCall = true;
64 }
65 }
66 assertTrue("No client call recorded", foundClientCall);
67 assertTrue("No service call recorded", foundServiceCall);
68 }
69 }