01: /*
02: * Copyright 2005-2006 The Kuali Foundation.
03: *
04: *
05: * Licensed under the Educational Community License, Version 1.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.opensource.org/licenses/ecl1.php
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package edu.iu.uis.eden.messaging;
18:
19: import java.util.List;
20:
21: import javax.xml.namespace.QName;
22:
23: import org.junit.Test;
24: import org.kuali.bus.services.KSBServiceLocator;
25: import org.kuali.bus.test.KSBTestCase;
26: import org.kuali.rice.config.Config;
27: import org.kuali.rice.core.Core;
28:
29: import edu.iu.uis.eden.messaging.bam.BAMService;
30: import edu.iu.uis.eden.messaging.bam.BAMTargetEntry;
31:
32: /**
33: * Test store and forward capabilities in calling services
34: *
35: * @author Kuali Rice Team (kuali-rice@googlegroups.com)
36: */
37: public class StoreAndForwardTest extends KSBTestCase {
38:
39: public boolean startClient1() {
40: return true;
41: }
42:
43: @Test
44: public void testServiceCall() throws Exception {
45: Core.getCurrentContextConfig().overrideProperty(
46: Config.STORE_AND_FORWARD, "true");
47: QName serviceName = new QName("TestCl1", "testXmlAsyncService");
48: KEWXMLService testXmlAsyncService = (KEWXMLService) KSBServiceLocator
49: .getMessageHelper().getServiceAsynchronously(
50: serviceName);
51: testXmlAsyncService.invoke("message content");
52: verifyServiceCalls();
53: }
54:
55: private void verifyServiceCalls() throws Exception {
56: BAMService bamService = KSBServiceLocator.getBAMService();
57: List<BAMTargetEntry> bamCalls = bamService
58: .getCallsForService(QName
59: .valueOf("{TestCl1}testXmlAsyncService-forwardHandler"));
60: assertTrue("No service call recorded", bamCalls.size() > 0);
61: boolean foundClientCall = false;
62: boolean foundServiceCall = false;
63: for (BAMTargetEntry bamEntry : bamCalls) {
64: if (bamEntry.getServerInvocation()) {
65: foundServiceCall = true;
66: } else {
67: foundClientCall = true;
68: }
69: }
70: assertTrue("No client call recorded", foundClientCall);
71: assertTrue("No service call recorded", foundServiceCall);
72: }
73: }
|