summaryrefslogtreecommitdiffstats
path: root/policy-endpoints/src/test/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'policy-endpoints/src/test/java/org')
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpClientTest.java95
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java49
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/MyJacksonProvider.java83
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEchoReqResp.java5
4 files changed, 1 insertions, 231 deletions
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpClientTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpClientTest.java
index 5d609a65..7e03b1f6 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpClientTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpClientTest.java
@@ -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();
}
/**
@@ -351,26 +348,6 @@ public class HttpClientTest {
}
@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()
.build(BusTopicParams.builder().clientName(TEST_HTTP_AUTH_CLIENT).useHttps(true)
@@ -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)
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 c367d133..68c9dc8a 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
@@ -91,7 +91,6 @@ public class HttpServerTest {
HttpServletServerFactoryInstance.getServerFactory().destroy();
- MyJacksonProvider.resetSome();
MyGsonProvider.resetSome();
MyYamlProvider.resetSome();
}
@@ -132,38 +131,6 @@ public class HttpServerTest {
}
@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
index cd922eba..00000000
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/MyJacksonProvider.java
+++ /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;
- }
-
-}
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 c211881f..2a3e244d 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
@@ -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;