View Javadoc

1   /**
2    * Copyright 2005-2011 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.ksb.messaging;
17  
18  import static org.junit.Assert.assertEquals;
19  
20  import javax.xml.namespace.QName;
21  
22  import org.junit.Test;
23  import org.kuali.rice.core.api.config.property.ConfigContext;
24  import org.kuali.rice.ksb.api.KsbApiServiceLocator;
25  import org.kuali.rice.ksb.messaging.service.KSBJavaService;
26  import org.kuali.rice.ksb.service.KSBServiceLocator;
27  import org.kuali.rice.ksb.test.KSBTestCase;
28  import org.kuali.rice.ksb.util.KSBConstants;
29  
30  /**
31   * verify that value1 and value2 are preserved when passed into message helper and making an async call.  
32   * 
33   * @author Kuali Rice Team (rice.collab@kuali.org)
34   *
35   */
36  public class Value1AndValue2PersistedOnMessageCall extends KSBTestCase {
37      
38      @Test public void testCallingQueueAsnyc() throws Exception {
39  	KSBTestUtils.setMessagingToAsync();
40  	ConfigContext.getCurrentContextConfig().putProperty(KSBConstants.Config.MESSAGING_OFF, "true");
41  	
42  	QName serviceName = QName.valueOf("{testAppsSharedTopic}sharedTopic");
43  	String value1 = "value1";
44  	String value2 = "value2";
45  	KSBJavaService testJavaAsyncService = (KSBJavaService) KsbApiServiceLocator.getMessageHelper().getServiceAsynchronously(serviceName, null, null, value1, value2);
46  	testJavaAsyncService.invoke(new ClientAppServiceSharedPayloadObj("message content", false));
47  	
48  	PersistedMessageBO message = KSBServiceLocator.getMessageQueueService().getNextDocuments(null).get(0);
49  	assertEquals("value1 incorrectly saved", value1, message.getValue1());
50  	assertEquals("value2 incorrectly saved", value2, message.getValue2());
51  	
52      }
53  
54  }