Remove jackson from policy-common 88/110388/2
authorJim Hahn <jrh3@att.com>
Mon, 20 Jul 2020 20:33:10 +0000 (16:33 -0400)
committerJim Hahn <jrh3@att.com>
Mon, 20 Jul 2020 21:06:04 +0000 (17:06 -0400)
Issue-ID: POLICY-1528
Change-Id: Ic4b9314a770e53cefb93776bfede35591363690e
Signed-off-by: Jim Hahn <jrh3@att.com>
policy-endpoints/pom.xml
policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxy.java
policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusPublisher.java
policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/internal/JerseyClient.java
policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyServletServer.java
policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpClientTest.java
policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java
policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/MyJacksonProvider.java [deleted file]
policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEchoReqResp.java

index 4c5b912..4ed6bde 100644 (file)
             <artifactId>gson</artifactId>
         </dependency>
 
-        <dependency>
-            <groupId>com.fasterxml.jackson.core</groupId>
-            <artifactId>jackson-annotations</artifactId>
-        </dependency>
-
         <dependency>
             <groupId>org.apache.httpcomponents</groupId>
             <artifactId>httpclient</artifactId>
index 6f3094f..b86532f 100644 (file)
@@ -20,7 +20,6 @@
 
 package org.onap.policy.common.endpoints.event.comm;
 
-import com.fasterxml.jackson.annotation.JsonIgnore;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
@@ -313,42 +312,36 @@ class TopicEndpointProxy implements TopicEndpoint {
         return sinks;
     }
 
-    @JsonIgnore
     @GsonJsonIgnore
     @Override
     public List<UebTopicSource> getUebTopicSources() {
         return UebTopicFactories.getSourceFactory().inventory();
     }
 
-    @JsonIgnore
     @GsonJsonIgnore
     @Override
     public List<DmaapTopicSource> getDmaapTopicSources() {
         return DmaapTopicFactories.getSourceFactory().inventory();
     }
 
-    @JsonIgnore
     @GsonJsonIgnore
     @Override
     public List<NoopTopicSource> getNoopTopicSources() {
         return NoopTopicFactories.getSourceFactory().inventory();
     }
 
-    @JsonIgnore
     @GsonJsonIgnore
     @Override
     public List<UebTopicSink> getUebTopicSinks() {
         return UebTopicFactories.getSinkFactory().inventory();
     }
 
-    @JsonIgnore
     @GsonJsonIgnore
     @Override
     public List<DmaapTopicSink> getDmaapTopicSinks() {
         return DmaapTopicFactories.getSinkFactory().inventory();
     }
 
