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 --- .../endpoints/event/comm/TopicEndpointProxy.java | 9 +++ .../event/comm/bus/internal/BusPublisher.java | 4 +- .../http/client/internal/JerseyClient.java | 2 + .../http/server/internal/JettyServletServer.java | 4 +- .../event/comm/TopicEndpointProxyTest.java | 11 ++++ .../event/comm/bus/internal/BusTopicBaseTest.java | 8 ++- .../comm/bus/internal/InlineBusTopicSinkTest.java | 8 ++- .../bus/internal/InlineDmaapTopicSinkTest.java | 8 ++- .../comm/bus/internal/InlineUebTopicSinkTest.java | 8 ++- .../internal/SingleThreadedBusTopicSourceTest.java | 10 ++- .../SingleThreadedDmaapTopicSourceTest.java | 8 ++- .../internal/SingleThreadedUebTopicSourceTest.java | 8 ++- .../event/comm/bus/internal/TopicBaseTest.java | 18 ++++-- .../endpoints/http/server/test/HttpServerTest.java | 11 ++++ .../http/server/test/RestEchoReqResp.java | 3 + .../event/comm/TopicEndpointProxyTest.json | 74 ++++++++++++++++++++++ .../event/comm/bus/internal/BusTopicBaseTest.json | 12 ++++ .../comm/bus/internal/InlineBusTopicSinkTest.json | 13 ++++ .../bus/internal/InlineDmaapTopicSinkTest.json | 13 ++++ .../comm/bus/internal/InlineUebTopicSinkTest.json | 13 ++++ .../internal/SingleThreadedBusTopicSourceTest.json | 16 +++++ .../SingleThreadedDmaapTopicSourceTest.json | 16 +++++ .../internal/SingleThreadedUebTopicSourceTest.json | 16 +++++ .../event/comm/bus/internal/TopicBaseTest.json | 8 +++ .../http/server/internal/HttpServerTest.json | 7 ++ 25 files changed, 292 insertions(+), 16 deletions(-) create mode 100644 policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxyTest.json create mode 100644 policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicBaseTest.json create mode 100644 policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineBusTopicSinkTest.json create mode 100644 policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineDmaapTopicSinkTest.json create mode 100644 policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineUebTopicSinkTest.json create mode 100644 policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSourceTest.json create mode 100644 policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedDmaapTopicSourceTest.json create mode 100644 policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedUebTopicSourceTest.json create mode 100644 policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/TopicBaseTest.json create mode 100644 policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/http/server/internal/HttpServerTest.json (limited to 'policy-endpoints/src') diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxy.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxy.java index 9912761f..ebed381d 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxy.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxy.java @@ -31,6 +31,7 @@ import org.onap.policy.common.endpoints.event.comm.bus.NoopTopicSink; import org.onap.policy.common.endpoints.event.comm.bus.NoopTopicSource; import org.onap.policy.common.endpoints.event.comm.bus.UebTopicSink; import org.onap.policy.common.endpoints.event.comm.bus.UebTopicSource; +import org.onap.policy.common.gson.annotation.GsonJsonIgnore; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -229,35 +230,42 @@ class TopicEndpointProxy implements TopicEndpoint { } @JsonIgnore + @GsonJsonIgnore @Override public List getUebTopicSources() { return UebTopicSource.factory.inventory(); } @JsonIgnore + @GsonJsonIgnore @Override public List getDmaapTopicSources() { return DmaapTopicSource.factory.inventory(); } + @JsonIgnore + @GsonJsonIgnore @Override public List getNoopTopicSources() { return NoopTopicSource.factory.inventory(); } @JsonIgnore + @GsonJsonIgnore @Override public List getUebTopicSinks() { return UebTopicSink.factory.inventory(); } @JsonIgnore + @GsonJsonIgnore @Override public List getDmaapTopicSinks() { return DmaapTopicSink.factory.inventory(); } @JsonIgnore + @GsonJsonIgnore @Override public List getNoopTopicSinks() { return NoopTopicSink.factory.inventory(); @@ -325,6 +333,7 @@ class TopicEndpointProxy implements TopicEndpoint { * @return list of managed endpoints */ @JsonIgnore + @GsonJsonIgnore protected List getEndpoints() { final List endpoints = new ArrayList<>(); diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusPublisher.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusPublisher.java index 9b2e6f5c..1c2d6eeb 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusPublisher.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusPublisher.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * policy-endpoints * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2018 Samsung Electronics Co., Ltd. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -41,6 +41,7 @@ import org.onap.dmaap.mr.client.response.MRPublisherResponse; import org.onap.dmaap.mr.test.clients.ProtocolTypeConstants; import org.onap.policy.common.endpoints.event.comm.bus.DmaapTopicSinkFactory; import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties; +import org.onap.policy.common.gson.annotation.GsonJsonIgnore; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -72,6 +73,7 @@ public interface BusPublisher { * The actual Cambria publisher. */ @JsonIgnore + @GsonJsonIgnore protected volatile CambriaBatchingPublisher publisher; /** diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/internal/JerseyClient.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/internal/JerseyClient.java index 2287486e..01f9fbe3 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/internal/JerseyClient.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/internal/JerseyClient.java @@ -41,6 +41,7 @@ import org.glassfish.jersey.client.ClientProperties; import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature; import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams; import org.onap.policy.common.endpoints.http.client.HttpClient; +import org.onap.policy.common.gson.annotation.GsonJsonIgnore; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -270,6 +271,7 @@ public class JerseyClient implements HttpClient { } @JsonIgnore + @GsonJsonIgnore @Override public String getPassword() { return password; diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyServletServer.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyServletServer.java index 0c52aca8..76ad116f 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyServletServer.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyServletServer.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,6 +44,7 @@ import org.eclipse.jetty.util.security.Credential; import org.eclipse.jetty.util.ssl.SslContextFactory; import org.onap.aaf.cadi.filter.CadiFilter; import org.onap.policy.common.endpoints.http.server.HttpServletServer; +import org.onap.policy.common.gson.annotation.GsonJsonIgnore; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -486,6 +487,7 @@ public abstract class JettyServletServer implements HttpServletServer, Runnable * @return the password */ @JsonIgnore + @GsonJsonIgnore public String getPassword() { return password; } diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxyTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxyTest.java index 19dde432..a311c0b0 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxyTest.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxyTest.java @@ -33,6 +33,7 @@ import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; import org.onap.policy.common.endpoints.event.comm.bus.DmaapTopicPropertyBuilder; import org.onap.policy.common.endpoints.event.comm.bus.NoopTopicPropertyBuilder; import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties; +import org.onap.policy.common.utils.gson.GsonTestUtils; public class TopicEndpointProxyTest { @@ -111,6 +112,16 @@ public class TopicEndpointProxyTest { || exists(topics, DMAAP_SINK_TOPIC); } + @Test + public void testSerialize() { + TopicEndpoint manager = new TopicEndpointProxy(); + + manager.addTopicSources(configuration); + manager.addTopicSinks(configuration); + + new GsonTestUtils().compareGson(manager, TopicEndpointProxyTest.class); + } + @Test public void addTopicSources() { TopicEndpoint manager = new TopicEndpointProxy(); diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicBaseTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicBaseTest.java index 56d3b47a..83a94bd5 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicBaseTest.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicBaseTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * policy-endpoints * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ import static org.junit.Assert.assertTrue; import org.junit.Before; import org.junit.Test; import org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase; +import org.onap.policy.common.utils.gson.GsonTestUtils; public class BusTopicBaseTest extends TopicTestBase { @@ -48,6 +49,11 @@ public class BusTopicBaseTest extends TopicTestBase { assertNotNull(base.toString()); } + @Test + public void testSerialize() { + new GsonTestUtils().compareGson(base, BusTopicBaseTest.class); + } + @Test public void testGetApiKey() { assertEquals(MY_API_KEY, base.getApiKey()); diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineBusTopicSinkTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineBusTopicSinkTest.java index 7330e6f7..cb6eb107 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineBusTopicSinkTest.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineBusTopicSinkTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * policy-endpoints * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,6 +37,7 @@ import org.junit.Test; import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; import org.onap.policy.common.endpoints.event.comm.TopicListener; import org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase; +import org.onap.policy.common.utils.gson.GsonTestUtils; public class InlineBusTopicSinkTest extends TopicTestBase { @@ -57,6 +58,11 @@ public class InlineBusTopicSinkTest extends TopicTestBase { sink.shutdown(); } + @Test + public void testSerialize() { + new GsonTestUtils().compareGson(sink, InlineBusTopicSinkTest.class); + } + @Test public void testInlineBusTopicSinkImpl() { // verify that different wrappers can be built diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineDmaapTopicSinkTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineDmaapTopicSinkTest.java index bf064100..aaab402c 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineDmaapTopicSinkTest.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineDmaapTopicSinkTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * policy-endpoints * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ import org.junit.Before; import org.junit.Test; import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; import org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase; +import org.onap.policy.common.utils.gson.GsonTestUtils; public class InlineDmaapTopicSinkTest extends TopicTestBase { private InlineDmaapTopicSink sink; @@ -47,6 +48,11 @@ public class InlineDmaapTopicSinkTest extends TopicTestBase { sink.shutdown(); } + @Test + public void testSerialize() { + new GsonTestUtils().compareGson(sink, InlineDmaapTopicSinkTest.class); + } + @Test public void testToString() { assertTrue(sink.toString().startsWith("InlineDmaapTopicSink [")); diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineUebTopicSinkTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineUebTopicSinkTest.java index 610070e3..2516406f 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineUebTopicSinkTest.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineUebTopicSinkTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * policy-endpoints * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ import org.junit.Before; import org.junit.Test; import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; import org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase; +import org.onap.policy.common.utils.gson.GsonTestUtils; public class InlineUebTopicSinkTest extends TopicTestBase { private InlineUebTopicSink sink; @@ -47,6 +48,11 @@ public class InlineUebTopicSinkTest extends TopicTestBase { sink.shutdown(); } + @Test + public void testSerialize() { + new GsonTestUtils().compareGson(sink, InlineUebTopicSinkTest.class); + } + @Test public void testToString() { assertTrue(sink.toString().startsWith("InlineUebTopicSink [")); diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSourceTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSourceTest.java index d0e8569b..f930fb6b 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSourceTest.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSourceTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * policy-endpoints * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,6 +43,7 @@ import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; import org.onap.policy.common.endpoints.event.comm.TopicListener; import org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase; import org.onap.policy.common.endpoints.event.comm.bus.internal.BusConsumer.FilterableBusConsumer; +import org.onap.policy.common.utils.gson.GsonTestUtils; public class SingleThreadedBusTopicSourceTest extends TopicTestBase { private Thread thread; @@ -68,6 +69,11 @@ public class SingleThreadedBusTopicSourceTest extends TopicTestBase { source.shutdown(); } + @Test + public void testSerialize() { + new GsonTestUtils().compareGson(source, SingleThreadedBusTopicSourceTest.class); + } + @Test public void testRegister() { source.register(listener); @@ -146,7 +152,7 @@ public class SingleThreadedBusTopicSourceTest extends TopicTestBase { // do nothing } }; - + assertNotNull(source2.makePollerThread()); } diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedDmaapTopicSourceTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedDmaapTopicSourceTest.java index c7444034..29c34591 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedDmaapTopicSourceTest.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedDmaapTopicSourceTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * policy-endpoints * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ import org.junit.Before; import org.junit.Test; import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; import org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase; +import org.onap.policy.common.utils.gson.GsonTestUtils; public class SingleThreadedDmaapTopicSourceTest extends TopicTestBase { private SingleThreadedDmaapTopicSource source; @@ -48,6 +49,11 @@ public class SingleThreadedDmaapTopicSourceTest extends TopicTestBase { source.shutdown(); } + @Test + public void testSerialize() { + new GsonTestUtils().compareGson(source, SingleThreadedDmaapTopicSourceTest.class); + } + @Test public void testToString() { assertTrue(source.toString().startsWith("SingleThreadedDmaapTopicSource [")); diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedUebTopicSourceTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedUebTopicSourceTest.java index b8cb0c13..99dc6fb7 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedUebTopicSourceTest.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedUebTopicSourceTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * policy-endpoints * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ import org.junit.Before; import org.junit.Test; import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; import org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase; +import org.onap.policy.common.utils.gson.GsonTestUtils; public class SingleThreadedUebTopicSourceTest extends TopicTestBase { private SingleThreadedUebTopicSource source; @@ -47,6 +48,11 @@ public class SingleThreadedUebTopicSourceTest extends TopicTestBase { source.shutdown(); } + @Test + public void testSerialize() { + new GsonTestUtils().compareGson(source, SingleThreadedUebTopicSourceTest.class); + } + @Test public void testToString() { assertTrue(source.toString().startsWith("SingleThreadedUebTopicSource [")); diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/TopicBaseTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/TopicBaseTest.java index 76883b3c..a8ea84fc 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/TopicBaseTest.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/TopicBaseTest.java @@ -2,14 +2,14 @@ * ============LICENSE_START======================================================= * ONAP Policy Engine - Common Modules * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -37,6 +37,7 @@ import org.junit.Test; import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; import org.onap.policy.common.endpoints.event.comm.TopicListener; import org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase; +import org.onap.policy.common.utils.gson.GsonTestUtils; public class TopicBaseTest extends TopicTestBase { @@ -48,7 +49,7 @@ public class TopicBaseTest extends TopicTestBase { @Before public void setUp() { super.setUp(); - + base = new TopicBaseImpl(servers, MY_TOPIC); } @@ -72,6 +73,11 @@ public class TopicBaseTest extends TopicTestBase { new TopicBaseImpl(servers, ""); } + @Test + public void testSerialize() { + new GsonTestUtils().compareGson(base, TopicBaseTest.class); + } + @Test public void testRegister() { TopicListener listener = mock(TopicListener.class); @@ -246,7 +252,7 @@ public class TopicBaseTest extends TopicTestBase { /** * Constructor. - * + * * @param servers list of servers * @param topic topic name */ @@ -285,7 +291,7 @@ public class TopicBaseTest extends TopicTestBase { /** * Adds an event to the list of recent events. - * + * * @param event event to be added */ public void addEvent(String event) { 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; diff --git a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxyTest.json b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxyTest.json new file mode 100644 index 00000000..11624af0 --- /dev/null +++ b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxyTest.json @@ -0,0 +1,74 @@ +{ + "locked" : false, + "alive" : false, + "topicSources" : [ { + "servers" : [ "my-server" ], + "topic" : "ueb-source", + "recentEvents" : [ ], + "alive" : false, + "locked" : false, + "apiKey" : null, + "apiSecret" : null, + "useHttps" : true, + "allowSelfSignedCerts" : true, + "consumerGroup" : "${obj.topicSources[0].consumerGroup}", + "consumerInstance" : "${obj.topicSources[0].consumerInstance}", + "fetchTimeout" : 15000, + "fetchLimit" : 100, + "topicCommInfrastructure" : "UEB" + }, { + "servers" : [ "my-server" ], + "topic" : "dmaap-source", + "recentEvents" : [ ], + "alive" : false, + "locked" : false, + "apiKey" : "my-api-key", + "apiSecret" : "my-api-secret", + "useHttps" : true, + "allowSelfSignedCerts" : true, + "consumerGroup" : "my-cons-group", + "consumerInstance" : "my-cons-inst", + "fetchTimeout" : 101, + "fetchLimit" : 100, + "topicCommInfrastructure" : "DMAAP" + }, { + "servers" : [ "my-server" ], + "topic" : "noop-source", + "recentEvents" : [ ], + "alive" : false, + "locked" : false, + "topicCommInfrastructure" : "NOOP" + } ], + "topicSinks" : [ { + "servers" : [ "my-server" ], + "topic" : "ueb-sink", + "recentEvents" : [ ], + "alive" : false, + "locked" : false, + "apiKey" : null, + "apiSecret" : null, + "useHttps" : true, + "allowSelfSignedCerts" : true, + "topicCommInfrastructure" : "UEB", + "partitionKey" : "${obj.topicSinks[0].partitionKey}" + }, { + "servers" : [ "my-server" ], + "topic" : "dmaap-sink", + "recentEvents" : [ ], + "alive" : false, + "locked" : false, + "apiKey" : "my-api-key", + "apiSecret" : "my-api-secret", + "useHttps" : true, + "allowSelfSignedCerts" : true, + "topicCommInfrastructure" : "DMAAP", + "partitionKey" : "my-partition" + }, { + "servers" : [ "my-server" ], + "topic" : "noop-sink", + "recentEvents" : [ ], + "alive" : false, + "locked" : false, + "topicCommInfrastructure" : "NOOP" + } ] +} diff --git a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicBaseTest.json b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicBaseTest.json new file mode 100644 index 00000000..49eafaf1 --- /dev/null +++ b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicBaseTest.json @@ -0,0 +1,12 @@ +{ + "servers" : [ "svra", "svrb" ], + "topic" : "my-topic", + "recentEvents" : [ ], + "alive" : false, + "locked" : false, + "apiKey" : "my-api-key", + "apiSecret" : "my-api-secret", + "useHttps" : true, + "allowSelfSignedCerts" : true, + "topicCommInfrastructure" : "NOOP" +} diff --git a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineBusTopicSinkTest.json b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineBusTopicSinkTest.json new file mode 100644 index 00000000..98318751 --- /dev/null +++ b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineBusTopicSinkTest.json @@ -0,0 +1,13 @@ +{ + "servers" : [ "svra", "svrb" ], + "topic" : "my-topic", + "recentEvents" : [ ], + "alive" : false, + "locked" : false, + "apiKey" : "my-api-key", + "apiSecret" : "my-api-secret", + "useHttps" : true, + "allowSelfSignedCerts" : true, + "topicCommInfrastructure" : "NOOP", + "partitionKey" : "my-partition" +} diff --git a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineDmaapTopicSinkTest.json b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineDmaapTopicSinkTest.json new file mode 100644 index 00000000..a83f5c97 --- /dev/null +++ b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineDmaapTopicSinkTest.json @@ -0,0 +1,13 @@ +{ + "servers" : [ "svra", "svrb" ], + "topic" : "my-topic", + "recentEvents" : [ ], + "alive" : false, + "locked" : false, + "apiKey" : "my-api-key", + "apiSecret" : "my-api-secret", + "useHttps" : true, + "allowSelfSignedCerts" : true, + "topicCommInfrastructure" : "DMAAP", + "partitionKey" : "my-partition" +} diff --git a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineUebTopicSinkTest.json b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineUebTopicSinkTest.json new file mode 100644 index 00000000..4ec0c80f --- /dev/null +++ b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineUebTopicSinkTest.json @@ -0,0 +1,13 @@ +{ + "servers" : [ "svra", "svrb" ], + "topic" : "my-topic", + "recentEvents" : [ ], + "alive" : false, + "locked" : false, + "apiKey" : "my-api-key", + "apiSecret" : "my-api-secret", + "useHttps" : true, + "allowSelfSignedCerts" : true, + "topicCommInfrastructure" : "UEB", + "partitionKey" : "my-partition" +} diff --git a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSourceTest.json b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSourceTest.json new file mode 100644 index 00000000..4f880257 --- /dev/null +++ b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSourceTest.json @@ -0,0 +1,16 @@ +{ + "servers" : [ "svra", "svrb" ], + "topic" : "my-topic", + "recentEvents" : [ ], + "alive" : false, + "locked" : false, + "apiKey" : "my-api-key", + "apiSecret" : "my-api-secret", + "useHttps" : true, + "allowSelfSignedCerts" : true, + "consumerGroup" : "my-cons-group", + "consumerInstance" : "my-cons-inst", + "fetchTimeout" : 101, + "fetchLimit" : 100, + "topicCommInfrastructure" : "NOOP" +} diff --git a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedDmaapTopicSourceTest.json b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedDmaapTopicSourceTest.json new file mode 100644 index 00000000..82e4b3ff --- /dev/null +++ b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedDmaapTopicSourceTest.json @@ -0,0 +1,16 @@ +{ + "servers" : [ "svra", "svrb" ], + "topic" : "my-topic", + "recentEvents" : [ ], + "alive" : false, + "locked" : false, + "apiKey" : "my-api-key", + "apiSecret" : "my-api-secret", + "useHttps" : true, + "allowSelfSignedCerts" : true, + "consumerGroup" : "my-cons-group", + "consumerInstance" : "my-cons-inst", + "fetchTimeout" : 101, + "fetchLimit" : 100, + "topicCommInfrastructure" : "DMAAP" +} diff --git a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedUebTopicSourceTest.json b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedUebTopicSourceTest.json new file mode 100644 index 00000000..4eeacc6d --- /dev/null +++ b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedUebTopicSourceTest.json @@ -0,0 +1,16 @@ +{ + "servers" : [ "svra", "svrb" ], + "topic" : "my-topic", + "recentEvents" : [ ], + "alive" : false, + "locked" : false, + "apiKey" : "my-api-key", + "apiSecret" : "my-api-secret", + "useHttps" : true, + "allowSelfSignedCerts" : true, + "consumerGroup" : "my-cons-group", + "consumerInstance" : "my-cons-inst", + "fetchTimeout" : 101, + "fetchLimit" : 100, + "topicCommInfrastructure" : "UEB" +} diff --git a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/TopicBaseTest.json b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/TopicBaseTest.json new file mode 100644 index 00000000..7431854d --- /dev/null +++ b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/TopicBaseTest.json @@ -0,0 +1,8 @@ +{ + "servers" : [ "svra", "svrb" ], + "topic" : "my-topic", + "recentEvents" : [ ], + "alive" : false, + "locked" : false, + "topicCommInfrastructure" : "NOOP" +} diff --git a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/http/server/internal/HttpServerTest.json b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/http/server/internal/HttpServerTest.json new file mode 100644 index 00000000..5f4a7a90 --- /dev/null +++ b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/http/server/internal/HttpServerTest.json @@ -0,0 +1,7 @@ +{ + "aaf": false, + "alive": false, + "host": "localhost", + "name": "echo", + "port": ${obj.port} +} -- cgit 1.2.3-korg