Skip to content

Commit 30a6b50

Browse files
committed
Align naming change for Jackson components
This commit polishes the renaming of JsonComponent to JacksonComponent and the use of JacksonModule instead of Module in Jackson 2. This also adds integration tests that use a JacksonComponent with WebMvcTest and WebFluxTest. Closes gh-47864
1 parent 9c8716e commit 30a6b50

File tree

22 files changed

+294
-28
lines changed

22 files changed

+294
-28
lines changed

core/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@
4444
* Using this annotation only enables auto-configuration that is relevant to JSON tests.
4545
* Similarly, component scanning is limited to beans annotated with:
4646
* <ul>
47-
* <li>{@code @JsonComponent}</li>
47+
* <li>{@code @JacksonComponent}</li>
4848
* </ul>
4949
* <p>
5050
* as well as beans that implement:
5151
* <ul>
52-
* <li>{@code Module}, if Jackson is available</li>
52+
* <li>{@code JacksonModule}, if Jackson is available</li>
5353
* </ul>
5454
* <p>
5555
* By default, tests annotated with {@code JsonTest} will also initialize
@@ -88,8 +88,8 @@
8888

8989
/**
9090
* Determines if default filtering should be used with
91-
* {@link SpringBootApplication @SpringBootApplication}. By default only
92-
* {@code @JsonComponent} and {@code Module} beans are included.
91+
* {@link SpringBootApplication @SpringBootApplication}. By default, only
92+
* {@code @JacksonComponent} and {@code JacksonModule} beans are included.
9393
* @see #includeFilters()
9494
* @see #excludeFilters()
9595
* @return if default filters should be used

module/spring-boot-graphql-test/src/main/java/org/springframework/boot/graphql/test/autoconfigure/GraphQlTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
* <ul>
4848
* <li>{@code @Controller}
4949
* <li>{@code RuntimeWiringConfigurer}
50-
* <li>{@code @JsonComponent}
50+
* <li>{@code @JacksonComponent}
5151
* <li>{@code Converter}
5252
* <li>{@code GenericConverter}
5353
* <li>{@code DataFetcherExceptionResolver}
@@ -121,7 +121,7 @@
121121
* Determines if default filtering should be used with
122122
* {@link SpringBootApplication @SpringBootApplication}. By default, only
123123
* {@code @Controller} (when no explicit {@link #controllers() controllers} are
124-
* defined), {@code RuntimeWiringConfigurer}, {@code @JsonComponent},
124+
* defined), {@code RuntimeWiringConfigurer}, {@code @JacksonComponent},
125125
* {@code Converter}, {@code GenericConverter}, {@code DataFetcherExceptionResolver},
126126
* {@code Instrumentation} and {@code GraphQlSourceBuilderCustomizer} beans are
127127
* included.

module/spring-boot-jackson/src/test/java/org/springframework/boot/jackson/autoconfigure/JacksonAutoConfigurationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ void cborMapperBuilderIsNotSharedAcrossMultipleInjectionPoints() {
609609
}
610610

611611
@Test
612-
void jsonComponentThatInjectsJsonMapperCausesBeanCurrentlyInCreationException() {
612+
void jacksonComponentThatInjectsJsonMapperCausesBeanCurrentlyInCreationException() {
613613
this.contextRunner.withUserConfiguration(CircularDependencySerializerConfiguration.class).run((context) -> {
614614
assertThat(context).hasFailed();
615615
assertThat(context).getFailure().hasRootCauseInstanceOf(BeanCurrentlyInCreationException.class);

module/spring-boot-jackson/src/test/java/org/springframework/boot/jackson/autoconfigure/jsontest/app/ExampleCustomObject.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import java.util.UUID;
2121

2222
/**
23-
* Example object to read/write as JSON through {@link ExampleJsonComponent}.
23+
* Example object to read/write as JSON through {@link ExampleJacksonComponent}.
2424
*
2525
* @author Phillip Webb
2626
* @param value the value
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@
3131
import org.springframework.boot.test.autoconfigure.json.JsonTest;
3232

3333
/**
34-
* Example {@link JacksonComponent @JsonComponent} for use with {@link JsonTest @JsonTest}
35-
* tests.
34+
* Example {@link JacksonComponent @JacksonComponent} for use with
35+
* {@link JsonTest @JsonTest} tests.
3636
*
3737
* @author Phillip Webb
3838
*/
3939
@JacksonComponent
40-
public class ExampleJsonComponent {
40+
public class ExampleJacksonComponent {
4141

4242
static class Serializer extends ObjectValueSerializer<ExampleCustomObject> {
4343

module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/autoconfigure/RestClientTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@
4545
* Using this annotation only enables auto-configuration that is relevant to rest client
4646
* tests. Similarly, component scanning is limited to beans annotated with:
4747
* <ul>
48-
* <li>{@code @JsonComponent}</li>
48+
* <li>{@code @JacksonComponent}</li>
4949
* </ul>
5050
* <p>
5151
* as well as beans that implement:
5252
* <ul>
53-
* <li>{@code Module}, if Jackson is available</li>
53+
* <li>{@code JacksonModule}, if Jackson is available</li>
5454
* </ul>
5555
* <p>
5656
* By default, tests annotated with {@code RestClientTest} will also auto-configure a
@@ -107,8 +107,8 @@
107107

108108
/**
109109
* Determines if default filtering should be used with
110-
* {@link SpringBootApplication @SpringBootApplication}. By default only
111-
* {@code @JsonComponent} and {@code Module} beans are included.
110+
* {@link SpringBootApplication @SpringBootApplication}. By default, only
111+
* {@code @JacksonComponent} and {@code JacksonModule} beans are included.
112112
* @see #includeFilters()
113113
* @see #excludeFilters()
114114
* @return if default filters should be used

module/spring-boot-webclient-test/src/main/java/org/springframework/boot/webclient/test/autoconfigure/WebClientTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
* Using this annotation only enables auto-configuration that is relevant to rest client
4444
* tests. Similarly, component scanning is limited to beans annotated with:
4545
* <ul>
46-
* <li>{@code @JsonComponent}</li>
46+
* <li>{@code @JacksonComponent}</li>
4747
* </ul>
4848
* <p>
4949
* as well as beans that implement:
@@ -97,8 +97,8 @@
9797

9898
/**
9999
* Determines if default filtering should be used with
100-
* {@link SpringBootApplication @SpringBootApplication}. By default only
101-
* {@code @JsonComponent} and {@code Module} beans are included.
100+
* {@link SpringBootApplication @SpringBootApplication}. By default, only
101+
* {@code @JacksonComponent} and {@code JacksonModule} beans are included.
102102
* @see #includeFilters()
103103
* @see #excludeFilters()
104104
* @return if default filters should be used

module/spring-boot-webflux-test/src/main/java/org/springframework/boot/webflux/test/autoconfigure/WebFluxTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@
4949
* <ul>
5050
* <li>{@code @Controller}</li>
5151
* <li>{@code @ControllerAdvice}</li>
52-
* <li>{@code @JsonComponent}</li>
52+
* <li>{@code @JacksonComponent}</li>
5353
* </ul>
5454
* <p>
5555
* as well as beans that implement:
5656
* <ul>
5757
* <li>{@code Converter}</li>
5858
* <li>{@code GenericConverter}</li>
5959
* <li>{@code IDialect}, if Thymeleaf is available</li>
60-
* <li>{@code Module}, if Jackson is available</li>
60+
* <li>{@code JacksonModule}, if Jackson is available</li>
6161
* <li>{@code WebExceptionHandler}</li>
6262
* <li>{@code WebFluxConfigurer}</li>
6363
* <li>{@code WebFilter}</li>

module/spring-boot-webflux-test/src/main/java/org/springframework/boot/webflux/test/autoconfigure/WebFluxTypeExcludeFilter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class WebFluxTypeExcludeFilter extends StandardAnnotationCustomizableTypeExclude
4343
private static final Class<?>[] NO_CONTROLLERS = {};
4444

4545
private static final String[] OPTIONAL_INCLUDES = { "tools.jackson.databind.JacksonModule",
46-
"org.springframework.boot.jackson.JsonComponent" };
46+
"org.springframework.boot.jackson.JacksonComponent" };
4747

4848
private static final Set<Class<?>> KNOWN_INCLUDES;
4949

module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/ExampleController2.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import org.springframework.stereotype.Controller;
2222
import org.springframework.web.bind.annotation.GetMapping;
2323
import org.springframework.web.bind.annotation.PathVariable;
24+
import org.springframework.web.bind.annotation.PostMapping;
25+
import org.springframework.web.bind.annotation.ResponseBody;
2426
import org.springframework.web.bind.annotation.RestController;
2527

2628
/**
@@ -42,4 +44,10 @@ public Mono<String> two(@PathVariable ExampleId id) {
4244
return Mono.just(id.getId() + "two");
4345
}
4446

47+
@PostMapping("/two/{id}")
48+
@ResponseBody
49+
public Mono<ExampleResult> twoUpdate(@PathVariable String id) {
50+
return Mono.just(new ExampleResult(id));
51+
}
52+
4553
}

0 commit comments

Comments
 (0)