1 /**
2 * Copyright 2005-2014 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 RoleService via remote calls
32 *
33 * @author Kuali Rice Team (kuali-rice@googlegroups.com)
34 *
35 */
36 public class RoleServiceRemoteTest extends RoleServiceTest {
37
38 public void setUp() throws Exception {
39 super.setUp();
40 }
41
42 //@Override
43 //protected Lifecycle getLoadApplicationLifecycle() {
44 // return new BaseLifecycle() {
45 // public void start() throws Exception {
46 // new JettyServerLifecycle(getConfigIntProp("kim.test.port"), "/" + getConfigProp("app.context.name"), "/../kim/src/test/webapp").start();
47 // super.start();
48 // }
49 // };
50 //}
51
52 private int getConfigIntProp(String intPropKey) {
53 return Integer.parseInt(getConfigProp(intPropKey));
54 }
55
56 private String getConfigProp(String propKey) {
57 return ConfigContext.getCurrentContextConfig().getProperty(propKey);
58 }
59
60 /**
61 * This method tries to get a client proxy for the specified KIM service
62 *
63 * @param svcName - name of the KIM service desired
64 * @return the proxy object
65 * @throws Exception
66 */
67 protected Object getKimService(String svcName) throws Exception {
68 ServiceBus serviceBus = KsbApiServiceLocator.getServiceBus();
69 List<Endpoint> endpoints = serviceBus.getRemoteEndpoints(
70 new QName(KimApiConstants.Namespaces.KIM_NAMESPACE_2_0, svcName));
71 if (endpoints.size() > 1) {
72 fail("Found more than one RemotedServiceHolder for " + svcName);
73 }
74 Endpoint endpoint = endpoints.get(0);
75 return endpoint.getService();
76 }
77 }