GH-570 Remove hard dependency on Gson for GCP
Resolves #570 polish test
This commit is contained in:
@@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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")) {
|
if (System.getenv().containsKey("spring.cloud.function.definition")) {
|
||||||
this.functionName = System.getenv("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
|
Thread.currentThread() // TODO: remove after upgrading to 1.0.0-alpha-2-rc5
|
||||||
.setContextClassLoader(FunctionInvoker.class.getClassLoader());
|
.setContextClassLoader(FunctionInvoker.class.getClassLoader());
|
||||||
initialize(null);
|
initialize(null);
|
||||||
|
|||||||
@@ -257,24 +257,45 @@ public class FunctionInvokerBackgroundTests {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class IncomingRequest {
|
public static class IncomingRequest {
|
||||||
|
|
||||||
String message;
|
String message;
|
||||||
|
|
||||||
IncomingRequest(String message) {
|
public IncomingRequest(String message) {
|
||||||
this.message = 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;
|
String message;
|
||||||
|
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
OutgoingResponse(String message) {
|
OutgoingResponse(String message) {
|
||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public OutgoingResponse() {
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -145,24 +145,46 @@ public class FunctionInvokerHttpTests {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class IncomingRequest {
|
public static class IncomingRequest {
|
||||||
|
|
||||||
String message;
|
String message;
|
||||||
|
|
||||||
IncomingRequest(String message) {
|
public IncomingRequest(String message) {
|
||||||
this.message = 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;
|
String message;
|
||||||
|
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
OutgoingResponse(String message) {
|
OutgoingResponse(String message) {
|
||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public OutgoingResponse() {
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,17 +119,28 @@ public class FunctionInvokerIntegrationTests {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Foo {
|
public static class Foo {
|
||||||
|
|
||||||
String value;
|
String value;
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Foo() {
|
||||||
|
}
|
||||||
|
|
||||||
Foo(String value) {
|
Foo(String value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Bar {
|
public static class Bar {
|
||||||
|
|
||||||
String value;
|
String value;
|
||||||
|
|
||||||
@@ -137,6 +148,16 @@ public class FunctionInvokerIntegrationTests {
|
|||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Bar() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public class FunctionSampleGcpIntegrationTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testSample() throws IOException, InterruptedException {
|
public void testSample() throws IOException, InterruptedException {
|
||||||
try (LocalServerTestSupport.ServerProcess process = LocalServerTestSupport.startServer(CloudFunctionMain.class)) {
|
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\"");
|
assertThat(result).isEqualTo("\"HELLO\"");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user