Skip to content

Commit 99dd82d

Browse files
committed
Migrated modules to parent-boot-2 usign spring-boot 2.1:
spring-mvc-forms-thymeleaf spring-rest spring-rest-angular spring-rest-query-language spring-rest-shell spring-rest-simple spring-rest-template spring-resttemplate spring-security-mvc-boot spring-security-openid spring-security-sso spring-security-thymeleaf
1 parent 743949a commit 99dd82d

22 files changed

Lines changed: 58 additions & 67 deletions

File tree

‎spring-mvc-forms-thymeleaf/pom.xml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
<description>spring forms examples using thymeleaf</description>
1010

1111
<parent>
12-
<artifactId>parent-boot-2.0-temp</artifactId>
12+
<artifactId>parent-boot-2</artifactId>
1313
<groupId>com.baeldung</groupId>
1414
<version>0.0.1-SNAPSHOT</version>
15-
<relativePath>../parent-boot-2.0-temp</relativePath>
15+
<relativePath>../parent-boot-2</relativePath>
1616
</parent>
1717

1818
<dependencies>

‎spring-rest-angular/pom.xml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
<packaging>war</packaging>
99

1010
<parent>
11-
<artifactId>parent-boot-2.0-temp</artifactId>
11+
<artifactId>parent-boot-2</artifactId>
1212
<groupId>com.baeldung</groupId>
1313
<version>0.0.1-SNAPSHOT</version>
14-
<relativePath>../parent-boot-2.0-temp</relativePath>
14+
<relativePath>../parent-boot-2</relativePath>
1515
</parent>
1616

1717
<dependencies>

‎spring-rest-angular/src/main/java/org/baeldung/web/main/Application.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
import org.springframework.context.annotation.Bean;
77
import org.springframework.context.annotation.Import;
88
import org.springframework.web.filter.ShallowEtagHeaderFilter;
9-
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
9+
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
1010

