|
1 | 1 | /*
|
2 |
| - * Copyright 2012-2023 the original author or authors. |
| 2 | + * Copyright 2012-2024 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
43 | 43 | import org.springframework.http.HttpHeaders;
|
44 | 44 | import org.springframework.http.MediaType;
|
45 | 45 | import org.springframework.test.web.servlet.MockMvc;
|
46 |
| -import org.springframework.test.web.servlet.MvcResult; |
47 | 46 | import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
48 | 47 | import org.springframework.web.servlet.HandlerMapping;
|
49 | 48 | import org.springframework.web.servlet.function.RouterFunction;
|
|
52 | 51 | import org.springframework.web.socket.server.support.WebSocketHandlerMapping;
|
53 | 52 |
|
54 | 53 | import static org.assertj.core.api.Assertions.assertThat;
|
55 |
| -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.asyncDispatch; |
56 | 54 | import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
57 | 55 | import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
58 | 56 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
@@ -88,8 +86,7 @@ void shouldContributeDefaultBeans() {
|
88 | 86 | void simpleQueryShouldWork() {
|
89 | 87 | testWith((mockMvc) -> {
|
90 | 88 | String query = "{ bookById(id: \\\"book-1\\\"){ id name pageCount author } }";
|
91 |
| - MvcResult result = mockMvc.perform(post("/graphql").content("{\"query\": \"" + query + "\"}")).andReturn(); |
92 |
| - mockMvc.perform(asyncDispatch(result)) |
| 89 | + mockMvc.perform(post("/graphql").content("{\"query\": \"" + query + "\"}")) |
93 | 90 | .andExpect(status().isOk())
|
94 | 91 | .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_GRAPHQL_RESPONSE))
|
95 | 92 | .andExpect(jsonPath("data.bookById.name").value("GraphQL for beginners"));
|
@@ -120,8 +117,7 @@ void shouldRejectQueryWithInvalidJson() {
|
120 | 117 | void shouldConfigureWebInterceptors() {
|
121 | 118 | testWith((mockMvc) -> {
|
122 | 119 | String query = "{ bookById(id: \\\"book-1\\\"){ id name pageCount author } }";
|
123 |
| - MvcResult result = mockMvc.perform(post("/graphql").content("{\"query\": \"" + query + "\"}")).andReturn(); |
124 |
| - mockMvc.perform(asyncDispatch(result)) |
| 120 | + mockMvc.perform(post("/graphql").content("{\"query\": \"" + query + "\"}")) |
125 | 121 | .andExpect(status().isOk())
|
126 | 122 | .andExpect(header().string("X-Custom-Header", "42"));
|
127 | 123 | });
|
@@ -152,12 +148,10 @@ void shouldSupportCors() {
|
152 | 148 | testWith((mockMvc) -> {
|
153 | 149 | String query = "{" + " bookById(id: \\\"book-1\\\"){ " + " id" + " name" + " pageCount"
|
154 | 150 | + " author" + " }" + "}";
|
155 |
| - MvcResult result = mockMvc |
| 151 | + mockMvc |
156 | 152 | .perform(post("/graphql").header(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "POST")
|
157 | 153 | .header(HttpHeaders.ORIGIN, "https://example.com")
|
158 | 154 | .content("{\"query\": \"" + query + "\"}"))
|
159 |
| - .andReturn(); |
160 |
| - mockMvc.perform(asyncDispatch(result)) |
161 | 155 | .andExpect(status().isOk())
|
162 | 156 | .andExpect(header().stringValues(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN, "https://example.com"))
|
163 | 157 | .andExpect(header().stringValues(HttpHeaders.ACCESS_CONTROL_ALLOW_CREDENTIALS, "true"));
|
|
0 commit comments