1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.rice.ksb.test;
18
19 import org.kuali.rice.core.api.config.property.ConfigContext;
20 import org.kuali.rice.core.api.lifecycle.Lifecycle;
21 import org.kuali.rice.core.api.resourceloader.ResourceLoader;
22 import org.kuali.rice.core.framework.persistence.ojb.BaseOjbConfigurer;
23 import org.kuali.rice.core.api.resourceloader.ResourceLoader;
24 import org.kuali.rice.core.impl.resourceloader.SpringResourceLoader;
25 import org.kuali.rice.core.impl.resourceloader.SpringResourceLoader;
26 import org.kuali.rice.ksb.api.KsbApiServiceLocator;
27 import org.kuali.rice.ksb.messaging.resourceloader.KSBResourceLoaderFactory;
28 import org.kuali.rice.ksb.server.TestClient1;
29 import org.kuali.rice.ksb.server.TestClient2;
30 import org.kuali.rice.test.BaselineTestCase;
31
32 import javax.xml.namespace.QName;
33 import java.util.List;
34
35 @BaselineTestCase.BaselineMode(BaselineTestCase.Mode.ROLLBACK)
36 public abstract class KSBTestCase extends BaselineTestCase {
37
38 private static final String KSB_MODULE_NAME = "ksb";
39
40 private TestClient1 testClient1;
41 private TestClient2 testClient2;
42 private ResourceLoader springContextResourceLoader;
43
44 public KSBTestCase() {
45 super(KSB_MODULE_NAME);
46 }
47
48 @Override
49 public void setUp() throws Exception {
50
51
52
53
54
55 ConfigContext.destroy();
56
57
58
59
60 System.setProperty("http.keepAlive", "false");
61
62 super.setUp();
63 if (startClient1() || startClient2()) {
64 KsbApiServiceLocator.getServiceBus().synchronize();
65 }
66 }
67
68 @Override
69 protected List<Lifecycle> getPerTestLifecycles() {
70 List<Lifecycle> lifecycles = super.getSuiteLifecycles();
71 if (this.disableJta()) {
72 System.setProperty(BaseOjbConfigurer.OJB_PROPERTIES_PROP, "RiceNoJtaOJB.properties");
73 this.springContextResourceLoader = new SpringResourceLoader(new QName("ksbtestharness"), "KSBTestHarnessNoJtaSpring.xml", null);
74 } else {
75 this.springContextResourceLoader = new SpringResourceLoader(new QName("ksbtestharness"), "KSBTestHarnessSpring.xml", null);
76 }
77
78 lifecycles.add(this.springContextResourceLoader);
79 if (startClient1()) {
80 this.testClient1 = new TestClient1();
81 lifecycles.add(this.testClient1);
82 }
83 if (startClient2()) {
84 this.testClient2 = new TestClient2();
85 lifecycles.add(this.testClient2);
86 }
87 return lifecycles;
88 }
89
90 public boolean startClient1() {
91 return false;
92 }
93
94 public boolean startClient2() {
95 return false;
96 }
97
98 public TestClient1 getTestClient1() {
99 return this.testClient1;
100 }
101
102 public TestClient2 getTestClient2() {
103 return this.testClient2;
104 }
105
106 public ResourceLoader getSpringContextResourceLoader() {
107 return this.springContextResourceLoader;
108 }
109
110 public void setSpringContextResourceLoader(ResourceLoader testHarnessResourceLoader) {
111 this.springContextResourceLoader = testHarnessResourceLoader;
112 }
113
114 protected boolean disableJta() {
115 return false;
116 }
117 }