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