Skip to content

Commit 9e245d9

Browse files
committed
Fixed #126
1 parent 84de2d6 commit 9e245d9

File tree

3 files changed

+124
-12
lines changed

3 files changed

+124
-12
lines changed

src/test/java/org/woehlke/simpleworklist/SmokeTests.java

Lines changed: 48 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,41 @@
33
import lombok.extern.slf4j.Slf4j;
44
import org.junit.jupiter.api.*;
55
import org.springframework.beans.factory.annotation.Autowired;
6+
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
67
import org.springframework.boot.test.context.SpringBootTest;
78
import org.springframework.boot.web.server.LocalServerPort;
89
import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext;
910
import org.springframework.security.core.context.SecurityContextHolder;
1011
import org.springframework.test.web.servlet.MockMvc;
11-
import org.springframework.web.context.WebApplicationContext;
12+
import org.woehlke.simpleworklist.config.FunctionalRequirements;
1213
import org.woehlke.simpleworklist.config.UserAccountTestDataService;
1314

1415
import java.net.URL;
1516

17+
import static org.hamcrest.Matchers.containsString;
1618
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.*;
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)
2329
public 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(){
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package org.woehlke.simpleworklist.config;
2+
3+
public enum FunctionalRequirements {
4+
5+
F001("Server Starts"),
6+
F002("Home Page rendered"),
7+
F003("Registration"),
8+
F004("Password Recovery"),
9+
F005("Login"),
10+
F006("Page after first successful Login"),
11+
F007("Add first new Task to Inbox"),
12+
F008("Add another new Task to Inbox"),
13+
F009("Add Task to ProjectRoot"),
14+
F010("Add SubProject to ProjectRoot"),
15+
F011("setFocus of a Task"),
16+
F012("unSetFocus of a Task"),
17+
F013("show /taskstate/inbox"),
18+
F014("show /taskstate/today"),
19+
F015("show /taskstate/next"),
20+
F016("show /taskstate/waiting"),
21+
F017("show /taskstate/scheduled"),
22+
F018("show /taskstate/someday"),
23+
F019("show /taskstate/focus"),
24+
F020("show /taskstate/completed"),
25+
F021("show /taskstate/trash"),
26+
F022("Task Edit"),
27+
F023("Task Edit Form -> change Taskstate via DropDown"),
28+
F024("Task complete"),
29+
F025("Task incomplete"),
30+
F026("Task delete"),
31+
F027("Task undelete");
32+
33+
private String name;
34+
35+
public String getName(){
36+
return name;
37+
}
38+
39+
FunctionalRequirements(String name){
40+
this.name = name;
41+
}
42+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package org.woehlke.simpleworklist.config;
2+
3+
public interface Requirements {
4+
5+
String Functional_Requirements = "Functional Requirements";
6+
7+
String F001 = "F001 Server Starts";
8+
String F002 = "F002 Home Page rendered";
9+
String F003 = "F003 Registration";
10+
String F004 = "F004 Password Recovery";
11+
String F005 = "F005 Login";
12+
String F006 = "F006 Page after first successful Login";
13+
String F007 = "F007 Add first new Task to Inbox";
14+
String F008 = "F008 Add another new Task to Inbox";
15+
String F009 = "F009 Add Task to ProjectRoot";
16+
String F010 = "F010 Add SubProject to ProjectRoot";
17+
String F011 = "F011 setFocus of a Task";
18+
String F012 = "F012 unSetFocus of a Task";
19+
String F013 = "F013 show /taskstate/inbox";
20+
String F014 = "F014 show /taskstate/today";
21+
String F015 = "F015 show /taskstate/next";
22+
String F016 = "F016 show /taskstate/waiting";
23+
String F017 = "F017 show /taskstate/scheduled";
24+
String F018 = "F018 show /taskstate/someday";
25+
String F019 = "F019 show /taskstate/focus";
26+
String F020 = "F020 show /taskstate/completed";
27+
String F021 = "F021 show /taskstate/trash";
28+
String F022 = "F022 Task Edit";
29+
String F023 = "F023 Task Edit Form -> change Taskstate via DropDown";
30+
String F024 = "F024 Task complete";
31+
String F025 = "F025 Task incomplete";
32+
String F026 = "F026 Task delete";
33+
String F027 = "F027 Task undelete";
34+
}

0 commit comments

Comments
 (0)