aboutsummaryrefslogtreecommitdiffstats
path: root/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2019-02-13 10:53:12 -0500
committerJim Hahn <jrh3@att.com>2019-02-13 12:29:39 -0500
commitc064f5e9ea7e385ae8c730bb9e9fc5fdd45e25d6 (patch)
treeddf1281d011e5e110085c0c0535c5cde741bcd78 /policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http
parenteaaf4f237ad0dce620b5385ce8c7424dd01d2c26 (diff)
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 <jrh3@att.com>
Diffstat (limited to 'policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http')
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java11
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEchoReqResp.java3
2 files changed, 14 insertions, 0 deletions
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;
@@ -233,6 +234,16 @@ public class HttpServerTest {
}
@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;