Skip to content

Commit d8ea797

Browse files
committed
Merge branch '3.5.x' into 4.0.x
Closes gh-49672
2 parents dc78572 + 8c605cc commit d8ea797

4 files changed

Lines changed: 17 additions & 3 deletions

File tree

documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/testing/spring-boot-applications.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ There are javadoc:org.springframework.graphql.test.tester.GraphQlTester[] varian
456456

457457
Spring Boot helps you to test your {url-spring-graphql-docs}/controllers.html[Spring GraphQL Controllers] with the javadoc:org.springframework.boot.graphql.test.autoconfigure.GraphQlTest[format=annotation] annotation from the `spring-boot-graphql-test` module.
458458
javadoc:org.springframework.boot.graphql.test.autoconfigure.GraphQlTest[format=annotation] auto-configures the Spring GraphQL infrastructure, without any transport nor server being involved.
459-
This limits scanned beans to javadoc:org.springframework.stereotype.Controller[format=annotation], javadoc:org.springframework.graphql.execution.RuntimeWiringConfigurer[], javadoc:org.springframework.boot.jackson.JacksonComponent[], javadoc:org.springframework.boot.jackson2.JsonComponent[format=annotation] (deprecated), javadoc:org.springframework.core.convert.converter.Converter[], javadoc:org.springframework.core.convert.converter.GenericConverter[], javadoc:org.springframework.graphql.execution.DataFetcherExceptionResolver[], javadoc:graphql.execution.instrumentation.Instrumentation[] and javadoc:org.springframework.boot.graphql.autoconfigure.GraphQlSourceBuilderCustomizer[].
459+
This limits scanned beans to javadoc:org.springframework.stereotype.Controller[format=annotation], javadoc:org.springframework.web.bind.annotation.ControllerAdvice[format=annotation], javadoc:org.springframework.graphql.execution.RuntimeWiringConfigurer[], javadoc:org.springframework.boot.jackson.JacksonComponent[], javadoc:org.springframework.boot.jackson2.JsonComponent[format=annotation] (deprecated), javadoc:org.springframework.core.convert.converter.Converter[], javadoc:org.springframework.core.convert.converter.GenericConverter[], javadoc:org.springframework.graphql.execution.DataFetcherExceptionResolver[], javadoc:graphql.execution.instrumentation.Instrumentation[] and javadoc:org.springframework.boot.graphql.autoconfigure.GraphQlSourceBuilderCustomizer[].
460460
Regular javadoc:org.springframework.stereotype.Component[format=annotation] and javadoc:org.springframework.boot.context.properties.ConfigurationProperties[format=annotation] beans are not scanned when the javadoc:org.springframework.boot.graphql.test.autoconfigure.GraphQlTest[format=annotation] annotation is used.
461461
javadoc:org.springframework.boot.context.properties.EnableConfigurationProperties[format=annotation] can be used to include javadoc:org.springframework.boot.context.properties.ConfigurationProperties[format=annotation] beans.
462462

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
* relevant to GraphQL tests, including the following:
4747
* <ul>
4848
* <li>{@code @Controller}
49+
* <li>{@code @ControllerAdvice}
4950
* <li>{@code RuntimeWiringConfigurer}
5051
* <li>{@code @JacksonComponent}
5152
* <li>{@code @JsonComponent} (deprecated)
@@ -122,8 +123,8 @@
122123
* Determines if default filtering should be used with
123124
* {@link SpringBootApplication @SpringBootApplication}. By default, only
124125
* {@code @Controller} (when no explicit {@link #controllers() controllers} are
125-
* defined), {@code RuntimeWiringConfigurer}, {@code @JacksonComponent},
126-
* {@code @JsonComponent} (deprecated), {@code Converter}, {@code GenericConverter},
126+
* defined), {@code ControllerAdvice}, {@code RuntimeWiringConfigurer},
127+
* {@code @JacksonComponent}, {@code @JsonComponent} (deprecated), {@code Converter}, {@code GenericConverter},
127128
* {@code DataFetcherExceptionResolver}, {@code Instrumentation} and
128129
* {@code GraphQlSourceBuilderCustomizer} beans are included.
129130
* @see #includeFilters()

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import org.springframework.stereotype.Controller;
3535
import org.springframework.util.ClassUtils;
3636
import org.springframework.util.ObjectUtils;
37+
import org.springframework.web.bind.annotation.ControllerAdvice;
3738

