001    /**
002     * Copyright 2005-2013 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     */
016    package org.kuali.rice.kim.test.service;
017    
018    import static org.junit.Assert.fail;
019    
020    import java.util.List;
021    
022    import javax.xml.namespace.QName;
023    
024    import org.kuali.rice.core.api.config.property.ConfigContext;
025    import org.kuali.rice.kim.api.KimApiConstants;
026    import org.kuali.rice.ksb.api.KsbApiServiceLocator;
027    import org.kuali.rice.ksb.api.bus.Endpoint;
028    import org.kuali.rice.ksb.api.bus.ServiceBus;
029    
030    /**
031     * Test the PermissionService via remote calls
032     * 
033     * @author Kuali Rice Team (kuali-rice@googlegroups.com)
034     *
035     */
036    public class PermissionServiceRemoteTest extends PermissionServiceTest {
037    
038            public void setUp() throws Exception {
039                    super.setUp();
040            }
041    
042            /*@Override
043            protected Lifecycle getLoadApplicationLifecycle() {
044                    return getJettyServerLifecycle();
045            } */
046            
047            private int getConfigIntProp(String intPropKey) {
048                    return Integer.parseInt(getConfigProp(intPropKey));
049            }
050    
051            private String getConfigProp(String propKey) {
052                    return ConfigContext.getCurrentContextConfig().getProperty(propKey);
053            }
054            
055            /**
056             * This method tries to get a client proxy for the specified KIM service
057             * 
058             * @param  svcName - name of the KIM service desired
059             * @return the proxy object
060             * @throws Exception 
061             */
062            protected Object getKimService(String svcName) throws Exception {
063                    ServiceBus serviceBus = KsbApiServiceLocator.getServiceBus();
064                    List<Endpoint> endpoints = serviceBus.getRemoteEndpoints(
065                    new QName(KimApiConstants.Namespaces.KIM_NAMESPACE_2_0, svcName));
066                    if (endpoints.size() > 1) {
067                            fail("Found more than one RemotedServiceHolder for " + svcName);
068                    }
069                    Endpoint endpoint = endpoints.get(0);
070                    return endpoint.getService();
071            }
072    }