001: /*
002: * Copyright 2005-2006 The Kuali Foundation.
003: *
004: *
005: * Licensed under the Educational Community License, Version 1.0 (the "License"); you may not use this file except in
006: * compliance with the License. You may obtain a copy of the License at
007: *
008: * http://www.opensource.org/licenses/ecl1.php
009: *
010: * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS
011: * IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
012: * language governing permissions and limitations under the License.
013: */
014: package edu.iu.uis.eden.messaging;
015:
016: import java.util.List;
017:
018: import javax.xml.namespace.QName;
019:
020: import org.junit.Test;
021: import org.kuali.bus.services.KSBServiceLocator;
022: import org.kuali.bus.test.KSBTestCase;
023: import org.kuali.rice.config.Config;
024: import org.kuali.rice.core.Core;
025:
026: import edu.iu.uis.eden.messaging.bam.BAMService;
027: import edu.iu.uis.eden.messaging.bam.BAMTargetEntry;
028: import edu.iu.uis.eden.messaging.callbacks.SimpleCallback;
029: import edu.iu.uis.eden.messaging.remotedservices.SOAPService;
030: import edu.iu.uis.eden.messaging.remotedservices.ServiceCallInformationHolder;
031: import edu.iu.uis.eden.messaging.resourceloading.KSBResourceLoaderFactory;
032:
033: /**
034: * Tests that queues work over soap
035: *
036: * @author Kuali Rice Team (kuali-rice@googlegroups.com)
037: */
038: public class SOAPMessagingTest extends KSBTestCase {
039:
040: public boolean startClient1() {
041: return true;
042: }
043:
044: @Test
045: public void testSuccessfullyCallingSOAPTopic() throws Exception {
046: // ensure test harness has entries for TestClient1
047: ((Runnable) KSBResourceLoaderFactory.getRemoteResourceLocator())
048: .run();
049:
050: QName serviceName = new QName("testNameSpace",
051: "soap-repeatTopic");
052:
053: SOAPService testJavaAsyncService = (SOAPService) KSBServiceLocator
054: .getMessageHelper().getServiceAsynchronously(
055: serviceName);
056: testJavaAsyncService.doTheThing("The param");
057: verifyServiceCalls(serviceName);
058:
059: assertTrue("Test harness topic never called",
060: ((Boolean) ServiceCallInformationHolder.stuff
061: .get("TestHarnessCalled")).booleanValue());
062: assertTrue("Cliet1 app topic never called",
063: ((Boolean) ServiceCallInformationHolder.stuff
064: .get("Client1SOAPServiceCalled"))
065: .booleanValue());
066: }
067:
068: @Test
069: public void testSuccessfullyCallingSOAPTopicAsync()
070: throws Exception {
071: KSBTestUtils.setMessagingToAsync();
072:
073: QName serviceName = new QName("testNameSpace",
074: "soap-repeatTopic");
075:
076: SimpleCallback callback = new SimpleCallback();
077: SOAPService testJavaAsyncService = (SOAPService) KSBServiceLocator
078: .getMessageHelper().getServiceAsynchronously(
079: serviceName);
080: testJavaAsyncService.doTheThing("The param");
081: callback.waitForAsyncCall(3000);
082: verifyServiceCalls(serviceName);
083: assertTrue("Test harness topic never called",
084: ((Boolean) ServiceCallInformationHolder.stuff
085: .get("TestHarnessCalled")).booleanValue());
086: assertTrue("Cliet1 app topic never called",
087: ((Boolean) ServiceCallInformationHolder.stuff
088: .get("Client1SOAPServiceCalled"))
089: .booleanValue());
090: }
091:
092: private void verifyServiceCalls(QName serviceName) throws Exception {
093: BAMService bamService = KSBServiceLocator.getBAMService();
094: List<BAMTargetEntry> bamCalls = bamService
095: .getCallsForService(serviceName);
096: assertTrue("No service call recorded", bamCalls.size() > 0);
097: boolean foundClientCall = false;
098: boolean foundServiceCall = false;
099: for (BAMTargetEntry bamEntry : bamCalls) {
100: if (bamEntry.getServerInvocation()) {
101: foundServiceCall = true;
102: } else {
103: foundClientCall = true;
104: }
105: }
106: assertTrue("No client call recorded", foundClientCall);
107: assertTrue("No service call recorded", foundServiceCall);
108: assertEquals("Wrong number of calls recorded", 2, bamCalls
109: .size());
110: }
111: }
|