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
This commit is contained in:
geroza 2018-12-11 12:17:29 -02:00
parent 743949afe6
commit 99dd82d2ff
22 changed files with 58 additions and 67 deletions

View File

@ -9,10 +9,10 @@
<description>spring forms examples using thymeleaf</description> <description>spring forms examples using thymeleaf</description>
<parent> <parent>
<artifactId>parent-boot-2.0-temp</artifactId> <artifactId>parent-boot-2</artifactId>
<groupId>com.baeldung</groupId> <groupId>com.baeldung</groupId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
<relativePath>../parent-boot-2.0-temp</relativePath> <relativePath>../parent-boot-2</relativePath>
</parent> </parent>
<dependencies> <dependencies>

View File

@ -8,10 +8,10 @@
<packaging>war</packaging> <packaging>war</packaging>
<parent> <parent>
<artifactId>parent-boot-2.0-temp</artifactId> <artifactId>parent-boot-2</artifactId>
<groupId>com.baeldung</groupId> <groupId>com.baeldung</groupId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
<relativePath>../parent-boot-2.0-temp</relativePath> <relativePath>../parent-boot-2</relativePath>
</parent> </parent>
<dependencies> <dependencies>

View File

@ -6,12 +6,12 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
import org.springframework.web.filter.ShallowEtagHeaderFilter; import org.springframework.web.filter.ShallowEtagHeaderFilter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@SpringBootApplication @SpringBootApplication
@EnableAutoConfiguration @EnableAutoConfiguration
@Import(PersistenceConfig.class) @Import(PersistenceConfig.class)
public class Application extends WebMvcConfigurerAdapter { public class Application implements WebMvcConfigurer {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(Application.class, args); SpringApplication.run(Application.class, args);

View File

@ -1,62 +1,66 @@
package org.baeldung.web.service; package org.baeldung.web.service;
import static io.restassured.RestAssured.given;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsCollectionContaining.hasItems;
import static org.hamcrest.core.IsEqual.equalTo;
import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.RandomStringUtils;
import org.baeldung.web.main.Application; import org.baeldung.web.main.Application;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
import static io.restassured.RestAssured.given;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsCollectionContaining.hasItems;
import static org.hamcrest.core.IsEqual.equalTo;
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(classes = Application.class, webEnvironment = WebEnvironment.DEFINED_PORT) @SpringBootTest(classes = Application.class, webEnvironment = WebEnvironment.RANDOM_PORT)
public class StudentServiceIntegrationTest { public class StudentServiceIntegrationTest {
private static final String ENDPOINT = "http://localhost:8080/student/get"; @LocalServerPort
int port;
private static final String ENDPOINT = "http://localhost:%s/student/get";
@Test @Test
public void givenRequestForStudents_whenPageIsOne_expectContainsNames() { public void givenRequestForStudents_whenPageIsOne_expectContainsNames() {
given().params("page", "0", "size", "2").get(ENDPOINT).then().assertThat() given().params("page", "0", "size", "2").get(String.format(ENDPOINT, port)).then().assertThat()
.body("content.name", hasItems("Bryan", "Ben")); .body("content.name", hasItems("Bryan", "Ben"));
} }
@Test @Test
public void givenRequestForStudents_whenSizeIsTwo_expectTwoItems() { public void givenRequestForStudents_whenSizeIsTwo_expectTwoItems() {
given().params("page", "0", "size", "2").get(ENDPOINT).then().assertThat().body("size", equalTo(2)); given().params("page", "0", "size", "2").get(String.format(ENDPOINT, port)).then().assertThat().body("size", equalTo(2));
} }
@Test @Test
public void givenRequestForStudents_whenSizeIsTwo_expectNumberOfElementsTwo() { public void givenRequestForStudents_whenSizeIsTwo_expectNumberOfElementsTwo() {
given().params("page", "0", "size", "2").get(ENDPOINT).then().assertThat().body("numberOfElements", equalTo(2)); given().params("page", "0", "size", "2").get(String.format(ENDPOINT, port)).then().assertThat().body("numberOfElements", equalTo(2));
} }
@Test @Test
public void givenRequestForStudents_whenResourcesAreRetrievedPaged_thenExpect200() { public void givenRequestForStudents_whenResourcesAreRetrievedPaged_thenExpect200() {
given().params("page", "0", "size", "2").get(ENDPOINT).then().statusCode(200); given().params("page", "0", "size", "2").get(String.format(ENDPOINT, port)).then().statusCode(200);
} }
@Test @Test
public void givenRequestForStudents_whenPageOfResourcesAreRetrievedOutOfBounds_thenExpect500() { public void givenRequestForStudents_whenPageOfResourcesAreRetrievedOutOfBounds_thenExpect500() {
given().params("page", "1000", "size", "2").get(ENDPOINT).then().statusCode(500); given().params("page", "1000", "size", "2").get(String.format(ENDPOINT, port)).then().statusCode(500);
} }
@Test @Test
public void givenRequestForStudents_whenPageNotValid_thenExpect500() { public void givenRequestForStudents_whenPageNotValid_thenExpect500() {
given().params("page", RandomStringUtils.randomNumeric(5), "size", "2").get(ENDPOINT).then().statusCode(500); given().params("page", RandomStringUtils.randomNumeric(5), "size", "2").get(String.format(ENDPOINT, port)).then().statusCode(500);
} }
@Test @Test
public void givenRequestForStudents_whenPageSizeIsFive_expectFiveItems() { public void givenRequestForStudents_whenPageSizeIsFive_expectFiveItems() {
given().params("page", "0", "size", "5").get(ENDPOINT).then().body("content.size()", is(5)); given().params("page", "0", "size", "5").get(String.format(ENDPOINT, port)).then().body("content.size()", is(5));
} }
@Test @Test
public void givenResourcesExist_whenFirstPageIsRetrieved_thenPageContainsResources() { public void givenResourcesExist_whenFirstPageIsRetrieved_thenPageContainsResources() {
given().params("page", "0", "size", "2").get(ENDPOINT).then().assertThat().body("first", equalTo(true)); given().params("page", "0", "size", "2").get(String.format(ENDPOINT, port)).then().assertThat().body("first", equalTo(true));
} }
} }

View File

@ -7,10 +7,10 @@
<packaging>war</packaging> <packaging>war</packaging>
<parent> <parent>
<artifactId>parent-boot-2.0-temp</artifactId> <artifactId>parent-boot-2</artifactId>
<groupId>com.baeldung</groupId> <groupId>com.baeldung</groupId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
<relativePath>../parent-boot-2.0-temp</relativePath> <relativePath>../parent-boot-2</relativePath>
</parent> </parent>
<dependencies> <dependencies>

View File

@ -8,10 +8,10 @@
<description>A simple project to demonstrate Spring REST Shell features.</description> <description>A simple project to demonstrate Spring REST Shell features.</description>
<parent> <parent>
<artifactId>parent-boot-2.0-temp</artifactId> <artifactId>parent-boot-2</artifactId>
<groupId>com.baeldung</groupId> <groupId>com.baeldung</groupId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
<relativePath>../parent-boot-2.0-temp</relativePath> <relativePath>../parent-boot-2</relativePath>
</parent> </parent>
<dependencies> <dependencies>

View File

@ -8,10 +8,10 @@
<packaging>war</packaging> <packaging>war</packaging>
<parent> <parent>
<artifactId>parent-boot-2.0-temp</artifactId> <artifactId>parent-boot-2</artifactId>
<groupId>com.baeldung</groupId> <groupId>com.baeldung</groupId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
<relativePath>../parent-boot-2.0-temp</relativePath> <relativePath>../parent-boot-2</relativePath>
</parent> </parent>
<dependencies> <dependencies>

View File

@ -8,10 +8,10 @@
<packaging>jar</packaging> <packaging>jar</packaging>
<parent> <parent>
<artifactId>parent-boot-2.0-temp</artifactId> <artifactId>parent-boot-2</artifactId>
<groupId>com.baeldung</groupId> <groupId>com.baeldung</groupId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
<relativePath>../parent-boot-2.0-temp</relativePath> <relativePath>../parent-boot-2</relativePath>
</parent> </parent>
<dependencies> <dependencies>

View File

@ -7,10 +7,10 @@
<packaging>war</packaging> <packaging>war</packaging>
<parent> <parent>
<artifactId>parent-boot-2.0-temp</artifactId> <artifactId>parent-boot-2</artifactId>
<groupId>com.baeldung</groupId> <groupId>com.baeldung</groupId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
<relativePath>../parent-boot-2.0-temp</relativePath> <relativePath>../parent-boot-2</relativePath>
</parent> </parent>
<dependencies> <dependencies>

View File

@ -43,7 +43,7 @@ public class EmployeeClient
ResponseEntity<List<Employee>> response = ResponseEntity<List<Employee>> response =
restTemplate.exchange( restTemplate.exchange(
"http://localhost:8080/spring-rest/employees/", "http://localhost:8082/spring-rest/employees/",
HttpMethod.GET, HttpMethod.GET,
null, null,
new ParameterizedTypeReference<List<Employee>>(){}); new ParameterizedTypeReference<List<Employee>>(){});
@ -61,7 +61,7 @@ public class EmployeeClient
EmployeeList response = EmployeeList response =
restTemplate.getForObject( restTemplate.getForObject(
"http://localhost:8080/spring-rest/employees/v2", "http://localhost:8082/spring-rest/employees/v2",
EmployeeList.class); EmployeeList.class);
List<Employee> employees = response.getEmployees(); List<Employee> employees = response.getEmployees();
@ -80,7 +80,7 @@ public class EmployeeClient
newEmployees.add(new Employee(4, "CEO")); newEmployees.add(new Employee(4, "CEO"));
restTemplate.postForObject( restTemplate.postForObject(
"http://localhost:8080/spring-rest/employees/", "http://localhost:8082/spring-rest/employees/",
newEmployees, newEmployees,
ResponseEntity.class); ResponseEntity.class);
} }
@ -94,7 +94,7 @@ public class EmployeeClient
newEmployees.add(new Employee(4, "CEO")); newEmployees.add(new Employee(4, "CEO"));
restTemplate.postForObject( restTemplate.postForObject(
"http://localhost:8080/spring-rest/employees/v2/", "http://localhost:8082/spring-rest/employees/v2/",
new EmployeeList(newEmployees), new EmployeeList(newEmployees),
ResponseEntity.class); ResponseEntity.class);
} }

