Skip to content

Commit ba34b02

Browse files
committed
work
1 parent 0107f6a commit ba34b02

10 files changed

+466
-69
lines changed

src/test/java/org/woehlke/java/simpleworklist/domain/UserLoginControllerIT.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public void runAfterTestClass() {
110110
}
111111
}
112112

113-
113+
@Order(1)
114114
@Test
115115
public void testLoginFormular() {
116116
try {
@@ -125,6 +125,7 @@ public void testLoginFormular() {
125125
}
126126
}
127127

128+
@Order(2)
128129
@Test
129130
public void testFinish() {
130131
//deleteAll();

src/test/java/org/woehlke/java/simpleworklist/domain/UserPasswordRecoveryControllerIT.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ public void runAfterTestClass() {
141141
@Autowired
142142
private UserAccountPasswordRecoveryService userAccountPasswordRecoveryService;
143143

144+
@Order(1)
144145
@Test
145146
public void testResetPassword() {
146147
try {
@@ -155,6 +156,7 @@ public void testResetPassword() {
155156
}
156157
}
157158

159+
@Order(2)
158160
@Test
159161
public void testEnterNewPasswordFormular() {
160162
try {
@@ -169,7 +171,7 @@ public void testEnterNewPasswordFormular() {
169171
}
170172
}
171173

172-
174+
@Order(3)
173175
@Test
174176
public void testEnterNewPasswordFormularWithToken() {
175177
userAccountPasswordRecoveryService.passwordRecoverySendEmailTo(emails[0]);
@@ -198,6 +200,7 @@ public void testEnterNewPasswordFormularWithToken() {
198200
}
199201
}
200202

203+
@Order(4)
201204
@Test
202205
public void finish(){
203206
deleteAll();

src/test/java/org/woehlke/java/simpleworklist/domain/UserRegistrationControllerIT.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext;
1111
import org.springframework.context.annotation.Import;
1212
import org.springframework.security.core.context.SecurityContextHolder;
13+
import org.springframework.security.core.userdetails.UsernameNotFoundException;
1314
import org.springframework.security.test.context.support.WithMockUser;
1415
import org.springframework.test.web.servlet.MockMvc;
1516
import org.woehlke.java.simpleworklist.SimpleworklistApplication;
@@ -26,8 +27,7 @@
2627
import java.util.UUID;
2728

2829
import static org.hamcrest.Matchers.containsString;
29-
import static org.junit.jupiter.api.Assertions.assertNotNull;
30-
import static org.junit.jupiter.api.Assertions.assertTrue;
30+
import static org.junit.jupiter.api.Assertions.*;
3131
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
3232
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
3333
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.model;
@@ -142,6 +142,7 @@ public void runAfterTestClass() {
142142
@Autowired
143143
private UserAccountRegistrationService userAccountRegistrationService;
144144

145+
@Order(1)
145146
@Test
146147
public void testSignInFormularEmail() {
147148
try {
@@ -157,6 +158,7 @@ public void testSignInFormularEmail() {
157158
}
158159
}
159160

161+
@Order(2)
160162
@Test
161163
public void testSignInFormularAccount() {
162164
try {
@@ -172,9 +174,9 @@ public void testSignInFormularAccount() {
172174
}
173175
}
174176

175-
177+
@Order(3)
176178
@Test
177-
public void testRegisterNewUserCheckResponseAndRegistrationForm() throws Exception{
179+
public void testRegisterNewUserCheckResponseAndRegistrationForm() {
178180
userAccountRegistrationService.registrationSendEmailTo(emails[0]);
179181
try {
180182
Thread.sleep(2000);
@@ -187,12 +189,19 @@ public void testRegisterNewUserCheckResponseAndRegistrationForm() throws Excepti
187189
|| o.getDoubleOptInStatus()== UserAccountRegistrationStatus.REGISTRATION_SENT_MAIL;
188190
assertTrue(result);
189191
String url = "/user/register/confirm/"+o.getToken();
190-
this.mockMvc.perform(
191-
get(url)).andDo(print())
192+
try {
193+
this.mockMvc.perform(
194+
get(url)).andDo(print())
192195
.andExpect(view().name(containsString("user/register/registerConfirmForm")))
193196
.andExpect(model().attributeExists("userAccountForm"));
197+
} catch (Exception e){
198+
assertNotNull(e.getMessage());
199+
assertFalse(username_email.compareTo(e.getMessage())==0);
200+
}
194201
userAccountRegistrationService.registrationUserCreated(o);
195202
}
203+
204+
@Order(4)
196205
@WithMockUser("test@test01.de")
197206
@Test
198207
public void finish(){

src/test/java/org/woehlke/java/simpleworklist/domain/db/user/ChatMessageServiceIT.java

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public class ChatMessageServiceIT {
5454
private final String eyecatcherH3 = "******************************************************************";
5555

5656
@BeforeEach
57-
public void setUp() throws Exception {
57+
public void setUp() {
5858
log.info(eyecatcherH1);
5959
log.info(" @BeforeEach setUp()");
6060
log.info(eyecatcherH2);
@@ -64,26 +64,40 @@ public void setUp() throws Exception {
6464
}
6565

6666
@BeforeAll
67-
public void runBeforeTestClass() throws Exception {
67+
public void runBeforeTestClass() {
6868
log.info(eyecatcherH1);
6969
log.info(" @BeforeTestClass runBeforeTestClass");
7070
log.info(eyecatcherH2);
71-
URL base = new URL("http://localhost:" + port + "/");
72-
log.info(" Server URL: " + base.toString());
73-
log.info(eyecatcherH2);
74-
userAccountTestDataService.setUp();
71+
try {
72+
URL base = new URL("http://localhost:" + port + "/");
73+
log.info(" Server URL: " + base.toString());
74+
log.info(eyecatcherH2);
75+
userAccountTestDataService.setUp();
76+
} catch (Exception ex) {
77+
log.warn("Exception: " + ex.getLocalizedMessage());
78+
for (StackTraceElement e : ex.getStackTrace()) {
79+
log.warn(e.getClassName() + "." + e.getMethodName() + "in: " + e.getFileName() + " line: " + e.getLineNumber());
80+
}
81+
}
7582
log.info(eyecatcherH2);
7683
log.info(" @BeforeTestClass runBeforeTestClass");
7784
log.info(eyecatcherH1);
7885
}
7986

8087
@AfterAll
81-
public void runAfterTestClass() throws Exception {
88+
public void runAfterTestClass() {
8289
log.info(eyecatcherH1);
8390
log.info(" @AfterTestClass clearContext");
8491
log.info(eyecatcherH2);
85-
URL base = new URL("http://localhost:" + port + "/");
86-
log.info(" Server URL: " + base.toString());
92+
try {
93+
URL base = new URL("http://localhost:" + port + "/");
94+
log.info(" Server URL: " + base.toString());
95+
} catch (Exception ex) {
96+
log.warn("Exception: " + ex.getLocalizedMessage());
97+
for (StackTraceElement e : ex.getStackTrace()) {
98+
log.warn(e.getClassName() + "." + e.getMethodName() + "in: " + e.getFileName() + " line: " + e.getLineNumber());
99+
}
100+
}
87101
log.info(eyecatcherH2);
88102
SecurityContextHolder.clearContext();
89103
log.info(eyecatcherH1);

src/test/java/org/woehlke/java/simpleworklist/domain/db/user/TokenGeneratorServiceIT.java

Lines changed: 77 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
11
package org.woehlke.java.simpleworklist.domain.db.user;
22

33
import lombok.extern.slf4j.Slf4j;
4-
import org.junit.jupiter.api.MethodOrderer;
5-
import org.junit.jupiter.api.TestInstance;
6-
import org.junit.jupiter.api.TestMethodOrder;
4+
import org.junit.jupiter.api.*;
5+
import org.springframework.beans.factory.annotation.Autowired;
76
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
87
import org.springframework.boot.context.properties.EnableConfigurationProperties;
98
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
109
import org.springframework.boot.test.context.SpringBootTest;
10+
import org.springframework.boot.web.server.LocalServerPort;
11+
import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext;
1112
import org.springframework.context.annotation.Import;
13+
import org.springframework.security.core.context.SecurityContextHolder;
14+
import org.springframework.test.web.servlet.MockMvc;
1215
import org.woehlke.java.simpleworklist.SimpleworklistApplication;
1316
import org.woehlke.java.simpleworklist.config.SimpleworklistProperties;
17+
import org.woehlke.java.simpleworklist.config.UserAccountTestDataService;
1418
import org.woehlke.java.simpleworklist.config.WebMvcConfig;
1519
import org.woehlke.java.simpleworklist.config.WebSecurityConfig;
1620

21+
import java.net.URL;
22+
1723
@Slf4j
1824
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
1925
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
@@ -28,4 +34,72 @@
2834
SimpleworklistProperties.class
2935
})
3036
public class TokenGeneratorServiceIT {
37+
38+
@Autowired
39+
private ServletWebServerApplicationContext server;
40+
41+
@Autowired
42+
private MockMvc mockMvc;
43+
44+
@SuppressWarnings("deprecation")
45+
@LocalServerPort
46+
private int port;
47+
48+
@Autowired
49+
private UserAccountTestDataService userAccountTestDataService;
50+
51+
private final String eyecatcherH1 = "##################################################################";
52+
private final String eyecatcherH2 = "------------------------------------------------------------------";
53+
private final String eyecatcherH3 = "******************************************************************";
54+
55+
@BeforeEach
56+
public void setUp() {
57+
log.info(eyecatcherH1);
58+
log.info(" @BeforeEach setUp()");
59+
log.info(eyecatcherH2);
60+
61+
//userAccountTestDataService.setUp();
62+
log.info(eyecatcherH1);
63+
}
64+
65+
@BeforeAll
66+
public void runBeforeTestClass() {
67+
log.info(eyecatcherH1);
68+
log.info(" @BeforeTestClass runBeforeTestClass");
69+
log.info(eyecatcherH2);
70+
try {
71+
URL base = new URL("http://localhost:" + port + "/");
72+
log.info(" Server URL: " + base.toString());
73+
log.info(eyecatcherH2);
74+
userAccountTestDataService.setUp();
75+
} catch (Exception ex) {
76+
log.warn("Exception: " + ex.getLocalizedMessage());
77+
for (StackTraceElement e : ex.getStackTrace()) {
78+
log.warn(e.getClassName() + "." + e.getMethodName() + "in: " + e.getFileName() + " line: " + e.getLineNumber());
79+
}
80+
}
81+
log.info(eyecatcherH2);
82+
log.info(" @BeforeTestClass runBeforeTestClass");
83+
log.info(eyecatcherH1);
84+
}
85+
86+
@AfterAll
87+
public void runAfterTestClass() {
88+
log.info(eyecatcherH1);
89+
log.info(" @AfterTestClass clearContext");
90+
log.info(eyecatcherH2);
91+
try {
92+
URL base = new URL("http://localhost:" + port + "/");
93+
log.info(" Server URL: " + base.toString());
94+
} catch (Exception ex) {
95+
log.warn("Exception: " + ex.getLocalizedMessage());
96+
for (StackTraceElement e : ex.getStackTrace()) {
97+
log.warn(e.getClassName() + "." + e.getMethodName() + "in: " + e.getFileName() + " line: " + e.getLineNumber());
98+
}
99+
}
100+
log.info(eyecatcherH2);
101+
SecurityContextHolder.clearContext();
102+
log.info(eyecatcherH1);
103+
}
104+
31105
}

0 commit comments

Comments
 (0)