File tree 13 files changed +54
-44
lines changed
spring-boot/src/test/java
spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration
spring-boot-bootstrap/src/test/java/org/baeldung
spring-boot-client/src/test/java/org/baeldung/boot/client
spring-boot-disable-console-logging
disabling-console-logback
spring-cloud/spring-cloud-vault
13 files changed +54
-44
lines changed Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ public DataSource dataSource() {
47
47
final DriverManagerDataSource dataSource = new DriverManagerDataSource ();
48
48
49
49
dataSource .setDriverClassName ("com.mysql.cj.jdbc.Driver" );
50
- dataSource .setUrl ("jdbc:mysql://localhost:3306/myDb?createDatabaseIfNotExist=true" );
50
+ dataSource .setUrl ("jdbc:mysql://localhost:3306/myDb?createDatabaseIfNotExist=true&&serverTimezone=UTC " );
51
51
dataSource .setUsername ("mysqluser" );
52
52
dataSource .setPassword ("mysqlpass" );
53
53
Original file line number Diff line number Diff line change 4
4
import static org .apache .commons .lang3 .RandomStringUtils .randomNumeric ;
5
5
import static org .junit .Assert .assertEquals ;
6
6
import static org .junit .Assert .assertTrue ;
7
- import io .restassured .RestAssured ;
8
- import io .restassured .response .Response ;
9
7
10
8
import java .util .List ;
11
9
12
10
import org .baeldung .persistence .model .Book ;
13
11
import org .junit .Test ;
14
- import org .junit .runner .RunWith ;
15
- import org .springframework .boot .test .context .SpringBootTest ;
16
- import org .springframework .boot .test .context .SpringBootTest .WebEnvironment ;
17
12
import org .springframework .http .HttpStatus ;
18
13
import org .springframework .http .MediaType ;
19
- import org .springframework .test .context .junit4 .SpringRunner ;
20
14
21
- @ RunWith (SpringRunner .class )
22
- @ SpringBootTest (classes = Application .class , webEnvironment = WebEnvironment .DEFINED_PORT )
15
+ import io .restassured .RestAssured ;
16
+ import io .restassured .response .Response ;
17
+
23
18
public class SpringBootBootstrapIntegrationTest {
24
19
25
- private static final String API_ROOT = "http://localhost:8081 /api/books" ;
20
+ private static final String API_ROOT = "http://localhost:8080 /api/books" ;
26
21
27
22
@ Test
28
23
public void whenGetAllBooks_thenOK () {
Original file line number Diff line number Diff line change 10
10
import org .junit .runner .RunWith ;
11
11
import org .springframework .beans .factory .annotation .Autowired ;
12
12
import org .springframework .boot .test .autoconfigure .web .client .RestClientTest ;
13
- import org .springframework .boot .test .context .SpringBootTest ;
14
13
import org .springframework .http .MediaType ;
15
14
import org .springframework .test .context .junit4 .SpringRunner ;
16
15
import org .springframework .test .web .client .MockRestServiceServer ;
17
16
18
17
import com .fasterxml .jackson .databind .ObjectMapper ;
19
18
20
19
@ RunWith (SpringRunner .class )
21
- @ SpringBootTest (classes = Application .class )
22
- @ RestClientTest (DetailsServiceClient .class )
20
+ @ RestClientTest ({ DetailsServiceClient .class , Application .class })
23
21
public class DetailsServiceClientIntegrationTest {
24
22
25
23
@ Autowired
@@ -34,7 +32,8 @@ public class DetailsServiceClientIntegrationTest {
34
32
@ Before
35
33
public void setUp () throws Exception {
36
34
String detailsString = objectMapper .writeValueAsString (new Details ("John Smith" , "john" ));
37
- this .server .expect (requestTo ("/john/details" )).andRespond (withSuccess (detailsString , MediaType .APPLICATION_JSON ));
35
+ this .server .expect (requestTo ("/john/details" ))
36
+ .andRespond (withSuccess (detailsString , MediaType .APPLICATION_JSON ));
38
37
}
39
38
40
39
@ Test
Original file line number Diff line number Diff line change
1
+ baeldung.log
Original file line number Diff line number Diff line change 8
8
<parent >
9
9
<groupId >org.springframework.boot</groupId >
10
10
<artifactId >spring-boot-starter-parent</artifactId >
11
- <version >2.0.5 .RELEASE</version >
11
+ <version >2.1.1 .RELEASE</version >
12
12
</parent >
13
13
14
14
<dependencies >
Original file line number Diff line number Diff line change
1
+ all.log
Original file line number Diff line number Diff line change 8
8
<parent >
9
9
<groupId >org.springframework.boot</groupId >
10
10
<artifactId >spring-boot-starter-parent</artifactId >
11
- <version >2.0.5 .RELEASE</version >
11
+ <version >2.1.1 .RELEASE</version >
12
12
</parent >
13
13
14
14
<dependencies >
Original file line number Diff line number Diff line change
1
+ disabled-console.log
Original file line number Diff line number Diff line change 1
- <project xmlns =" http://maven.apache.org/POM/4.0.0" xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance" xsi : schemaLocation =" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >
2
- <modelVersion >4.0.0</modelVersion >
3
- <artifactId >disabling-console-logback</artifactId >
4
- <name >disabling-console-logback</name >
1
+ <project xmlns =" http://maven.apache.org/POM/4.0.0"
2
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
3
+ xsi : schemaLocation =" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >
4
+ <modelVersion >4.0.0</modelVersion >
5
+ <artifactId >disabling-console-logback</artifactId >
6
+ <name >disabling-console-logback</name >
7
+
8
+ <parent >
9
+ <artifactId >spring-boot-disable-console-logging</artifactId >
10
+ <groupId >com.baeldung</groupId >
11
+ <version >0.0.1-SNAPSHOT</version >
12
+ <relativePath >../</relativePath >
13
+ </parent >
14
+
15
+ <dependencies >
16
+ <dependency >
17
+ <groupId >org.springframework.boot</groupId >
18
+ <artifactId >spring-boot-starter-web</artifactId >
19
+ </dependency >
20
+ </dependencies >
5
21
6
- <parent >
7
- <groupId >com.baeldung</groupId >
8
- <artifactId >spring-boot-disable-console-logging</artifactId >
9
- <version >0.0.1-SNAPSHOT</version >
10
- </parent >
11
-
12
- <dependencies >
13
- <dependency >
14
- <groupId >org.springframework.boot</groupId >
15
- <artifactId >spring-boot-starter-web</artifactId >
16
- </dependency >
17
- </dependencies >
18
-
19
22
</project >
Original file line number Diff line number Diff line change 1
1
package com .baeldung .intro ;
2
2
3
+ import static org .hamcrest .Matchers .equalTo ;
4
+ import static org .springframework .test .web .servlet .result .MockMvcResultMatchers .content ;
5
+ import static org .springframework .test .web .servlet .result .MockMvcResultMatchers .status ;
6
+
3
7
import org .junit .Test ;
4
8
import org .junit .runner .RunWith ;
5
9
import org .springframework .beans .factory .annotation .Autowired ;
6
10
import org .springframework .boot .test .autoconfigure .web .servlet .AutoConfigureMockMvc ;
7
11
import org .springframework .boot .test .context .SpringBootTest ;
8
12
import org .springframework .http .MediaType ;
9
- import org .springframework .test .context .TestPropertySource ;
10
13
import org .springframework .test .context .junit4 .SpringRunner ;
11
14
import org .springframework .test .web .servlet .MockMvc ;
12
15
import org .springframework .test .web .servlet .request .MockMvcRequestBuilders ;
13
16
14
- import static org .hamcrest .Matchers .equalTo ;
15
- import static org .springframework .test .web .servlet .result .MockMvcResultMatchers .content ;
16
- import static org .springframework .test .web .servlet .result .MockMvcResultMatchers .status ;
17
-
18
17
@ RunWith (SpringRunner .class )
19
18
@ SpringBootTest (webEnvironment = SpringBootTest .WebEnvironment .MOCK )
20
19
@ AutoConfigureMockMvc
Original file line number Diff line number Diff line change 4
4
import org .junit .Test ;
5
5
import org .junit .runner .RunWith ;
6
6
import org .springframework .boot .test .context .SpringBootTest ;
7
+ import org .springframework .boot .test .context .SpringBootTest .WebEnvironment ;
7
8
import org .springframework .test .context .junit4 .SpringJUnit4ClassRunner ;
8
- import org .springframework .test .context .web .WebAppConfiguration ;
9
9
10
10
@ RunWith (SpringJUnit4ClassRunner .class )
11
- @ SpringBootTest (classes = DemoApplication .class )
12
- @ WebAppConfiguration
11
+ @ SpringBootTest (classes = DemoApplication .class , webEnvironment = WebEnvironment .RANDOM_PORT )
13
12
public class DemoApplicationIntegrationTest {
14
13
15
14
@ Test
Original file line number Diff line number Diff line change 22
22
import org .springframework .boot .test .autoconfigure .jdbc .AutoConfigureTestDatabase ;
23
23
import org .springframework .boot .test .autoconfigure .web .servlet .AutoConfigureMockMvc ;
24
24
import org .springframework .boot .test .context .SpringBootTest ;
25
+ import org .springframework .boot .test .context .SpringBootTest .WebEnvironment ;
25
26
import org .springframework .http .MediaType ;
26
27
import org .springframework .test .context .junit4 .SpringRunner ;
27
28
import org .springframework .test .web .servlet .MockMvc ;
28
29
29
30
@ RunWith (SpringRunner .class )
30
- @ SpringBootTest (webEnvironment = SpringBootTest . WebEnvironment .MOCK , classes = DemoApplication .class )
31
- @ AutoConfigureMockMvc
31
+ @ SpringBootTest (webEnvironment = WebEnvironment .RANDOM_PORT , classes = DemoApplication .class )
32
+ @ AutoConfigureMockMvc
32
33
// @TestPropertySource(locations = "classpath:application-integrationtest.properties")
33
34
@ AutoConfigureTestDatabase
34
35
public class EmployeeRestControllerIntegrationTest {
Original file line number Diff line number Diff line change 24
24
<project .build.sourceEncoding>UTF-8</project .build.sourceEncoding>
25
25
<project .reporting.outputEncoding>UTF-8</project .reporting.outputEncoding>
26
26
<java .version>1.8</java .version>
27
- <spring-cloud .version>Finchley.SR1 </spring-cloud .version>
27
+ <spring-cloud .version>Greenwich.M3 </spring-cloud .version>
28
28
</properties >
29
29
30
30
<dependencies >
82
82
</plugin >
83
83
</plugins >
84
84
</build >
85
+
86
+ <repositories >
87
+ <repository >
88
+ <id >spring-milestones</id >
89
+ <name >Spring Milestones</name >
90
+ <url >http://repo.spring.io/milestone</url >
91
+ <snapshots >
92
+ <enabled >false</enabled >
93
+ </snapshots >
94
+ </repository >
95
+ </repositories >
85
96
86
97
87
98
</project >
You can’t perform that action at this time.
0 commit comments