Introduce Jackson 3 support for views
This commit introduces Jackson 3 based variants of the following Jackson 2 classes (and related dependent classes). MappingJackson2JsonView -> JacksonJsonView MappingJackson2XmlView-> JacksonXmlView See gh-33798
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
* Copyright 2002-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -37,7 +37,7 @@ import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.servlet.View;
|
||||
import org.springframework.web.servlet.view.ContentNegotiatingViewResolver;
|
||||
import org.springframework.web.servlet.view.InternalResourceViewResolver;
|
||||
import org.springframework.web.servlet.view.json.MappingJackson2JsonView;
|
||||
import org.springframework.web.servlet.view.json.JacksonJsonView;
|
||||
import org.springframework.web.servlet.view.xml.MarshallingView;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
@@ -51,6 +51,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
* {@link org.springframework.test.web.servlet.samples.standalone.RequestParameterTests}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
class ViewResolutionTests {
|
||||
|
||||
@@ -78,7 +79,7 @@ class ViewResolutionTests {
|
||||
void jsonOnly() {
|
||||
WebTestClient testClient =
|
||||
MockMvcWebTestClient.bindToController(new PersonController())
|
||||
.singleView(new MappingJackson2JsonView())
|
||||
.singleView(new JacksonJsonView())
|
||||
.build();
|
||||
|
||||
testClient.get().uri("/person/Corea")
|
||||
@@ -111,7 +112,7 @@ class ViewResolutionTests {
|
||||
marshaller.setClassesToBeBound(Person.class);
|
||||
|
||||
List<View> viewList = new ArrayList<>();
|
||||
viewList.add(new MappingJackson2JsonView());
|
||||
viewList.add(new JacksonJsonView());
|
||||
viewList.add(new MarshallingView(marshaller));
|
||||
|
||||
ContentNegotiationManager manager = new ContentNegotiationManager(
|
||||
|
||||
@@ -35,6 +35,7 @@ import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.servlet.View;
|
||||
import org.springframework.web.servlet.view.ContentNegotiatingViewResolver;
|
||||
import org.springframework.web.servlet.view.InternalResourceViewResolver;
|
||||
import org.springframework.web.servlet.view.json.JacksonJsonView;
|
||||
import org.springframework.web.servlet.view.json.MappingJackson2JsonView;
|
||||
import org.springframework.web.servlet.view.xml.MarshallingView;
|
||||
|
||||
@@ -70,7 +71,7 @@ class ViewResolutionTests {
|
||||
|
||||
@Test
|
||||
void jsonOnly() throws Exception {
|
||||
standaloneSetup(new PersonController()).setSingleView(new MappingJackson2JsonView()).build()
|
||||
standaloneSetup(new PersonController()).setSingleView(new JacksonJsonView()).build()
|
||||
.perform(get("/person/Corea"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
|
||||
|
||||
Reference in New Issue
Block a user