1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.rice.ksb.messaging;
18
19 import javax.xml.namespace.QName;
20
21 import org.junit.Test;
22 import org.kuali.rice.core.resourceloader.GlobalResourceLoader;
23 import org.kuali.rice.ksb.messaging.RemoteResourceServiceLocatorImpl;
24 import org.kuali.rice.ksb.messaging.remotedservices.GenericTestService;
25 import org.kuali.rice.ksb.messaging.remotedservices.TestServiceInterface;
26 import org.kuali.rice.ksb.messaging.resourceloader.KSBResourceLoaderFactory;
27 import org.kuali.rice.ksb.messaging.serviceconnectors.BusLocalConnector;
28 import org.kuali.rice.ksb.messaging.serviceconnectors.ServiceConnector;
29 import org.kuali.rice.ksb.messaging.serviceconnectors.ServiceConnectorFactory;
30 import org.kuali.rice.ksb.service.KSBServiceLocator;
31 import org.kuali.rice.ksb.test.KSBTestCase;
32
33
34
35
36
37
38 public class DevModeTest extends KSBTestCase {
39
40 @Override
41 public void setUp() throws Exception {
42 System.setProperty("dev.mode", "true");
43
44 System.setProperty("additional.config.locations", "classpath:org/kuali/rice/ksb/messaging/dev_mode_config.xml");
45 super.setUp();
46 }
47
48
49
50 @Override
51 public void tearDown() throws Exception {
52 try {
53 System.clearProperty("dev.mode");
54
55 System.clearProperty("additional.config.locations");
56 } finally {
57 super.tearDown();
58 }
59 }
60
61
62
63 @Test public void testCallInDevMode() throws Exception {
64 QName serviceName = new QName("KEW", "testLocalServiceFavoriteCall");
65 TestServiceInterface service = (TestServiceInterface) GlobalResourceLoader.getService(serviceName);
66 service.invoke();
67 assertTrue("No calls to dev defined service", GenericTestService.NUM_CALLS > 0);
68
69 RemoteResourceServiceLocatorImpl rrsl = (RemoteResourceServiceLocatorImpl)KSBResourceLoaderFactory.getRemoteResourceLocator();
70
71 ServiceConnector serviceConnector = ServiceConnectorFactory.getServiceConnector(rrsl.getAllServices(serviceName).get(0).getServiceInfo());
72 assertTrue("Not BusLocalConnector", serviceConnector instanceof BusLocalConnector);
73 assertNull("Service in service definition needs to be null for async communications serialization", ((BusLocalConnector)serviceConnector).getServiceInfo().getServiceDefinition().getService());
74
75 service = (TestServiceInterface) KSBServiceLocator.getMessageHelper().getServiceAsynchronously(serviceName);
76 service.invoke();
77 assertTrue("No calls to dev defined service", GenericTestService.NUM_CALLS > 1);
78
79 assertTrue("should be no registered services", KSBServiceLocator.getServiceRegistry().fetchAll().size() == 0);
80 }
81 }