01: /*
02: * Copyright 2005-2006 The Kuali Foundation.
03: *
04: *
05: * Licensed under the Educational Community License, Version 1.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.opensource.org/licenses/ecl1.php
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package edu.iu.uis.eden.messaging;
18:
19: import javax.xml.namespace.QName;
20:
21: import org.junit.Test;
22: import org.kuali.bus.services.KSBServiceLocator;
23: import org.kuali.bus.test.KSBTestCase;
24: import org.kuali.rice.resourceloader.GlobalResourceLoader;
25:
26: import edu.iu.uis.eden.messaging.remotedservices.GenericTestService;
27: import edu.iu.uis.eden.messaging.remotedservices.TestServiceInterface;
28: import edu.iu.uis.eden.messaging.resourceloading.KSBResourceLoaderFactory;
29: import edu.iu.uis.eden.messaging.serviceconnectors.BusLocalConnector;
30: import edu.iu.uis.eden.messaging.serviceconnectors.ServiceConnector;
31: import edu.iu.uis.eden.messaging.serviceconnectors.ServiceConnectorFactory;
32:
33: /**
34: *
35: * @author Kuali Rice Team (kuali-rice@googlegroups.com)
36: */
37: public class DevModeTest extends KSBTestCase {
38:
39: @Override
40: public void setUp() throws Exception {
41: System.setProperty("dev.mode", "true");
42: System
43: .setProperty("additional.config.locations",
44: "classpath:edu/iu/uis/eden/messaging/dev_mode_config.xml");
45: super .setUp();
46: }
47:
48: @Override
49: public void tearDown() throws Exception {
50: System.clearProperty("dev.mode");
51: System.clearProperty("additional.config.locations");
52: super .tearDown();
53: }
54:
55: @Test
56: public void testCallInDevMode() throws Exception {
57: QName serviceName = new QName("KEW",
58: "testLocalServiceFavoriteCall");
59: TestServiceInterface service = (TestServiceInterface) GlobalResourceLoader
60: .getService(serviceName);
61: service.invoke();
62: assertTrue("No calls to dev defined service",
63: GenericTestService.NUM_CALLS > 0);
64:
65: RemoteResourceServiceLocatorImpl rrsl = (RemoteResourceServiceLocatorImpl) KSBResourceLoaderFactory
66: .getRemoteResourceLocator();
67:
68: ServiceConnector serviceConnector = ServiceConnectorFactory
69: .getServiceConnector(rrsl.getAllServices(serviceName)
70: .get(0).getServiceInfo());
71: assertTrue("Not BusLocalConnector",
72: serviceConnector instanceof BusLocalConnector);
73: assertNull(
74: "Service in service definition needs to be null for async communications serialization",
75: serviceConnector.getServiceHolder().getServiceInfo()
76: .getServiceDefinition().getService());
77:
78: service = (TestServiceInterface) KSBServiceLocator
79: .getMessageHelper().getServiceAsynchronously(
80: serviceName);
81: service.invoke();
82: assertTrue("No calls to dev defined service",
83: GenericTestService.NUM_CALLS > 1);
84:
85: assertTrue(
86: "should be no registered services",
87: KSBServiceLocator.getIPTableService().fetchAll().size() == 0);
88: }
89: }
|