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