3839
/**
3940
* {@link TypeExcludeFilter} for {@link GraphQlTest @GraphQlTest}.
@@ -51,6 +52,7 @@ class GraphQlTypeExcludeFilter extends StandardAnnotationCustomizableTypeExclude
5152

5253
static {
5354
Set<Class<?>> includes = new LinkedHashSet<>();
55+
includes.add(ControllerAdvice.class);
5456
includes.add(JacksonComponent.class);
5557
includes.add(RuntimeWiringConfigurer.class);
5658
includes.add(Converter.class);

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import org.springframework.stereotype.Controller;
4343
import org.springframework.stereotype.Repository;
4444
import org.springframework.stereotype.Service;
45+
import org.springframework.web.bind.annotation.ControllerAdvice;
4546

4647
import static org.assertj.core.api.Assertions.assertThat;
4748

@@ -59,6 +60,7 @@ void matchWhenHasNoControllers() throws Exception {
5960
GraphQlTypeExcludeFilter filter = new GraphQlTypeExcludeFilter(WithNoControllers.class);
6061
assertThat(excludes(filter, Controller1.class)).isFalse();
6162
assertThat(excludes(filter, Controller2.class)).isFalse();
63+
assertThat(excludes(filter, ExampleControllerAdvice.class)).isFalse();
6264
assertThat(excludes(filter, ExampleRuntimeWiringConfigurer.class)).isFalse();
6365
assertThat(excludes(filter, ExampleService.class)).isTrue();
6466
assertThat(excludes(filter, ExampleRepository.class)).isTrue();
@@ -74,6 +76,7 @@ void matchWhenHasController() throws Exception {
7476
GraphQlTypeExcludeFilter filter = new GraphQlTypeExcludeFilter(WithController.class);
7577
assertThat(excludes(filter, Controller1.class)).isFalse();
7678
assertThat(excludes(filter, Controller2.class)).isTrue();
79+
assertThat(excludes(filter, ExampleControllerAdvice.class)).isFalse();
7780
assertThat(excludes(filter, ExampleRuntimeWiringConfigurer.class)).isFalse();
7881
assertThat(excludes(filter, ExampleService.class)).isTrue();
7982
assertThat(excludes(filter, ExampleRepository.class)).isTrue();
@@ -89,6 +92,7 @@ void matchNotUsingDefaultFilters() throws Exception {
8992
GraphQlTypeExcludeFilter filter = new GraphQlTypeExcludeFilter(NotUsingDefaultFilters.class);
9093
assertThat(excludes(filter, Controller1.class)).isTrue();
9194
assertThat(excludes(filter, Controller2.class)).isTrue();
95+
assertThat(excludes(filter, ExampleControllerAdvice.class)).isTrue();
9296
assertThat(excludes(filter, ExampleRuntimeWiringConfigurer.class)).isTrue();
9397
assertThat(excludes(filter, ExampleService.class)).isTrue();
9498
assertThat(excludes(filter, ExampleRepository.class)).isTrue();
@@ -104,6 +108,7 @@ void matchWithIncludeFilter() throws Exception {
104108
GraphQlTypeExcludeFilter filter = new GraphQlTypeExcludeFilter(WithIncludeFilter.class);
105109
assertThat(excludes(filter, Controller1.class)).isFalse();
106110
assertThat(excludes(filter, Controller2.class)).isFalse();
111+
assertThat(excludes(filter, ExampleControllerAdvice.class)).isFalse();
107112
assertThat(excludes(filter, ExampleRuntimeWiringConfigurer.class)).isFalse();
108113
assertThat(excludes(filter, ExampleService.class)).isTrue();
109114
assertThat(excludes(filter, ExampleRepository.class)).isFalse();
@@ -119,6 +124,7 @@ void matchWithExcludeFilter() throws Exception {
119124
GraphQlTypeExcludeFilter filter = new GraphQlTypeExcludeFilter(WithExcludeFilter.class);
120125
assertThat(excludes(filter, Controller1.class)).isTrue();
121126
assertThat(excludes(filter, Controller2.class)).isFalse();
127+
assertThat(excludes(filter, ExampleControllerAdvice.class)).isFalse();
122128
assertThat(excludes(filter, ExampleRuntimeWiringConfigurer.class)).isFalse();
123129
assertThat(excludes(filter, ExampleService.class)).isTrue();
124130
assertThat(excludes(filter, ExampleRepository.class)).isTrue();
@@ -169,6 +175,11 @@ static class Controller2 {
169175

170176
}
171177

178+
@ControllerAdvice
179+
static class ExampleControllerAdvice {
180+
181+
}
182+
172183
@Service
173184
static class ExampleService {
174185

0 commit comments

Comments
 (0)