3
3
import lombok .extern .slf4j .Slf4j ;
4
4
import org .junit .jupiter .api .*;
5
5
import org .springframework .beans .factory .annotation .Autowired ;
6
+ import org .springframework .boot .test .autoconfigure .web .servlet .AutoConfigureMockMvc ;
6
7
import org .springframework .boot .test .context .SpringBootTest ;
7
8
import org .springframework .boot .web .server .LocalServerPort ;
8
9
import org .springframework .boot .web .servlet .context .ServletWebServerApplicationContext ;
9
10
import org .springframework .security .core .context .SecurityContextHolder ;
10
11
import org .springframework .test .web .servlet .MockMvc ;
11
- import org .springframework . web . context . WebApplicationContext ;
12
+ import org .woehlke . simpleworklist . config . FunctionalRequirements ;
12
13
import org .woehlke .simpleworklist .config .UserAccountTestDataService ;
13
14
14
15
import java .net .URL ;
15
16
17
+ import static org .hamcrest .Matchers .containsString ;
16
18
import static org .junit .jupiter .api .Assertions .assertTrue ;
17
- import static org .springframework .test .web .servlet .setup .MockMvcBuilders .webAppContextSetup ;
19
+ import static org .springframework .test .web .servlet .request .MockMvcRequestBuilders .get ;
20
+ import static org .springframework .test .web .servlet .result .MockMvcResultHandlers .print ;
21
+ import static org .springframework .test .web .servlet .result .MockMvcResultMatchers .*;
22
+ import static org .woehlke .simpleworklist .config .Requirements .*;
18
23
19
24
@ Slf4j
20
25
@ TestMethodOrder (MethodOrderer .OrderAnnotation .class )
21
26
@ TestInstance (TestInstance .Lifecycle .PER_CLASS )
22
- @ SpringBootTest (webEnvironment = SpringBootTest .WebEnvironment .DEFINED_PORT )
27
+ @ AutoConfigureMockMvc
28
+ @ SpringBootTest (webEnvironment = SpringBootTest .WebEnvironment .RANDOM_PORT )
23
29
public class SmokeTests {
24
30
25
31
@ Autowired
26
- ServletWebServerApplicationContext server ;
32
+ private ServletWebServerApplicationContext server ;
27
33
28
34
@ LocalServerPort
29
- int port ;
35
+ private int port ;
30
36
31
37
protected URL base ;
32
38
33
39
@ Autowired
34
- protected WebApplicationContext wac ;
35
-
36
- protected MockMvc mockMvc ;
40
+ private MockMvc mockMvc ;
37
41
38
42
@ Autowired
39
43
private UserAccountTestDataService userAccountTestDataService ;
@@ -49,7 +53,6 @@ public void setUp() throws Exception {
49
53
log .info (" @BeforeEach setUp()" );
50
54
log .info (eyecatcherH2 );
51
55
this .base = new URL ("http://localhost:" + port + "/" );
52
- this .mockMvc = webAppContextSetup (wac ).build ();
53
56
log .info (" Server URL: " +this .base .toString ());
54
57
//userAccountTestDataService.setUp();
55
58
log .info (eyecatcherH1 );
@@ -61,7 +64,6 @@ public void runBeforeTestClass() throws Exception {
61
64
log .info (" @BeforeTestClass runBeforeTestClass" );
62
65
log .info (eyecatcherH2 );
63
66
this .base = new URL ("http://localhost:" + port + "/" );
64
- this .mockMvc = webAppContextSetup (wac ).build ();
65
67
log .info (" Server URL: " +this .base .toString ());
66
68
log .info (eyecatcherH2 );
67
69
userAccountTestDataService .setUp ();
@@ -80,7 +82,7 @@ public void runAfterTestClass() {
80
82
}
81
83
82
84
83
- @ DisplayName ("Test Mock helloService + helloRepository" )
85
+ @ DisplayName (F001 )
84
86
@ Order (1 )
85
87
@ Test
86
88
public void testF001ServerStarts (){
@@ -92,15 +94,25 @@ public void testF001ServerStarts(){
92
94
log .info (eyecatcherH2 );
93
95
}
94
96
97
+ @ DisplayName (F002 )
95
98
@ Order (2 )
96
99
@ Test
97
- public void testF002HomePageRendered (){
100
+ public void testF002HomePageRendered () throws Exception {
98
101
log .info (eyecatcherH1 );
99
102
log .info ("testF002HomePageRendered" );
100
103
log .info (eyecatcherH2 );
104
+ this .mockMvc .perform (get ( this .base .toString () ))
105
+ .andDo (print ())
106
+ .andExpect (status ().is3xxRedirection ())
107
+ .andExpect (redirectedUrl (this .base +"user/login" ));
108
+ this .mockMvc .perform (get ( this .base +"user/login" ))
109
+ .andDo (print ())
110
+ .andExpect (status ().isOk ())
111
+ .andExpect (content ().string (containsString ("SimpleWorklist" )));
101
112
log .info (eyecatcherH2 );
102
113
}
103
114
115
+ @ DisplayName (F003 )
104
116
@ Order (3 )
105
117
@ Test
106
118
public void testF003Registration (){
@@ -109,6 +121,7 @@ public void testF003Registration(){
109
121
log .info (eyecatcherH2 );
110
122
}
111
123
124
+ @ DisplayName (F004 )
112
125
@ Order (4 )
113
126
@ Test
114
127
public void testF004PasswordRecovery (){
@@ -117,6 +130,7 @@ public void testF004PasswordRecovery(){
117
130
log .info (eyecatcherH2 );
118
131
}
119
132
133
+ @ DisplayName (F005 )
120
134
@ Order (5 )
121
135
@ Test
122
136
public void testF005Login (){
@@ -125,6 +139,7 @@ public void testF005Login(){
125
139
log .info (eyecatcherH2 );
126
140
}
127
141
142
+ @ DisplayName (F006 )
128
143
@ Order (6 )
129
144
@ Test
130
145
public void testF006PageAfterFirstSuccessfulLogin (){
@@ -133,6 +148,7 @@ public void testF006PageAfterFirstSuccessfulLogin(){
133
148
log .info (eyecatcherH2 );
134
149
}
135
150
151
+ @ DisplayName (F007 )
136
152
@ Order (7 )
137
153
@ Test
138
154
public void testF007AddFirstNewTaskToInbox (){
@@ -141,6 +157,7 @@ public void testF007AddFirstNewTaskToInbox(){
141
157
log .info (eyecatcherH2 );
142
158
}
143
159
160
+ @ DisplayName (F008 )
144
161
@ Order (8 )
145
162
@ Test
146
163
public void testF008AddAnotherNewTaskToInbox (){
@@ -149,6 +166,7 @@ public void testF008AddAnotherNewTaskToInbox(){
149
166
log .info (eyecatcherH2 );
150
167
}
151
168
169
+ @ DisplayName (F009 )
152
170
@ Order (9 )
153
171
@ Test
154
172
public void testF009AddTaskToProjectRoot (){
@@ -157,6 +175,7 @@ public void testF009AddTaskToProjectRoot(){
157
175
log .info (eyecatcherH2 );
158
176
}
159
177
178
+ @ DisplayName (F010 )
160
179
@ Order (10 )
161
180
@ Test
162
181
public void testF010AddSubProjectToProjectRoot (){
@@ -165,6 +184,7 @@ public void testF010AddSubProjectToProjectRoot(){
165
184
log .info (eyecatcherH2 );
166
185
}
167
186
187
+ @ DisplayName (F011 )
168
188
@ Order (11 )
169
189
@ Test
170
190
public void testF011SetFocusOfTask (){
@@ -173,6 +193,7 @@ public void testF011SetFocusOfTask(){
173
193
log .info (eyecatcherH2 );
174
194
}
175
195
196
+ @ DisplayName (F012 )
176
197
@ Order (12 )
177
198
@ Test
178
199
public void testF012UnSetFocusOfTask (){
@@ -181,6 +202,7 @@ public void testF012UnSetFocusOfTask(){
181
202
log .info (eyecatcherH2 );
182
203
}
183
204
205
+ @ DisplayName (F013 )
184
206
@ Order (13 )
185
207
@ Test
186
208
public void testF013ShowTaskstateInbox (){
@@ -189,6 +211,7 @@ public void testF013ShowTaskstateInbox(){
189
211
log .info (eyecatcherH2 );
190
212
}
191
213
214
+ @ DisplayName (F014 )
192
215
@ Order (14 )
193
216
@ Test
194
217
public void testF014ShowTaskstateToday (){
@@ -197,6 +220,7 @@ public void testF014ShowTaskstateToday(){
197
220
log .info (eyecatcherH2 );
198
221
}
199
222
223
+ @ DisplayName (F015 )
200
224
@ Order (15 )
201
225
@ Test
202
226
public void testF015ShowTaskstateNext (){
@@ -205,6 +229,7 @@ public void testF015ShowTaskstateNext(){
205
229
log .info (eyecatcherH2 );
206
230
}
207
231
232
+ @ DisplayName (F016 )
208
233
@ Order (16 )
209
234
@ Test
210
235
public void testF016ShowTaskstateWaiting (){
@@ -213,6 +238,7 @@ public void testF016ShowTaskstateWaiting(){
213
238
log .info (eyecatcherH2 );
214
239
}
215
240
241
+ @ DisplayName (F017 )
216
242
@ Order (17 )
217
243
@ Test
218
244
public void testF017ShowTaskstateScheduled (){
@@ -221,6 +247,7 @@ public void testF017ShowTaskstateScheduled(){
221
247
log .info (eyecatcherH2 );
222
248
}
223
249
250
+ @ DisplayName (F018 )
224
251
@ Order (18 )
225
252
@ Test
226
253
public void testF018ShowTaskstateSomeday (){
@@ -229,6 +256,7 @@ public void testF018ShowTaskstateSomeday(){
229
256
log .info (eyecatcherH2 );
230
257
}
231
258
259
+ @ DisplayName (F019 )
232
260
@ Order (19 )
233
261
@ Test
234
262
public void testF019ShowTaskstateFocus (){
@@ -237,6 +265,7 @@ public void testF019ShowTaskstateFocus(){
237
265
log .info (eyecatcherH2 );
238
266
}
239
267
268
+ @ DisplayName (F020 )
240
269
@ Order (20 )
241
270
@ Test
242
271
public void testF020ShowTaskstateCompleted (){
@@ -245,6 +274,7 @@ public void testF020ShowTaskstateCompleted(){
245
274
log .info (eyecatcherH2 );
246
275
}
247
276
277
+ @ DisplayName (F021 )
248
278
@ Order (21 )
249
279
@ Test
250
280
public void testF021ShowTaskstateTrash (){
@@ -253,6 +283,7 @@ public void testF021ShowTaskstateTrash(){
253
283
log .info (eyecatcherH2 );
254
284
}
255
285
286
+ @ DisplayName (F022 )
256
287
@ Order (22 )
257
288
@ Test
258
289
public void testF022TaskEdit (){
@@ -261,6 +292,7 @@ public void testF022TaskEdit(){
261
292
log .info (eyecatcherH2 );
262
293
}
263
294
295
+ @ DisplayName (F023 )
264
296
@ Order (23 )
265
297
@ Test
266
298
public void testF023TaskEditFormChangeTaskstateViaDropDown (){
@@ -269,6 +301,7 @@ public void testF023TaskEditFormChangeTaskstateViaDropDown(){
269
301
log .info (eyecatcherH2 );
270
302
}
271
303
304
+ @ DisplayName (F024 )
272
305
@ Order (24 )
273
306
@ Test
274
307
public void testF024TaskComplete (){
@@ -277,6 +310,7 @@ public void testF024TaskComplete(){
277
310
log .info (eyecatcherH2 );
278
311
}
279
312
313
+ @ DisplayName (F025 )
280
314
@ Order (25 )
281
315
@ Test
282
316
public void testF025TaskIncomplete (){
@@ -285,6 +319,7 @@ public void testF025TaskIncomplete(){
285
319
log .info (eyecatcherH2 );
286
320
}
287
321
322
+ @ DisplayName (F026 )
288
323
@ Order (26 )
289
324
@ Test
290
325
public void testF026TaskDelete (){
@@ -293,6 +328,7 @@ public void testF026TaskDelete(){
293
328
log .info (eyecatcherH2 );
294
329
}
295
330
331
+ @ DisplayName (F027 )
296
332
@ Order (27 )
297
333
@ Test
298
334
public void testF027TaskUndelete (){
0 commit comments