1111
@SpringBootApplication
1212
@EnableAutoConfiguration
1313
@Import(PersistenceConfig.class)
14-
public class Application extends WebMvcConfigurerAdapter {
14+
public class Application implements WebMvcConfigurer {
1515

1616
public static void main(String[] args) {
1717
SpringApplication.run(Application.class, args);
Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,66 @@
11
package org.baeldung.web.service;
22

3+
import static io.restassured.RestAssured.given;
4+
import static org.hamcrest.core.Is.is;
5+
import static org.hamcrest.core.IsCollectionContaining.hasItems;
6+
import static org.hamcrest.core.IsEqual.equalTo;
7+
38
import org.apache.commons.lang3.RandomStringUtils;
49
import org.baeldung.web.main.Application;
510
import org.junit.Test;
611
import org.junit.runner.RunWith;
712
import org.springframework.boot.test.context.SpringBootTest;
813
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
14+
import org.springframework.boot.web.server.LocalServerPort;
915
import org.springframework.test.context.junit4.SpringRunner;
1016

11-
import static io.restassured.RestAssured.given;
12-
import static org.hamcrest.core.Is.is;
13-
import static org.hamcrest.core.IsCollectionContaining.hasItems;
14-
import static org.hamcrest.core.IsEqual.equalTo;
15-
1617
@RunWith(SpringRunner.class)
17-
@SpringBootTest(classes = Application.class, webEnvironment = WebEnvironment.DEFINED_PORT)
18+
@SpringBootTest(classes = Application.class, webEnvironment = WebEnvironment.RANDOM_PORT)
1819
public class StudentServiceIntegrationTest {
20+
21+
@LocalServerPort
22+
int port;
1923

20-
private static final String ENDPOINT = "http://localhost:8080/student/get";
24+
private static final String ENDPOINT = "http://localhost:%s/student/get";
2125

2226
@Test
2327
public void givenRequestForStudents_whenPageIsOne_expectContainsNames() {
24-
given().params("page", "0", "size", "2").get(ENDPOINT).then().assertThat()
28+
given().params("page", "0", "size", "2").get(String.format(ENDPOINT, port)).then().assertThat()
2529
.body("content.name", hasItems("Bryan", "Ben"));
2630
}
2731

2832
@Test
2933
public void givenRequestForStudents_whenSizeIsTwo_expectTwoItems() {
30-
given().params("page", "0", "size", "2").get(ENDPOINT).then().assertThat().body("size", equalTo(2));
34+
given().params("page", "0", "size", "2").get(String.format(ENDPOINT, port)).then().assertThat().body("size", equalTo(2));
3135
}
3236

3337
@Test
3438
public void givenRequestForStudents_whenSizeIsTwo_expectNumberOfElementsTwo() {
35-
given().params("page", "0", "size", "2").get(ENDPOINT).then().assertThat().body("numberOfElements", equalTo(2));
39+
given().params("page", "0", "size", "2").get(String.format(ENDPOINT, port)).then().assertThat().body("numberOfElements", equalTo(2));
3640
}
3741

3842
@Test
3943
public void givenRequestForStudents_whenResourcesAreRetrievedPaged_thenExpect200() {
40-
given().params("page", "0", "size", "2").get(ENDPOINT).then().statusCode(200);
44+
given().params("page", "0", "size", "2").get(String.format(ENDPOINT, port)).then().statusCode(200);
4145
}
4246

4347
@Test
4448
public void givenRequestForStudents_whenPageOfResourcesAreRetrievedOutOfBounds_thenExpect500() {
45-
given().params("page", "1000", "size", "2").get(ENDPOINT).then().statusCode(500);
49+
given().params("page", "1000", "size", "2").get(String.format(ENDPOINT, port)).then().statusCode(500);
4650
}
4751

4852
@Test
4953
public void givenRequestForStudents_whenPageNotValid_thenExpect500() {
50-
given().params("page", RandomStringUtils.randomNumeric(5), "size", "2").get(ENDPOINT).then().statusCode(500);
54+
given().params("page", RandomStringUtils.randomNumeric(5), "size", "2").get(String.format(ENDPOINT, port)).then().statusCode(500);
5155
}
5256

5357
@Test
5458
public void givenRequestForStudents_whenPageSizeIsFive_expectFiveItems() {
55-
given().params("page", "0", "size", "5").get(ENDPOINT).then().body("content.size()", is(5));
59+
given().params("page", "0", "size", "5").get(String.format(ENDPOINT, port)).then().body("content.size()", is(5));
5660
}
5761

5862
@Test
5963
public void givenResourcesExist_whenFirstPageIsRetrieved_thenPageContainsResources() {
60-
given().params("page", "0", "size", "2").get(ENDPOINT).then().assertThat().body("first", equalTo(true));
64+
given().params("page", "0", "size", "2").get(String.format(ENDPOINT, port)).then().assertThat().body("first", equalTo(true));
6165
}
6266
}

‎spring-rest-query-language/pom.xml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
<packaging>war</packaging>
88

99
<parent>
10-
<artifactId>parent-boot-2.0-temp</artifactId>
10+
<artifactId>parent-boot-2</artifactId>
1111
<groupId>com.baeldung</groupId>
1212
<version>0.0.1-SNAPSHOT</version>
13-
<relativePath>../parent-boot-2.0-temp</relativePath>
13+
<relativePath>../parent-boot-2</relativePath>
1414
</parent>
1515

1616
<dependencies>

‎spring-rest-shell/pom.xml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
<description>A simple project to demonstrate Spring REST Shell features.</description>
99

1010
<parent>
11-
<artifactId>parent-boot-2.0-temp</artifactId>
11+
<artifactId>parent-boot-2</artifactId>
1212
<groupId>com.baeldung</groupId>
1313
<version>0.0.1-SNAPSHOT</version>
14-
<relativePath>../parent-boot-2.0-temp</relativePath>
14+
<relativePath>../parent-boot-2</relativePath>
1515
</parent>
1616

1717
<dependencies>

‎spring-rest-simple/pom.xml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
<packaging>war</packaging>
99

1010
<parent>
11-
<artifactId>parent-boot-2.0-temp</artifactId>
11+
<artifactId>parent-boot-2</artifactId>
1212
<groupId>com.baeldung</groupId>
1313
<version>0.0.1-SNAPSHOT</version>
14-
<relativePath>../parent-boot-2.0-temp</relativePath>
14+
<relativePath>../parent-boot-2</relativePath>
1515
</parent>
1616

1717
<dependencies>

‎spring-rest-template/pom.xml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
<packaging>jar</packaging>
99

1010
<parent>
11-
<artifactId>parent-boot-2.0-temp</artifactId>
11+
<artifactId>parent-boot-2</artifactId>
1212
<groupId>com.baeldung</groupId>
1313
<version>0.0.1-SNAPSHOT</version>
14-
<relativePath>../parent-boot-2.0-temp</relativePath>
14+
<relativePath>../parent-boot-2</relativePath>
1515
</parent>
1616

1717
<dependencies>

‎spring-rest/pom.xml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
<packaging>war</packaging>
88

99
<parent>
10-
<artifactId>parent-boot-2.0-temp</artifactId>
10+
<artifactId>parent-boot-2</artifactId>
1111
<groupId>com.baeldung</groupId>
1212
<version>0.0.1-SNAPSHOT</version>
13-
<relativePath>../parent-boot-2.0-temp</relativePath>
13+
<relativePath>../parent-boot-2</relativePath>
1414
</parent>
1515

1616
<dependencies>

‎spring-rest/src/main/java/com/baeldung/resttemplate/lists/client/EmployeeClient.java‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public List<Employee> getAllEmployeesUsingParameterizedTypeReference()
4343

4444
ResponseEntity<List<Employee>> response =
4545
restTemplate.exchange(
46-
"http://localhost:8080/spring-rest/employees/",
46+
"http://localhost:8082/spring-rest/employees/",
4747
HttpMethod.GET,
4848
null,
4949
new ParameterizedTypeReference<List<Employee>>(){});
@@ -61,7 +61,7 @@ public List<Employee> getAllEmployeesUsingWrapperClass()
6161

6262
EmployeeList response =
6363
restTemplate.getForObject(
64-
"http://localhost:8080/spring-rest/employees/v2",
64+
"http://localhost:8082/spring-rest/employees/v2",
6565
EmployeeList.class);
6666

6767
List<Employee> employees = response.getEmployees();
@@ -80,7 +80,7 @@ public void createEmployeesUsingLists()
8080
newEmployees.add(new Employee(4, "CEO"));
8181

8282
restTemplate.postForObject(
83-
"http://localhost:8080/spring-rest/employees/",
83+
"http://localhost:8082/spring-rest/employees/",
8484
newEmployees,
8585
ResponseEntity.class);
8686
}
@@ -94,7 +94,7 @@ public void createEmployeesUsingWrapperClass()
9494
newEmployees.add(new Employee(4, "CEO"));
9595

9696
restTemplate.postForObject(
97-
"http://localhost:8080/spring-rest/employees/v2/",
97+
"http://localhost:8082/spring-rest/employees/v2/",
9898
new EmployeeList(newEmployees),
9999
ResponseEntity.class);
100100
}

0 commit comments

Comments
 (0)