View File

@ -1,13 +0,0 @@
package com.baeldung.sampleapp.web.controller.advice;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.servlet.mvc.method.annotation.AbstractJsonpResponseBodyAdvice;
@ControllerAdvice
public class JsonpControllerAdvice extends AbstractJsonpResponseBodyAdvice {
public JsonpControllerAdvice() {
super("callback");
}
}

View File

@ -9,9 +9,9 @@ import org.springframework.context.annotation.ComponentScan;
@EnableAutoConfiguration @EnableAutoConfiguration
@ComponentScan("com.baeldung.web.upload") @ComponentScan("com.baeldung.web.upload")
@SpringBootApplication @SpringBootApplication
public class Application extends SpringBootServletInitializer { public class UploadApplication extends SpringBootServletInitializer {
public static void main(final String[] args) { public static void main(final String[] args) {
SpringApplication.run(Application.class, args); SpringApplication.run(UploadApplication.class, args);
} }
} }

View File

@ -14,7 +14,7 @@ import com.baeldung.web.log.app.Application;
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(classes = { CustomApplication.class, ImageApplication.class, PropertyEditorApplication.class, @SpringBootTest(classes = { CustomApplication.class, ImageApplication.class, PropertyEditorApplication.class,
ResponseHeadersApplication.class, Application.class, com.baeldung.web.upload.app.Application.class, ResponseHeadersApplication.class, Application.class, com.baeldung.web.upload.app.UploadApplication.class,
MainApplication.class}) MainApplication.class})
public class SpringContextIntegrationTest { public class SpringContextIntegrationTest {

View File

@ -8,10 +8,10 @@
<packaging>war</packaging> <packaging>war</packaging>
<parent> <parent>
<artifactId>parent-boot-2.0-temp</artifactId> <artifactId>parent-boot-2</artifactId>
<groupId>com.baeldung</groupId> <groupId>com.baeldung</groupId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
<relativePath>../parent-boot-2.0-temp</relativePath> <relativePath>../parent-boot-2</relativePath>
</parent> </parent>
<dependencies> <dependencies>

View File

@ -11,10 +11,10 @@
<description>Spring Security MVC Boot</description> <description>Spring Security MVC Boot</description>
<parent> <parent>
<artifactId>parent-boot-2.0-temp</artifactId> <artifactId>parent-boot-2</artifactId>
<groupId>com.baeldung</groupId> <groupId>com.baeldung</groupId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
<relativePath>../parent-boot-2.0-temp</relativePath> <relativePath>../parent-boot-2</relativePath>
</parent> </parent>
<dependencies> <dependencies>
@ -36,7 +36,7 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.thymeleaf.extras</groupId> <groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity4</artifactId> <artifactId>thymeleaf-extras-springsecurity5</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>

View File

@ -1,6 +1,6 @@
<!DOCTYPE html> <!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" <html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3"> xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
<head> <head>
<title>Private</title> <title>Private</title>
</head> </head>

View File

@ -9,10 +9,10 @@
<description>Spring OpenID sample project</description> <description>Spring OpenID sample project</description>
<parent> <parent>
<artifactId>parent-boot-2.0-temp</artifactId> <artifactId>parent-boot-2</artifactId>
<groupId>com.baeldung</groupId> <groupId>com.baeldung</groupId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
<relativePath>../parent-boot-2.0-temp</relativePath> <relativePath>../parent-boot-2</relativePath>
</parent> </parent>
<dependencies> <dependencies>

View File

@ -9,10 +9,10 @@
<packaging>pom</packaging> <packaging>pom</packaging>
<parent> <parent>
<artifactId>parent-boot-2.0-temp</artifactId> <artifactId>parent-boot-2</artifactId>
<groupId>com.baeldung</groupId> <groupId>com.baeldung</groupId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
<relativePath>../parent-boot-2.0-temp</relativePath> <relativePath>../parent-boot-2</relativePath>
</parent> </parent>
<modules> <modules>
@ -24,7 +24,7 @@
<properties> <properties>
<rest-assured.version>3.1.0</rest-assured.version> <rest-assured.version>3.1.0</rest-assured.version>
<oauth.version>2.3.3.RELEASE</oauth.version> <oauth.version>2.3.3.RELEASE</oauth.version>
<oauth-auto.version>2.0.1.RELEASE</oauth-auto.version> <oauth-auto.version>2.1.1.RELEASE</oauth-auto.version>
</properties> </properties>
</project> </project>

View File

@ -37,7 +37,7 @@
<dependency> <dependency>
<groupId>org.thymeleaf.extras</groupId> <groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity4</artifactId> <artifactId>thymeleaf-extras-springsecurity5</artifactId>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -38,7 +38,7 @@
<dependency> <dependency>
<groupId>org.thymeleaf.extras</groupId> <groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity4</artifactId> <artifactId>thymeleaf-extras-springsecurity5</artifactId>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -11,10 +11,10 @@
<description>Spring Security with Thymeleaf tutorial</description> <description>Spring Security with Thymeleaf tutorial</description>
<parent> <parent>
<artifactId>parent-boot-2.0-temp</artifactId> <artifactId>parent-boot-2</artifactId>
<groupId>com.baeldung</groupId> <groupId>com.baeldung</groupId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
<relativePath>../parent-boot-2.0-temp</relativePath> <relativePath>../parent-boot-2</relativePath>
</parent> </parent>
<dependencies> <dependencies>
@ -43,7 +43,7 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.thymeleaf.extras</groupId> <groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity4</artifactId> <artifactId>thymeleaf-extras-springsecurity5</artifactId>
</dependency> </dependency>
</dependencies> </dependencies>