-    @JsonIgnore
     @GsonJsonIgnore
     @Override
     public List<NoopTopicSink> getNoopTopicSinks() {
@@ -416,7 +409,6 @@ class TopicEndpointProxy implements TopicEndpoint {
      *
      * @return list of managed endpoints
      */
-    @JsonIgnore
     @GsonJsonIgnore
     protected List<Startable> getEndpoints() {
         final List<Startable> endpoints = new ArrayList<>();
index c2b590a..09d5294 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * policy-endpoints
  * ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2020 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");
@@ -25,7 +25,6 @@ import com.att.nsa.apiClient.http.HttpClient.ConnectionType;
 import com.att.nsa.cambria.client.CambriaBatchingPublisher;
 import com.att.nsa.cambria.client.CambriaClientBuilders;
 import com.att.nsa.cambria.client.CambriaClientBuilders.PublisherBuilder;
-import com.fasterxml.jackson.annotation.JsonIgnore;
 import java.net.MalformedURLException;
 import java.security.GeneralSecurityException;
 import java.util.ArrayList;
@@ -69,7 +68,6 @@ public interface BusPublisher {
         /**
          * The actual Cambria publisher.
          */
-        @JsonIgnore
         @GsonJsonIgnore
         protected CambriaBatchingPublisher publisher;
 
index ab19b7e..f4f0705 100644 (file)
@@ -22,7 +22,6 @@
 
 package org.onap.policy.common.endpoints.http.client.internal;
 
-import com.fasterxml.jackson.annotation.JsonIgnore;
 import java.security.KeyManagementException;
 import java.security.NoSuchAlgorithmException;
 import java.security.SecureRandom;
@@ -298,7 +297,6 @@ public class JerseyClient implements HttpClient {
         return userName;
     }
 
-    @JsonIgnore
     @GsonJsonIgnore
     @Override
     public String getPassword() {
index 6825f07..699d5d4 100644 (file)
@@ -21,7 +21,6 @@
 
 package org.onap.policy.common.endpoints.http.server.internal;
 
-import com.fasterxml.jackson.annotation.JsonIgnore;
 import java.util.EnumSet;
 import javax.servlet.DispatcherType;
 import org.eclipse.jetty.security.ConstraintMapping;
@@ -492,7 +491,6 @@ public abstract class JettyServletServer implements HttpServletServer, Runnable
      *
      * @return the password
      */
-    @JsonIgnore
     @GsonJsonIgnore
     public String getPassword() {
         return password;
index 5d609a6..7e03b1f 100644 (file)
@@ -63,8 +63,6 @@ public class HttpClientTest {
     private static final String FALSE_STRING = "false";
     private static final String ALPHA123 = "alpha123";
     private static final String PUT_HELLO = "PUT:hello:{myParameter=myValue}";
-    private static final String DOT_GSON = "." + "GSON";
-    private static final String DOT_JACKSON = "." + "JACKSON";
     private static final String DOT_PDP = "." + "PDP";
     private static final String DOT_PAP = "." + "PAP";
 
@@ -143,7 +141,6 @@ public class HttpClientTest {
         HttpClientFactoryInstance.getClientFactory().destroy();
 
         MyGsonProvider.resetSome();
-        MyJacksonProvider.resetSome();
     }
 
     /**
@@ -350,26 +347,6 @@ public class HttpClientTest {
         assertEquals(PUT_HELLO, body);
     }
 
-    @Test
-    public void testHttpPutAuthClient_JacksonProvider() throws Exception {
-        final HttpClient client = HttpClientFactoryInstance.getClientFactory()
-                        .build(BusTopicParams.builder().clientName(TEST_HTTP_AUTH_CLIENT).useHttps(true)
-                                        .allowSelfSignedCerts(true).hostname(LOCALHOST).port(6667).basePath(JUNIT_ECHO)
-                                        .userName("x").password("y").managed(true)
-                                        .serializationProvider(MyJacksonProvider.class.getName()).build());
-
-        Entity<MyEntity> entity = Entity.entity(new MyEntity(MY_VALUE), MediaType.APPLICATION_JSON);
-        final Response response = client.put(HELLO, entity, Collections.emptyMap());
-        final String body = HttpClient.getBody(response, String.class);
-
-        assertEquals(200, response.getStatus());
-        assertEquals(PUT_HELLO, body);
-
-        assertTrue(MyJacksonProvider.hasWrittenSome());
-
-        assertFalse(MyGsonProvider.hasWrittenSome());
-    }
-
     @Test
     public void testHttpPutAuthClient_GsonProvider() throws Exception {
         final HttpClient client = HttpClientFactoryInstance.getClientFactory()
@@ -386,8 +363,6 @@ public class HttpClientTest {
         assertEquals(PUT_HELLO, body);
 
         assertTrue(MyGsonProvider.hasWrittenSome());
-
-        assertFalse(MyJacksonProvider.hasWrittenSome());
     }
 
     @Test
@@ -488,7 +463,6 @@ public class HttpClientTest {
         response = clientPdp.get("test");
         assertEquals(500, response.getStatus());
 
-        assertFalse(MyJacksonProvider.hasWrittenSome());
         assertFalse(MyGsonProvider.hasWrittenSome());
 
         // try with empty path
@@ -508,75 +482,6 @@ public class HttpClientTest {
         assertEquals(200, response.getStatus());
     }
 
-    @Test
-    public void testHttpAuthClientProps_MixedProviders() throws Exception {
-        final Properties httpProperties = new Properties();
-
-        httpProperties.setProperty(PolicyEndPointProperties.PROPERTY_HTTP_CLIENT_SERVICES, "GSON,JACKSON");
-        httpProperties.setProperty(PolicyEndPointProperties.PROPERTY_HTTP_CLIENT_SERVICES + DOT_GSON
-                        + PolicyEndPointProperties.PROPERTY_HTTP_HOST_SUFFIX, LOCALHOST);
-        httpProperties.setProperty(PolicyEndPointProperties.PROPERTY_HTTP_CLIENT_SERVICES + DOT_GSON
-                        + PolicyEndPointProperties.PROPERTY_HTTP_PORT_SUFFIX, "6666");
-        httpProperties.setProperty(PolicyEndPointProperties.PROPERTY_HTTP_CLIENT_SERVICES + DOT_GSON
-                        + PolicyEndPointProperties.PROPERTY_HTTP_URL_SUFFIX, JUNIT_ECHO);
-        httpProperties.setProperty(PolicyEndPointProperties.PROPERTY_HTTP_CLIENT_SERVICES + DOT_GSON
-                        + PolicyEndPointProperties.PROPERTY_HTTP_HTTPS_SUFFIX, FALSE_STRING);
-        httpProperties.setProperty(PolicyEndPointProperties.PROPERTY_HTTP_CLIENT_SERVICES + DOT_GSON
-                        + PolicyEndPointProperties.PROPERTY_MANAGED_SUFFIX, "true");
-        httpProperties.setProperty(
-                        PolicyEndPointProperties.PROPERTY_HTTP_CLIENT_SERVICES + DOT_GSON
-                                        + PolicyEndPointProperties.PROPERTY_HTTP_SERIALIZATION_PROVIDER,
-                        MyGsonProvider.class.getName());
-
-        httpProperties.setProperty(PolicyEndPointProperties.PROPERTY_HTTP_CLIENT_SERVICES + DOT_JACKSON
-                        + PolicyEndPointProperties.PROPERTY_HTTP_HOST_SUFFIX, LOCALHOST);
-        httpProperties.setProperty(PolicyEndPointProperties.PROPERTY_HTTP_CLIENT_SERVICES + DOT_JACKSON
-                        + PolicyEndPointProperties.PROPERTY_HTTP_PORT_SUFFIX, "6666");
-        httpProperties.setProperty(PolicyEndPointProperties.PROPERTY_HTTP_CLIENT_SERVICES + DOT_JACKSON
-                        + PolicyEndPointProperties.PROPERTY_HTTP_URL_SUFFIX, JUNIT_ECHO);
-        httpProperties.setProperty(PolicyEndPointProperties.PROPERTY_HTTP_CLIENT_SERVICES + DOT_JACKSON
-                        + PolicyEndPointProperties.PROPERTY_HTTP_HTTPS_SUFFIX, FALSE_STRING);
-        httpProperties.setProperty(PolicyEndPointProperties.PROPERTY_HTTP_CLIENT_SERVICES + DOT_JACKSON
-                        + PolicyEndPointProperties.PROPERTY_MANAGED_SUFFIX, "true");
-        httpProperties.setProperty(
-                        PolicyEndPointProperties.PROPERTY_HTTP_CLIENT_SERVICES + DOT_JACKSON
-                                        + PolicyEndPointProperties.PROPERTY_HTTP_SERIALIZATION_PROVIDER,
-                        MyJacksonProvider.class.getName());
-
-        final List<HttpClient> clients = HttpClientFactoryInstance.getClientFactory().build(httpProperties);
-        assertEquals(2, clients.size());
-
-        Entity<MyEntity> entity = Entity.entity(new MyEntity(MY_VALUE), MediaType.APPLICATION_JSON);
-
-        // use gson client
-        MyGsonProvider.resetSome();
-        MyJacksonProvider.resetSome();
-        HttpClient client = HttpClientFactoryInstance.getClientFactory().get("GSON");
-
-        Response response = client.put(HELLO, entity, Collections.emptyMap());
-        String body = HttpClient.getBody(response, String.class);
-
-        assertEquals(200, response.getStatus());
-        assertEquals(PUT_HELLO, body);
-
-        assertTrue(MyGsonProvider.hasWrittenSome());
-        assertFalse(MyJacksonProvider.hasWrittenSome());
-
-        // use jackson client
-        MyGsonProvider.resetSome();
-        MyJacksonProvider.resetSome();
-        client = HttpClientFactoryInstance.getClientFactory().get("JACKSON");
-
-        response = client.put(HELLO, entity, Collections.emptyMap());
-        body = HttpClient.getBody(response, String.class);
-
-        assertEquals(200, response.getStatus());
-        assertEquals(PUT_HELLO, body);
-
-        assertTrue(MyJacksonProvider.hasWrittenSome());
-        assertFalse(MyGsonProvider.hasWrittenSome());
-    }
-
     private HttpClient getAuthHttpClient() throws HttpClientConfigException {
         return HttpClientFactoryInstance.getClientFactory()
                         .build(BusTopicParams.builder().clientName(TEST_HTTP_AUTH_CLIENT).useHttps(true)
index c367d13..68c9dc8 100644 (file)
@@ -91,7 +91,6 @@ public class HttpServerTest {
 
         HttpServletServerFactoryInstance.getServerFactory().destroy();
 
-        MyJacksonProvider.resetSome();
         MyGsonProvider.resetSome();
         MyYamlProvider.resetSome();
     }
@@ -131,38 +130,6 @@ public class HttpServerTest {
         assertEquals(reqText, response);
     }
 
-    @Test
-    public void testJacksonPackageServer() throws Exception {
-        logger.info("-- testJacksonPackageServer() --");
-
-        HttpServletServer server = HttpServletServerFactoryInstance.getServerFactory()
-                        .build("echo", LOCALHOST, port, "/", false, true);
-
-        server.setSerializationProvider(MyJacksonProvider.class.getName());
-        server.addServletPackage("/*", this.getClass().getPackage().getName());
-        server.addFilterClass("/*", TestFilter.class.getName());
-        server.waitedStart(5000);
-
-        assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port).isAlive());
-
-        RestEchoReqResp request = new RestEchoReqResp();
-        request.setRequestId(100);
-        request.setText(SOME_TEXT);
-        String reqText = gson.toJson(request);
-
-        String response = http(portUrl + JUNIT_ECHO_FULL_REQUEST, JSON_MEDIA, reqText);
-        assertEquals(reqText, response);
-
-        assertTrue(MyJacksonProvider.hasReadSome());
-        assertTrue(MyJacksonProvider.hasWrittenSome());
-
-        assertFalse(MyGsonProvider.hasReadSome());
-        assertFalse(MyGsonProvider.hasWrittenSome());
-
-        assertFalse(MyYamlProvider.hasReadSome());
-        assertFalse(MyYamlProvider.hasWrittenSome());
-    }
-
     @Test
     public void testGsonPackageServer() throws Exception {
         logger.info("-- testGsonPackageServer() --");
@@ -188,9 +155,6 @@ public class HttpServerTest {
         assertTrue(MyGsonProvider.hasReadSome());
         assertTrue(MyGsonProvider.hasWrittenSome());
 
-        assertFalse(MyJacksonProvider.hasReadSome());
-        assertFalse(MyJacksonProvider.hasWrittenSome());
-
         assertFalse(MyYamlProvider.hasReadSome());
         assertFalse(MyYamlProvider.hasWrittenSome());
     }
@@ -224,9 +188,6 @@ public class HttpServerTest {
 
         assertFalse(MyGsonProvider.hasReadSome());
         assertFalse(MyGsonProvider.hasWrittenSome());
-
-        assertFalse(MyJacksonProvider.hasReadSome());
-        assertFalse(MyJacksonProvider.hasWrittenSome());
     }
 
     @Test
@@ -256,7 +217,6 @@ public class HttpServerTest {
 
         HttpServletServer server = HttpServletServerFactoryInstance.getServerFactory()
                         .build("echo", LOCALHOST, port, "/", false, true);
-        server.setSerializationProvider(MyJacksonProvider.class.getName());
         server.addServletClass("/*", RestEchoService.class.getName());
         server.addFilterClass("/*", TestFilter.class.getName());
         server.waitedStart(5000);
@@ -271,9 +231,6 @@ public class HttpServerTest {
         String response = http(portUrl + JUNIT_ECHO_FULL_REQUEST, JSON_MEDIA, reqText);
         assertEquals(reqText, response);
 
-        assertTrue(MyJacksonProvider.hasReadSome());
-        assertTrue(MyJacksonProvider.hasWrittenSome());
-
         assertFalse(MyGsonProvider.hasReadSome());
         assertFalse(MyGsonProvider.hasWrittenSome());
 
@@ -305,9 +262,6 @@ public class HttpServerTest {
         assertTrue(MyGsonProvider.hasReadSome());
         assertTrue(MyGsonProvider.hasWrittenSome());
 
-        assertFalse(MyJacksonProvider.hasReadSome());
-        assertFalse(MyJacksonProvider.hasWrittenSome());
-
         assertFalse(MyYamlProvider.hasReadSome());
         assertFalse(MyYamlProvider.hasWrittenSome());
     }
@@ -340,9 +294,6 @@ public class HttpServerTest {
 
         assertFalse(MyGsonProvider.hasReadSome());
         assertFalse(MyGsonProvider.hasWrittenSome());
-
-        assertFalse(MyJacksonProvider.hasReadSome());
-        assertFalse(MyJacksonProvider.hasWrittenSome());
     }
 
     @Test
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/MyJacksonProvider.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/MyJacksonProvider.java
deleted file mode 100644 (file)
index cd922eb..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP
- * ================================================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.common.endpoints.http.server.test;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
-import lombok.AccessLevel;
-import lombok.Setter;
-import org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JacksonJsonProvider;
-
-/**
- * JacksonJsonProvider that tracks activities.
- */
-public class MyJacksonProvider extends JacksonJsonProvider {
-
-    @Setter(AccessLevel.PRIVATE)
-    private static boolean readSome = false;
-
-    @Setter(AccessLevel.PRIVATE)
-    private static boolean wroteSome = false;
-
-    /**
-     * Constructs the object and resets the variables to indicate that no activity has
-     * occurred yet.
-     */
-    public MyJacksonProvider() {
-        super();
-    }
-
-    @Override
-    public Object readFrom(Class<Object> type, Type genericType, Annotation[] annotations, MediaType mediaType,
-                    MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException {
-
-        setReadSome(true);
-        return super.readFrom(type, genericType, annotations, mediaType, httpHeaders, entityStream);
-    }
-
-    @Override
-    public void writeTo(Object object, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType,
-                    MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException {
-
-        setWroteSome(true);
-        super.writeTo(object, type, genericType, annotations, mediaType, httpHeaders, entityStream);
-    }
-
-    public static boolean hasReadSome() {
-        return readSome;
-    }
-
-    public static boolean hasWrittenSome() {
-        return wroteSome;
-    }
-
-    public static void resetSome() {
-        MyJacksonProvider.readSome = false;
-        MyJacksonProvider.wroteSome = false;
-    }
-
-}
index c211881..2a3e244 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP
  * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2020 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.
@@ -20,7 +20,6 @@
 
 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;
 
@@ -29,12 +28,10 @@ import org.onap.policy.common.gson.annotation.GsonJsonProperty;
  * both jackson and gson.
  */
 public class RestEchoReqResp {
-    @JsonProperty("reqId")
     @GsonJsonProperty("reqId")
     @SerializedName("reqId")
     private int requestId;
 
-    @JsonProperty("textValue")
     @GsonJsonProperty("textValue")
     @SerializedName("textValue")
     private String text;