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