aboutsummaryrefslogtreecommitdiffstats
path: root/policy-endpoints/src
diff options
context:
space:
mode:
Diffstat (limited to 'policy-endpoints/src')
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpoint.java5
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointManager.java37
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxy.java63
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/BusTopicSink.java14
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/BusTopicSource.java34
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicFactories.java43
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSink.java11
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSinkFactory.java9
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSource.java10
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSourceFactory.java32
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedDmaapTopicSourceFactory.java8
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedUebTopicSourceFactory.java8
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicFactories.java43
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSink.java5
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSource.java5
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicFactories.java43
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSink.java10
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSource.java10
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumer.java43
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusPublisher.java10
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSource.java9
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/client/TopicSinkClient.java4
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/features/NetLoggerFeatureApi.java7
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/features/NetLoggerFeatureProviders.java41
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClient.java9
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientConfigException.java44
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientFactory.java17
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientFactoryInstance.java37
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/IndexedHttpClientFactory.java14
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/HttpServletServer.java28
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/HttpServletServerFactoryInstance.java38
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/properties/PolicyEndPointProperties.java164
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/DmaapPropertyUtils.java15
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/NetLoggerUtil.java5
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/ParameterUtils.java3
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicFactoryTestBase.java33
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSinkTest.java4
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSourceFactoryTest.java13
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSourceTest.java4
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSinkTest.java4
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSourceFactoryTest.java13
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSourceTest.java4
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumerTest.java4
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/client/TopicSinkClientTest.java12
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpClientTest.java69
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpExceptionsTest.java33
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java96
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEndpoints.java14
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/CommonTestData.java15
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/RestServerParametersTest.java8
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/TopicParameterGroupTest.java6
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/utils/NetLoggerUtilTest.java3
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/utils/ParameterUtilsTest.java11
53 files changed, 794 insertions, 430 deletions
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpoint.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpoint.java
index ff8b9513..7bc7abab 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpoint.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpoint.java
@@ -38,11 +38,6 @@ import org.onap.policy.common.endpoints.event.comm.bus.UebTopicSource;
public interface TopicEndpoint extends Startable, Lockable {
/**
- * singleton for global access.
- */
- TopicEndpoint manager = new TopicEndpointProxy();
-
- /**
* Add topics configuration (sources and sinks) into a single list.
*
* @param properties topic configuration
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointManager.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointManager.java
new file mode 100644
index 00000000..c390afc6
--- /dev/null
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointManager.java
@@ -0,0 +1,37 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * Copyright (C) 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.common.endpoints.event.comm;
+
+import lombok.Getter;
+
+public class TopicEndpointManager {
+
+ /**
+ * Topic endpoint manager.
+ */
+ @Getter
+ private static TopicEndpoint manager = new TopicEndpointProxy();
+
+
+ private TopicEndpointManager() {
+ // do nothing
+ }
+}
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 806d077c..00980fc4 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
@@ -25,10 +25,13 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import org.onap.policy.common.capabilities.Startable;
+import org.onap.policy.common.endpoints.event.comm.bus.DmaapTopicFactories;
import org.onap.policy.common.endpoints.event.comm.bus.DmaapTopicSink;
import org.onap.policy.common.endpoints.event.comm.bus.DmaapTopicSource;
+import org.onap.policy.common.endpoints.event.comm.bus.NoopTopicFactories;
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.UebTopicFactories;
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;
@@ -71,9 +74,9 @@ class TopicEndpointProxy implements TopicEndpoint {
List<TopicSource> sources = new ArrayList<>();
- sources.addAll(UebTopicSource.factory.build(properties));
- sources.addAll(DmaapTopicSource.factory.build(properties));
- sources.addAll(NoopTopicSource.factory.build(properties));
+ sources.addAll(UebTopicFactories.getSourceFactory().build(properties));
+ sources.addAll(DmaapTopicFactories.getSourceFactory().build(properties));
+ sources.addAll(NoopTopicFactories.getSourceFactory().build(properties));
if (this.isLocked()) {
for (final TopicSource source : sources) {
@@ -92,9 +95,9 @@ class TopicEndpointProxy implements TopicEndpoint {
final List<TopicSink> sinks = new ArrayList<>();
- sinks.addAll(UebTopicSink.factory.build(properties));
- sinks.addAll(DmaapTopicSink.factory.build(properties));
- sinks.addAll(NoopTopicSink.factory.build(properties));
+ sinks.addAll(UebTopicFactories.getSinkFactory().build(properties));
+ sinks.addAll(DmaapTopicFactories.getSinkFactory().build(properties));
+ sinks.addAll(NoopTopicFactories.getSinkFactory().build(properties));
if (this.isLocked()) {
for (final TopicSink sink : sinks) {
@@ -110,9 +113,9 @@ class TopicEndpointProxy implements TopicEndpoint {
final List<TopicSource> sources = new ArrayList<>();
- sources.addAll(UebTopicSource.factory.inventory());
- sources.addAll(DmaapTopicSource.factory.inventory());
- sources.addAll(NoopTopicSource.factory.inventory());
+ sources.addAll(UebTopicFactories.getSourceFactory().inventory());
+ sources.addAll(DmaapTopicFactories.getSourceFactory().inventory());
+ sources.addAll(NoopTopicFactories.getSourceFactory().inventory());
return sources;
}
@@ -161,9 +164,9 @@ class TopicEndpointProxy implements TopicEndpoint {
final List<TopicSink> sinks = new ArrayList<>();
- sinks.addAll(UebTopicSink.factory.inventory());
- sinks.addAll(DmaapTopicSink.factory.inventory());
- sinks.addAll(NoopTopicSink.factory.inventory());
+ sinks.addAll(UebTopicFactories.getSinkFactory().inventory());
+ sinks.addAll(DmaapTopicFactories.getSinkFactory().inventory());
+ sinks.addAll(NoopTopicFactories.getSinkFactory().inventory());
return sinks;
}
@@ -240,42 +243,42 @@ class TopicEndpointProxy implements TopicEndpoint {
@GsonJsonIgnore
@Override
public List<UebTopicSource> getUebTopicSources() {
- return UebTopicSource.factory.inventory();
+ return UebTopicFactories.getSourceFactory().inventory();
}
@JsonIgnore
@GsonJsonIgnore
@Override
public List<DmaapTopicSource> getDmaapTopicSources() {
- return DmaapTopicSource.factory.inventory();
+ return DmaapTopicFactories.getSourceFactory().inventory();
}
@JsonIgnore
@GsonJsonIgnore
@Override
public List<NoopTopicSource> getNoopTopicSources() {
- return NoopTopicSource.factory.inventory();
+ return NoopTopicFactories.getSourceFactory().inventory();
}
@JsonIgnore
@GsonJsonIgnore
@Override
public List<UebTopicSink> getUebTopicSinks() {
- return UebTopicSink.factory.inventory();
+ return UebTopicFactories.getSinkFactory().inventory();
}
@JsonIgnore
@GsonJsonIgnore
@Override
public List<DmaapTopicSink> getDmaapTopicSinks() {
- return DmaapTopicSink.factory.inventory();
+ return DmaapTopicFactories.getSinkFactory().inventory();
}
@JsonIgnore
@GsonJsonIgnore
@Override
public List<NoopTopicSink> getNoopTopicSinks() {
- return NoopTopicSink.factory.inventory();
+ return NoopTopicFactories.getSinkFactory().inventory();
}
@Override
@@ -354,14 +357,14 @@ class TopicEndpointProxy implements TopicEndpoint {
public void shutdown() {
this.stop();
- UebTopicSource.factory.destroy();
- UebTopicSink.factory.destroy();
+ UebTopicFactories.getSourceFactory().destroy();
+ UebTopicFactories.getSinkFactory().destroy();
- DmaapTopicSource.factory.destroy();
- DmaapTopicSink.factory.destroy();
+ DmaapTopicFactories.getSourceFactory().destroy();
+ DmaapTopicFactories.getSinkFactory().destroy();
- NoopTopicSink.factory.destroy();
- NoopTopicSource.factory.destroy();
+ NoopTopicFactories.getSinkFactory().destroy();
+ NoopTopicFactories.getSourceFactory().destroy();
}
@@ -465,32 +468,32 @@ class TopicEndpointProxy implements TopicEndpoint {
@Override
public UebTopicSource getUebTopicSource(String topicName) {
- return UebTopicSource.factory.get(topicName);
+ return UebTopicFactories.getSourceFactory().get(topicName);
}
@Override
public UebTopicSink getUebTopicSink(String topicName) {
- return UebTopicSink.factory.get(topicName);
+ return UebTopicFactories.getSinkFactory().get(topicName);
}
@Override
public DmaapTopicSource getDmaapTopicSource(String topicName) {
- return DmaapTopicSource.factory.get(topicName);
+ return DmaapTopicFactories.getSourceFactory().get(topicName);
}
@Override
public NoopTopicSource getNoopTopicSource(String topicName) {
- return NoopTopicSource.factory.get(topicName);
+ return NoopTopicFactories.getSourceFactory().get(topicName);
}
@Override
public DmaapTopicSink getDmaapTopicSink(String topicName) {
- return DmaapTopicSink.factory.get(topicName);
+ return DmaapTopicFactories.getSinkFactory().get(topicName);
}
@Override
public NoopTopicSink getNoopTopicSink(String topicName) {
- return NoopTopicSink.factory.get(topicName);
+ return NoopTopicFactories.getSinkFactory().get(topicName);
}
private IllegalArgumentException parmException(String topicName) {
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/BusTopicSink.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/BusTopicSink.java
index ed796585..e77beea1 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/BusTopicSink.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/BusTopicSink.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* policy-endpoints
* ================================================================================
- * Copyright (C) 2017 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.
* 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.
@@ -26,21 +26,17 @@ import org.onap.policy.common.endpoints.event.comm.TopicSink;
* Topic Sink over Bus Infrastructure (DMAAP/UEB).
*/
public interface BusTopicSink extends ApiKeyEnabled, TopicSink {
- /**
- * Log Failures after X number of retries.
- */
- public static final int DEFAULT_LOG_SEND_FAILURES_AFTER = 1;
/**
* Sets the UEB partition key for published messages.
- *
+ *
* @param partitionKey the partition key
*/
public void setPartitionKey(String partitionKey);
/**
* Return the partition key in used by the system to publish messages.
- *
+ *
* @return the partition key
*/
public String getPartitionKey();
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/BusTopicSource.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/BusTopicSource.java
index 5ab4d46f..cd9bc015 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/BusTopicSource.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/BusTopicSource.java
@@ -2,14 +2,14 @@
* ============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.
* ================================================================================
* 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.
@@ -29,49 +29,29 @@ import org.onap.policy.common.endpoints.event.comm.TopicSource;
public interface BusTopicSource extends ApiKeyEnabled, TopicSource {
/**
- * Default Timeout fetching in milliseconds.
- */
- public static int DEFAULT_TIMEOUT_MS_FETCH = 15000;
-
- /**
- * Default maximum number of messages fetch at the time.
- */
- public static int DEFAULT_LIMIT_FETCH = 100;
-
- /**
- * Definition of No Timeout fetching.
- */
- public static int NO_TIMEOUT_MS_FETCH = -1;
-
- /**
- * Definition of No limit fetching.
- */
- public static int NO_LIMIT_FETCH = -1;
-
- /**
* Gets the consumer group.
- *
+ *
* @return consumer group
*/
public String getConsumerGroup();
/**
* Gets the consumer instance.
- *
+ *
* @return consumer instance
*/
public String getConsumerInstance();
/**
* Gets the fetch timeout.
- *
+ *
* @return fetch timeout
*/
public int getFetchTimeout();
/**
* Gets the fetch limit.
- *
+ *
* @return fetch limit
*/
public int getFetchLimit();
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicFactories.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicFactories.java
new file mode 100644
index 00000000..d5a46f8f
--- /dev/null
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicFactories.java
@@ -0,0 +1,43 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * Copyright (C) 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.common.endpoints.event.comm.bus;
+
+import lombok.Getter;
+
+public class DmaapTopicFactories {
+
+ /**
+ * Factory for instantiation and management of sinks.
+ */
+ @Getter
+ private static final DmaapTopicSinkFactory sinkFactory = new IndexedDmaapTopicSinkFactory();
+
+ /**
+ * Factory for instantiation and management of sources.
+ */
+ @Getter
+ private static final DmaapTopicSourceFactory sourceFactory = new IndexedDmaapTopicSourceFactory();
+
+
+ private DmaapTopicFactories() {
+ // do nothing
+ }
+}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSink.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSink.java
index fc1587e4..805ed108 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSink.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSink.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* policy-endpoints
* ================================================================================
- * Copyright (C) 2017 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.
* 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.
@@ -22,9 +22,4 @@ package org.onap.policy.common.endpoints.event.comm.bus;
public interface DmaapTopicSink extends BusTopicSink {
- /**
- * Factory of UebTopicWriter for instantiation and management purposes.
- */
-
- public static final DmaapTopicSinkFactory factory = new IndexedDmaapTopicSinkFactory();
}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSinkFactory.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSinkFactory.java
index a3eb4df6..4409e827 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSinkFactory.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSinkFactory.java
@@ -30,15 +30,6 @@ import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
*/
public interface DmaapTopicSinkFactory {
- String DME2_READ_TIMEOUT_PROPERTY = "AFT_DME2_EP_READ_TIMEOUT_MS";
- String DME2_EP_CONN_TIMEOUT_PROPERTY = "AFT_DME2_EP_CONN_TIMEOUT";
- String DME2_ROUNDTRIP_TIMEOUT_PROPERTY = "AFT_DME2_ROUNDTRIP_TIMEOUT_MS";
- String DME2_VERSION_PROPERTY = "Version";
- String DME2_ROUTE_OFFER_PROPERTY = "routeOffer";
- String DME2_SERVICE_NAME_PROPERTY = "ServiceName";
- String DME2_SUBCONTEXT_PATH_PROPERTY = "SubContextPath";
- String DME2_SESSION_STICKINESS_REQUIRED_PROPERTY = "sessionstickinessrequired";
-
/**
* <pre>
* Instantiate a new DMAAP Topic Sink, with following params.
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSource.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSource.java
index 2cf07bda..9893fa15 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSource.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSource.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* policy-endpoints
* ================================================================================
- * Copyright (C) 2017 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.
* 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.
@@ -22,8 +22,4 @@ package org.onap.policy.common.endpoints.event.comm.bus;
public interface DmaapTopicSource extends BusTopicSource {
- /**
- * factory for managing and tracking DMAAP sources.
- */
- public static DmaapTopicSourceFactory factory = new IndexedDmaapTopicSourceFactory();
}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSourceFactory.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSourceFactory.java
index 35a79bf1..7b1f185b 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSourceFactory.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSourceFactory.java
@@ -8,9 +8,9 @@
* 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.
@@ -29,20 +29,12 @@ import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
* DMAAP Topic Source Factory.
*/
public interface DmaapTopicSourceFactory {
- String DME2_READ_TIMEOUT_PROPERTY = "AFT_DME2_EP_READ_TIMEOUT_MS";
- String DME2_EP_CONN_TIMEOUT_PROPERTY = "AFT_DME2_EP_CONN_TIMEOUT";
- String DME2_ROUNDTRIP_TIMEOUT_PROPERTY = "AFT_DME2_ROUNDTRIP_TIMEOUT_MS";
- String DME2_VERSION_PROPERTY = "Version";
- String DME2_ROUTE_OFFER_PROPERTY = "routeOffer";
- String DME2_SERVICE_NAME_PROPERTY = "ServiceName";
- String DME2_SUBCONTEXT_PATH_PROPERTY = "SubContextPath";
- String DME2_SESSION_STICKINESS_REQUIRED_PROPERTY = "sessionstickinessrequired";
/**
* Creates an DMAAP Topic Source based on properties files.
- *
+ *
* @param properties Properties containing initialization values
- *
+ *
* @return an DMAAP Topic Source
* @throws IllegalArgumentException if invalid parameters are present
*/
@@ -50,7 +42,7 @@ public interface DmaapTopicSourceFactory {
/**
* Instantiates a new DMAAP Topic Source.
- *
+ *
* @param busTopicParams parameters object
* @return a DMAAP Topic Source
*/
@@ -58,12 +50,12 @@ public interface DmaapTopicSourceFactory {
/**
* Instantiates a new DMAAP Topic Source.
- *
+ *
* @param servers list of servers
* @param topic topic name
* @param apiKey API Key
* @param apiSecret API Secret
- *
+ *
* @return an DMAAP Topic Source
* @throws IllegalArgumentException if invalid parameters are present
*/
@@ -71,10 +63,10 @@ public interface DmaapTopicSourceFactory {
/**
* Instantiates a new DMAAP Topic Source.
- *
+ *
* @param servers list of servers
* @param topic topic name
- *
+ *
* @return an DMAAP Topic Source
* @throws IllegalArgumentException if invalid parameters are present
*/
@@ -82,7 +74,7 @@ public interface DmaapTopicSourceFactory {
/**
* Destroys an DMAAP Topic Source based on a topic.
- *
+ *
* @param topic topic name
* @throws IllegalArgumentException if invalid parameters are present
*/
@@ -95,7 +87,7 @@ public interface DmaapTopicSourceFactory {
/**
* Gets an DMAAP Topic Source based on topic name.
- *
+ *
* @param topic the topic name
* @return an DMAAP Topic Source with topic name
* @throws IllegalArgumentException if an invalid topic is provided
@@ -105,7 +97,7 @@ public interface DmaapTopicSourceFactory {
/**
* Provides a snapshot of the DMAAP Topic Sources.
- *
+ *
* @return a list of the DMAAP Topic Sources
*/
List<DmaapTopicSource> inventory();
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedDmaapTopicSourceFactory.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedDmaapTopicSourceFactory.java
index c895a409..d7f4695e 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedDmaapTopicSourceFactory.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedDmaapTopicSourceFactory.java
@@ -96,8 +96,8 @@ class IndexedDmaapTopicSourceFactory implements DmaapTopicSourceFactory {
.topic(topic)
.apiKey(apiKey)
.apiSecret(apiSecret)
- .fetchTimeout(DmaapTopicSource.DEFAULT_TIMEOUT_MS_FETCH)
- .fetchLimit(DmaapTopicSource.DEFAULT_LIMIT_FETCH)
+ .fetchTimeout(PolicyEndPointProperties.DEFAULT_TIMEOUT_MS_FETCH)
+ .fetchLimit(PolicyEndPointProperties.DEFAULT_LIMIT_FETCH)
.managed(true)
.useHttps(false)
.allowSelfSignedCerts(false)
@@ -133,9 +133,9 @@ class IndexedDmaapTopicSourceFactory implements DmaapTopicSourceFactory {
PolicyEndPointProperties.PROPERTY_TOPIC_SOURCE_CONSUMER_INSTANCE_SUFFIX, null))
.fetchTimeout(props.getInteger(
PolicyEndPointProperties.PROPERTY_TOPIC_SOURCE_FETCH_TIMEOUT_SUFFIX,
- DmaapTopicSource.DEFAULT_TIMEOUT_MS_FETCH))
+ PolicyEndPointProperties.DEFAULT_TIMEOUT_MS_FETCH))
.fetchLimit(props.getInteger(PolicyEndPointProperties.PROPERTY_TOPIC_SOURCE_FETCH_LIMIT_SUFFIX,
- DmaapTopicSource.DEFAULT_LIMIT_FETCH))
+ PolicyEndPointProperties.DEFAULT_LIMIT_FETCH))
.build());
dmaapTopicSourceLst.add(uebTopicSource);
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedUebTopicSourceFactory.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedUebTopicSourceFactory.java
index 6655aa12..5bdc8ab6 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedUebTopicSourceFactory.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedUebTopicSourceFactory.java
@@ -100,8 +100,8 @@ class IndexedUebTopicSourceFactory implements UebTopicSourceFactory {
.topic(topic)
.apiKey(apiKey)
.apiSecret(apiSecret)
- .fetchTimeout(UebTopicSource.DEFAULT_TIMEOUT_MS_FETCH)
- .fetchLimit(UebTopicSource.DEFAULT_LIMIT_FETCH)
+ .fetchTimeout(PolicyEndPointProperties.DEFAULT_TIMEOUT_MS_FETCH)
+ .fetchLimit(PolicyEndPointProperties.DEFAULT_LIMIT_FETCH)
.managed(true)
.useHttps(false)
.allowSelfSignedCerts(true).build());
@@ -136,9 +136,9 @@ class IndexedUebTopicSourceFactory implements UebTopicSourceFactory {
PolicyEndPointProperties.PROPERTY_TOPIC_SOURCE_CONSUMER_INSTANCE_SUFFIX, null))
.fetchTimeout(props.getInteger(
PolicyEndPointProperties.PROPERTY_TOPIC_SOURCE_FETCH_TIMEOUT_SUFFIX,
- UebTopicSource.DEFAULT_TIMEOUT_MS_FETCH))
+ PolicyEndPointProperties.DEFAULT_TIMEOUT_MS_FETCH))
.fetchLimit(props.getInteger(PolicyEndPointProperties.PROPERTY_TOPIC_SOURCE_FETCH_LIMIT_SUFFIX,
- UebTopicSource.DEFAULT_LIMIT_FETCH))
+ PolicyEndPointProperties.DEFAULT_LIMIT_FETCH))
.build());
newUebTopicSources.add(uebTopicSource);
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicFactories.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicFactories.java
new file mode 100644
index 00000000..aa85e714
--- /dev/null
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicFactories.java
@@ -0,0 +1,43 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * Copyright (C) 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.common.endpoints.event.comm.bus;
+
+import lombok.Getter;
+
+public class NoopTopicFactories {
+
+ /**
+ * Factory for instantiation and management of sinks.
+ */
+ @Getter
+ private static final NoopTopicSinkFactory sinkFactory = new NoopTopicSinkFactory();
+
+ /**
+ * Factory for instantiation and management of sources.
+ */
+ @Getter
+ private static final NoopTopicSourceFactory sourceFactory = new NoopTopicSourceFactory();
+
+
+ private NoopTopicFactories() {
+ // do nothing
+ }
+}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSink.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSink.java
index c52a30be..e7accad5 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSink.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSink.java
@@ -30,11 +30,6 @@ import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType;
public class NoopTopicSink extends NoopTopicEndpoint implements TopicSink {
/**
- * Factory.
- */
- public static final NoopTopicSinkFactory factory = new NoopTopicSinkFactory();
-
- /**
* Constructs the object.
*/
public NoopTopicSink(List<String> servers, String topic) {
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSource.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSource.java
index a5b9349e..6f2c4a1e 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSource.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSource.java
@@ -30,11 +30,6 @@ import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType;
public class NoopTopicSource extends NoopTopicEndpoint implements TopicSource {
/**
- * Factory.
- */
- public static final NoopTopicSourceFactory factory = new NoopTopicSourceFactory();
-
- /**
* Constructs the object.
*/
public NoopTopicSource(List<String> servers, String topic) {
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicFactories.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicFactories.java
new file mode 100644
index 00000000..d02758be
--- /dev/null
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicFactories.java
@@ -0,0 +1,43 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * Copyright (C) 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.common.endpoints.event.comm.bus;
+
+import lombok.Getter;
+
+public class UebTopicFactories {
+
+ /**
+ * Factory for instantiation and management of sinks.
+ */
+ @Getter
+ private static final UebTopicSinkFactory sinkFactory = new IndexedUebTopicSinkFactory();
+
+ /**
+ * Factory for instantiation and management of sources.
+ */
+ @Getter
+ private static final UebTopicSourceFactory sourceFactory = new IndexedUebTopicSourceFactory();
+
+
+ private UebTopicFactories() {
+ // do nothing
+ }
+}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSink.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSink.java
index bc1251d5..acfef6da 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSink.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSink.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* policy-endpoints
* ================================================================================
- * Copyright (C) 2017 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.
* 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.
@@ -25,8 +25,4 @@ package org.onap.policy.common.endpoints.event.comm.bus;
*/
public interface UebTopicSink extends BusTopicSink {
- /**
- * Factory of UEB Topic Sinks for instantiation and management purposes.
- */
- public static final UebTopicSinkFactory factory = new IndexedUebTopicSinkFactory();
}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSource.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSource.java
index ee4f013b..56534309 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSource.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSource.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* policy-endpoints
* ================================================================================
- * Copyright (C) 2017 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.
* 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.
@@ -26,8 +26,4 @@ package org.onap.policy.common.endpoints.event.comm.bus;
*/
public interface UebTopicSource extends BusTopicSource {
- /**
- * factory for managing and tracking UEB readers.
- */
- public static UebTopicSourceFactory factory = new IndexedUebTopicSourceFactory();
}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumer.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumer.java
index abf793d6..b66b4ba5 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumer.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumer.java
@@ -24,7 +24,6 @@ package org.onap.policy.common.endpoints.event.comm.bus.internal;
import com.att.nsa.cambria.client.CambriaClientBuilders;
import com.att.nsa.cambria.client.CambriaClientBuilders.ConsumerBuilder;
import com.att.nsa.cambria.client.CambriaConsumer;
-
import java.io.IOException;
import java.net.MalformedURLException;
import java.security.GeneralSecurityException;
@@ -38,7 +37,6 @@ import org.onap.dmaap.mr.client.MRClientFactory;
import org.onap.dmaap.mr.client.impl.MRConsumerImpl;
import org.onap.dmaap.mr.client.response.MRConsumerResponse;
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.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -52,9 +50,9 @@ public interface BusConsumer {
* fetch messages.
*
* @return list of messages
- * @throws Exception when error encountered by underlying libraries
+ * @throws IOException when error encountered by underlying libraries
*/
- public Iterable<String> fetch() throws InterruptedException, IOException;
+ public Iterable<String> fetch() throws IOException;
/**
* close underlying library consumer.
@@ -168,16 +166,24 @@ public interface BusConsumer {
}
@Override
- public Iterable<String> fetch() throws IOException, InterruptedException {
+ public Iterable<String> fetch() throws IOException {
try {
return getCurrentConsumer().fetch();
} catch (final IOException e) {
logger.error("{}: cannot fetch because of {} - backoff for {} ms.", this, e.getMessage(),
- this.fetchTimeout, e);
+ this.fetchTimeout);
+ sleepAfterFetchFailure();
+ throw e;
+ }
+ }
+ private void sleepAfterFetchFailure() {
+ try {
this.closeCondition.await(this.fetchTimeout, TimeUnit.MILLISECONDS);
- throw e;
+ } catch (InterruptedException e) {
+ logger.warn("{}: interrupted while handling fetch error", this, e);
+ Thread.currentThread().interrupt();
}
}
@@ -306,12 +312,12 @@ public interface BusConsumer {
}
@Override
- public Iterable<String> fetch() throws InterruptedException, IOException {
+ public Iterable<String> fetch() throws IOException {
final MRConsumerResponse response = this.consumer.fetchWithReturnConsumerResponse();
if (response == null) {
logger.warn("{}: DMaaP NULL response received", this);
- closeCondition.await(fetchTimeout, TimeUnit.MILLISECONDS);
+ sleepAfterFetchFailure();
return new ArrayList<>();
} else {
logger.debug("DMaaP consumer received {} : {}", response.getResponseCode(),
@@ -322,7 +328,7 @@ public interface BusConsumer {
logger.error("DMaaP consumer received: {} : {}", response.getResponseCode(),
response.getResponseMessage());
- closeCondition.await(fetchTimeout, TimeUnit.MILLISECONDS);
+ sleepAfterFetchFailure();
/* fall through */
}
@@ -335,6 +341,16 @@ public interface BusConsumer {
}
}
+ private void sleepAfterFetchFailure() {
+ try {
+ this.closeCondition.await(this.fetchTimeout, TimeUnit.MILLISECONDS);
+
+ } catch (InterruptedException e) {
+ logger.warn("{}: interrupted while handling fetch error", this, e);
+ Thread.currentThread().interrupt();
+ }
+ }
+
@Override
public void close() {
this.closeCondition.countDown();
@@ -434,7 +450,8 @@ public interface BusConsumer {
final String dme2RouteOffer = (busTopicParams.isAdditionalPropsValid()
- ? busTopicParams.getAdditionalProps().get(DmaapTopicSinkFactory.DME2_ROUTE_OFFER_PROPERTY)
+ ? busTopicParams.getAdditionalProps().get(
+ PolicyEndPointProperties.DME2_ROUTE_OFFER_PROPERTY)
: null);
if (busTopicParams.isEnvironmentInvalid()) {
@@ -474,7 +491,7 @@ public interface BusConsumer {
props = new Properties();
- props.setProperty(DmaapTopicSinkFactory.DME2_SERVICE_NAME_PROPERTY, serviceName);
+ props.setProperty(PolicyEndPointProperties.DME2_SERVICE_NAME_PROPERTY, serviceName);
props.setProperty("username", busTopicParams.getUserName());
props.setProperty("password", busTopicParams.getPassword());
@@ -489,7 +506,7 @@ public interface BusConsumer {
props.setProperty("Partner", busTopicParams.getPartner());
}
if (dme2RouteOffer != null) {
- props.setProperty(DmaapTopicSinkFactory.DME2_ROUTE_OFFER_PROPERTY, dme2RouteOffer);
+ props.setProperty(PolicyEndPointProperties.DME2_ROUTE_OFFER_PROPERTY, dme2RouteOffer);
}
props.setProperty("Latitude", busTopicParams.getLatitude());
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 67adf3b4..469794c7 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
@@ -26,7 +26,6 @@ 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;
@@ -34,12 +33,10 @@ import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
-
import org.apache.commons.lang3.StringUtils;
import org.onap.dmaap.mr.client.impl.MRSimplerBatchPublisher;
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;
@@ -299,7 +296,8 @@ public interface BusPublisher {
busTopicParams.getUserName(),busTopicParams.getPassword(),busTopicParams.isUseHttps());
String dme2RouteOffer = busTopicParams.isAdditionalPropsValid()
- ? busTopicParams.getAdditionalProps().get(DmaapTopicSinkFactory.DME2_ROUTE_OFFER_PROPERTY)
+ ? busTopicParams.getAdditionalProps().get(
+ PolicyEndPointProperties.DME2_ROUTE_OFFER_PROPERTY)
: null;
validateParams(busTopicParams, dme2RouteOffer);
@@ -310,13 +308,13 @@ public interface BusPublisher {
props.setProperty("Environment", busTopicParams.getEnvironment());
props.setProperty("AFT_ENVIRONMENT", busTopicParams.getAftEnvironment());
- props.setProperty(DmaapTopicSinkFactory.DME2_SERVICE_NAME_PROPERTY, serviceName);
+ props.setProperty(PolicyEndPointProperties.DME2_SERVICE_NAME_PROPERTY, serviceName);
if (busTopicParams.getPartner() != null) {
props.setProperty("Partner", busTopicParams.getPartner());
}
if (dme2RouteOffer != null) {
- props.setProperty(DmaapTopicSinkFactory.DME2_ROUTE_OFFER_PROPERTY, dme2RouteOffer);
+ props.setProperty(PolicyEndPointProperties.DME2_ROUTE_OFFER_PROPERTY, dme2RouteOffer);
}
props.setProperty("Latitude", busTopicParams.getLatitude());
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSource.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSource.java
index 0953465b..164f2b16 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSource.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSource.java
@@ -29,6 +29,7 @@ import org.onap.policy.common.endpoints.event.comm.FilterableTopicSource;
import org.onap.policy.common.endpoints.event.comm.TopicListener;
import org.onap.policy.common.endpoints.event.comm.bus.BusTopicSource;
import org.onap.policy.common.endpoints.event.comm.bus.internal.BusConsumer.FilterableBusConsumer;
+import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
import org.onap.policy.common.endpoints.utils.NetLoggerUtil;
import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType;
import org.onap.policy.common.utils.network.NetworkUtil;
@@ -103,13 +104,13 @@ public abstract class SingleThreadedBusTopicSource extends BusTopicBase
}
if (busTopicParams.getFetchTimeout() <= 0) {
- this.fetchTimeout = NO_TIMEOUT_MS_FETCH;
+ this.fetchTimeout = PolicyEndPointProperties.NO_TIMEOUT_MS_FETCH;
} else {
this.fetchTimeout = busTopicParams.getFetchTimeout();
}
if (busTopicParams.getFetchLimit() <= 0) {
- this.fetchLimit = NO_LIMIT_FETCH;
+ this.fetchLimit = PolicyEndPointProperties.NO_LIMIT_FETCH;
} else {
this.fetchLimit = busTopicParams.getFetchLimit();
}
@@ -225,7 +226,7 @@ public abstract class SingleThreadedBusTopicSource extends BusTopicBase
while (this.alive) {
try {
fetchAllMessages();
- } catch (Exception e) {
+ } catch (IOException | RuntimeException e) {
logger.error("{}: cannot fetch because of ", this, e.getMessage(), e);
}
}
@@ -233,7 +234,7 @@ public abstract class SingleThreadedBusTopicSource extends BusTopicBase
logger.info("{}: exiting thread", this);
}
- private void fetchAllMessages() throws InterruptedException, IOException {
+ private void fetchAllMessages() throws IOException {
for (String event : this.consumer.fetch()) {
synchronized (this) {
this.recentEvents.add(event);
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/client/TopicSinkClient.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/client/TopicSinkClient.java
index f08a1381..9f8b3c06 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/client/TopicSinkClient.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/client/TopicSinkClient.java
@@ -24,7 +24,7 @@ package org.onap.policy.common.endpoints.event.comm.client;
import java.util.List;
import lombok.Getter;
import lombok.NonNull;
-import org.onap.policy.common.endpoints.event.comm.TopicEndpoint;
+import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
import org.onap.policy.common.endpoints.event.comm.TopicSink;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
@@ -109,6 +109,6 @@ public class TopicSinkClient {
* @return the sinks for the topic
*/
protected List<TopicSink> getTopicSinks(final String topic) {
- return TopicEndpoint.manager.getTopicSinks(topic);
+ return TopicEndpointManager.getManager().getTopicSinks(topic);
}
}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/features/NetLoggerFeatureApi.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/features/NetLoggerFeatureApi.java
index 4e7d4444..a99ecd26 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/features/NetLoggerFeatureApi.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/features/NetLoggerFeatureApi.java
@@ -23,7 +23,6 @@ package org.onap.policy.common.endpoints.features;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType;
import org.onap.policy.common.utils.services.OrderedService;
-import org.onap.policy.common.utils.services.OrderedServiceImpl;
import org.slf4j.Logger;
/**
@@ -32,12 +31,6 @@ import org.slf4j.Logger;
public interface NetLoggerFeatureApi extends OrderedService {
/**
- * Feature providers implementing this interface.
- */
- OrderedServiceImpl<NetLoggerFeatureApi> providers =
- new OrderedServiceImpl<>(NetLoggerFeatureApi.class);
-
- /**
* Intercepts a message before it is logged.
*
* @return true if this feature intercepts and takes ownership of the operation
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/features/NetLoggerFeatureProviders.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/features/NetLoggerFeatureProviders.java
new file mode 100644
index 00000000..db2b05d1
--- /dev/null
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/features/NetLoggerFeatureProviders.java
@@ -0,0 +1,41 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * Copyright (C) 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.common.endpoints.features;
+
+import lombok.Getter;
+import org.onap.policy.common.utils.services.OrderedServiceImpl;
+
+/**
+ * Providers for network logging feature.
+ */
+public class NetLoggerFeatureProviders {
+
+ /**
+ * Feature providers implementing this interface.
+ */
+ @Getter
+ private static OrderedServiceImpl<NetLoggerFeatureApi> providers =
+ new OrderedServiceImpl<>(NetLoggerFeatureApi.class);
+
+ private NetLoggerFeatureProviders() {
+ // do nothing
+ }
+}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClient.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClient.java
index 2e3b9afb..2fe46fb3 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClient.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClient.java
@@ -7,9 +7,9 @@
* 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.
@@ -33,11 +33,6 @@ import org.onap.policy.common.capabilities.Startable;
public interface HttpClient extends Startable {
/**
- * Factory.
- */
- HttpClientFactory factory = new IndexedHttpClientFactory();
-
- /**
* GET request.
*
* @param path context uri path.
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientConfigException.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientConfigException.java
new file mode 100644
index 00000000..98ec576f
--- /dev/null
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientConfigException.java
@@ -0,0 +1,44 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * Copyright (C) 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.common.endpoints.http.client;
+
+/**
+ * Exception generated by HttpClient builder.
+ */
+public class HttpClientConfigException extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ public HttpClientConfigException() {
+ super();
+ }
+
+ public HttpClientConfigException(String message) {
+ super(message);
+ }
+
+ public HttpClientConfigException(Throwable cause) {
+ super(cause);
+ }
+
+ public HttpClientConfigException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientFactory.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientFactory.java
index 5f4c4c9d..b155f729 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientFactory.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientFactory.java
@@ -8,9 +8,9 @@
* 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.
@@ -21,8 +21,6 @@
package org.onap.policy.common.endpoints.http.client;
-import java.security.KeyManagementException;
-import java.security.NoSuchAlgorithmException;
import java.util.List;
import java.util.Properties;
import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
@@ -35,17 +33,16 @@ public interface HttpClientFactory {
/**
* Build and http client with the following parameters.
*/
- HttpClient build(BusTopicParams busTopicParams)
- throws KeyManagementException, NoSuchAlgorithmException, ClassNotFoundException;
+ HttpClient build(BusTopicParams busTopicParams) throws HttpClientConfigException;
/**
* Build http client from properties.
*/
- List<HttpClient> build(Properties properties) throws KeyManagementException, NoSuchAlgorithmException;
+ List<HttpClient> build(Properties properties) throws HttpClientConfigException;
/**
* Get http client.
- *
+ *
* @param name the name
* @return the http client
*/
@@ -53,14 +50,14 @@ public interface HttpClientFactory {
/**
* List of http clients.
- *
+ *
* @return http clients
*/
List<HttpClient> inventory();
/**
* Destroy by name.
- *
+ *
* @param name name
*/
void destroy(String name);
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientFactoryInstance.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientFactoryInstance.java
new file mode 100644
index 00000000..c2921640
--- /dev/null
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientFactoryInstance.java
@@ -0,0 +1,37 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * Copyright (C) 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.common.endpoints.http.client;
+
+import lombok.Getter;
+
+public class HttpClientFactoryInstance {
+
+ /**
+ * The client factory.
+ */
+ @Getter
+ private static final HttpClientFactory clientFactory = new IndexedHttpClientFactory();
+
+
+ private HttpClientFactoryInstance() {
+ // do nothing
+ }
+}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/IndexedHttpClientFactory.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/IndexedHttpClientFactory.java
index c2d0e400..edf8ff6f 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/IndexedHttpClientFactory.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/IndexedHttpClientFactory.java
@@ -47,14 +47,17 @@ class IndexedHttpClientFactory implements HttpClientFactory {
protected HashMap<String, HttpClient> clients = new HashMap<>();
@Override
- public synchronized HttpClient build(BusTopicParams busTopicParams)
- throws KeyManagementException, NoSuchAlgorithmException, ClassNotFoundException {
+ public synchronized HttpClient build(BusTopicParams busTopicParams) throws HttpClientConfigException {
if (clients.containsKey(busTopicParams.getClientName())) {
return clients.get(busTopicParams.getClientName());
}
- JerseyClient client =
- new JerseyClient(busTopicParams);
+ JerseyClient client;
+ try {
+ client = new JerseyClient(busTopicParams);
+ } catch (KeyManagementException | NoSuchAlgorithmException | ClassNotFoundException e) {
+ throw new HttpClientConfigException(e);
+ }
if (busTopicParams.isManaged()) {
clients.put(busTopicParams.getClientName(), client);
@@ -64,8 +67,7 @@ class IndexedHttpClientFactory implements HttpClientFactory {
}
@Override
- public synchronized List<HttpClient> build(Properties properties)
- throws KeyManagementException, NoSuchAlgorithmException {
+ public synchronized List<HttpClient> build(Properties properties) throws HttpClientConfigException {
ArrayList<HttpClient> clientList = new ArrayList<>();
String clientNames = properties.getProperty(PolicyEndPointProperties.PROPERTY_HTTP_CLIENT_SERVICES);
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/HttpServletServer.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/HttpServletServer.java
index b674e265..73b1e544 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/HttpServletServer.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/HttpServletServer.java
@@ -7,9 +7,9 @@
* 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.
@@ -27,22 +27,16 @@ import org.onap.policy.common.capabilities.Startable;
*/
public interface HttpServletServer extends Startable {
-
- /**
- * Factory of Http Servlet Servers.
- */
- HttpServletServerFactory factory = new IndexedHttpServletServerFactory();
-
/**
* Get the port.
- *
+ *
* @return port
*/
int getPort();
/**
* Enables basic authentication with user and password on the the relative path relativeUriPath.
- *
+ *
* @param user user
* @param password password
* @param relativeUriPath relative path
@@ -63,7 +57,7 @@ public interface HttpServletServer extends Startable {
/**
* Sets the serialization provider to be used when classes are added to the service.
- *
+ *
* @param provider the provider to use for message serialization and de-serialization
*/
void setSerializationProvider(String provider);
@@ -78,10 +72,10 @@ public interface HttpServletServer extends Startable {
/**
* Adds a JAX-RS servlet class to serve REST requests.
- *
+ *
* @param servletPath servlet path
* @param restClass JAX-RS API Class
- *
+ *
* @throws IllegalArgumentException unable to process because of invalid input
* @throws IllegalStateException unable to process because of invalid state
*/
@@ -89,10 +83,10 @@ public interface HttpServletServer extends Startable {
/**
* Adds a package containing JAX-RS classes to serve REST requests.
- *
+ *
* @param servletPath servlet path
* @param restPackage JAX-RS package to scan
- *
+ *
* @throws IllegalArgumentException unable to process because of invalid input
* @throws IllegalStateException unable to process because of invalid state
*/
@@ -100,10 +94,10 @@ public interface HttpServletServer extends Startable {
/**
* Blocking start of the http server.
- *
+ *
* @param maxWaitTime max time to wait for the start to take place
* @return true if start was successful
- *
+ *
* @throws IllegalArgumentException if arguments are invalid
* @throws InterruptedException if the blocking operation is interrupted
*/
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/HttpServletServerFactoryInstance.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/HttpServletServerFactoryInstance.java
new file mode 100644
index 00000000..a56be701
--- /dev/null
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/HttpServletServerFactoryInstance.java
@@ -0,0 +1,38 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * Copyright (C) 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.common.endpoints.http.server;
+
+import lombok.Getter;
+
+public class HttpServletServerFactoryInstance {
+
+ /**
+ * The servlet factory.
+ */
+ @Getter
+ private static final HttpServletServerFactory serverFactory = new IndexedHttpServletServerFactory();
+
+
+ private HttpServletServerFactoryInstance() {
+ // do nothing
+ }
+
+}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/properties/PolicyEndPointProperties.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/properties/PolicyEndPointProperties.java
index 0d59fd2f..ed300422 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/properties/PolicyEndPointProperties.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/properties/PolicyEndPointProperties.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,86 +20,134 @@
package org.onap.policy.common.endpoints.properties;
-public interface PolicyEndPointProperties {
+public class PolicyEndPointProperties {
/* Generic property suffixes */
- String PROPERTY_TOPIC_SERVERS_SUFFIX = ".servers";
- String PROPERTY_TOPIC_TOPICS_SUFFIX = ".topics";
- String PROPERTY_TOPIC_API_KEY_SUFFIX = ".apiKey";
- String PROPERTY_TOPIC_API_SECRET_SUFFIX = ".apiSecret";
- String PROPERTY_TOPIC_AAF_MECHID_SUFFIX = ".aafMechId";
- String PROPERTY_TOPIC_AAF_PASSWORD_SUFFIX = ".aafPassword";
- String PROPERTY_TOPIC_EFFECTIVE_TOPIC_SUFFIX = ".effectiveTopic";
- String PROPERTY_TOPIC_EVENTS_SUFFIX = ".events";
- String PROPERTY_TOPIC_EVENTS_FILTER_SUFFIX = ".filter";
- String PROPERTY_TOPIC_EVENTS_CUSTOM_MODEL_CODER_GSON_SUFFIX = ".events.custom.gson";
+ public static final String PROPERTY_TOPIC_SERVERS_SUFFIX = ".servers";
+ public static final String PROPERTY_TOPIC_TOPICS_SUFFIX = ".topics";
+ public static final String PROPERTY_TOPIC_API_KEY_SUFFIX = ".apiKey";
+ public static final String PROPERTY_TOPIC_API_SECRET_SUFFIX = ".apiSecret";
+ public static final String PROPERTY_TOPIC_AAF_MECHID_SUFFIX = ".aafMechId";
+ public static final String PROPERTY_TOPIC_AAF_PASSWORD_SUFFIX = ".aafPassword";
+ public static final String PROPERTY_TOPIC_EFFECTIVE_TOPIC_SUFFIX = ".effectiveTopic";
+ public static final String PROPERTY_TOPIC_EVENTS_SUFFIX = ".events";
+ public static final String PROPERTY_TOPIC_EVENTS_FILTER_SUFFIX = ".filter";
+ public static final String PROPERTY_TOPIC_EVENTS_CUSTOM_MODEL_CODER_GSON_SUFFIX = ".events.custom.gson";
- String PROPERTY_TOPIC_SOURCE_CONSUMER_GROUP_SUFFIX = ".consumerGroup";
- String PROPERTY_TOPIC_SOURCE_CONSUMER_INSTANCE_SUFFIX = ".consumerInstance";
- String PROPERTY_TOPIC_SOURCE_FETCH_TIMEOUT_SUFFIX = ".fetchTimeout";
- String PROPERTY_TOPIC_SOURCE_FETCH_LIMIT_SUFFIX = ".fetchLimit";
- String PROPERTY_MANAGED_SUFFIX = ".managed";
- String PROPERTY_AAF_SUFFIX = ".aaf";
+ public static final String PROPERTY_TOPIC_SOURCE_CONSUMER_GROUP_SUFFIX = ".consumerGroup";
+ public static final String PROPERTY_TOPIC_SOURCE_CONSUMER_INSTANCE_SUFFIX = ".consumerInstance";
+ public static final String PROPERTY_TOPIC_SOURCE_FETCH_TIMEOUT_SUFFIX = ".fetchTimeout";
+ public static final String PROPERTY_TOPIC_SOURCE_FETCH_LIMIT_SUFFIX = ".fetchLimit";
+ public static final String PROPERTY_MANAGED_SUFFIX = ".managed";
+ public static final String PROPERTY_AAF_SUFFIX = ".aaf";
- String PROPERTY_TOPIC_SINK_PARTITION_KEY_SUFFIX = ".partitionKey";
+ public static final String PROPERTY_TOPIC_SINK_PARTITION_KEY_SUFFIX = ".partitionKey";
- String PROPERTY_ALLOW_SELF_SIGNED_CERTIFICATES_SUFFIX = ".selfSignedCertificates";
+ public static final String PROPERTY_ALLOW_SELF_SIGNED_CERTIFICATES_SUFFIX = ".selfSignedCertificates";
/* UEB Properties */
- String PROPERTY_UEB_SOURCE_TOPICS = "ueb.source.topics";
- String PROPERTY_UEB_SINK_TOPICS = "ueb.sink.topics";
+ public static final String PROPERTY_UEB_SOURCE_TOPICS = "ueb.source.topics";
+ public static final String PROPERTY_UEB_SINK_TOPICS = "ueb.sink.topics";
/* DMAAP Properties */
- String PROPERTY_DMAAP_SOURCE_TOPICS = "dmaap.source.topics";
- String PROPERTY_DMAAP_SINK_TOPICS = "dmaap.sink.topics";
-
- String PROPERTY_DMAAP_DME2_PARTNER_SUFFIX = ".dme2.partner";
- String PROPERTY_DMAAP_DME2_ROUTE_OFFER_SUFFIX = ".dme2.routeOffer";
- String PROPERTY_DMAAP_DME2_ENVIRONMENT_SUFFIX = ".dme2.environment";
- String PROPERTY_DMAAP_DME2_AFT_ENVIRONMENT_SUFFIX = ".dme2.aft.environment";
- String PROPERTY_DMAAP_DME2_LATITUDE_SUFFIX = ".dme2.latitude";
- String PROPERTY_DMAAP_DME2_LONGITUDE_SUFFIX = ".dme2.longitude";
-
- String PROPERTY_DMAAP_DME2_EP_READ_TIMEOUT_MS_SUFFIX = ".dme2.epReadTimeoutMs";
- String PROPERTY_DMAAP_DME2_EP_CONN_TIMEOUT_SUFFIX = ".dme2.epConnTimeout";
- String PROPERTY_DMAAP_DME2_ROUNDTRIP_TIMEOUT_MS_SUFFIX = ".dme2.roundtripTimeoutMs";
- String PROPERTY_DMAAP_DME2_VERSION_SUFFIX = ".dme2.version";
- String PROPERTY_DMAAP_DME2_SERVICE_NAME_SUFFIX = ".dme2.serviceName";
- String PROPERTY_DMAAP_DME2_SUB_CONTEXT_PATH_SUFFIX = ".dme2.subContextPath";
- String PROPERTY_DMAAP_DME2_SESSION_STICKINESS_REQUIRED_SUFFIX =
+ public static final String PROPERTY_DMAAP_SOURCE_TOPICS = "dmaap.source.topics";
+ public static final String PROPERTY_DMAAP_SINK_TOPICS = "dmaap.sink.topics";
+
+ public static final String PROPERTY_DMAAP_DME2_PARTNER_SUFFIX = ".dme2.partner";
+ public static final String PROPERTY_DMAAP_DME2_ROUTE_OFFER_SUFFIX = ".dme2.routeOffer";
+ public static final String PROPERTY_DMAAP_DME2_ENVIRONMENT_SUFFIX = ".dme2.environment";
+ public static final String PROPERTY_DMAAP_DME2_AFT_ENVIRONMENT_SUFFIX = ".dme2.aft.environment";
+ public static final String PROPERTY_DMAAP_DME2_LATITUDE_SUFFIX = ".dme2.latitude";
+ public static final String PROPERTY_DMAAP_DME2_LONGITUDE_SUFFIX = ".dme2.longitude";
+
+ public static final String PROPERTY_DMAAP_DME2_EP_READ_TIMEOUT_MS_SUFFIX = ".dme2.epReadTimeoutMs";
+ public static final String PROPERTY_DMAAP_DME2_EP_CONN_TIMEOUT_SUFFIX = ".dme2.epConnTimeout";
+ public static final String PROPERTY_DMAAP_DME2_ROUNDTRIP_TIMEOUT_MS_SUFFIX = ".dme2.roundtripTimeoutMs";
+ public static final String PROPERTY_DMAAP_DME2_VERSION_SUFFIX = ".dme2.version";
+ public static final String PROPERTY_DMAAP_DME2_SERVICE_NAME_SUFFIX = ".dme2.serviceName";
+ public static final String PROPERTY_DMAAP_DME2_SUB_CONTEXT_PATH_SUFFIX = ".dme2.subContextPath";
+ public static final String PROPERTY_DMAAP_DME2_SESSION_STICKINESS_REQUIRED_SUFFIX =
".dme2.sessionStickinessRequired";
- String PROPERTY_NOOP_SOURCE_TOPICS = "noop.source.topics";
- String PROPERTY_NOOP_SINK_TOPICS = "noop.sink.topics";
+ public static final String PROPERTY_NOOP_SOURCE_TOPICS = "noop.source.topics";
+ public static final String PROPERTY_NOOP_SINK_TOPICS = "noop.sink.topics";
/* HTTP Server Properties */
- String PROPERTY_HTTP_SERVER_SERVICES = "http.server.services";
+ public static final String PROPERTY_HTTP_SERVER_SERVICES = "http.server.services";
- String PROPERTY_HTTP_HOST_SUFFIX = ".host";
- String PROPERTY_HTTP_PORT_SUFFIX = ".port";
- String PROPERTY_HTTP_CONTEXT_URIPATH_SUFFIX = ".contextUriPath";
+ public static final String PROPERTY_HTTP_HOST_SUFFIX = ".host";
+ public static final String PROPERTY_HTTP_PORT_SUFFIX = ".port";
+ public static final String PROPERTY_HTTP_CONTEXT_URIPATH_SUFFIX = ".contextUriPath";
- String PROPERTY_HTTP_AUTH_USERNAME_SUFFIX = ".userName";
- String PROPERTY_HTTP_AUTH_PASSWORD_SUFFIX = ".password";
- String PROPERTY_HTTP_AUTH_URIPATH_SUFFIX = ".authUriPath";
+ public static final String PROPERTY_HTTP_AUTH_USERNAME_SUFFIX = ".userName";
+ public static final String PROPERTY_HTTP_AUTH_PASSWORD_SUFFIX = ".password";
+ public static final String PROPERTY_HTTP_AUTH_URIPATH_SUFFIX = ".authUriPath";
- String PROPERTY_HTTP_FILTER_CLASSES_SUFFIX = ".filterClasses";
- String PROPERTY_HTTP_REST_CLASSES_SUFFIX = ".restClasses";
- String PROPERTY_HTTP_REST_PACKAGES_SUFFIX = ".restPackages";
- String PROPERTY_HTTP_REST_URIPATH_SUFFIX = ".restUriPath";
+ public static final String PROPERTY_HTTP_FILTER_CLASSES_SUFFIX = ".filterClasses";
+ public static final String PROPERTY_HTTP_REST_CLASSES_SUFFIX = ".restClasses";
+ public static final String PROPERTY_HTTP_REST_PACKAGES_SUFFIX = ".restPackages";
+ public static final String PROPERTY_HTTP_REST_URIPATH_SUFFIX = ".restUriPath";
- String PROPERTY_HTTP_HTTPS_SUFFIX = ".https";
- String PROPERTY_HTTP_SWAGGER_SUFFIX = ".swagger";
+ public static final String PROPERTY_HTTP_HTTPS_SUFFIX = ".https";
+ public static final String PROPERTY_HTTP_SWAGGER_SUFFIX = ".swagger";
- String PROPERTY_HTTP_SERIALIZATION_PROVIDER = ".serialization.provider";
+ public static final String PROPERTY_HTTP_SERIALIZATION_PROVIDER = ".serialization.provider";
/* HTTP Client Properties */
- String PROPERTY_HTTP_CLIENT_SERVICES = "http.client.services";
+ public static final String PROPERTY_HTTP_CLIENT_SERVICES = "http.client.services";
- String PROPERTY_HTTP_URL_SUFFIX = PROPERTY_HTTP_CONTEXT_URIPATH_SUFFIX;
+ public static final String PROPERTY_HTTP_URL_SUFFIX = PROPERTY_HTTP_CONTEXT_URIPATH_SUFFIX;
+
+
+ /* DMaaP DME2 Topic Properties */
+
+ public static final String DME2_READ_TIMEOUT_PROPERTY = "AFT_DME2_EP_READ_TIMEOUT_MS";
+ public static final String DME2_EP_CONN_TIMEOUT_PROPERTY = "AFT_DME2_EP_CONN_TIMEOUT";
+ public static final String DME2_ROUNDTRIP_TIMEOUT_PROPERTY = "AFT_DME2_ROUNDTRIP_TIMEOUT_MS";
+ public static final String DME2_VERSION_PROPERTY = "Version";
+ public static final String DME2_ROUTE_OFFER_PROPERTY = "routeOffer";
+ public static final String DME2_SERVICE_NAME_PROPERTY = "ServiceName";
+ public static final String DME2_SUBCONTEXT_PATH_PROPERTY = "SubContextPath";
+ public static final String DME2_SESSION_STICKINESS_REQUIRED_PROPERTY = "sessionstickinessrequired";
+
+
+ /* Topic Sink Values */
+
+ /**
+ * Log Failures after X number of retries.
+ */
+ public static final int DEFAULT_LOG_SEND_FAILURES_AFTER = 1;
+
+
+ /* Topic Source values */
+
+ /**
+ * Default Timeout fetching in milliseconds.
+ */
+ public static final int DEFAULT_TIMEOUT_MS_FETCH = 15000;
+
+ /**
+ * Default maximum number of messages fetch at the time.
+ */
+ public static final int DEFAULT_LIMIT_FETCH = 100;
+
+ /**
+ * Definition of No Timeout fetching.
+ */
+ public static final int NO_TIMEOUT_MS_FETCH = -1;
+
+ /**
+ * Definition of No limit fetching.
+ */
+ public static final int NO_LIMIT_FETCH = -1;
+
+
+ private PolicyEndPointProperties() {
+ // do nothing
+ }
}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/DmaapPropertyUtils.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/DmaapPropertyUtils.java
index 6b44e5c8..7e0d3ff6 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/DmaapPropertyUtils.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/DmaapPropertyUtils.java
@@ -27,7 +27,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
-import org.onap.policy.common.endpoints.event.comm.bus.DmaapTopicSourceFactory;
import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams.TopicParamsBuilder;
import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
@@ -43,25 +42,25 @@ public class DmaapPropertyUtils {
Map<String,String> map = new HashMap<>();
map.put(PolicyEndPointProperties.PROPERTY_DMAAP_DME2_ROUTE_OFFER_SUFFIX,
- DmaapTopicSourceFactory.DME2_ROUTE_OFFER_PROPERTY);
+ PolicyEndPointProperties.DME2_ROUTE_OFFER_PROPERTY);
map.put(PolicyEndPointProperties.PROPERTY_DMAAP_DME2_EP_READ_TIMEOUT_MS_SUFFIX,
- DmaapTopicSourceFactory.DME2_READ_TIMEOUT_PROPERTY);
+ PolicyEndPointProperties.DME2_READ_TIMEOUT_PROPERTY);
map.put(PolicyEndPointProperties.PROPERTY_DMAAP_DME2_EP_CONN_TIMEOUT_SUFFIX,
- DmaapTopicSourceFactory.DME2_EP_CONN_TIMEOUT_PROPERTY);
+ PolicyEndPointProperties.DME2_EP_CONN_TIMEOUT_PROPERTY);
map.put(PolicyEndPointProperties.PROPERTY_DMAAP_DME2_ROUNDTRIP_TIMEOUT_MS_SUFFIX,
- DmaapTopicSourceFactory.DME2_ROUNDTRIP_TIMEOUT_PROPERTY);
+ PolicyEndPointProperties.DME2_ROUNDTRIP_TIMEOUT_PROPERTY);
map.put(PolicyEndPointProperties.PROPERTY_DMAAP_DME2_VERSION_SUFFIX,
- DmaapTopicSourceFactory.DME2_VERSION_PROPERTY);
+ PolicyEndPointProperties.DME2_VERSION_PROPERTY);
map.put(PolicyEndPointProperties.PROPERTY_DMAAP_DME2_SUB_CONTEXT_PATH_SUFFIX,
- DmaapTopicSourceFactory.DME2_SUBCONTEXT_PATH_PROPERTY);
+ PolicyEndPointProperties.DME2_SUBCONTEXT_PATH_PROPERTY);
map.put(PolicyEndPointProperties.PROPERTY_DMAAP_DME2_SESSION_STICKINESS_REQUIRED_SUFFIX,
- DmaapTopicSourceFactory.DME2_SESSION_STICKINESS_REQUIRED_PROPERTY);
+ PolicyEndPointProperties.DME2_SESSION_STICKINESS_REQUIRED_PROPERTY);
PROP_TO_DME = Collections.unmodifiableMap(map);
}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/NetLoggerUtil.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/NetLoggerUtil.java
index f82e6a8c..d8f48a26 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/NetLoggerUtil.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/NetLoggerUtil.java
@@ -22,6 +22,7 @@ package org.onap.policy.common.endpoints.utils;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.features.NetLoggerFeatureApi;
+import org.onap.policy.common.endpoints.features.NetLoggerFeatureProviders;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -110,7 +111,7 @@ public class NetLoggerUtil {
*/
private static boolean featureBeforeLog(Logger eventLogger, EventType type, CommInfrastructure protocol,
String topic, String message) {
- for (NetLoggerFeatureApi feature : NetLoggerFeatureApi.providers.getList()) {
+ for (NetLoggerFeatureApi feature : NetLoggerFeatureProviders.getProviders().getList()) {
try {
if (feature.beforeLog(eventLogger, type, protocol, topic, message)) {
return true;
@@ -137,7 +138,7 @@ public class NetLoggerUtil {
*/
private static boolean featureAfterLog(Logger eventLogger, EventType type, CommInfrastructure protocol,
String topic, String message) {
- for (NetLoggerFeatureApi feature : NetLoggerFeatureApi.providers.getList()) {
+ for (NetLoggerFeatureApi feature : NetLoggerFeatureProviders.getProviders().getList()) {
try {
if (feature.afterLog(eventLogger, type, protocol, topic, message)) {
return true;
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/ParameterUtils.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/ParameterUtils.java
index 40ce8fa5..cabfe58f 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/ParameterUtils.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/ParameterUtils.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 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.
@@ -32,7 +33,7 @@ import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
*
* @author Ajith Sreekumar (ajith.sreekumar@est.tech)
*/
-public abstract class ParameterUtils {
+public class ParameterUtils {
/**
* Private constructor used to prevent sub class instantiation.
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicFactoryTestBase.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicFactoryTestBase.java
index 67304f91..92d5a865 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicFactoryTestBase.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicFactoryTestBase.java
@@ -34,6 +34,7 @@ import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperti
import java.util.Map;
import org.onap.policy.common.endpoints.event.comm.Topic;
import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
+import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
/**
* Base class for DmaapTopicXxxFactory tests.
@@ -51,9 +52,9 @@ public abstract class DmaapTopicFactoryTestBase<T extends Topic> extends BusTopi
@Override
public void testBuildProperties() {
-
+
super.testBuildProperties();
-
+
// check properties specific to DMaaP/DME2
initFactory();
@@ -66,13 +67,13 @@ public abstract class DmaapTopicFactoryTestBase<T extends Topic> extends BusTopi
assertEquals(MY_PARTNER, params.getPartner());
Map<String, String> add = params.getAdditionalProps();
- assertEquals(MY_CONN_TIMEOUT, add.get(DmaapTopicSinkFactory.DME2_EP_CONN_TIMEOUT_PROPERTY));
- assertEquals(MY_READ_TIMEOUT, add.get(DmaapTopicSinkFactory.DME2_READ_TIMEOUT_PROPERTY));
- assertEquals(MY_ROUNDTRIP_TIMEOUT, add.get(DmaapTopicSinkFactory.DME2_ROUNDTRIP_TIMEOUT_PROPERTY));
- assertEquals(MY_ROUTE, add.get(DmaapTopicSinkFactory.DME2_ROUTE_OFFER_PROPERTY));
- assertEquals(MY_STICKINESS, add.get(DmaapTopicSinkFactory.DME2_SESSION_STICKINESS_REQUIRED_PROPERTY));
- assertEquals(MY_SUBCONTEXT, add.get(DmaapTopicSinkFactory.DME2_SUBCONTEXT_PATH_PROPERTY));
- assertEquals(MY_DME_VERSION, add.get(DmaapTopicSinkFactory.DME2_VERSION_PROPERTY));
+ assertEquals(MY_CONN_TIMEOUT, add.get(PolicyEndPointProperties.DME2_EP_CONN_TIMEOUT_PROPERTY));
+ assertEquals(MY_READ_TIMEOUT, add.get(PolicyEndPointProperties.DME2_READ_TIMEOUT_PROPERTY));
+ assertEquals(MY_ROUNDTRIP_TIMEOUT, add.get(PolicyEndPointProperties.DME2_ROUNDTRIP_TIMEOUT_PROPERTY));
+ assertEquals(MY_ROUTE, add.get(PolicyEndPointProperties.DME2_ROUTE_OFFER_PROPERTY));
+ assertEquals(MY_STICKINESS, add.get(PolicyEndPointProperties.DME2_SESSION_STICKINESS_REQUIRED_PROPERTY));
+ assertEquals(MY_SUBCONTEXT, add.get(PolicyEndPointProperties.DME2_SUBCONTEXT_PATH_PROPERTY));
+ assertEquals(MY_DME_VERSION, add.get(PolicyEndPointProperties.DME2_VERSION_PROPERTY));
}
@Override
@@ -81,23 +82,23 @@ public abstract class DmaapTopicFactoryTestBase<T extends Topic> extends BusTopi
// check "additional" properties
expectNullAddProp(PROPERTY_DMAAP_DME2_EP_CONN_TIMEOUT_SUFFIX,
- DmaapTopicSinkFactory.DME2_EP_CONN_TIMEOUT_PROPERTY);
+ PolicyEndPointProperties.DME2_EP_CONN_TIMEOUT_PROPERTY);
expectNullAddProp(PROPERTY_DMAAP_DME2_EP_READ_TIMEOUT_MS_SUFFIX,
- DmaapTopicSinkFactory.DME2_READ_TIMEOUT_PROPERTY);
+ PolicyEndPointProperties.DME2_READ_TIMEOUT_PROPERTY);
expectNullAddProp(PROPERTY_DMAAP_DME2_ROUNDTRIP_TIMEOUT_MS_SUFFIX,
- DmaapTopicSinkFactory.DME2_ROUNDTRIP_TIMEOUT_PROPERTY);
+ PolicyEndPointProperties.DME2_ROUNDTRIP_TIMEOUT_PROPERTY);
- expectNullAddProp(PROPERTY_DMAAP_DME2_ROUTE_OFFER_SUFFIX, DmaapTopicSinkFactory.DME2_ROUTE_OFFER_PROPERTY);
+ expectNullAddProp(PROPERTY_DMAAP_DME2_ROUTE_OFFER_SUFFIX, PolicyEndPointProperties.DME2_ROUTE_OFFER_PROPERTY);
expectNullAddProp(PROPERTY_DMAAP_DME2_SESSION_STICKINESS_REQUIRED_SUFFIX,
- DmaapTopicSinkFactory.DME2_SESSION_STICKINESS_REQUIRED_PROPERTY);
+ PolicyEndPointProperties.DME2_SESSION_STICKINESS_REQUIRED_PROPERTY);
expectNullAddProp(PROPERTY_DMAAP_DME2_SUB_CONTEXT_PATH_SUFFIX,
- DmaapTopicSinkFactory.DME2_SUBCONTEXT_PATH_PROPERTY);
+ PolicyEndPointProperties.DME2_SUBCONTEXT_PATH_PROPERTY);
- expectNullAddProp(PROPERTY_DMAAP_DME2_VERSION_SUFFIX, DmaapTopicSinkFactory.DME2_VERSION_PROPERTY);
+ expectNullAddProp(PROPERTY_DMAAP_DME2_VERSION_SUFFIX, PolicyEndPointProperties.DME2_VERSION_PROPERTY);
}
@Override
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSinkTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSinkTest.java
index 52ba3e9e..9136108a 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSinkTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSinkTest.java
@@ -2,7 +2,7 @@
* ============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.
@@ -28,7 +28,7 @@ public class DmaapTopicSinkTest {
@Test
public void test() {
- assertNotNull(DmaapTopicSink.factory);
+ assertNotNull(DmaapTopicFactories.getSinkFactory());
}
}
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSourceFactoryTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSourceFactoryTest.java
index d6187420..b4c2f758 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSourceFactoryTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSourceFactoryTest.java
@@ -35,6 +35,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
+import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
public class DmaapTopicSourceFactoryTest extends DmaapTopicFactoryTestBase<DmaapTopicSource> {
@@ -80,11 +81,11 @@ public class DmaapTopicSourceFactoryTest extends DmaapTopicFactoryTestBase<Dmaap
// check default values for source-specific parameters
checkDefault(PROPERTY_TOPIC_SOURCE_FETCH_LIMIT_SUFFIX,
- params2 -> params2.getFetchLimit() == DmaapTopicSource.DEFAULT_LIMIT_FETCH,
+ params2 -> params2.getFetchLimit() == PolicyEndPointProperties.DEFAULT_LIMIT_FETCH,
null, "", "invalid-limit-number");
checkDefault(PROPERTY_TOPIC_SOURCE_FETCH_TIMEOUT_SUFFIX,
- params2 -> params2.getFetchTimeout() == DmaapTopicSource.DEFAULT_TIMEOUT_MS_FETCH,
+ params2 -> params2.getFetchTimeout() == PolicyEndPointProperties.DEFAULT_TIMEOUT_MS_FETCH,
null, "", "invalid-timeout-number");
}
@@ -97,8 +98,8 @@ public class DmaapTopicSourceFactoryTest extends DmaapTopicFactoryTestBase<Dmaap
BusTopicParams params = factory.params.getFirst();
assertEquals(MY_API_KEY, params.getApiKey());
assertEquals(MY_API_SECRET, params.getApiSecret());
- assertEquals(DmaapTopicSource.DEFAULT_LIMIT_FETCH, params.getFetchLimit());
- assertEquals(DmaapTopicSource.DEFAULT_TIMEOUT_MS_FETCH, params.getFetchTimeout());
+ assertEquals(PolicyEndPointProperties.DEFAULT_LIMIT_FETCH, params.getFetchLimit());
+ assertEquals(PolicyEndPointProperties.DEFAULT_TIMEOUT_MS_FETCH, params.getFetchTimeout());
}
@Test
@@ -110,8 +111,8 @@ public class DmaapTopicSourceFactoryTest extends DmaapTopicFactoryTestBase<Dmaap
BusTopicParams params = factory.params.getFirst();
assertEquals(null, params.getApiKey());
assertEquals(null, params.getApiSecret());
- assertEquals(DmaapTopicSource.DEFAULT_LIMIT_FETCH, params.getFetchLimit());
- assertEquals(DmaapTopicSource.DEFAULT_TIMEOUT_MS_FETCH, params.getFetchTimeout());
+ assertEquals(PolicyEndPointProperties.DEFAULT_LIMIT_FETCH, params.getFetchLimit());
+ assertEquals(PolicyEndPointProperties.DEFAULT_TIMEOUT_MS_FETCH, params.getFetchTimeout());
}
@Test
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSourceTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSourceTest.java
index 6828444a..1735e2ee 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSourceTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSourceTest.java
@@ -2,7 +2,7 @@
* ============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.
@@ -28,7 +28,7 @@ public class DmaapTopicSourceTest {
@Test
public void test() {
- assertNotNull(DmaapTopicSource.factory);
+ assertNotNull(DmaapTopicFactories.getSourceFactory());
}
}
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSinkTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSinkTest.java
index 3e7aca01..77452604 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSinkTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSinkTest.java
@@ -2,7 +2,7 @@
* ============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.
@@ -28,7 +28,7 @@ public class UebTopicSinkTest {
@Test
public void test() {
- assertNotNull(UebTopicSink.factory);
+ assertNotNull(UebTopicFactories.getSinkFactory());
}
}
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSourceFactoryTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSourceFactoryTest.java
index 468805de..81e30756 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSourceFactoryTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSourceFactoryTest.java
@@ -35,6 +35,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
+import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
public class UebTopicSourceFactoryTest extends UebTopicFactoryTestBase<UebTopicSource> {
@@ -81,11 +82,11 @@ public class UebTopicSourceFactoryTest extends UebTopicFactoryTestBase<UebTopicS
// check default values for source-specific parameters
checkDefault(PROPERTY_TOPIC_SOURCE_FETCH_LIMIT_SUFFIX,
- params2 -> params2.getFetchLimit() == UebTopicSource.DEFAULT_LIMIT_FETCH,
+ params2 -> params2.getFetchLimit() == PolicyEndPointProperties.DEFAULT_LIMIT_FETCH,
null, "", "invalid-limit-number");
checkDefault(PROPERTY_TOPIC_SOURCE_FETCH_TIMEOUT_SUFFIX,
- params2 -> params2.getFetchTimeout() == UebTopicSource.DEFAULT_TIMEOUT_MS_FETCH,
+ params2 -> params2.getFetchTimeout() == PolicyEndPointProperties.DEFAULT_TIMEOUT_MS_FETCH,
null, "", "invalid-timeout-number");
}
@@ -98,8 +99,8 @@ public class UebTopicSourceFactoryTest extends UebTopicFactoryTestBase<UebTopicS
BusTopicParams params = factory.params.getFirst();
assertEquals(MY_API_KEY, params.getApiKey());
assertEquals(MY_API_SECRET, params.getApiSecret());
- assertEquals(UebTopicSource.DEFAULT_LIMIT_FETCH, params.getFetchLimit());
- assertEquals(UebTopicSource.DEFAULT_TIMEOUT_MS_FETCH, params.getFetchTimeout());
+ assertEquals(PolicyEndPointProperties.DEFAULT_LIMIT_FETCH, params.getFetchLimit());
+ assertEquals(PolicyEndPointProperties.DEFAULT_TIMEOUT_MS_FETCH, params.getFetchTimeout());
}
@Test
@@ -111,8 +112,8 @@ public class UebTopicSourceFactoryTest extends UebTopicFactoryTestBase<UebTopicS
BusTopicParams params = factory.params.getFirst();
assertEquals(null, params.getApiKey());
assertEquals(null, params.getApiSecret());
- assertEquals(UebTopicSource.DEFAULT_LIMIT_FETCH, params.getFetchLimit());
- assertEquals(UebTopicSource.DEFAULT_TIMEOUT_MS_FETCH, params.getFetchTimeout());
+ assertEquals(PolicyEndPointProperties.DEFAULT_LIMIT_FETCH, params.getFetchLimit());
+ assertEquals(PolicyEndPointProperties.DEFAULT_TIMEOUT_MS_FETCH, params.getFetchTimeout());
assertEquals(true, params.isAllowSelfSignedCerts());
}
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSourceTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSourceTest.java
index 11bb3f4d..9ef8af84 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSourceTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSourceTest.java
@@ -2,7 +2,7 @@
* ============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.
@@ -28,7 +28,7 @@ public class UebTopicSourceTest {
@Test
public void test() {
- assertNotNull(UebTopicSource.factory);
+ assertNotNull(UebTopicFactories.getSourceFactory());
}
}
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumerTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumerTest.java
index a32083fa..0255c100 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumerTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumerTest.java
@@ -91,10 +91,6 @@ public class BusConsumerTest extends TopicTestBase {
} catch (IOException e) {
assertEquals(ex, e);
-
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- assertEquals(ex, e);
}
}
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/client/TopicSinkClientTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/client/TopicSinkClientTest.java
index 07630cd4..e30f38a7 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/client/TopicSinkClientTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/client/TopicSinkClientTest.java
@@ -38,7 +38,7 @@ import java.util.concurrent.atomic.AtomicReference;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
-import org.onap.policy.common.endpoints.event.comm.TopicEndpoint;
+import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
import org.onap.policy.common.endpoints.event.comm.TopicSink;
public class TopicSinkClientTest {
@@ -66,14 +66,14 @@ public class TopicSinkClientTest {
props.setProperty("noop.sink.topics", TOPIC);
// clear all topics and then configure one topic
- TopicEndpoint.manager.shutdown();
- TopicEndpoint.manager.addTopicSinks(props);
+ TopicEndpointManager.getManager().shutdown();
+ TopicEndpointManager.getManager().addTopicSinks(props);
}
@AfterClass
public static void tearDown() {
// clear all topics after the tests
- TopicEndpoint.manager.shutdown();
+ TopicEndpointManager.getManager().shutdown();
}
/**
@@ -82,7 +82,7 @@ public class TopicSinkClientTest {
@Test
public void testGetTopicSinks() throws Exception {
- sink = TopicEndpoint.manager.getNoopTopicSink(TOPIC);
+ sink = TopicEndpointManager.getManager().getNoopTopicSink(TOPIC);
assertNotNull(sink);
final AtomicReference<String> evref = new AtomicReference<>(null);
@@ -106,7 +106,7 @@ public class TopicSinkClientTest {
@Test
public void testTopicSinkClient_GetTopic() throws TopicSinkClientException {
- assertEquals(TOPIC, new TopicSinkClient(TopicEndpoint.manager.getNoopTopicSink(TOPIC)).getTopic());
+ assertEquals(TOPIC, new TopicSinkClient(TopicEndpointManager.getManager().getNoopTopicSink(TOPIC)).getTopic());
assertEquals(TOPIC, new TopicSinkClient(TOPIC).getTopic());
assertThatThrownBy(() -> new TopicSinkClient((TopicSink) null)).isInstanceOf(IllegalArgumentException.class);
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 f559b112..2aaf1367 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
@@ -25,8 +25,6 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-import java.security.KeyManagementException;
-import java.security.NoSuchAlgorithmException;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -40,7 +38,10 @@ import org.junit.BeforeClass;
import org.junit.Test;
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.endpoints.http.client.HttpClientConfigException;
+import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
import org.onap.policy.common.endpoints.http.server.HttpServletServer;
+import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
import org.onap.policy.common.endpoints.http.server.internal.JettyJerseyServer;
import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
import org.onap.policy.common.utils.network.NetworkUtil;
@@ -72,7 +73,7 @@ public class HttpClientTest {
/* echo server - http + no auth */
final HttpServletServer echoServerNoAuth =
- HttpServletServer.factory.build("echo", LOCALHOST, 6666, "/", false, true);
+ HttpServletServerFactoryInstance.getServerFactory().build("echo", LOCALHOST, 6666, "/", false, true);
echoServerNoAuth.addServletPackage("/*", HttpClientTest.class.getPackage().getName());
echoServerNoAuth.waitedStart(5000);
@@ -112,8 +113,8 @@ public class HttpClientTest {
/* echo server - https + basic auth */
- final HttpServletServer echoServerAuth =
- HttpServletServer.factory.build("echo", true, LOCALHOST, 6667, "/", false, true);
+ final HttpServletServer echoServerAuth = HttpServletServerFactoryInstance.getServerFactory()
+ .build("echo", true, LOCALHOST, 6667, "/", false, true);
echoServerAuth.setBasicAuthentication("x", "y", null);
echoServerAuth.addServletPackage("/*", HttpClientTest.class.getPackage().getName());
echoServerAuth.addFilterClass("/*", TestFilter.class.getName());
@@ -132,7 +133,7 @@ public class HttpClientTest {
*/
@Before
public void setUp() {
- HttpClient.factory.destroy();
+ HttpClientFactoryInstance.getClientFactory().destroy();
MyGsonProvider.resetSome();
MyJacksonProvider.resetSome();
@@ -143,8 +144,8 @@ public class HttpClientTest {
*/
@AfterClass
public static void tearDownAfterClass() {
- HttpServletServer.factory.destroy();
- HttpClient.factory.destroy();
+ HttpServletServerFactoryInstance.getServerFactory().destroy();
+ HttpClientFactoryInstance.getClientFactory().destroy();
if (savedValuesMap.containsKey(JettyJerseyServer.SYSTEM_KEYSTORE_PROPERTY_NAME)) {
System.setProperty(JettyJerseyServer.SYSTEM_KEYSTORE_PROPERTY_NAME,
@@ -254,10 +255,11 @@ public class HttpClientTest {
@Test
public void testHttpPutAuthClient_JacksonProvider() throws Exception {
- final HttpClient client = HttpClient.factory.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());
+ 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());
@@ -273,10 +275,11 @@ public class HttpClientTest {
@Test
public void testHttpPutAuthClient_GsonProvider() throws Exception {
- final HttpClient client = HttpClient.factory.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(MyGsonProvider.class.getName()).build());
+ 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(MyGsonProvider.class.getName()).build());
Entity<MyEntity> entity = Entity.entity(new MyEntity(MY_VALUE), MediaType.APPLICATION_JSON);
final Response response = client.put(HELLO, entity, Collections.emptyMap());
@@ -368,21 +371,22 @@ public class HttpClientTest {
httpProperties.setProperty(PolicyEndPointProperties.PROPERTY_HTTP_CLIENT_SERVICES + DOT_PDP
+ PolicyEndPointProperties.PROPERTY_MANAGED_SUFFIX, "true");
- final List<HttpServletServer> servers = HttpServletServer.factory.build(httpProperties);
+ final List<HttpServletServer> servers =
+ HttpServletServerFactoryInstance.getServerFactory().build(httpProperties);
assertEquals(2, servers.size());
- final List<HttpClient> clients = HttpClient.factory.build(httpProperties);
+ final List<HttpClient> clients = HttpClientFactoryInstance.getClientFactory().build(httpProperties);
assertEquals(2, clients.size());
for (final HttpServletServer server : servers) {
server.waitedStart(10000);
}
- final HttpClient clientPap = HttpClient.factory.get("PAP");
+ final HttpClient clientPap = HttpClientFactoryInstance.getClientFactory().get("PAP");
final Response response = clientPap.get();
assertEquals(200, response.getStatus());
- final HttpClient clientPdp = HttpClient.factory.get("PDP");
+ final HttpClient clientPdp = HttpClientFactoryInstance.getClientFactory().get("PDP");
final Response response2 = clientPdp.get("test");
assertEquals(500, response2.getStatus());
@@ -425,7 +429,7 @@ public class HttpClientTest {
+ PolicyEndPointProperties.PROPERTY_HTTP_SERIALIZATION_PROVIDER,
MyJacksonProvider.class.getName());
- final List<HttpClient> clients = HttpClient.factory.build(httpProperties);
+ final List<HttpClient> clients = HttpClientFactoryInstance.getClientFactory().build(httpProperties);
assertEquals(2, clients.size());
Entity<MyEntity> entity = Entity.entity(new MyEntity(MY_VALUE), MediaType.APPLICATION_JSON);
@@ -433,7 +437,7 @@ public class HttpClientTest {
// use gson client
MyGsonProvider.resetSome();
MyJacksonProvider.resetSome();
- HttpClient client = HttpClient.factory.get("GSON");
+ HttpClient client = HttpClientFactoryInstance.getClientFactory().get("GSON");
Response response = client.put(HELLO, entity, Collections.emptyMap());
String body = HttpClient.getBody(response, String.class);
@@ -447,7 +451,7 @@ public class HttpClientTest {
// use jackson client
MyGsonProvider.resetSome();
MyJacksonProvider.resetSome();
- client = HttpClient.factory.get("JACKSON");
+ client = HttpClientFactoryInstance.getClientFactory().get("JACKSON");
response = client.put(HELLO, entity, Collections.emptyMap());
body = HttpClient.getBody(response, String.class);
@@ -459,18 +463,19 @@ public class HttpClientTest {
assertFalse(MyGsonProvider.hasWrittenSome());
}
- private HttpClient getAuthHttpClient()
- throws KeyManagementException, NoSuchAlgorithmException, ClassNotFoundException {
- return HttpClient.factory.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).build());
+ private HttpClient getAuthHttpClient() throws HttpClientConfigException {
+ return 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).build());
}
private HttpClient getNoAuthHttpClient(String clientName, boolean https, int port)
- throws KeyManagementException, NoSuchAlgorithmException, ClassNotFoundException {
- return HttpClient.factory.build(BusTopicParams.builder().clientName(clientName)
- .useHttps(https).allowSelfSignedCerts(https).hostname(LOCALHOST).port(port).basePath(JUNIT_ECHO)
- .userName(null).password(null).managed(true).build());
+ throws HttpClientConfigException {
+ return HttpClientFactoryInstance.getClientFactory()
+ .build(BusTopicParams.builder().clientName(clientName).useHttps(https)
+ .allowSelfSignedCerts(https).hostname(LOCALHOST).port(port).basePath(JUNIT_ECHO)
+ .userName(null).password(null).managed(true).build());
}
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpExceptionsTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpExceptionsTest.java
new file mode 100644
index 00000000..85135759
--- /dev/null
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpExceptionsTest.java
@@ -0,0 +1,33 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * Copyright (C) 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.
+ * 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 org.junit.Test;
+import org.onap.policy.common.endpoints.http.client.HttpClientConfigException;
+import org.onap.policy.common.utils.test.ExceptionsTester;
+
+public class HttpExceptionsTest extends ExceptionsTester {
+
+ @Test
+ public void testHttpClientConfigException() {
+ test(HttpClientConfigException.class);
+ }
+}
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 c6ff2f32..f2b53648 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.endpoints.http.server.HttpServletServerFactoryInstance;
import org.onap.policy.common.utils.gson.GsonTestUtils;
import org.onap.policy.common.utils.network.NetworkUtil;
import org.slf4j.Logger;
@@ -79,7 +80,7 @@ public class HttpServerTest {
incrementPort();
portUrl = LOCALHOST_PREFIX + port;
- HttpServletServer.factory.destroy();
+ HttpServletServerFactoryInstance.getServerFactory().destroy();
MyJacksonProvider.resetSome();
MyGsonProvider.resetSome();
@@ -91,19 +92,20 @@ public class HttpServerTest {
@AfterClass
public static void tearDownAfterClass() {
- HttpServletServer.factory.destroy();
+ HttpServletServerFactoryInstance.getServerFactory().destroy();
}
@Test
public void testDefaultPackageServer() throws Exception {
logger.info("-- testDefaultPackageServer() --");
- HttpServletServer server = HttpServletServer.factory.build("echo", LOCALHOST, port, "/", false, true);
+ HttpServletServer server = HttpServletServerFactoryInstance.getServerFactory()
+ .build("echo", LOCALHOST, port, "/", false, true);
server.addServletPackage("/*", this.getClass().getPackage().getName());
server.addFilterClass("/*", TestFilter.class.getName());
server.waitedStart(5000);
- assertTrue(HttpServletServer.factory.get(port).isAlive());
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port).isAlive());
RestEchoReqResp request = new RestEchoReqResp();
request.setRequestId(100);
@@ -118,14 +120,15 @@ public class HttpServerTest {
public void testJacksonPackageServer() throws Exception {
logger.info("-- testJacksonPackageServer() --");
- HttpServletServer server = HttpServletServer.factory.build("echo", LOCALHOST, port, "/", false, true);
+ 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(HttpServletServer.factory.get(port).isAlive());
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port).isAlive());
RestEchoReqResp request = new RestEchoReqResp();
request.setRequestId(100);
@@ -146,14 +149,15 @@ public class HttpServerTest {
public void testGsonPackageServer() throws Exception {
logger.info("-- testGsonPackageServer() --");
- HttpServletServer server = HttpServletServer.factory.build("echo", LOCALHOST, port, "/", false, true);
+ HttpServletServer server = HttpServletServerFactoryInstance.getServerFactory()
+ .build("echo", LOCALHOST, port, "/", false, true);
server.setSerializationProvider(MyGsonProvider.class.getName());
server.addServletPackage("/*", this.getClass().getPackage().getName());
server.addFilterClass("/*", TestFilter.class.getName());
server.waitedStart(5000);
- assertTrue(HttpServletServer.factory.get(port).isAlive());
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port).isAlive());
RestEchoReqResp request = new RestEchoReqResp();
request.setRequestId(100);
@@ -174,12 +178,13 @@ public class HttpServerTest {
public void testDefaultClassServer() throws Exception {
logger.info("-- testDefaultClassServer() --");
- HttpServletServer server = HttpServletServer.factory.build("echo", LOCALHOST, port, "/", false, true);
+ HttpServletServer server = HttpServletServerFactoryInstance.getServerFactory()
+ .build("echo", LOCALHOST, port, "/", false, true);
server.addServletClass("/*", RestEchoService.class.getName());
server.addFilterClass("/*", TestFilter.class.getName());
server.waitedStart(5000);
- assertTrue(HttpServletServer.factory.get(port).isAlive());
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port).isAlive());
RestEchoReqResp request = new RestEchoReqResp();
request.setRequestId(100);
@@ -194,13 +199,14 @@ public class HttpServerTest {
public void testJacksonClassServer() throws Exception {
logger.info("-- testJacksonClassServer() --");
- HttpServletServer server = HttpServletServer.factory.build("echo", LOCALHOST, port, "/", false, true);
+ 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);
- assertTrue(HttpServletServer.factory.get(port).isAlive());
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port).isAlive());
RestEchoReqResp request = new RestEchoReqResp();
request.setRequestId(100);
@@ -221,13 +227,14 @@ public class HttpServerTest {
public void testGsonClassServer() throws Exception {
logger.info("-- testGsonClassServer() --");
- HttpServletServer server = HttpServletServer.factory.build("echo", LOCALHOST, port, "/", false, true);
+ HttpServletServer server = HttpServletServerFactoryInstance.getServerFactory()
+ .build("echo", LOCALHOST, port, "/", false, true);
server.setSerializationProvider(MyGsonProvider.class.getName());
server.addServletClass("/*", RestEchoService.class.getName());
server.addFilterClass("/*", TestFilter.class.getName());
server.waitedStart(5000);
- assertTrue(HttpServletServer.factory.get(port).isAlive());
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port).isAlive());
RestEchoReqResp request = new RestEchoReqResp();
request.setRequestId(100);
@@ -246,7 +253,8 @@ public class HttpServerTest {
@Test
public void testSerialize() {
- HttpServletServer server = HttpServletServer.factory.build("echo", LOCALHOST, port, "/", false, true);
+ HttpServletServer server = HttpServletServerFactoryInstance.getServerFactory()
+ .build("echo", LOCALHOST, port, "/", false, true);
server.addServletPackage("/*", this.getClass().getPackage().getName());
server.addFilterClass("/*", TestFilter.class.getName());
@@ -258,13 +266,14 @@ public class HttpServerTest {
public void testSingleServer() throws Exception {
logger.info("-- testSingleServer() --");
- HttpServletServer server = HttpServletServer.factory.build("echo", LOCALHOST, port, "/", false, true);
+ HttpServletServer server = HttpServletServerFactoryInstance.getServerFactory()
+ .build("echo", LOCALHOST, port, "/", false, true);
server.addServletPackage("/*", this.getClass().getPackage().getName());
server.addFilterClass("/*", TestFilter.class.getName());
server.waitedStart(5000);
- assertTrue(HttpServletServer.factory.get(port).isAlive());
- assertFalse(HttpServletServer.factory.get(port).isAaf());
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port).isAlive());
+ assertFalse(HttpServletServerFactoryInstance.getServerFactory().get(port).isAaf());
String response = http(portUrl + JUNIT_ECHO_HELLO);
assertEquals(HELLO, response);
@@ -274,32 +283,34 @@ public class HttpServerTest {
response = http(portUrl + "/junit/echo/hello?block=true");
assertEquals("FILTERED", response);
- assertTrue(HttpServletServer.factory.get(port).isAlive());
- assertEquals(1, HttpServletServer.factory.inventory().size());
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port).isAlive());
+ assertEquals(1, HttpServletServerFactoryInstance.getServerFactory().inventory().size());
server.setAafAuthentication("/*");
- assertTrue(HttpServletServer.factory.get(port).isAaf());
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port).isAaf());
- HttpServletServer.factory.destroy(port);
- assertEquals(0, HttpServletServer.factory.inventory().size());
+ HttpServletServerFactoryInstance.getServerFactory().destroy(port);
+ assertEquals(0, HttpServletServerFactoryInstance.getServerFactory().inventory().size());
}
@Test
public void testMultipleServers() throws Exception {
logger.info("-- testMultipleServers() --");
- HttpServletServer server1 = HttpServletServer.factory.build("echo-1", false,LOCALHOST, port, "/", true, true);
+ HttpServletServer server1 = HttpServletServerFactoryInstance.getServerFactory()
+ .build("echo-1", false,LOCALHOST, port, "/", true, true);
server1.addServletPackage("/*", this.getClass().getPackage().getName());
server1.waitedStart(5000);
int port2 = port + 1;
- HttpServletServer server2 = HttpServletServer.factory.build("echo-2", LOCALHOST, port2, "/", false, true);
+ HttpServletServer server2 = HttpServletServerFactoryInstance.getServerFactory()
+ .build("echo-2", LOCALHOST, port2, "/", false, true);
server2.addServletPackage("/*", this.getClass().getPackage().getName());
server2.waitedStart(5000);
- assertTrue(HttpServletServer.factory.get(port).isAlive());
- assertTrue(HttpServletServer.factory.get(port2).isAlive());
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port).isAlive());
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port2).isAlive());
String response = http(portUrl + JUNIT_ECHO_HELLO);
assertTrue(HELLO.equals(response));
@@ -312,8 +323,8 @@ public class HttpServerTest {
assertThatThrownBy(() -> http(LOCALHOST_PREFIX + port2 + SWAGGER_JSON)).isInstanceOf(IOException.class);
- HttpServletServer.factory.destroy();
- assertTrue(HttpServletServer.factory.inventory().isEmpty());
+ HttpServletServerFactoryInstance.getServerFactory().destroy();
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().inventory().isEmpty());
}
@Test
@@ -322,11 +333,12 @@ public class HttpServerTest {
String randomName = UUID.randomUUID().toString();
- HttpServletServer server = HttpServletServer.factory.build(randomName, LOCALHOST, port, "/", false, true);
+ HttpServletServer server = HttpServletServerFactoryInstance.getServerFactory()
+ .build(randomName, LOCALHOST, port, "/", false, true);
server.addServletPackage("/*", this.getClass().getPackage().getName());
server.waitedStart(5000);
- assertTrue(HttpServletServer.factory.get(port).isAlive());
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port).isAlive());
String response = http(portUrl + JUNIT_ECHO_HELLO);
assertTrue(HELLO.equals(response));
@@ -334,8 +346,8 @@ public class HttpServerTest {
response = http(portUrl + "/junit/endpoints/http/servers");
assertTrue(response.contains(randomName));
- HttpServletServer.factory.destroy();
- assertTrue(HttpServletServer.factory.inventory().isEmpty());
+ HttpServletServerFactoryInstance.getServerFactory().destroy();
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().inventory().isEmpty());
}
@Test
@@ -343,17 +355,18 @@ public class HttpServerTest {
logger.info("-- testServiceClass() --");
String randomName = UUID.randomUUID().toString();
- HttpServletServer server = HttpServletServer.factory.build(randomName, LOCALHOST, port, "/", false, true);
+ HttpServletServer server = HttpServletServerFactoryInstance.getServerFactory()
+ .build(randomName, LOCALHOST, port, "/", false, true);
server.addServletClass("/*", RestEchoService.class.getName());
server.waitedStart(5000);
- assertTrue(HttpServletServer.factory.get(port).isAlive());
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port).isAlive());
String response = http(portUrl + JUNIT_ECHO_HELLO);
assertTrue(HELLO.equals(response));
- HttpServletServer.factory.destroy();
- assertTrue(HttpServletServer.factory.inventory().isEmpty());
+ HttpServletServerFactoryInstance.getServerFactory().destroy();
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().inventory().isEmpty());
}
@Test
@@ -362,12 +375,13 @@ public class HttpServerTest {
String randomName = UUID.randomUUID().toString();
- HttpServletServer server = HttpServletServer.factory.build(randomName, LOCALHOST, port, "/", false, true);
+ HttpServletServer server = HttpServletServerFactoryInstance.getServerFactory()
+ .build(randomName, LOCALHOST, port, "/", false, true);
server.addServletClass("/*", RestEchoService.class.getName());
server.addServletClass("/*", RestEndpoints.class.getName());
server.waitedStart(5000);
- assertTrue(HttpServletServer.factory.get(port).isAlive());
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port).isAlive());
String response = http(portUrl + JUNIT_ECHO_HELLO);
assertTrue(HELLO.equals(response));
@@ -375,8 +389,8 @@ public class HttpServerTest {
response = http(portUrl + "/junit/endpoints/http/servers");
assertTrue(response.contains(randomName));
- HttpServletServer.factory.destroy();
- assertTrue(HttpServletServer.factory.inventory().isEmpty());
+ HttpServletServerFactoryInstance.getServerFactory().destroy();
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().inventory().isEmpty());
}
/**
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEndpoints.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEndpoints.java
index fe199645..6ada15c5 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEndpoints.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEndpoints.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-endpoints
* ================================================================================
- * Copyright (C) 2017 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.
@@ -28,23 +28,23 @@ import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import org.onap.policy.common.endpoints.http.server.HttpServletServer;
+import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
@Path("/junit/endpoints")
public class RestEndpoints {
/**
* Returns the http servers.
- *
+ *
* @return the list of servers as a string
*/
@GET
@Path("http/servers")
@Produces(MediaType.TEXT_PLAIN)
- public String httpServers() {
- List<HttpServletServer> servers =
- HttpServletServer.factory.inventory();
+ public String httpServers() {
+ List<HttpServletServer> servers = HttpServletServerFactoryInstance.getServerFactory().inventory();
return servers.toString();
}
-
-
+
+
}
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/CommonTestData.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/CommonTestData.java
index 80d1e865..346ac5d6 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/CommonTestData.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/CommonTestData.java
@@ -1,6 +1,8 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 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.
@@ -40,7 +42,7 @@ import org.onap.policy.common.utils.coder.StandardCoder;
*/
public class CommonTestData {
- public static final String REST_SERVER_PASSWORD = "zb!XztG34";
+ public static final String REST_SERVER_PASS = "zb!XztG34";
public static final String REST_SERVER_USER = "healthcheck";
public static final int REST_SERVER_PORT = 6969;
public static final String REST_SERVER_HOST = "0.0.0.0";
@@ -50,9 +52,11 @@ public class CommonTestData {
public static final String TOPIC_NAME = "POLICY-PDP-PAP";
public static final String TOPIC_INFRA = "dmaap";
public static final String TOPIC_SERVER = "message-router";
- public static final List<TopicParameters> TOPIC_PARAMS =
+
+ protected static final List<TopicParameters> TOPIC_PARAMS =
Arrays.asList(getTopicParameters(TOPIC_NAME, TOPIC_INFRA, TOPIC_SERVER));
- public static final Coder coder = new StandardCoder();
+
+ protected static final Coder coder = new StandardCoder();
/**
* Create topic parameters for test cases.
@@ -102,7 +106,7 @@ public class CommonTestData {
map.put("host", REST_SERVER_HOST);
map.put("port", REST_SERVER_PORT);
map.put("userName", REST_SERVER_USER);
- map.put("password", REST_SERVER_PASSWORD);
+ map.put("password", REST_SERVER_PASS);
}
return map;
@@ -133,7 +137,6 @@ public class CommonTestData {
*/
public String getParameterGroupAsString(String filePath) throws IOException {
File file = new File(filePath);
- String json = new String(Files.readAllBytes(file.toPath()), StandardCharsets.UTF_8);
- return json;
+ return new String(Files.readAllBytes(file.toPath()), StandardCharsets.UTF_8);
}
}
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/RestServerParametersTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/RestServerParametersTest.java
index ca2b3c4c..58bf98b3 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/RestServerParametersTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/RestServerParametersTest.java
@@ -1,6 +1,8 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 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.
@@ -41,7 +43,7 @@ public class RestServerParametersTest {
private static final Coder coder = new StandardCoder();
@Test
- public void test() throws Exception {
+ public void test() {
final RestServerParameters restServerParameters =
testData.toObject(testData.getRestServerParametersMap(false), RestServerParameters.class);
final GroupValidationResult validationResult = restServerParameters.validate();
@@ -49,13 +51,13 @@ public class RestServerParametersTest {
assertEquals(CommonTestData.REST_SERVER_HOST, restServerParameters.getHost());
assertEquals(CommonTestData.REST_SERVER_PORT, restServerParameters.getPort());
assertEquals(CommonTestData.REST_SERVER_USER, restServerParameters.getUserName());
- assertEquals(CommonTestData.REST_SERVER_PASSWORD, restServerParameters.getPassword());
+ assertEquals(CommonTestData.REST_SERVER_PASS, restServerParameters.getPassword());
assertEquals(CommonTestData.REST_SERVER_HTTPS, restServerParameters.isHttps());
assertEquals(CommonTestData.REST_SERVER_AAF, restServerParameters.isAaf());
}
@Test
- public void testValidate() throws Exception {
+ public void testValidate() {
final RestServerParameters restServerParameters =
testData.toObject(testData.getRestServerParametersMap(false), RestServerParameters.class);
final GroupValidationResult result = restServerParameters.validate();
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/TopicParameterGroupTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/TopicParameterGroupTest.java
index eaf0b2a9..db26a1a4 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/TopicParameterGroupTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/TopicParameterGroupTest.java
@@ -1,6 +1,8 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 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.
@@ -40,7 +42,7 @@ public class TopicParameterGroupTest {
private static final Coder coder = new StandardCoder();
@Test
- public void test() throws Exception {
+ public void test() {
final TopicParameterGroup topicParameterGroup =
testData.toObject(testData.getTopicParameterGroupMap(false), TopicParameterGroup.class);
final GroupValidationResult validationResult = topicParameterGroup.validate();
@@ -50,7 +52,7 @@ public class TopicParameterGroupTest {
}
@Test
- public void testValidate() throws Exception {
+ public void testValidate() {
final TopicParameterGroup topicParameterGroup =
testData.toObject(testData.getTopicParameterGroupMap(false), TopicParameterGroup.class);
final GroupValidationResult result = topicParameterGroup.validate();
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/utils/NetLoggerUtilTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/utils/NetLoggerUtilTest.java
index 2860377e..1e8c0316 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/utils/NetLoggerUtilTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/utils/NetLoggerUtilTest.java
@@ -31,6 +31,7 @@ import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.features.NetLoggerFeatureApi;
+import org.onap.policy.common.endpoints.features.NetLoggerFeatureProviders;
import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType;
import org.slf4j.Logger;
@@ -51,7 +52,7 @@ public class NetLoggerUtilTest {
*/
@BeforeClass
public static void setUp() {
- netLoggerFeature = (NetLoggerFeature) NetLoggerFeatureApi.providers.getList().get(0);
+ netLoggerFeature = (NetLoggerFeature) NetLoggerFeatureProviders.getProviders().getList().get(0);
}
/**
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/utils/ParameterUtilsTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/utils/ParameterUtilsTest.java
index 7e5c3a12..06c16e9c 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/utils/ParameterUtilsTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/utils/ParameterUtilsTest.java
@@ -1,6 +1,8 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 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.
@@ -34,6 +36,7 @@ import org.onap.policy.common.endpoints.parameters.TopicParameterGroup;
* @author Ajith Sreekumar (ajith.sreekumar@est.tech)
*/
public class ParameterUtilsTest {
+ private static final String SERVERS = ".servers";
/**
* Test getTopicProperties from TopicParameterGroup.
@@ -49,9 +52,9 @@ public class ParameterUtilsTest {
assertEquals(CommonTestData.TOPIC_NAME,
topicProperties.getProperty(CommonTestData.TOPIC_INFRA + ".sink.topics"));
assertEquals(CommonTestData.TOPIC_SERVER, topicProperties
- .getProperty(CommonTestData.TOPIC_INFRA + ".source.topics." + CommonTestData.TOPIC_NAME + ".servers"));
+ .getProperty(CommonTestData.TOPIC_INFRA + ".source.topics." + CommonTestData.TOPIC_NAME + SERVERS));
assertEquals(CommonTestData.TOPIC_SERVER, topicProperties
- .getProperty(CommonTestData.TOPIC_INFRA + ".sink.topics." + CommonTestData.TOPIC_NAME + ".servers"));
+ .getProperty(CommonTestData.TOPIC_INFRA + ".sink.topics." + CommonTestData.TOPIC_NAME + SERVERS));
}
@Test
@@ -62,12 +65,12 @@ public class ParameterUtilsTest {
assertEquals(CommonTestData.TOPIC_NAME,
topicProperties.getProperty(CommonTestData.TOPIC_INFRA + ".source.topics"));
assertEquals(CommonTestData.TOPIC_SERVER, topicProperties
- .getProperty(CommonTestData.TOPIC_INFRA + ".source.topics." + CommonTestData.TOPIC_NAME + ".servers"));
+ .getProperty(CommonTestData.TOPIC_INFRA + ".source.topics." + CommonTestData.TOPIC_NAME + SERVERS));
ParameterUtils.updateTopicProperties(topicProperties, "sink", CommonTestData.TOPIC_INFRA,
CommonTestData.TOPIC_NAME, Arrays.asList(CommonTestData.TOPIC_SERVER));
assertEquals(CommonTestData.TOPIC_NAME,
topicProperties.getProperty(CommonTestData.TOPIC_INFRA + ".sink.topics"));
assertEquals(CommonTestData.TOPIC_SERVER, topicProperties
- .getProperty(CommonTestData.TOPIC_INFRA + ".sink.topics." + CommonTestData.TOPIC_NAME + ".servers"));
+ .getProperty(CommonTestData.TOPIC_INFRA + ".sink.topics." + CommonTestData.TOPIC_NAME + SERVERS));
}
}