From c064f5e9ea7e385ae8c730bb9e9fc5fdd45e25d6 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Wed, 13 Feb 2019 10:53:12 -0500 Subject: Add gson handler and tests Added JacksonHandler which provides jackson behavior in gson. Also added classes to facilitate testing of gson serializations. Added compareGson(xxx, Class). Removed trailing spaces from some files. Updated license dates. Replaced incorrect constant with ${xxx} in json test file. Fixed typo in test method name. Change-Id: If05b654d76a4ffc88646f03334be82b32506f28f Issue-ID: POLICY-1428 Signed-off-by: Jim Hahn --- .../common/endpoints/http/server/test/HttpServerTest.java | 11 +++++++++++ .../common/endpoints/http/server/test/RestEchoReqResp.java | 3 +++ 2 files changed, 14 insertions(+) (limited to 'policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http') diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java index 3d80793e..972fc666 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java @@ -39,6 +39,7 @@ import org.junit.AfterClass; import org.junit.Before; import org.junit.Test; import org.onap.policy.common.endpoints.http.server.HttpServletServer; +import org.onap.policy.common.utils.gson.GsonTestUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -232,6 +233,16 @@ public class HttpServerTest { assertFalse(MyJacksonProvider.hasWrittenSome()); } + @Test + public void testSerialize() { + HttpServletServer server = HttpServletServer.factory.build("echo", "localhost", port, "/", false, true); + server.addServletPackage("/*", this.getClass().getPackage().getName()); + server.addFilterClass("/*", TestFilter.class.getCanonicalName()); + + // ensure we can serialize the server + new GsonTestUtils().compareGson(server, HttpServerTest.class); + } + @Test public void testSingleServer() throws Exception { logger.info("-- testSingleServer() --"); diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEchoReqResp.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEchoReqResp.java index 5778eeeb..c211881f 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEchoReqResp.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEchoReqResp.java @@ -22,6 +22,7 @@ package org.onap.policy.common.endpoints.http.server.test; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.gson.annotations.SerializedName; +import org.onap.policy.common.gson.annotation.GsonJsonProperty; /** * "ECHO" request and response supporting serialization and de-serialization via @@ -29,10 +30,12 @@ import com.google.gson.annotations.SerializedName; */ public class RestEchoReqResp { @JsonProperty("reqId") + @GsonJsonProperty("reqId") @SerializedName("reqId") private int requestId; @JsonProperty("textValue") + @GsonJsonProperty("textValue") @SerializedName("textValue") private String text; -- cgit 1.2.3-korg