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