1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.ksb.messaging;
17
18 import static org.junit.Assert.assertTrue;
19
20 import javax.xml.namespace.QName;
21
22 import junit.framework.Assert;
23
24 import org.junit.Test;
25 import org.kuali.rice.core.api.config.property.ConfigContext;
26 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
27 import org.kuali.rice.ksb.api.KsbApiServiceLocator;
28 import org.kuali.rice.ksb.api.bus.ServiceBus;
29 import org.kuali.rice.ksb.messaging.remotedservices.GenericTestService;
30 import org.kuali.rice.ksb.messaging.remotedservices.TestServiceInterface;
31 import org.kuali.rice.ksb.messaging.serviceconnectors.BusLocalConnector;
32 import org.kuali.rice.ksb.messaging.serviceconnectors.ServiceConnector;
33 import org.kuali.rice.ksb.messaging.serviceconnectors.ServiceConnectorFactory;
34 import org.kuali.rice.ksb.test.KSBTestCase;
35
36
37
38
39
40 public class DevModeTest extends KSBTestCase {
41
42 @Override
43 public void setUp() throws Exception {
44
45 System.setProperty("a.test.specific.config.location", "classpath:org/kuali/rice/ksb/messaging/dev_mode_config.xml");
46 super.setUp();
47 }
48
49 @Override
50 public void tearDown() throws Exception {
51 try {
52
53 System.clearProperty("a.test.specific.config.location");
54 } finally {
55 super.tearDown();
56 }
57 }
58
59 @Test public void testCallInDevMode() throws Exception {
60
61 Assert.assertEquals(ConfigContext.getCurrentContextConfig().getDevMode(), Boolean.TRUE);
62
63 QName serviceName = new QName("KEW", "testLocalServiceFavoriteCall");
64 TestServiceInterface service = (TestServiceInterface) GlobalResourceLoader.getService(serviceName);
65 service.invoke();
66 assertTrue("No calls to dev defined service", GenericTestService.NUM_CALLS > 0);
67
68 ServiceBus serviceBus = KsbApiServiceLocator.getServiceBus();
69
70 ServiceConnector serviceConnector = ServiceConnectorFactory.getServiceConnector(serviceBus.getLocalEndpoint(serviceName).getServiceConfiguration());
71 assertTrue("Not BusLocalConnector", serviceConnector instanceof BusLocalConnector);
72
73
74 service = (TestServiceInterface) KsbApiServiceLocator.getMessageHelper().getServiceAsynchronously(serviceName);
75 service.invoke();
76 assertTrue("No calls to dev defined service", GenericTestService.NUM_CALLS > 1);
77
78 Assert.assertEquals("should be no registered services", KsbApiServiceLocator.getServiceRegistry().getAllServices().size(), 0);
79 }
80 }