Skip to content

Commit e562430

Browse files
authored
Fix gRpc test
Signed-off-by: Oleg Zhurakousky <oleg.zhurakousky@broadcom.com>
1 parent 9958f09 commit e562430

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

spring-cloud-gateway-integration-tests/grpc/src/test/java/org/springframework/cloud/gateway/tests/grpc/JsonToGrpcApplicationTests.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@
4040

4141
import org.springframework.boot.test.context.SpringBootTest;
4242
import org.springframework.boot.test.web.server.LocalServerPort;
43+
import org.springframework.http.HttpEntity;
44+
import org.springframework.http.HttpHeaders;
45+
import org.springframework.http.MediaType;
4346
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
4447
import org.springframework.web.client.RestTemplate;
4548

@@ -72,9 +75,11 @@ public void shouldConvertFromJSONToGRPC() {
7275
configurer.addRoute(grpcServerPort, "/json/hello",
7376
"JsonToGrpc=file:src/main/proto/hello.pb,file:src/main/proto/hello.proto,HelloService,hello");
7477

78+
HttpHeaders headers = new HttpHeaders();
79+
headers.setContentType(MediaType.APPLICATION_JSON);
80+
HttpEntity<String> request = new HttpEntity<>("{\"firstName\":\"Duff\", \"lastName\":\"McKagan\"}", headers);
7581
String response = restTemplate
76-
.postForEntity("https://localhost:" + this.gatewayPort + "/json/hello",
77-
"{\"firstName\":\"Duff\", \"lastName\":\"McKagan\"}", String.class)
82+
.postForEntity("https://localhost:" + this.gatewayPort + "/json/hello", request, String.class)
7883
.getBody();
7984

8085
Assertions.assertThat(response).isNotNull();

0 commit comments

Comments
 (0)