summaryrefslogtreecommitdiffstats
path: root/sdnr/wt/devicemanager/provider/src/test
diff options
context:
space:
mode:
authorRavi Pendurty <ravi.pendurty@highstreet-technologies.com>2020-08-18 15:30:11 +0200
committerRavi Pendurty <ravi.pendurty@highstreet-technologies.com>2020-08-18 16:05:02 +0200
commit6e164bc0f1f6688714033e95731942a89f5f1868 (patch)
tree45e1192ca4edd763bab0587da8652a3cba4af2e9 /sdnr/wt/devicemanager/provider/src/test
parente0ba85f7ef526aaa270f8a6cd5baad8e32eb920e (diff)
Develop a VES Provider
Common VES provider will be used by devicemanager bundles and other bundles for sending VES messages Issue-ID: SDNC-1188 Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com> Change-Id: Ied23b82a528aac23d7bebab272a2f414e67d0866 Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/devicemanager/provider/src/test')
-rw-r--r--sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestVESCollectorClient.java91
1 files changed, 91 insertions, 0 deletions
diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestVESCollectorClient.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestVESCollectorClient.java
new file mode 100644
index 000000000..99e7d7bf9
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestVESCollectorClient.java
@@ -0,0 +1,91 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : ccsdk features
+ * ================================================================================
+ * Copyright (C) 2020 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.devicemanager.test;
+
+import com.google.common.io.Files;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import org.junit.After;
+import org.junit.Test;
+import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.vescollectorconnector.impl.VESCollectorClient;
+
+public class TestVESCollectorClient {
+
+ private static final String TESTCONFIG_CONTENT_NO_AUTH = "[VESCollector]\n" + "VES_COLLECTOR_IP=127.0.0.1\n"
+ + "VES_COLLECTOR_PORT=8080\n" + "VES_COLLECTOR_TLS_ENABLED=false\n" + "VES_COLLECTOR_USERNAME=sample1\n"
+ + "VES_COLLECTOR_PASSWORD=sample1\n" + "VES_COLLECTOR_VERSION=v7\n" + "REPORTING_ENTITY_NAME=ONAP SDN-R\n" + "";
+
+ private static final String TESTCONFIG_CONTENT_AUTH = "[VESCollector]\n" + "VES_COLLECTOR_IP=127.0.0.1\n"
+ + "VES_COLLECTOR_PORT=8080\n" + "VES_COLLECTOR_TLS_ENABLED=true\n" + "VES_COLLECTOR_USERNAME=sample1\n"
+ + "VES_COLLECTOR_PASSWORD=sample1\n" + "VES_COLLECTOR_VERSION=v7\n" + "REPORTING_ENTITY_NAME=ONAP SDN-R\n" + "";
+
+ private static final String message = "Test Message";
+ private static final String CONFIG_FILE = "test.properties";
+
+ @Test
+ public void testNoAuth() throws Exception {
+ ConfigurationFileRepresentation vesCfg;
+ VESCollectorClient vesClient;
+
+ Files.asCharSink(new File(CONFIG_FILE), StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT_NO_AUTH);
+ vesCfg = new ConfigurationFileRepresentation(CONFIG_FILE);
+ vesClient = new VESCollectorClient(vesCfg);
+
+ vesClient.publishVESMessage(message);
+ vesClient.close();
+
+ }
+
+ @Test
+ public void testAuth() throws Exception {
+ ConfigurationFileRepresentation vesCfg;
+ VESCollectorClient vesClient;
+
+ Files.asCharSink(new File("test.properties"), StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT_AUTH);
+ vesCfg = new ConfigurationFileRepresentation("test.properties");
+
+ vesClient = new VESCollectorClient(vesCfg);
+ vesClient.publishVESMessage(message);
+ vesClient.close();
+ }
+
+ @After
+ public void after() throws InterruptedException, IOException {
+
+ delete(new File(CONFIG_FILE));
+
+ }
+
+ private static void delete(File f) throws IOException {
+ if (f.isDirectory()) {
+ for (File c : f.listFiles()) {
+ delete(c);
+ }
+ }
+ if (!f.delete()) {
+ throw new FileNotFoundException("Failed to delete file: " + f);
+ }
+ }
+}