Upgrade to Spring GraphQL 1.0.0-SNAPSHOT
This commit switches to 1.0.0-SNAPSHOT for Spring GraphQL, before its upcoming 1.0.0-M6 version. This commit adapts to the changes introduced in spring-projects/spring-graphql#317 : now that `GraphQlClient` has been introduced, `GraphQlTester` has been aligned with the new infrastructure. The `@GraphQlTest` and `@SpringBootTest` testing support is now using different variants for each. All samples have been updated to use the proper GraphQL terminology, see and spring-projects/spring-graphql#310 . See gh-29637pull/30406/head
parent
dfd4097436
commit
81754c8bc4
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright 2012-2022 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.docs.features.testing.springbootapplications.springgraphqltests;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.graphql.tester.AutoConfigureHttpGraphQlTester;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.graphql.test.tester.HttpGraphQlTester;
|
||||
|
||||
@AutoConfigureHttpGraphQlTester
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.MOCK)
|
||||
class GraphQlIntegrationTests {
|
||||
|
||||
@Test
|
||||
void shouldGreetWithSpecificName(@Autowired HttpGraphQlTester graphQlTester) {
|
||||
HttpGraphQlTester authenticatedTester = graphQlTester.mutate()
|
||||
.webTestClient(
|
||||
(client) -> client.defaultHeaders((headers) -> headers.setBasicAuth("admin", "ilovespring")))
|
||||
.build();
|
||||
authenticatedTester.document("{ greeting(name: \"Alice\") } ").execute().path("greeting").entity(String.class)
|
||||
.isEqualTo("Hello, Alice!");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 2012-2022 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.docs.features.testing.springbootapplications.springgraphqltests
|
||||
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.boot.test.autoconfigure.graphql.tester.AutoConfigureHttpGraphQlTester
|
||||
import org.springframework.boot.test.context.SpringBootTest
|
||||
import org.springframework.graphql.test.tester.HttpGraphQlTester
|
||||
import org.springframework.http.HttpHeaders
|
||||
import org.springframework.test.web.reactive.server.WebTestClient
|
||||
|
||||
@AutoConfigureHttpGraphQlTester
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.MOCK)
|
||||
class GraphQlIntegrationTests {
|
||||
|
||||
@Test
|
||||
fun shouldGreetWithSpecificName(@Autowired graphQlTester: HttpGraphQlTester) {
|
||||
val authenticatedTester = graphQlTester.mutate()
|
||||
.webTestClient { client: WebTestClient.Builder ->
|
||||
client.defaultHeaders { headers: HttpHeaders ->
|
||||
headers.setBasicAuth("admin", "ilovespring")
|
||||
}
|
||||
}.build()
|
||||
authenticatedTester.document("{ greeting(name: \"Alice\") } ").execute()
|
||||
.path("greeting").entity(String::class.java).isEqualTo("Hello, Alice!")
|
||||
}
|
||||
}
|
10
spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/graphql/tester/AutoConfigureWebGraphQlTester.java → spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/graphql/tester/AutoConfigureHttpGraphQlTester.java
10
spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/graphql/tester/AutoConfigureWebGraphQlTester.java → spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/graphql/tester/AutoConfigureHttpGraphQlTester.java
9
spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/graphql/tester/WebGraphQlTesterAutoConfiguration.java → spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/graphql/tester/HttpGraphQlTesterAutoConfiguration.java
9
spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/graphql/tester/WebGraphQlTesterAutoConfiguration.java → spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/graphql/tester/HttpGraphQlTesterAutoConfiguration.java
@ -0,0 +1,2 @@
|
||||
# AutoConfigureHttpGraphQlTester auto-configuration imports
|
||||
org.springframework.boot.test.autoconfigure.graphql.tester.HttpGraphQlTesterAutoConfiguration
|
@ -1,2 +0,0 @@
|
||||
# AutoConfigureWebGraphQlTester auto-configuration imports
|
||||
org.springframework.boot.test.autoconfigure.graphql.tester.WebGraphQlTesterAutoConfiguration
|
10
spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/graphql/tester/WebGraphQlTesterContextCustomizerIntegrationTests.java → spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/graphql/tester/HttpGraphQlTesterContextCustomizerIntegrationTests.java
10
spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/graphql/tester/WebGraphQlTesterContextCustomizerIntegrationTests.java → spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/graphql/tester/HttpGraphQlTesterContextCustomizerIntegrationTests.java
10
spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/graphql/tester/WebGraphQlTesterContextCustomizerWithCustomBasePathTests.java → spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/graphql/tester/HttpGraphQlTesterContextCustomizerWithCustomBasePathTests.java
10
spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/graphql/tester/WebGraphQlTesterContextCustomizerWithCustomBasePathTests.java → spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/graphql/tester/HttpGraphQlTesterContextCustomizerWithCustomBasePathTests.java
10
spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/graphql/tester/WebGraphQlTesterContextCustomizerWithCustomContextPathTests.java → spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/graphql/tester/HttpGraphQlTesterContextCustomizerWithCustomContextPathTests.java
10
spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/graphql/tester/WebGraphQlTesterContextCustomizerWithCustomContextPathTests.java → spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/graphql/tester/HttpGraphQlTesterContextCustomizerWithCustomContextPathTests.java
Loading…
Reference in New Issue