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