GH-570 Remove hard dependency on Gson for GCP

Resolves #570

polish test
This commit is contained in:
Oleg Zhurakousky
2021-04-06 12:20:39 +02:00
parent 731aa3fe0c
commit 8cfb4dc1c0
5 changed files with 74 additions and 11 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2020-2020 the original author or authors.
* 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.
@@ -66,7 +66,6 @@ public class FunctionInvoker extends AbstractSpringFunctionAdapterInitializer<Ht
if (System.getenv().containsKey("spring.cloud.function.definition")) {
this.functionName = System.getenv("spring.cloud.function.definition");
}
System.setProperty("spring.http.converters.preferred-json-mapper", "gson");
Thread.currentThread() // TODO: remove after upgrading to 1.0.0-alpha-2-rc5
.setContextClassLoader(FunctionInvoker.class.getClassLoader());
initialize(null);

View File

@@ -257,24 +257,45 @@ public class FunctionInvokerBackgroundTests {
}
private static class IncomingRequest {
public static class IncomingRequest {
String message;
IncomingRequest(String message) {
public IncomingRequest(String message) {
this.message = message;
}
public IncomingRequest() {
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
private static class OutgoingResponse {
public static class OutgoingResponse {
String message;
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
OutgoingResponse(String message) {
this.message = message;
}
public OutgoingResponse() {
}
}
}

View File

@@ -145,24 +145,46 @@ public class FunctionInvokerHttpTests {
}
private static class IncomingRequest {
public static class IncomingRequest {
String message;
IncomingRequest(String message) {
public IncomingRequest(String message) {
this.message = message;
}
public IncomingRequest() {
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
private static class OutgoingResponse {
public static class OutgoingResponse {
String message;
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
OutgoingResponse(String message) {
this.message = message;
}
public OutgoingResponse() {
}
}
}

View File

@@ -119,17 +119,28 @@ public class FunctionInvokerIntegrationTests {
}
private static class Foo {
public static class Foo {
String value;
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public Foo() {
}
Foo(String value) {
this.value = value;
}
}
private static class Bar {
public static class Bar {
String value;
@@ -137,6 +148,16 @@ public class FunctionInvokerIntegrationTests {
this.value = value;
}
Bar() {
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
}

View File

@@ -31,7 +31,7 @@ public class FunctionSampleGcpIntegrationTest {
@Test
public void testSample() throws IOException, InterruptedException {
try (LocalServerTestSupport.ServerProcess process = LocalServerTestSupport.startServer(CloudFunctionMain.class)) {
String result = rest.postForObject("http://localhost:8080/", "Hello", String.class);
String result = rest.postForObject("http://localhost:8080/", "\"Hello\"", String.class);
assertThat(result).isEqualTo("\"HELLO\"");
}
}