Add AutoConfigureGraphQl test annotation
This commit adds the `@AutoConfigureGraphQl` test annotation. It can be used to import the relevant auto-configurations when testing a GraphQL application. Currently, it will get the main `GraphQlAutoConfiguration`, but also what's required for configuring codecs and validation support. See gh-29140
This commit is contained in:
parent
6dbcd0e95e
commit
9a92a9c91d
|
@ -55,6 +55,7 @@ dependencies {
|
||||||
optional("org.springframework.data:spring-data-neo4j")
|
optional("org.springframework.data:spring-data-neo4j")
|
||||||
optional("org.springframework.data:spring-data-r2dbc")
|
optional("org.springframework.data:spring-data-r2dbc")
|
||||||
optional("org.springframework.data:spring-data-redis")
|
optional("org.springframework.data:spring-data-redis")
|
||||||
|
optional("org.springframework.graphql:spring-graphql-test")
|
||||||
optional("org.springframework.restdocs:spring-restdocs-mockmvc") {
|
optional("org.springframework.restdocs:spring-restdocs-mockmvc") {
|
||||||
exclude group: "javax.servlet", module: "javax.servlet-api"
|
exclude group: "javax.servlet", module: "javax.servlet-api"
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2020-2021 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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springframework.boot.test.autoconfigure.graphql;
|
||||||
|
|
||||||
|
import java.lang.annotation.Documented;
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Inherited;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link ImportAutoConfiguration Auto-configuration imports} for typical Spring GraphQL
|
||||||
|
* tests. Most tests should consider using {@link GraphQlTest @GraphQlTest} rather than
|
||||||
|
* using this annotation directly.
|
||||||
|
*
|
||||||
|
* @author Brian Clozel
|
||||||
|
* @since 2.7.0
|
||||||
|
* @see GraphQlTest
|
||||||
|
* @see org.springframework.boot.autoconfigure.http.codec.CodecsAutoConfiguration
|
||||||
|
* @see org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration
|
||||||
|
* @see org.springframework.boot.autoconfigure.graphql.GraphQlAutoConfiguration
|
||||||
|
*/
|
||||||
|
@Target(ElementType.TYPE)
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Documented
|
||||||
|
@Inherited
|
||||||
|
@ImportAutoConfiguration
|
||||||
|
public @interface AutoConfigureGraphQl {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2020-2021 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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto-configuration for GraphQL testing.
|
||||||
|
*/
|
||||||
|
package org.springframework.boot.test.autoconfigure.graphql;
|
|
@ -188,6 +188,12 @@ org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfigurati
|
||||||
org.springframework.boot.autoconfigure.web.servlet.HttpEncodingAutoConfiguration,\
|
org.springframework.boot.autoconfigure.web.servlet.HttpEncodingAutoConfiguration,\
|
||||||
org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration
|
org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration
|
||||||
|
|
||||||
|
# AutoConfigureGraphQl auto-configuration imports
|
||||||
|
org.springframework.boot.test.autoconfigure.graphql.AutoConfigureGraphQl=\
|
||||||
|
org.springframework.boot.autoconfigure.http.codec.CodecsAutoConfiguration,\
|
||||||
|
org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration,\
|
||||||
|
org.springframework.boot.autoconfigure.graphql.GraphQlAutoConfiguration
|
||||||
|
|
||||||
# AutoConfigureWebServiceClient
|
# AutoConfigureWebServiceClient
|
||||||
org.springframework.boot.test.autoconfigure.webservices.client.AutoConfigureWebServiceClient=\
|
org.springframework.boot.test.autoconfigure.webservices.client.AutoConfigureWebServiceClient=\
|
||||||
org.springframework.boot.test.autoconfigure.webservices.client.WebServiceClientTemplateAutoConfiguration,\
|
org.springframework.boot.test.autoconfigure.webservices.client.WebServiceClientTemplateAutoConfiguration,\
|
||||||
|
|
Loading…
Reference in New Issue