33import lombok .extern .slf4j .Slf4j ;
44import org .junit .jupiter .api .*;
55import org .springframework .beans .factory .annotation .Autowired ;
6+ import org .springframework .boot .test .autoconfigure .web .servlet .AutoConfigureMockMvc ;
67import org .springframework .boot .test .context .SpringBootTest ;
78import org .springframework .boot .web .server .LocalServerPort ;
89import org .springframework .boot .web .servlet .context .ServletWebServerApplicationContext ;
910import org .springframework .security .core .context .SecurityContextHolder ;
1011import org .springframework .test .web .servlet .MockMvc ;
11- import org .springframework . web . context . WebApplicationContext ;
12+ import org .woehlke . simpleworklist . config . FunctionalRequirements ;
1213import org .woehlke .simpleworklist .config .UserAccountTestDataService ;
1314
1415import java .net .URL ;
1516
17+ import static org .hamcrest .Matchers .containsString ;
1618import 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 .*;
1823
1924@ Slf4j
2025@ TestMethodOrder (MethodOrderer .OrderAnnotation .class )
2126@ TestInstance (TestInstance .Lifecycle .PER_CLASS )
22- @ SpringBootTest (webEnvironment = SpringBootTest .WebEnvironment .DEFINED_PORT )
27+ @ AutoConfigureMockMvc
28+ @ SpringBootTest (webEnvironment = SpringBootTest .WebEnvironment .RANDOM_PORT )
2329public class SmokeTests {
2430
2531 @ Autowired
26- ServletWebServerApplicationContext server ;
32+ private ServletWebServerApplicationContext server ;
2733
2834 @ LocalServerPort
29- int port ;
35+ private int port ;
3036
3137 protected URL base ;
3238
3339 @ Autowired
34- protected WebApplicationContext wac ;
35-
36- protected MockMvc mockMvc ;
40+ private MockMvc mockMvc ;
3741
3842 @ Autowired
3943 private UserAccountTestDataService userAccountTestDataService ;
@@ -49,7 +53,6 @@ public void setUp() throws Exception {
4953 log .info (" @BeforeEach setUp()" );
5054 log .info (eyecatcherH2 );
5155 this .base = new URL ("http://localhost:" + port + "/" );
52- this .mockMvc = webAppContextSetup (wac ).build ();
5356 log .info (" Server URL: " +this .base .toString ());
5457 //userAccountTestDataService.setUp();
5558 log .info (eyecatcherH1 );
@@ -61,7 +64,6 @@ public void runBeforeTestClass() throws Exception {
6164 log .info (" @BeforeTestClass runBeforeTestClass" );
6265 log .info (eyecatcherH2 );
6366 this .base = new URL ("http://localhost:" + port + "/" );
64- this .mockMvc = webAppContextSetup (wac ).build ();
6567 log .info (" Server URL: " +this .base .toString ());
6668 log .info (eyecatcherH2 );
6769 userAccountTestDataService .setUp ();
@@ -80,7 +82,7 @@ public void runAfterTestClass() {
8082 }
8183
8284
83- @ DisplayName ("Test Mock helloService + helloRepository" )
85+ @ DisplayName (F001 )
8486 @ Order (1 )
8587 @ Test
8688 public void testF001ServerStarts (){
@@ -92,15 +94,25 @@ public void testF001ServerStarts(){
9294 log .info (eyecatcherH2 );
9395 }
9496
97+ @ DisplayName (F002 )
9598 @ Order (2 )
9699 @ Test
97- public void testF002HomePageRendered (){
100+ public void testF002HomePageRendered () throws Exception {
98101 log .info (eyecatcherH1 );
99102 log .info ("testF002HomePageRendered" );
100103 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" )));
101112 log .info (eyecatcherH2 );
102113 }
103114
115+ @ DisplayName (F003 )
104116 @ Order (3 )
105117 @ Test
106118 public void testF003Registration (){
@@ -109,6 +121,7 @@ public void testF003Registration(){
109121 log .info (eyecatcherH2 );
110122 }
111123
124+ @ DisplayName (F004 )
112125 @ Order (4 )
113126 @ Test
114127 public void testF004PasswordRecovery (){
@@ -117,6 +130,7 @@ public void testF004PasswordRecovery(){
117130 log .info (eyecatcherH2 );
118131 }
119132
133+ @ DisplayName (F005 )
120134 @ Order (5 )
121135 @ Test
122136 public void testF005Login (){
@@ -125,6 +139,7 @@ public void testF005Login(){
125139 log .info (eyecatcherH2 );
126140 }
127141
142+ @ DisplayName (F006 )
128143 @ Order (6 )
129144 @ Test
130145 public void testF006PageAfterFirstSuccessfulLogin (){
@@ -133,6 +148,7 @@ public void testF006PageAfterFirstSuccessfulLogin(){
133148 log .info (eyecatcherH2 );
134149 }
135150
151+ @ DisplayName (F007 )
136152 @ Order (7 )
137153 @ Test
138154 public void testF007AddFirstNewTaskToInbox (){
@@ -141,6 +157,7 @@ public void testF007AddFirstNewTaskToInbox(){
141157 log .info (eyecatcherH2 );
142158 }
143159
160+ @ DisplayName (F008 )
144161 @ Order (8 )
145162 @ Test
146163 public void testF008AddAnotherNewTaskToInbox (){
@@ -149,6 +166,7 @@ public void testF008AddAnotherNewTaskToInbox(){
149166 log .info (eyecatcherH2 );
150167 }
151168
169+ @ DisplayName (F009 )
152170 @ Order (9 )
153171 @ Test
154172 public void testF009AddTaskToProjectRoot (){
@@ -157,6 +175,7 @@ public void testF009AddTaskToProjectRoot(){
157175 log .info (eyecatcherH2 );
158176 }
159177
178+ @ DisplayName (F010 )
160179 @ Order (10 )
161180 @ Test
162181 public void testF010AddSubProjectToProjectRoot (){
@@ -165,6 +184,7 @@ public void testF010AddSubProjectToProjectRoot(){
165184 log .info (eyecatcherH2 );
166185 }
167186
187+ @ DisplayName (F011 )
168188 @ Order (11 )
169189 @ Test
170190 public void testF011SetFocusOfTask (){
@@ -173,6 +193,7 @@ public void testF011SetFocusOfTask(){
173193 log .info (eyecatcherH2 );
174194 }
175195
196+ @ DisplayName (F012 )
176197 @ Order (12 )
177198 @ Test
178199 public void testF012UnSetFocusOfTask (){
@@ -181,6 +202,7 @@ public void testF012UnSetFocusOfTask(){
181202 log .info (eyecatcherH2 );
182203 }
183204
205+ @ DisplayName (F013 )
184206 @ Order (13 )
185207 @ Test
186208 public void testF013ShowTaskstateInbox (){
@@ -189,6 +211,7 @@ public void testF013ShowTaskstateInbox(){
189211 log .info (eyecatcherH2 );
190212 }
191213
214+ @ DisplayName (F014 )
192215 @ Order (14 )
193216 @ Test
194217 public void testF014ShowTaskstateToday (){
@@ -197,6 +220,7 @@ public void testF014ShowTaskstateToday(){
197220 log .info (eyecatcherH2 );
198221 }
199222
223+ @ DisplayName (F015 )
200224 @ Order (15 )
201225 @ Test
202226 public void testF015ShowTaskstateNext (){
@@ -205,6 +229,7 @@ public void testF015ShowTaskstateNext(){
205229 log .info (eyecatcherH2 );
206230 }
207231
232+ @ DisplayName (F016 )
208233 @ Order (16 )
209234 @ Test
210235 public void testF016ShowTaskstateWaiting (){
@@ -213,6 +238,7 @@ public void testF016ShowTaskstateWaiting(){
213238 log .info (eyecatcherH2 );
214239 }
215240
241+ @ DisplayName (F017 )
216242 @ Order (17 )
217243 @ Test
218244 public void testF017ShowTaskstateScheduled (){
@@ -221,6 +247,7 @@ public void testF017ShowTaskstateScheduled(){
221247 log .info (eyecatcherH2 );
222248 }
223249
250+ @ DisplayName (F018 )
224251 @ Order (18 )
225252 @ Test
226253 public void testF018ShowTaskstateSomeday (){
@@ -229,6 +256,7 @@ public void testF018ShowTaskstateSomeday(){
229256 log .info (eyecatcherH2 );
230257 }
231258
259+ @ DisplayName (F019 )
232260 @ Order (19 )
233261 @ Test
234262 public void testF019ShowTaskstateFocus (){
@@ -237,6 +265,7 @@ public void testF019ShowTaskstateFocus(){
237265 log .info (eyecatcherH2 );
238266 }
239267
268+ @ DisplayName (F020 )
240269 @ Order (20 )
241270 @ Test
242271 public void testF020ShowTaskstateCompleted (){
@@ -245,6 +274,7 @@ public void testF020ShowTaskstateCompleted(){
245274 log .info (eyecatcherH2 );
246275 }
247276
277+ @ DisplayName (F021 )
248278 @ Order (21 )
249279 @ Test
250280 public void testF021ShowTaskstateTrash (){
@@ -253,6 +283,7 @@ public void testF021ShowTaskstateTrash(){
253283 log .info (eyecatcherH2 );
254284 }
255285
286+ @ DisplayName (F022 )
256287 @ Order (22 )
257288 @ Test
258289 public void testF022TaskEdit (){
@@ -261,6 +292,7 @@ public void testF022TaskEdit(){
261292 log .info (eyecatcherH2 );
262293 }
263294
295+ @ DisplayName (F023 )
264296 @ Order (23 )
265297 @ Test
266298 public void testF023TaskEditFormChangeTaskstateViaDropDown (){
@@ -269,6 +301,7 @@ public void testF023TaskEditFormChangeTaskstateViaDropDown(){
269301 log .info (eyecatcherH2 );
270302 }
271303
304+ @ DisplayName (F024 )
272305 @ Order (24 )
273306 @ Test
274307 public void testF024TaskComplete (){
@@ -277,6 +310,7 @@ public void testF024TaskComplete(){
277310 log .info (eyecatcherH2 );
278311 }
279312
313+ @ DisplayName (F025 )
280314 @ Order (25 )
281315 @ Test
282316 public void testF025TaskIncomplete (){
@@ -285,6 +319,7 @@ public void testF025TaskIncomplete(){
285319 log .info (eyecatcherH2 );
286320 }
287321
322+ @ DisplayName (F026 )
288323 @ Order (26 )
289324 @ Test
290325 public void testF026TaskDelete (){
@@ -293,6 +328,7 @@ public void testF026TaskDelete(){
293328 log .info (eyecatcherH2 );
294329 }
295330
331+ @ DisplayName (F027 )
296332 @ Order (27 )
297333 @ Test
298334 public void testF027TaskUndelete (){
0 commit comments