JAVA-31602 :- Upgrade spring-boot-mvc-2, spring-boot-mvc-5 to boot 3.2.2 (#16188)
* JAVA-31602 :- Upgrade spring-boot-mvc-2, spring-boot-mvc-5 to boot 3.2.2 * JAVA-31602 :- Upgrade spring-boot-mvc-2, spring-boot-mvc-5 to boot 3.2.2 * Revert parent pom to restrict build * JAVA-31602 :- Upgrade spring-boot-mvc-2, spring-boot-mvc-5 to boot 3.2.2 * Fix version error * JAVA-31602 :- Upgrade spring-boot-mvc-2, spring-boot-mvc-5 to boot 3.2.2 * Fix version error * JAVA-31602 :- Upgrade spring-boot-mvc-2, spring-boot-mvc-5 to boot 3.2.2 * Fix version error * Fix version error * Enable in Parent POM * Fix haslength approach --------- Co-authored-by: Amit Pandey <amitpandey@cloud.upwork.com>
This commit is contained in:
parent
9cc307e108
commit
8bd2ca6893
|
@ -58,7 +58,7 @@
|
|||
<module>spring-boot-mvc-2</module>
|
||||
<module>spring-boot-mvc-3</module>
|
||||
<module>spring-boot-mvc-4</module>
|
||||
<!-- <module>spring-boot-mvc-5</module>--> <!-- failing after upgrading to spring boot 3.2.x -->
|
||||
<module>spring-boot-mvc-5</module>
|
||||
<module>spring-boot-mvc-birt</module>
|
||||
<module>spring-boot-mvc-jersey</module>
|
||||
<module>spring-boot-nashorn</module>
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
<groupId>io.rest-assured</groupId>
|
||||
<artifactId>rest-assured</artifactId>
|
||||
<scope>test</scope>
|
||||
<version>${rest-assured-version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
@ -80,7 +81,11 @@
|
|||
<properties>
|
||||
<spring.fox.version>3.0.0</spring.fox.version>
|
||||
<start-class>com.baeldung.springbootmvc.SpringBootMvcFnApplication</start-class>
|
||||
<maven.compiler.release>17</maven.compiler.release>
|
||||
<xstream.version>1.4.11.1</xstream.version>
|
||||
<rest-assured-version>5.4.0</rest-assured-version>
|
||||
<spring-boot.version>3.2.2</spring-boot.version>
|
||||
<junit-jupiter.version>5.10.2</junit-jupiter.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
|
@ -2,12 +2,9 @@ package com.baeldung.mime;
|
|||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
|
|
@ -4,8 +4,9 @@ import static org.springframework.web.servlet.function.RouterFunctions.route;
|
|||
import static org.springframework.web.servlet.function.ServerResponse.ok;
|
||||
import static org.springframework.web.servlet.function.ServerResponse.status;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.baeldung.springbootmvc.SpringBootMvcFnApplication.Error;
|
||||
import com.baeldung.springbootmvc.model.Product;
|
||||
import com.baeldung.springbootmvc.svc.ProductService;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.servlet.function.EntityResponse;
|
||||
|
@ -14,10 +15,6 @@ import org.springframework.web.servlet.function.RouterFunction;
|
|||
import org.springframework.web.servlet.function.ServerRequest;
|
||||
import org.springframework.web.servlet.function.ServerResponse;
|
||||
|
||||
import com.baeldung.springbootmvc.SpringBootMvcFnApplication.Error;
|
||||
import com.baeldung.springbootmvc.model.Product;
|
||||
import com.baeldung.springbootmvc.svc.ProductService;
|
||||
|
||||
@Component
|
||||
public class ProductController {
|
||||
|
||||
|
@ -27,10 +24,8 @@ public class ProductController {
|
|||
}
|
||||
|
||||
public RouterFunction<ServerResponse> productSearch(ProductService ps) {
|
||||
return route().nest(RequestPredicates.path("/product"), builder -> {
|
||||
builder.GET("/name/{name}", req -> ok().body(ps.findByName(req.pathVariable("name"))))
|
||||
.GET("/id/{id}", req -> ok().body(ps.findById(Integer.parseInt(req.pathVariable("id")))));
|
||||
})
|
||||
return route().nest(RequestPredicates.path("/product"), builder -> builder.GET("/name/{name}", req -> ok().body(ps.findByName(req.pathVariable("name"))))
|
||||
.GET("/id/{id}", req -> ok().body(ps.findById(Integer.parseInt(req.pathVariable("id"))))))
|
||||
.onError(ProductService.ItemNotFoundException.class, (e, req) -> EntityResponse.fromObject(new Error(e.getMessage()))
|
||||
.status(HttpStatus.NOT_FOUND)
|
||||
.build())
|
||||
|
|
|
@ -38,7 +38,7 @@ public class ProductService {
|
|||
}
|
||||
|
||||
public Product save(Product product) {
|
||||
if (StringUtils.isEmpty(product.getName()) || product.getPrice() == 0.0) {
|
||||
if (!StringUtils.hasLength(product.getName()) || product.getPrice() == 0.0) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
int newId = products.stream()
|
||||
|
|
|
@ -19,7 +19,7 @@ public class StudentService {
|
|||
new Student(2, "Sebastian","Bach"),
|
||||
new Student(3, "Pablo","Picasso"),
|
||||
}).stream()
|
||||
.collect(Collectors.toConcurrentMap(s -> s.getId(), Function.identity()));
|
||||
.collect(Collectors.toConcurrentMap(Student::getId, Function.identity()));
|
||||
|
||||
// DB id sequence mock
|
||||
private AtomicLong sequence = new AtomicLong(3);
|
||||
|
|
|
@ -65,22 +65,17 @@
|
|||
<layout>JAR</layout>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>9</source>
|
||||
<target>9</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<spring-boot.version>3.2.2</spring-boot.version>
|
||||
<junit-jupiter.version>5.10.2</junit-jupiter.version>
|
||||
<spring.fox.version>3.0.0</spring.fox.version>
|
||||
<start-class>com.baeldung.springboot.swagger.ArticleApplication</start-class>
|
||||
<spring-cloud.version>2021.0.5</spring-cloud.version>
|
||||
<spring-cloud.version>2023.0.0</spring-cloud.version>
|
||||
<commons-configuration.version>1.10</commons-configuration.version>
|
||||
<maven.compiler.release>17</maven.compiler.release>
|
||||
</properties>
|
||||
|
||||
</project>
|
|
@ -5,6 +5,9 @@ import jakarta.servlet.ServletInputStream;
|
|||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletRequestWrapper;
|
||||
import java.io.*;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
|
||||
public class EscapeHtmlRequestWrapper extends HttpServletRequestWrapper {
|
||||
private String body = null;
|
||||
|
@ -64,4 +67,12 @@ public class EscapeHtmlRequestWrapper extends HttpServletRequestWrapper {
|
|||
public BufferedReader getReader() throws IOException {
|
||||
return new BufferedReader(new InputStreamReader(this.getInputStream()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<String> getHeaders(String name) {
|
||||
if(HttpHeaders.CONTENT_LENGTH.equals(name)) {
|
||||
return Collections.enumeration(Collections.singletonList(String.valueOf(body.length())));
|
||||
}
|
||||
return super.getHeaders(name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import org.slf4j.LoggerFactory;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
|
@ -45,6 +46,7 @@ public class EscapeHtmlAspectIntegrationTest {
|
|||
|
||||
mockMvc.perform(MockMvcRequestBuilders.post(URI.create("/save"))
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header(HttpHeaders.CONTENT_LENGTH, 100)
|
||||
.content(objectMapper.writeValueAsString(requestBody)))
|
||||
.andExpect(MockMvcResultMatchers.status()
|
||||
.isCreated())
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.baeldung.modifyrequest;
|
||||
|
||||
import com.baeldung.modifyrequest.config.WebMvcConfiguration;
|
||||
import com.baeldung.modifyrequest.controller.UserController;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -9,6 +10,7 @@ import org.slf4j.LoggerFactory;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
|
@ -21,7 +23,7 @@ import java.util.Map;
|
|||
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@AutoConfigureMockMvc
|
||||
@WebMvcTest(UserController.class)
|
||||
@WebMvcTest(value ={UserController.class, WebMvcConfiguration.class})
|
||||
@ActiveProfiles("filterExample")
|
||||
public class EscapeHtmlFilterIntegrationTest {
|
||||
Logger logger = LoggerFactory.getLogger(EscapeHtmlFilterIntegrationTest.class);
|
||||
|
@ -44,6 +46,7 @@ public class EscapeHtmlFilterIntegrationTest {
|
|||
|
||||
mockMvc.perform(MockMvcRequestBuilders.post(URI.create("/save"))
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header(HttpHeaders.CONTENT_LENGTH, "100")
|
||||
.content(objectMapper.writeValueAsString(requestBody))).andExpect(MockMvcResultMatchers.status()
|
||||
.isCreated()).andExpect(MockMvcResultMatchers.content()
|
||||
.json(objectMapper.writeValueAsString(expectedResponseBody)));
|
||||
|
|
Loading…
Reference in New Issue