001/** 002 * Copyright 2005-2014 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.rice.kim.test.service; 017 018import static org.junit.Assert.fail; 019 020import java.util.List; 021 022import javax.xml.namespace.QName; 023 024import org.kuali.rice.core.api.config.property.ConfigContext; 025import org.kuali.rice.kim.api.KimApiConstants; 026import org.kuali.rice.ksb.api.KsbApiServiceLocator; 027import org.kuali.rice.ksb.api.bus.Endpoint; 028import org.kuali.rice.ksb.api.bus.ServiceBus; 029 030/** 031 * Test the RoleService via remote calls 032 * 033 * @author Kuali Rice Team (kuali-rice@googlegroups.com) 034 * 035 */ 036public class RoleServiceRemoteTest extends RoleServiceTest { 037 038 public void setUp() throws Exception { 039 super.setUp(); 040 } 041 042 //@Override 043 //protected Lifecycle getLoadApplicationLifecycle() { 044 // return new BaseLifecycle() { 045 // public void start() throws Exception { 046 // new JettyServerLifecycle(getConfigIntProp("kim.test.port"), "/" + getConfigProp("app.context.name"), "/../kim/src/test/webapp").start(); 047 // super.start(); 048 // } 049 // }; 050 //} 051 052 private int getConfigIntProp(String intPropKey) { 053 return Integer.parseInt(getConfigProp(intPropKey)); 054 } 055 056 private String getConfigProp(String propKey) { 057 return ConfigContext.getCurrentContextConfig().getProperty(propKey); 058 } 059 060 /** 061 * This method tries to get a client proxy for the specified KIM service 062 * 063 * @param svcName - name of the KIM service desired 064 * @return the proxy object 065 * @throws Exception 066 */ 067 protected Object getKimService(String svcName) throws Exception { 068 ServiceBus serviceBus = KsbApiServiceLocator.getServiceBus(); 069 List<Endpoint> endpoints = serviceBus.getRemoteEndpoints( 070 new QName(KimApiConstants.Namespaces.KIM_NAMESPACE_2_0, svcName)); 071 if (endpoints.size() > 1) { 072 fail("Found more than one RemotedServiceHolder for " + svcName); 073 } 074 Endpoint endpoint = endpoints.get(0); 075 return endpoint.getService(); 076 } 077}