1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 package junitx.ddtunit.optional.junit4;
39
40 import junit.framework.Test;
41 import junit.framework.TestSuite;
42 import junitx.ddtunit.DDTTestCase;
43 import junitx.ddtunit.optional.junit4.DDTUnit4ClassRunner;
44
45 import org.junit.After;
46 import org.junit.AfterClass;
47 import org.junit.Before;
48 import org.junit.BeforeClass;
49 import org.junit.runner.RunWith;
50 import org.slf4j.Logger;
51 import org.slf4j.LoggerFactory;
52
53
54
55
56
57
58
59 @RunWith(value = DDTUnit4ClassRunner.class)
60 public class DDTJUnit4ClassRunnerTest extends DDTTestCase {
61 final static Logger logger = LoggerFactory.getLogger(DDTJUnit4ClassRunnerTest.class);
62
63 @Before
64 public void before(){
65 logger.info("before");
66 }
67
68 @After
69 public void after(){
70 logger.info("after");
71 }
72
73 @BeforeClass
74 public static void beforeClass() {
75 logger.info("beforeClass");
76 }
77
78 @AfterClass
79 public static void afterClass() {
80 logger.info("afterClass");
81 }
82
83 protected void setUp() throws Exception {
84 logger.info("setUp()");
85 }
86
87 protected void tearDown() throws Exception {
88 logger.info("tearDown()");
89 }
90
91
92
93
94 public DDTJUnit4ClassRunnerTest(String name) {
95 super(name);
96 }
97
98
99 public DDTJUnit4ClassRunnerTest() {
100
101 }
102
103
104
105
106
107
108 public static Test suite() {
109 TestSuite ts = new TestSuite();
110
111 ts.addTestSuite(DDTJUnit4ClassRunnerTest.class);
112
113 return ts;
114 }
115
116
117
118
119 @org.junit.Test
120 public void simpleJUnitAssert() {
121 logger.info("simpleJUnitAssert");
122 assertTrue("Should be true", true);
123 assertNull("Should be null", null);
124 assertEquals("Should be equal", "xxx", "xxx");
125 }
126
127
128
129
130 public void initContext() {
131 initTestData("DDTJUnit4ClassRunnerTest");
132 }
133
134
135
136
137 @org.junit.Test
138 public void retrieveObjectData() {
139 logger.info("retrieveObjectData");
140 String obj = (String) getObject("myObj");
141
142 assertNotNull("Method-Test object should not be null", obj);
143 assertTrue("Wrong value for retrieved object", obj.startsWith("My "));
144 }
145
146
147
148
149 public void retrieveAssertData() {
150 String obj = (String) getObject("myObj");
151 fail();
152 assertNotNull("Method-Test object should not be null", obj);
153 assertTrue("Wrong value for retrieved object", obj.startsWith("My "));
154 addObjectToAssert("result", obj);
155 }
156
157 }