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