From 19f6abb1f996a6a31b6f330c7f4a998ba4f554da Mon Sep 17 00:00:00 2001 From: Rafal Wrzesniak Date: Tue, 14 Sep 2021 12:43:14 +0200 Subject: Create MessageConfig and move there common config class code Move most of code from fault and pnf config classes to common one Issue-ID: CCSDK-3455 Signed-off-by: Rafal Wrzesniak Change-Id: Iff7e29b33e7ff9c6b16e9d161abc3ce0718ed93c --- .../impl/DMaaPFaultVESMsgConsumer.java | 22 +-- .../impl/DMaaPPNFRegVESMsgConsumer.java | 20 +-- .../impl/DMaaPVESMsgConsumerImpl.java | 27 ++- .../impl/DMaaPVESMsgConsumerMain.java | 11 +- .../wt/mountpointregistrar/impl/FaultConfig.java | 173 ++----------------- .../wt/mountpointregistrar/impl/MessageConfig.java | 187 +++++++++++++++++++++ .../impl/MountpointRegistrarImpl.java | 4 +- .../impl/PNFRegistrationConfig.java | 173 ++----------------- .../test/TestDMaaPVESMsgConsumerMain.java | 22 +-- .../test/impl/DummyFaultVESMsgConsumer.java | 31 ---- .../test/impl/DummyPNFRegVESMsgConsumer.java | 32 ---- 11 files changed, 247 insertions(+), 455 deletions(-) create mode 100644 sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/MessageConfig.java delete mode 100644 sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/impl/DummyFaultVESMsgConsumer.java delete mode 100644 sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/impl/DummyPNFRegVESMsgConsumer.java (limited to 'sdnr') diff --git a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPFaultVESMsgConsumer.java b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPFaultVESMsgConsumer.java index e21903b72..ee9d0220a 100644 --- a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPFaultVESMsgConsumer.java +++ b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPFaultVESMsgConsumer.java @@ -33,13 +33,8 @@ public class DMaaPFaultVESMsgConsumer extends DMaaPVESMsgConsumerImpl { private static final Logger LOG = LoggerFactory.getLogger(DMaaPFaultVESMsgConsumer.class); - private static final String DEFAULT_SDNRUSER = "admin"; - private static final String DEFAULT_SDNRPASSWD = "admin"; - - private final GeneralConfig generalConfig; - public DMaaPFaultVESMsgConsumer(GeneralConfig generalConfig) { - this.generalConfig = generalConfig; + super(generalConfig); } @Override @@ -113,19 +108,4 @@ public class DMaaPFaultVESMsgConsumer extends DMaaPVESMsgConsumerImpl { } } - public String getBaseUrl() { - return generalConfig.getBaseUrl(); - } - - public String getSDNRUser() { - return generalConfig.getSDNRUser() != null ? generalConfig.getSDNRUser() : DEFAULT_SDNRUSER; - } - - public String getSDNRPasswd() { - return generalConfig.getSDNRPasswd() != null ? generalConfig.getSDNRPasswd() : DEFAULT_SDNRPASSWD; - } - - public FaultNotificationClient getFaultNotificationClient(String baseUrl) { - return new FaultNotificationClient(baseUrl); - } } diff --git a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPPNFRegVESMsgConsumer.java b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPPNFRegVESMsgConsumer.java index d278a7317..51d6d1950 100644 --- a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPPNFRegVESMsgConsumer.java +++ b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPPNFRegVESMsgConsumer.java @@ -34,13 +34,10 @@ public class DMaaPPNFRegVESMsgConsumer extends DMaaPVESMsgConsumerImpl { private static final String DEFAULT_PORT = "17830"; private static final String DEFAULT_USERNAME = "netconf"; private static final String DEFAULT_PASSWORD = "netconf"; - private static final String DEFAULT_SDNRUSER = "admin"; - private static final String DEFAULT_SDNRPASSWD = "admin"; - private final GeneralConfig generalConfig; public DMaaPPNFRegVESMsgConsumer(GeneralConfig generalConfig) { - this.generalConfig = generalConfig; + super(generalConfig); } @Override @@ -154,19 +151,4 @@ public class DMaaPPNFRegVESMsgConsumer extends DMaaPVESMsgConsumerImpl { return null; } - public String getBaseUrl() { - return generalConfig.getBaseUrl(); - } - - public String getSDNRUser() { - return generalConfig.getSDNRUser() != null ? generalConfig.getSDNRUser() : DEFAULT_SDNRUSER; - } - - public String getSDNRPasswd() { - return generalConfig.getSDNRPasswd() != null ? generalConfig.getSDNRPasswd() : DEFAULT_SDNRPASSWD; - } - - private PNFMountPointClient getPNFMountPointClient(String baseUrl) { - return new PNFMountPointClient(baseUrl); - } } diff --git a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumerImpl.java b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumerImpl.java index ac6c7f92d..4dcbfbb3e 100644 --- a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumerImpl.java +++ b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumerImpl.java @@ -3,6 +3,7 @@ * ONAP : ccsdk feature sdnr wt mountpoint-registrar * ================================================================================================= * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. + * Copyright (C) 2021 Samsung Electronics 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 @@ -18,7 +19,13 @@ package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl; +import java.util.List; import java.util.Properties; +import java.util.function.Consumer; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.JsonNodeType; import org.onap.dmaap.mr.client.MRClientFactory; import org.onap.dmaap.mr.client.MRConsumer; import org.onap.dmaap.mr.client.response.MRConsumerResponse; @@ -28,6 +35,8 @@ import org.slf4j.LoggerFactory; public abstract class DMaaPVESMsgConsumerImpl implements DMaaPVESMsgConsumer { private static final Logger LOG = LoggerFactory.getLogger(DMaaPVESMsgConsumerImpl.class); + private static final String DEFAULT_SDNRUSER = "admin"; + private static final String DEFAULT_SDNRPASSWD = "admin"; private final String name = this.getClass().getSimpleName(); private Properties properties = null; @@ -36,9 +45,10 @@ public abstract class DMaaPVESMsgConsumerImpl implements DMaaPVESMsgConsumer { private boolean ready = false; private int fetchPause = 5000; // Default pause between fetch - 5 seconds private int timeout = 15000; // Default timeout - 15 seconds + protected final GeneralConfig generalConfig; - protected DMaaPVESMsgConsumerImpl() { - + protected DMaaPVESMsgConsumerImpl(GeneralConfig generalConfig) { + this.generalConfig = generalConfig; } /* @@ -154,7 +164,16 @@ public abstract class DMaaPVESMsgConsumerImpl implements DMaaPVESMsgConsumer { running = false; } - /*@Override - public abstract void processMsg(String msg) throws Exception;*/ + public String getBaseUrl() { + return generalConfig.getBaseUrl(); + } + + public String getSDNRUser() { + return generalConfig.getSDNRUser() != null ? generalConfig.getSDNRUser() : DEFAULT_SDNRUSER; + } + + public String getSDNRPasswd() { + return generalConfig.getSDNRPasswd() != null ? generalConfig.getSDNRPasswd() : DEFAULT_SDNRPASSWD; + } } diff --git a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumerMain.java b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumerMain.java index f8ee7a48f..7ce618582 100644 --- a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumerMain.java +++ b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumerMain.java @@ -3,6 +3,7 @@ * ONAP : ccsdk feature sdnr wt mountpoint-registrar * ================================================================================================= * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. + * Copyright (C) 2021 Samsung Electronics 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 @@ -22,7 +23,6 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Properties; -import org.onap.ccsdk.features.sdnr.wt.common.configuration.Configuration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -40,18 +40,17 @@ public class DMaaPVESMsgConsumerMain implements Runnable { private FaultConfig faultConfig; private GeneralConfig generalConfig; - public DMaaPVESMsgConsumerMain(Map configMap, GeneralConfig generalConfig) { + public DMaaPVESMsgConsumerMain(Map configMap, GeneralConfig generalConfig) { this.generalConfig = generalConfig; - configMap.forEach((k, v) -> initialize(k, v)); + configMap.forEach(this::initialize); } - public void initialize(String domain, Configuration domainConfig) { + public void initialize(String domain, MessageConfig domainConfig) { LOG.debug("In initialize method : Domain = {} and domainConfig = {}", domain, domainConfig); - String consumerClass = null; + String consumerClass; Properties consumerProperties = new Properties(); if (domain.equalsIgnoreCase(_PNFREG_DOMAIN)) { this.pnfRegistrationConfig = (PNFRegistrationConfig) domainConfig; - consumerClass = _PNFREG_CLASS; LOG.debug("Consumer class = {}", consumerClass); diff --git a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/FaultConfig.java b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/FaultConfig.java index ddf5c5403..7c71f7ee7 100644 --- a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/FaultConfig.java +++ b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/FaultConfig.java @@ -3,6 +3,7 @@ * ONAP : ccsdk feature sdnr wt * ================================================================================================= * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. + * Copyright (C) 2021 Samsung Electronics 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 @@ -17,181 +18,27 @@ */ package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl; -import org.onap.ccsdk.features.sdnr.wt.common.configuration.Configuration; import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation; -public class FaultConfig implements Configuration { - private static final String SECTION_MARKER = "fault"; - - public static final String PROPERTY_KEY_CONSUMER_TRANSPORTTYPE = "TransportType"; - private static final String DEFAULT_VALUE_CONSUMER_TRANSPORTTYPE = "HTTPNOAUTH"; +public class FaultConfig extends MessageConfig { - public static final String PROPERTY_KEY_CONSUMER_PROTOCOL = "Protocol"; - private static final String DEFAULT_VALUE_CONSUMER_PROTOCOL = "http"; - - public static final String PROPERTY_KEY_CONSUMER_USERNAME = "username"; + private static final String SECTION_MARKER = "fault"; private static final String DEFAULT_VALUE_CONSUMER_USERNAME = "${DMAAP_FAULT_TOPIC_USERNAME}"; - - public static final String PROPERTY_KEY_CONSUMER_PASSWORD = "password"; private static final String DEFAULT_VALUE_CONSUMER_PASSWORD = "${DMAAP_FAULT_TOPIC_PASSWORD}"; - - public static final String PROPERTY_KEY_CONSUMER_HOST_PORT = "host"; - private static final String DEFAULT_VALUE_CONSUMER_HOST_PORT = "onap-dmaap:3904"; - - public static final String PROPERTY_KEY_CONSUMER_TOPIC = "topic"; private static final String DEFAULT_VALUE_CONSUMER_TOPIC = "unauthenticated.SEC_FAULT_OUTPUT"; - public static final String PROPERTY_KEY_CONSUMER_CONTENTTYPE = "contenttype"; - private static final String DEFAULT_VALUE_CONSUMER_CONTENTTYPE = "application/json"; - - public static final String PROPERTY_KEY_CONSUMER_GROUP = "group"; - private static final String DEFAULT_VALUE_CONSUMER_GROUP = "myG"; - - public static final String PROPERTY_KEY_CONSUMER_ID = "id"; - private static final String DEFAULT_VALUE_CONSUMER_ID = "C1"; - - public static final String PROPERTY_KEY_CONSUMER_TIMEOUT = "timeout"; - private static final String DEFAULT_VALUE_CONSUMER_TIMEOUT = "20000"; - - public static final String PROPERTY_KEY_CONSUMER_LIMIT = "limit"; - private static final String DEFAULT_VALUE_CONSUMER_LIMIT = "10000"; - - public static final String PROPERTY_KEY_CONSUMER_FETCHPAUSE = "fetchPause"; - private static final String DEFAULT_VALUE_CONSUMER_FETCHPAUSE = "5000"; - - public static final String PROPERTY_KEY_CONSUMER_CLIENT_READTIMEOUT = "jersey.config.client.readTimeout"; - private static final String DEFAULT_VALUE_CONSUMER_CLIENT_READTIMEOUT = "25000"; - - public static final String PROPERTY_KEY_CONSUMER_CLIENT_CONNECTTIMEOUT = "jersey.config.client.connectTimeout"; - private static final String DEFAULT_VALUE_CONSUMER_CLIENT_CONNECTTIMEOUT = "25000"; - - public static final String PROPERTY_KEY_CONSUMER_CLIENT_HTTPPROXY_AUTH_USER = "jersey.config.client.proxy.username"; - private static final String DEFAULT_VALUE_CONSUMER_CLIENT_HTTPPROXY_AUTH_USER = "${HTTP_PROXY_USERNAME}"; - - public static final String PROPERTY_KEY_CONSUMER_CLIENT_HTTPPROXY_AUTH_PASSWORD = "jersey.config.client.proxy.password"; - private static final String DEFAULT_VALUE_CONSUMER_CLIENT_HTTPPROXY_AUTH_PASSWORD = "${HTTP_PROXY_PASSWORD}"; - - public static final String PROPERTY_KEY_CONSUMER_CLIENT_HTTPPROXY_URI = "jersey.config.client.proxy.uri"; - private static final String DEFAULT_VALUE_CONSUMER_CLIENT_HTTPPROXY_URI = "${HTTP_PROXY_URI}"; - - private final ConfigurationFileRepresentation configuration; public FaultConfig(ConfigurationFileRepresentation configuration) { - this.configuration = configuration; - this.configuration.addSection(SECTION_MARKER); - defaults(); - } - - @Override - public String getSectionName() { - return SECTION_MARKER; - } - - @Override - public void defaults() { - - configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_TRANSPORTTYPE, - DEFAULT_VALUE_CONSUMER_TRANSPORTTYPE); - configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_PROTOCOL, - DEFAULT_VALUE_CONSUMER_PROTOCOL); - configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_USERNAME, + super(configuration); + sectionMarker = SECTION_MARKER; + super.configuration.addSection(SECTION_MARKER); + super.configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_USERNAME, DEFAULT_VALUE_CONSUMER_USERNAME); - configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_PASSWORD, + super.configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_PASSWORD, DEFAULT_VALUE_CONSUMER_PASSWORD); - configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_HOST_PORT, - DEFAULT_VALUE_CONSUMER_HOST_PORT); - configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_TOPIC, + super.configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_TOPIC, DEFAULT_VALUE_CONSUMER_TOPIC); - configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_CONTENTTYPE, - DEFAULT_VALUE_CONSUMER_CONTENTTYPE); - configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_GROUP, - DEFAULT_VALUE_CONSUMER_GROUP); - configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_ID, DEFAULT_VALUE_CONSUMER_ID); - configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_TIMEOUT, - DEFAULT_VALUE_CONSUMER_TIMEOUT); - configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_LIMIT, - DEFAULT_VALUE_CONSUMER_LIMIT); - configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_FETCHPAUSE, - DEFAULT_VALUE_CONSUMER_FETCHPAUSE); - configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_CLIENT_READTIMEOUT, - DEFAULT_VALUE_CONSUMER_CLIENT_READTIMEOUT); - configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_CLIENT_CONNECTTIMEOUT, - DEFAULT_VALUE_CONSUMER_CLIENT_CONNECTTIMEOUT); - configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_CLIENT_HTTPPROXY_AUTH_USER, - DEFAULT_VALUE_CONSUMER_CLIENT_HTTPPROXY_AUTH_USER); - configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_CLIENT_HTTPPROXY_AUTH_PASSWORD, - DEFAULT_VALUE_CONSUMER_CLIENT_HTTPPROXY_AUTH_PASSWORD); - configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_CLIENT_HTTPPROXY_URI, - DEFAULT_VALUE_CONSUMER_CLIENT_HTTPPROXY_URI); - - } - - public String getHostPort() { - return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_CONSUMER_HOST_PORT); - } - - public String getTransportType() { - return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_CONSUMER_TRANSPORTTYPE); - } - - public String getProtocol() { - return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_CONSUMER_PROTOCOL); - } - - public String getUsername() { - return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_CONSUMER_USERNAME); - } - - public String getPassword() { - return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_CONSUMER_PASSWORD); - } - - public String getTopic() { - return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_CONSUMER_TOPIC); - } - - public String getConsumerGroup() { - return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_CONSUMER_GROUP); - } - - public String getConsumerId() { - return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_CONSUMER_ID); - } - - public String getTimeout() { - return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_CONSUMER_TIMEOUT); - } - - public String getLimit() { - return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_CONSUMER_LIMIT); - } - - public String getFetchPause() { - return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_CONSUMER_FETCHPAUSE); - } - - public String getContenttype() { - return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_CONSUMER_CONTENTTYPE); - } - - public String getClientReadTimeout() { - return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_CONSUMER_CLIENT_READTIMEOUT); - } - - public String getClientConnectTimeout() { - return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_CONSUMER_CLIENT_CONNECTTIMEOUT); + defaults(); } - public String getHTTPProxyURI() { - return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_CONSUMER_CLIENT_HTTPPROXY_URI); - } - - public String getHTTPProxyUsername() { - return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_CONSUMER_CLIENT_HTTPPROXY_AUTH_USER); - } - - public String getHTTPProxyPassword() { - return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_CONSUMER_CLIENT_HTTPPROXY_AUTH_PASSWORD); - } - } diff --git a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/MessageConfig.java b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/MessageConfig.java new file mode 100644 index 000000000..8a6f6442e --- /dev/null +++ b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/MessageConfig.java @@ -0,0 +1,187 @@ +/* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt mountpoint-registrar + * ================================================================================================= + * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. + * Copyright (C) 2021 Samsung Electronics 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.ccsdk.features.sdnr.wt.mountpointregistrar.impl; + +import org.onap.ccsdk.features.sdnr.wt.common.configuration.Configuration; +import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation; + +public abstract class MessageConfig implements Configuration { + protected String sectionMarker; + + public static final String PROPERTY_KEY_CONSUMER_TRANSPORTTYPE = "TransportType"; + private static final String DEFAULT_VALUE_CONSUMER_TRANSPORTTYPE = "HTTPNOAUTH"; + + public static final String PROPERTY_KEY_CONSUMER_PROTOCOL = "Protocol"; + private static final String DEFAULT_VALUE_CONSUMER_PROTOCOL = "http"; + + public static final String PROPERTY_KEY_CONSUMER_USERNAME = "username"; + public static final String PROPERTY_KEY_CONSUMER_PASSWORD = "password"; + + public static final String PROPERTY_KEY_CONSUMER_HOST_PORT = "host"; + private static final String DEFAULT_VALUE_CONSUMER_HOST_PORT = "onap-dmaap:3904"; + + public static final String PROPERTY_KEY_CONSUMER_TOPIC = "topic"; + + public static final String PROPERTY_KEY_CONSUMER_CONTENTTYPE = "contenttype"; + private static final String DEFAULT_VALUE_CONSUMER_CONTENTTYPE = "application/json"; + + public static final String PROPERTY_KEY_CONSUMER_GROUP = "group"; + private static final String DEFAULT_VALUE_CONSUMER_GROUP = "myG"; + + public static final String PROPERTY_KEY_CONSUMER_ID = "id"; + private static final String DEFAULT_VALUE_CONSUMER_ID = "C1"; + + public static final String PROPERTY_KEY_CONSUMER_TIMEOUT = "timeout"; + private static final String DEFAULT_VALUE_CONSUMER_TIMEOUT = "20000"; + + public static final String PROPERTY_KEY_CONSUMER_LIMIT = "limit"; + private static final String DEFAULT_VALUE_CONSUMER_LIMIT = "10000"; + + public static final String PROPERTY_KEY_CONSUMER_FETCHPAUSE = "fetchPause"; + private static final String DEFAULT_VALUE_CONSUMER_FETCHPAUSE = "5000"; + + public static final String PROPERTY_KEY_CONSUMER_CLIENT_READTIMEOUT = "jersey.config.client.readTimeout"; + private static final String DEFAULT_VALUE_CONSUMER_CLIENT_READTIMEOUT = "25000"; + + public static final String PROPERTY_KEY_CONSUMER_CLIENT_CONNECTTIMEOUT = "jersey.config.client.connectTimeout"; + private static final String DEFAULT_VALUE_CONSUMER_CLIENT_CONNECTTIMEOUT = "25000"; + + public static final String PROPERTY_KEY_CONSUMER_CLIENT_HTTPPROXY_AUTH_USER = "jersey.config.client.proxy.username"; + private static final String DEFAULT_VALUE_CONSUMER_CLIENT_HTTPPROXY_AUTH_USER = "${HTTP_PROXY_USERNAME}"; + + public static final String PROPERTY_KEY_CONSUMER_CLIENT_HTTPPROXY_AUTH_PASSWORD = "jersey.config.client.proxy.password"; + private static final String DEFAULT_VALUE_CONSUMER_CLIENT_HTTPPROXY_AUTH_PASSWORD = "${HTTP_PROXY_PASSWORD}"; + + public static final String PROPERTY_KEY_CONSUMER_CLIENT_HTTPPROXY_URI = "jersey.config.client.proxy.uri"; + private static final String DEFAULT_VALUE_CONSUMER_CLIENT_HTTPPROXY_URI = "${HTTP_PROXY_URI}"; + + protected ConfigurationFileRepresentation configuration; + + public MessageConfig(ConfigurationFileRepresentation configuration) { + this.configuration = configuration; + } + + @Override + public String getSectionName() { + return sectionMarker; + } + + @Override + public void defaults() { + configuration.setPropertyIfNotAvailable(sectionMarker, PROPERTY_KEY_CONSUMER_TRANSPORTTYPE, + DEFAULT_VALUE_CONSUMER_TRANSPORTTYPE); + configuration.setPropertyIfNotAvailable(sectionMarker, PROPERTY_KEY_CONSUMER_PROTOCOL, + DEFAULT_VALUE_CONSUMER_PROTOCOL); + configuration.setPropertyIfNotAvailable(sectionMarker, PROPERTY_KEY_CONSUMER_HOST_PORT, + DEFAULT_VALUE_CONSUMER_HOST_PORT); + configuration.setPropertyIfNotAvailable(sectionMarker, PROPERTY_KEY_CONSUMER_CONTENTTYPE, + DEFAULT_VALUE_CONSUMER_CONTENTTYPE); + configuration.setPropertyIfNotAvailable(sectionMarker, PROPERTY_KEY_CONSUMER_GROUP, + DEFAULT_VALUE_CONSUMER_GROUP); + configuration.setPropertyIfNotAvailable(sectionMarker, PROPERTY_KEY_CONSUMER_ID, DEFAULT_VALUE_CONSUMER_ID); + configuration.setPropertyIfNotAvailable(sectionMarker, PROPERTY_KEY_CONSUMER_TIMEOUT, + DEFAULT_VALUE_CONSUMER_TIMEOUT); + configuration.setPropertyIfNotAvailable(sectionMarker, PROPERTY_KEY_CONSUMER_LIMIT, + DEFAULT_VALUE_CONSUMER_LIMIT); + configuration.setPropertyIfNotAvailable(sectionMarker, PROPERTY_KEY_CONSUMER_FETCHPAUSE, + DEFAULT_VALUE_CONSUMER_FETCHPAUSE); + configuration.setPropertyIfNotAvailable(sectionMarker, PROPERTY_KEY_CONSUMER_CLIENT_READTIMEOUT, + DEFAULT_VALUE_CONSUMER_CLIENT_READTIMEOUT); + configuration.setPropertyIfNotAvailable(sectionMarker, PROPERTY_KEY_CONSUMER_CLIENT_CONNECTTIMEOUT, + DEFAULT_VALUE_CONSUMER_CLIENT_CONNECTTIMEOUT); + configuration.setPropertyIfNotAvailable(sectionMarker, PROPERTY_KEY_CONSUMER_CLIENT_HTTPPROXY_AUTH_USER, + DEFAULT_VALUE_CONSUMER_CLIENT_HTTPPROXY_AUTH_USER); + configuration.setPropertyIfNotAvailable(sectionMarker, PROPERTY_KEY_CONSUMER_CLIENT_HTTPPROXY_AUTH_PASSWORD, + DEFAULT_VALUE_CONSUMER_CLIENT_HTTPPROXY_AUTH_PASSWORD); + configuration.setPropertyIfNotAvailable(sectionMarker, PROPERTY_KEY_CONSUMER_CLIENT_HTTPPROXY_URI, + DEFAULT_VALUE_CONSUMER_CLIENT_HTTPPROXY_URI); + } + + + + public String getHostPort() { + return configuration.getProperty(sectionMarker, PROPERTY_KEY_CONSUMER_HOST_PORT); + } + + public String getTransportType() { + return configuration.getProperty(sectionMarker, PROPERTY_KEY_CONSUMER_TRANSPORTTYPE); + } + + public String getProtocol() { + return configuration.getProperty(sectionMarker, PROPERTY_KEY_CONSUMER_PROTOCOL); + } + + public String getUsername() { + return configuration.getProperty(sectionMarker, PROPERTY_KEY_CONSUMER_USERNAME); + } + + public String getPassword() { + return configuration.getProperty(sectionMarker, PROPERTY_KEY_CONSUMER_PASSWORD); + } + + public String getTopic() { + return configuration.getProperty(sectionMarker, PROPERTY_KEY_CONSUMER_TOPIC); + } + + public String getConsumerGroup() { + return configuration.getProperty(sectionMarker, PROPERTY_KEY_CONSUMER_GROUP); + } + + public String getConsumerId() { + return configuration.getProperty(sectionMarker, PROPERTY_KEY_CONSUMER_ID); + } + + public String getTimeout() { + return configuration.getProperty(sectionMarker, PROPERTY_KEY_CONSUMER_TIMEOUT); + } + + public String getLimit() { + return configuration.getProperty(sectionMarker, PROPERTY_KEY_CONSUMER_LIMIT); + } + + public String getFetchPause() { + return configuration.getProperty(sectionMarker, PROPERTY_KEY_CONSUMER_FETCHPAUSE); + } + + public String getContenttype() { + return configuration.getProperty(sectionMarker, PROPERTY_KEY_CONSUMER_CONTENTTYPE); + } + + public String getClientReadTimeout() { + return configuration.getProperty(sectionMarker, PROPERTY_KEY_CONSUMER_CLIENT_READTIMEOUT); + } + + public String getClientConnectTimeout() { + return configuration.getProperty(sectionMarker, PROPERTY_KEY_CONSUMER_CLIENT_CONNECTTIMEOUT); + } + + public String getHTTPProxyURI() { + return configuration.getProperty(sectionMarker, PROPERTY_KEY_CONSUMER_CLIENT_HTTPPROXY_URI); + } + + public String getHTTPProxyUsername() { + return configuration.getProperty(sectionMarker, PROPERTY_KEY_CONSUMER_CLIENT_HTTPPROXY_AUTH_USER); + } + + public String getHTTPProxyPassword() { + return configuration.getProperty(sectionMarker, PROPERTY_KEY_CONSUMER_CLIENT_HTTPPROXY_AUTH_PASSWORD); + } +} diff --git a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/MountpointRegistrarImpl.java b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/MountpointRegistrarImpl.java index 01c0d5a0f..0159ed4f8 100644 --- a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/MountpointRegistrarImpl.java +++ b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/MountpointRegistrarImpl.java @@ -3,6 +3,7 @@ * ONAP : ccsdk feature sdnr wt * ================================================================================================= * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. + * Copyright (C) 2021 Samsung Electronics 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 @@ -21,7 +22,6 @@ package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl; import java.util.HashMap; import java.util.List; import java.util.Map; -import org.onap.ccsdk.features.sdnr.wt.common.configuration.Configuration; import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation; import org.onap.ccsdk.features.sdnr.wt.common.configuration.filechange.IConfigChangedListener; import org.slf4j.Logger; @@ -37,7 +37,7 @@ public class MountpointRegistrarImpl implements AutoCloseable, IConfigChangedLis private GeneralConfig generalConfig; private boolean dmaapEnabled = false; - private Map configMap = new HashMap<>(); + private Map configMap = new HashMap<>(); private DMaaPVESMsgConsumerMain dmaapConsumerMain = null; // Blueprint 1 diff --git a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/PNFRegistrationConfig.java b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/PNFRegistrationConfig.java index 2a934b79f..acc0b3a89 100644 --- a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/PNFRegistrationConfig.java +++ b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/PNFRegistrationConfig.java @@ -3,6 +3,7 @@ * ONAP : ccsdk feature sdnr wt * ================================================================================================= * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. + * Copyright (C) 2021 Samsung Electronics 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 @@ -15,183 +16,29 @@ * the License. * ============LICENSE_END========================================================================== */ - package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl; -import org.onap.ccsdk.features.sdnr.wt.common.configuration.Configuration; import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation; -public class PNFRegistrationConfig implements Configuration { - private static final String SECTION_MARKER = "pnfRegistration"; - - public static final String PROPERTY_KEY_CONSUMER_TRANSPORTTYPE = "TransportType"; - private static final String DEFAULT_VALUE_CONSUMER_TRANSPORTTYPE = "HTTPNOAUTH"; - - public static final String PROPERTY_KEY_CONSUMER_PROTOCOL = "Protocol"; - private static final String DEFAULT_VALUE_CONSUMER_PROTOCOL = "http"; +public class PNFRegistrationConfig extends MessageConfig { - public static final String PROPERTY_KEY_CONSUMER_USERNAME = "username"; + private static final String SECTION_MARKER = "pnfRegistration"; private static final String DEFAULT_VALUE_CONSUMER_USERNAME = "${DMAAP_PNFREG_TOPIC_USERNAME}"; - - public static final String PROPERTY_KEY_CONSUMER_PASSWORD = "password"; private static final String DEFAULT_VALUE_CONSUMER_PASSWORD = "${DMAAP_PNFREG_TOPIC_PASSWORD}"; - - public static final String PROPERTY_KEY_CONSUMER_HOST_PORT = "host"; - private static final String DEFAULT_VALUE_CONSUMER_HOST_PORT = "onap-dmaap:3904"; - - public static final String PROPERTY_KEY_CONSUMER_TOPIC = "topic"; private static final String DEFAULT_VALUE_CONSUMER_TOPIC = "unauthenticated.VES_PNFREG_OUTPUT"; - public static final String PROPERTY_KEY_CONSUMER_CONTENTTYPE = "contenttype"; - private static final String DEFAULT_VALUE_CONSUMER_CONTENTTYPE = "application/json"; - - public static final String PROPERTY_KEY_CONSUMER_GROUP = "group"; - private static final String DEFAULT_VALUE_CONSUMER_GROUP = "myG"; - - public static final String PROPERTY_KEY_CONSUMER_ID = "id"; - private static final String DEFAULT_VALUE_CONSUMER_ID = "C1"; - - public static final String PROPERTY_KEY_CONSUMER_TIMEOUT = "timeout"; - private static final String DEFAULT_VALUE_CONSUMER_TIMEOUT = "20000"; - - public static final String PROPERTY_KEY_CONSUMER_LIMIT = "limit"; - private static final String DEFAULT_VALUE_CONSUMER_LIMIT = "10000"; - - public static final String PROPERTY_KEY_CONSUMER_FETCHPAUSE = "fetchPause"; - private static final String DEFAULT_VALUE_CONSUMER_FETCHPAUSE = "5000"; - - public static final String PROPERTY_KEY_CONSUMER_CLIENT_READTIMEOUT = "jersey.config.client.readTimeout"; - private static final String DEFAULT_VALUE_CONSUMER_CLIENT_READTIMEOUT = "25000"; - - public static final String PROPERTY_KEY_CONSUMER_CLIENT_CONNECTTIMEOUT = "jersey.config.client.connectTimeout"; - private static final String DEFAULT_VALUE_CONSUMER_CLIENT_CONNECTTIMEOUT = "25000"; - - public static final String PROPERTY_KEY_CONSUMER_CLIENT_HTTPPROXY_AUTH_USER = "jersey.config.client.proxy.username"; - private static final String DEFAULT_VALUE_CONSUMER_CLIENT_HTTPPROXY_AUTH_USER = "${HTTP_PROXY_USERNAME}"; - - public static final String PROPERTY_KEY_CONSUMER_CLIENT_HTTPPROXY_AUTH_PASSWORD = "jersey.config.client.proxy.password"; - private static final String DEFAULT_VALUE_CONSUMER_CLIENT_HTTPPROXY_AUTH_PASSWORD = "${HTTP_PROXY_PASSWORD}"; - - public static final String PROPERTY_KEY_CONSUMER_CLIENT_HTTPPROXY_URI = "jersey.config.client.proxy.uri"; - private static final String DEFAULT_VALUE_CONSUMER_CLIENT_HTTPPROXY_URI = "${HTTP_PROXY_URI}"; - - private final ConfigurationFileRepresentation configuration; public PNFRegistrationConfig(ConfigurationFileRepresentation configuration) { - this.configuration = configuration; - this.configuration.addSection(SECTION_MARKER); - defaults(); - } - - @Override - public String getSectionName() { - return SECTION_MARKER; - } - - @Override - public void defaults() { - - configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_TRANSPORTTYPE, - DEFAULT_VALUE_CONSUMER_TRANSPORTTYPE); - configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_PROTOCOL, - DEFAULT_VALUE_CONSUMER_PROTOCOL); - configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_USERNAME, + super(configuration); + sectionMarker = SECTION_MARKER; + super.configuration.addSection(SECTION_MARKER); + super.configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_USERNAME, DEFAULT_VALUE_CONSUMER_USERNAME); - configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_PASSWORD, + super.configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_PASSWORD, DEFAULT_VALUE_CONSUMER_PASSWORD); - configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_HOST_PORT, - DEFAULT_VALUE_CONSUMER_HOST_PORT); - configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_TOPIC, + super.configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_TOPIC, DEFAULT_VALUE_CONSUMER_TOPIC); - configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_CONTENTTYPE, - DEFAULT_VALUE_CONSUMER_CONTENTTYPE); - configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_GROUP, - DEFAULT_VALUE_CONSUMER_GROUP); - configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_ID, DEFAULT_VALUE_CONSUMER_ID); - configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_TIMEOUT, - DEFAULT_VALUE_CONSUMER_TIMEOUT); - configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_LIMIT, - DEFAULT_VALUE_CONSUMER_LIMIT); - configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_FETCHPAUSE, - DEFAULT_VALUE_CONSUMER_FETCHPAUSE); - configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_CLIENT_READTIMEOUT, - DEFAULT_VALUE_CONSUMER_CLIENT_READTIMEOUT); - configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_CLIENT_CONNECTTIMEOUT, - DEFAULT_VALUE_CONSUMER_CLIENT_CONNECTTIMEOUT); - configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_CLIENT_HTTPPROXY_AUTH_USER, - DEFAULT_VALUE_CONSUMER_CLIENT_HTTPPROXY_AUTH_USER); - configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_CLIENT_HTTPPROXY_AUTH_PASSWORD, - DEFAULT_VALUE_CONSUMER_CLIENT_HTTPPROXY_AUTH_PASSWORD); - configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_CLIENT_HTTPPROXY_URI, - DEFAULT_VALUE_CONSUMER_CLIENT_HTTPPROXY_URI); - } - - public String getHostPort() { - return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_CONSUMER_HOST_PORT); - } - - public String getTransportType() { - return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_CONSUMER_TRANSPORTTYPE); - } - - public String getProtocol() { - return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_CONSUMER_PROTOCOL); - } - - public String getUsername() { - return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_CONSUMER_USERNAME); - } - - public String getPassword() { - return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_CONSUMER_PASSWORD); - } - - public String getTopic() { - return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_CONSUMER_TOPIC); - } - - public String getConsumerGroup() { - return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_CONSUMER_GROUP); - } - - public String getConsumerId() { - return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_CONSUMER_ID); - } - - public String getTimeout() { - return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_CONSUMER_TIMEOUT); - } - - public String getLimit() { - return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_CONSUMER_LIMIT); - } - - public String getFetchPause() { - return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_CONSUMER_FETCHPAUSE); - } - - public String getContenttype() { - return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_CONSUMER_CONTENTTYPE); - } - - public String getClientReadTimeout() { - return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_CONSUMER_CLIENT_READTIMEOUT); + defaults(); } - public String getClientConnectTimeout() { - return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_CONSUMER_CLIENT_CONNECTTIMEOUT); - } - - public String getHTTPProxyURI() { - return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_CONSUMER_CLIENT_HTTPPROXY_URI); - } - - public String getHTTPProxyUsername() { - return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_CONSUMER_CLIENT_HTTPPROXY_AUTH_USER); - } - - public String getHTTPProxyPassword() { - return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_CONSUMER_CLIENT_HTTPPROXY_AUTH_PASSWORD); - } - } diff --git a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestDMaaPVESMsgConsumerMain.java b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestDMaaPVESMsgConsumerMain.java index 032850afb..11fb2f3b9 100644 --- a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestDMaaPVESMsgConsumerMain.java +++ b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestDMaaPVESMsgConsumerMain.java @@ -3,6 +3,7 @@ * ONAP : ccsdk feature sdnr wt * ================================================================================================= * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. + * Copyright (C) 2021 Samsung Electronics 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 @@ -27,18 +28,12 @@ import java.util.List; import java.util.Map; import org.junit.After; import org.junit.Test; -import org.onap.ccsdk.features.sdnr.wt.common.configuration.Configuration; import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation; -import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.DMaaPVESMsgConsumer; -import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.DMaaPVESMsgConsumerMain; -import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.FaultConfig; -import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.GeneralConfig; -import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.PNFRegistrationConfig; +import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.*; public class TestDMaaPVESMsgConsumerMain { private static final String CONFIGURATIONFILE = "test1.properties"; - // @formatter:off private static final String TESTCONFIG_GENERAL = "[general]\n" + "dmaapEnabled=false\n" + "baseUrl=http://localhost:8181\n" @@ -46,7 +41,7 @@ public class TestDMaaPVESMsgConsumerMain { + "sdnrPasswd=admin\n" + "\n" + "[pnfRegistration]\n" - + "pnfRegConsumerClass=org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.test.impl.DummyPNFRegVESMsgConsumer\n" + + "pnfRegConsumerClass=org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.test.impl.DMaaPPNFRegVESMsgConsumer\n" + "TransportType=HTTPNOAUTH\n" + "host=onap-dmap:3904\n" + "topic=unauthenticated.VES_PNFREG_OUTPUT\n" @@ -57,7 +52,7 @@ public class TestDMaaPVESMsgConsumerMain { + "limit=10000\n" + "\n" + "[fault]\n" - + "faultConsumerClass=org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.test.impl.DummyFaultVESMsgConsumer\n" + + "faultConsumerClass=org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.DMaaPFaultVESMsgConsumer.java\n" + "TransportType=HTTPNOAUTH\n" + "host=onap-dmap:3904\n" + "topic=unauthenticated.SEC_FAULT_OUTPUT\n" @@ -77,7 +72,7 @@ public class TestDMaaPVESMsgConsumerMain { + "sdnrPasswd=admin\n" + "\n" + "[pnfRegistration]\n" - + "pnfRegConsumerClass=org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.test.impl.DummyPNFRegVESMsgConsumer\n" + + "pnfRegConsumerClass=org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.DMaaPPNFRegVESMsgConsumer.java\n" + "TransportType=HTTPNOAUTH\n" + "host=onap-dmap:3904\n" + "topic=unauthenticated.VES_PNFREG_OUTPUT\n" @@ -88,7 +83,7 @@ public class TestDMaaPVESMsgConsumerMain { + "limit=10000\n" + "\n" + "[fault]\n" - + "faultConsumerClass=org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.test.impl.DummyFaultVESMsgConsumer\n" + + "faultConsumerClass=org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.DMaaPFaultVESMsgConsumer.java\n" + "TransportType=HTTPNOAUTH\n" + "host=onap-dmap:3904\n" + "topic=unauthenticated.SEC_FAULT_OUTPUT\n" @@ -100,12 +95,11 @@ public class TestDMaaPVESMsgConsumerMain { + "fetchPause=WORLD\n" + "\n" + ""; - // @formatter:on public GeneralConfig generalConfig; - Map configMap = new HashMap(); + Map configMap = new HashMap<>(); DMaaPVESMsgConsumerMain dmaapMain; - // @Before + public void preTest1() { try { Files.asCharSink(new File(CONFIGURATIONFILE), StandardCharsets.UTF_8).write(TESTCONFIG_GENERAL); diff --git a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/impl/DummyFaultVESMsgConsumer.java b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/impl/DummyFaultVESMsgConsumer.java deleted file mode 100644 index d1e9015e7..000000000 --- a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/impl/DummyFaultVESMsgConsumer.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH 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.ccsdk.features.sdnr.wt.mountpointregistrar.test.impl; - -import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.DMaaPVESMsgConsumerImpl; - -public class DummyFaultVESMsgConsumer extends DMaaPVESMsgConsumerImpl { - - @Override - public void processMsg(String msg) throws Exception { - System.out.println("Message received is - " + msg); - - } - -} diff --git a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/impl/DummyPNFRegVESMsgConsumer.java b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/impl/DummyPNFRegVESMsgConsumer.java deleted file mode 100644 index a165182c0..000000000 --- a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/impl/DummyPNFRegVESMsgConsumer.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH 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.ccsdk.features.sdnr.wt.mountpointregistrar.test.impl; - -import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.DMaaPVESMsgConsumerImpl; - -public class DummyPNFRegVESMsgConsumer extends DMaaPVESMsgConsumerImpl { - - - @Override - public void processMsg(String msg) throws Exception { - System.out.println("Message received is - " + msg); - - } - -} -- cgit 1.2.3-korg