View Javadoc

1   /*
2    * Copyright 2006-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  
17  package org.kuali.rice.kim.test.service;
18  
19  import org.kuali.rice.core.api.config.property.ConfigContext;
20  import org.kuali.rice.kim.api.KimApiConstants;
21  import org.kuali.rice.ksb.api.KsbApiServiceLocator;
22  import org.kuali.rice.ksb.api.bus.Endpoint;
23  import org.kuali.rice.ksb.api.bus.ServiceBus;
24  
25  import javax.xml.namespace.QName;
26  import java.util.List;
27  
28  import static org.junit.Assert.fail;
29  
30  /**
31   * Test the GroupService via remote calls
32   * 
33   * @author Kuali Rice Team (kuali-rice@googlegroups.com)
34   *
35   */
36  public class GroupServiceRemoteTest extends GroupServiceTest {
37  
38  	public void setUp() throws Exception {
39  		super.setUp();
40  	}
41  
42  	/*@Override
43  	protected Lifecycle getLoadApplicationLifecycle() {
44  		return getJettyServerLifecycle();
45  	} */
46  	
47  	private int getConfigIntProp(String intPropKey) {
48  		return Integer.parseInt(getConfigProp(intPropKey));
49  	}
50  
51  	private String getConfigProp(String propKey) {
52  		return ConfigContext.getCurrentContextConfig().getProperty(propKey);
53  	}
54  	
55  	/**
56  	 * This method tries to get a client proxy for the specified KIM service
57  	 * 
58  	 * @param  svcName - name of the KIM service desired
59  	 * @return the proxy object
60  	 * @throws Exception 
61  	 */
62  	protected Object getKimService(String svcName) throws Exception {
63  		ServiceBus serviceBus = KsbApiServiceLocator.getServiceBus();
64  		List<Endpoint> endpoints = serviceBus.getRemoteEndpoints(new QName(KimApiConstants.Namespaces.KIM_NAMESPACE_2_0, svcName));
65  		if (endpoints.size() > 1) {
66  			fail("Found more than one RemotedServiceHolder for " + svcName);
67  		}
68  		Endpoint endpoint = endpoints.get(0);
69  		return endpoint.getService();
70  	}
71  }