GH-570 Remove hard dependency on Gson for GCP

Resolves #570
This commit is contained in:
Oleg Zhurakousky
2021-04-06 12:20:39 +02:00
parent 004813dfd2
commit 8fb29fac14
4 changed files with 73 additions and 10 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"); * 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);

View File

@@ -245,24 +245,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() {
}
} }
} }

View File

@@ -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() {
}
} }
} }

View File

@@ -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;
}
} }
} }