01: /*
02: * Copyright 2007 The Kuali Foundation
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License"); you may not use this file except in
05: * compliance with the License. You may obtain a copy of the License at
06: *
07: * http://www.opensource.org/licenses/ecl1.php
08: *
09: * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS
10: * IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
11: * language governing permissions and limitations under the License.
12: */
13: package edu.iu.uis.eden.messaging;
14:
15: import javax.xml.namespace.QName;
16:
17: import org.junit.Test;
18: import org.kuali.bus.services.KSBServiceLocator;
19: import org.kuali.bus.test.KSBTestCase;
20: import org.kuali.rice.RiceConstants;
21: import org.kuali.rice.config.Config;
22: import org.kuali.rice.core.Core;
23:
24: import edu.iu.uis.eden.messaging.callbacks.SimpleCallback;
25: import edu.iu.uis.eden.messaging.resourceloading.KSBResourceLoaderFactory;
26:
27: /**
28: * Test that a context object passed through messaging is preserved in
29: *
30: * async queue async topic
31: *
32: * @author Kuali Rice Team (kuali-rice@googlegroups.com)
33: *
34: */
35: public class ContextObjectMessagingTest extends KSBTestCase {
36:
37: public boolean startClient1() {
38: return true;
39: }
40:
41: @Test
42: public void testCallingQueueAsnyc() throws Exception {
43:
44: KSBTestUtils.setMessagingToAsync();
45: QName serviceName = new QName("testAppsSharedQueue",
46: "sharedQueue");
47: String contextObject = "my_context_object";
48: SimpleCallback callback = new SimpleCallback();
49:
50: KEWJavaService testJavaAsyncService = (KEWJavaService) KSBServiceLocator
51: .getMessageHelper().getServiceAsynchronously(
52: serviceName, callback, contextObject);
53:
54: synchronized (callback) {
55: testJavaAsyncService
56: .invoke(new ClientAppServiceSharedPayloadObj(
57: "message content", false));
58: callback.waitForAsyncCall();
59: }
60:
61: Object contextAfterMessaging = callback.getMethodCall()
62: .getContext();
63: assertEquals(contextObject, contextAfterMessaging);
64: }
65:
66: @Test
67: public void testCallingAsyncTopics() throws Exception {
68: KSBTestUtils.setMessagingToAsync();
69: QName serviceName = new QName("testAppsSharedTopic",
70: "sharedTopic");
71:
72: SimpleCallback callback = new SimpleCallback();
73: String contextObject = "my_context_object";
74: KEWJavaService testJavaAsyncService = (KEWJavaService) KSBServiceLocator
75: .getMessageHelper().getServiceAsynchronously(
76: serviceName, callback, contextObject);
77:
78: synchronized (callback) {
79: testJavaAsyncService
80: .invoke(new ClientAppServiceSharedPayloadObj(
81: "message content", false));
82: callback.waitForAsyncCall();
83: }
84:
85: Object contextAfterMessaging = callback.getMethodCall()
86: .getContext();
87: assertEquals(contextObject, contextAfterMessaging);
88: }
89:
90: }
|