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 static org.junit.Assert.fail;
19  
20  import java.util.List;
21  
22  import javax.xml.namespace.QName;
23  
24  import org.kuali.rice.core.api.config.property.ConfigContext;
25  import org.kuali.rice.kim.api.KimApiConstants;
26  import org.kuali.rice.ksb.api.KsbApiServiceLocator;
27  import org.kuali.rice.ksb.api.bus.Endpoint;
28  import org.kuali.rice.ksb.api.bus.ServiceBus;
29  
30  /**
31   * Test the PermissionService via remote calls
32   * 
33   * @author Kuali Rice Team (kuali-rice@googlegroups.com)
34   *
35   */
36  public class PermissionServiceRemoteTest extends PermissionServiceTest {
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(
65                  new QName(KimApiConstants.Namespaces.KIM_NAMESPACE_2_0, svcName));
66  		if (endpoints.size() > 1) {
67  			fail("Found more than one RemotedServiceHolder for " + svcName);
68  		}
69  		Endpoint endpoint = endpoints.get(0);
70  		return endpoint.getService();
71  	}
72  }