|
1 |
| package com.agical.rmock.extension.junit; |
|
2 |
| |
|
3 |
| import com.agical.rmock.core.configuration.ConfiguratorImpl; |
|
4 |
| import com.agical.rmock.core.hub.Hub; |
|
5 |
| import com.agical.rmock.core.strategy.TestStep; |
|
6 |
| import com.agical.rmock.core.strategy.impl.CompositeStep; |
|
7 |
| import com.agical.rmock.core.strategy.impl.FinallyStep; |
|
8 |
| import com.agical.rmock.core.strategy.impl.MethodStep; |
|
9 |
| |
|
10 |
| public abstract class BasicJUnitStrategyTestCase extends AbstractStrategyTestCase { |
|
11 |
474
| protected void setUp() throws Exception {
|
|
12 |
| } |
|
13 |
| |
|
14 |
538
| protected void tearDown() throws Exception {
|
|
15 |
| } |
|
16 |
| |
|
17 |
0
| public BasicJUnitStrategyTestCase() {
|
|
18 |
0
| this(null);
|
|
19 |
| } |
|
20 |
| |
|
21 |
18
| public BasicJUnitStrategyTestCase(String name) {
|
|
22 |
18
| this(name, ConfiguratorImpl.getInstance().getHub());
|
|
23 |
| } |
|
24 |
| |
|
25 |
1126
| public BasicJUnitStrategyTestCase(String name, Hub hub) {
|
|
26 |
1126
| super(name, hub);
|
|
27 |
| } |
|
28 |
| |
|
29 |
554
| protected TestStep createSetupStep(String test) {
|
|
30 |
554
| return new TestStep() {
|
|
31 |
554
| public void run() throws Throwable {
|
|
32 |
554
| setUp();
|
|
33 |
| } |
|
34 |
| }; |
|
35 |
| } |
|
36 |
| |
|
37 |
12
| protected TestStep createStrategy(String test) {
|
|
38 |
12
| FinallyStep finallyStep = new FinallyStep();
|
|
39 |
12
| CompositeStep compositeStep = new CompositeStep();
|
|
40 |
| |
|
41 |
12
| TestStep setupStep = createSetupStep(test);
|
|
42 |
12
| TestStep testMethod = createTestStep(test);
|
|
43 |
12
| TestStep tearDownStep = createTearDownStep(test);
|
|
44 |
| |
|
45 |
12
| compositeStep.addStep(setupStep);
|
|
46 |
12
| compositeStep.addStep(testMethod);
|
|
47 |
| |
|
48 |
| |
|
49 |
12
| finallyStep.setMainStep(compositeStep);
|
|
50 |
12
| finallyStep.setFinallyStep(tearDownStep);
|
|
51 |
12
| return finallyStep;
|
|
52 |
| } |
|
53 |
| |
|
54 |
548
| protected TestStep createTestStep(String test) {
|
|
55 |
548
| return new MethodStep(this, test);
|
|
56 |
| } |
|
57 |
| |
|
58 |
554
| protected TestStep createTearDownStep(String test) {
|
|
59 |
554
| return new TestStep() {
|
|
60 |
554
| public void run() throws Throwable {
|
|
61 |
554
| tearDown();
|
|
62 |
| } |
|
63 |
| }; |
|
64 |
| } |
|
65 |
| } |