View Javadoc

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