aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/java/org
diff options
context:
space:
mode:
authorVENKATESH KUMAR <vv770d@att.com>2018-02-14 17:45:04 +0000
committerVENKATESH KUMAR <vv770d@att.com>2018-02-14 12:50:13 -0500
commit4d3624549f41aeda68b8626270fc491ea99e5ee0 (patch)
treeb7d931e1dc29a183b0f9b3496bdefe6f299ef74e /src/test/java/org
parent2dfdd151440cd80dc25c928f283df7bcd71cd195 (diff)
Fix keystore alais config and TC
Change-Id: I8e0349f411dc05625b14536afc0acb1fac9a55c2 Signed-off-by: VENKATESH KUMAR <vv770d@att.com> Issue-ID: DCAEGEN2-227
Diffstat (limited to 'src/test/java/org')
-rw-r--r--src/test/java/org/onap/dcae/vestest/TestDmaapPropertyReader.java4
-rw-r--r--src/test/java/org/onap/dcae/vestest/TestEventProcessor.java23
-rw-r--r--src/test/java/org/onap/dcae/vestest/TestFetchConfig.java90
-rw-r--r--src/test/java/org/onap/dcae/vestest/TestLoadDynamicConfig.java57
-rw-r--r--src/test/java/org/onap/dcae/vestest/TestSchemaValidation.java18
-rw-r--r--src/test/java/org/onap/dcae/vestest/TestVESLogger.java115
6 files changed, 268 insertions, 39 deletions
diff --git a/src/test/java/org/onap/dcae/vestest/TestDmaapPropertyReader.java b/src/test/java/org/onap/dcae/vestest/TestDmaapPropertyReader.java
index e54b4cbb..2a7a205e 100644
--- a/src/test/java/org/onap/dcae/vestest/TestDmaapPropertyReader.java
+++ b/src/test/java/org/onap/dcae/vestest/TestDmaapPropertyReader.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* PROJECT
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -29,7 +29,7 @@ import org.onap.dcae.commonFunction.DmaapPropertyReader;
public class TestDmaapPropertyReader {
DmaapPropertyReader dr;
- String testinput = "src/test/resources/testDmaapConfig.json";
+ String testinput = "src/test/resources/testDmaapConfig_ip.json";
Boolean flag = false;
@Before
diff --git a/src/test/java/org/onap/dcae/vestest/TestEventProcessor.java b/src/test/java/org/onap/dcae/vestest/TestEventProcessor.java
index f11cc905..47672956 100644
--- a/src/test/java/org/onap/dcae/vestest/TestEventProcessor.java
+++ b/src/test/java/org/onap/dcae/vestest/TestEventProcessor.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* PROJECT
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -23,7 +23,6 @@ import static org.junit.Assert.*;
import java.io.File;
-import java.io.FileReader;
import java.net.URL;
import java.util.Map;
@@ -47,13 +46,13 @@ public class TestEventProcessor {
EventProcessor ec;
String ev= "{\"event\": {\"commonEventHeader\": { \"reportingEntityName\": \"VM name will be provided by ECOMP\", \"startEpochMicrosec\": 1477012779802988,\"lastEpochMicrosec\": 1477012789802988,\"eventId\": \"83\",\"sourceName\": \"Dummy VM name - No Metadata available\",\"sequence\": 83,\"priority\": \"Normal\",\"functionalRole\": \"vFirewall\",\"domain\": \"measurementsForVfScaling\",\"reportingEntityId\": \"VM UUID will be provided by ECOMP\",\"sourceId\": \"Dummy VM UUID - No Metadata available\",\"version\": 1.1},\"measurementsForVfScalingFields\": {\"measurementInterval\": 10,\"measurementsForVfScalingVersion\": 1.1,\"vNicUsageArray\": [{\"multicastPacketsIn\": 0,\"bytesIn\": 3896,\"unicastPacketsIn\": 0, \"multicastPacketsOut\": 0,\"broadcastPacketsOut\": 0, \"packetsOut\": 28,\"bytesOut\": 12178,\"broadcastPacketsIn\": 0,\"packetsIn\": 58,\"unicastPacketsOut\": 0,\"vNicIdentifier\": \"eth0\"}]}}}";
-
+ String testinput;
@Before
public void setUp() throws Exception {
CommonStartup.streamid="fault=sec_fault|syslog=sec_syslog|heartbeat=sec_heartbeat|measurementsForVfScaling=sec_measurement|mobileFlow=sec_mobileflow|other=sec_other|stateChange=sec_statechange|thresholdCrossingAlert=sec_thresholdCrossingAlert|voiceQuality=ves_voicequality|sipSignaling=ves_sipsignaling";
CommonStartup.eventTransformFlag = 1;
-
+ testinput = "src/test/resources/testDmaapConfig_ip.json";
}
@@ -81,7 +80,7 @@ public class TestEventProcessor {
DmaapPropertyReader dr;
EventPublisher ep = null;
- String testinput = "src/test/resources/testDmaapConfig.json";
+
Boolean flag = false;
dr = new DmaapPropertyReader(testinput);
@@ -106,9 +105,11 @@ public class TestEventProcessor {
DmaapPropertyReader dr;
EventPublisherHash eph = null;
+
Boolean flag = false;
+ dr = new DmaapPropertyReader(testinput);
eph = EventPublisherHash.getInstance();
-
+
if (eph.equals(null))
{
@@ -128,13 +129,14 @@ public class TestEventProcessor {
DmaapPropertyReader dr;
EventPublisherHash eph = null;
- String testinput = "src/test/resources/testDmaapConfig.json";
+
Boolean flag = false;
dr = new DmaapPropertyReader(testinput);
eph = EventPublisherHash.getInstance();
EventProcessor ec = new EventProcessor();
ec.event=new org.json.JSONObject(ev);
- CommonStartup.cambriaConfigFile="src/test/resources/testDmaapConfig.json";
+ CommonStartup.cambriaConfigFile="src/test/resources/testDmaapConfig_ip.json";
+
CambriaBatchingPublisher pub = eph.Dmaaphash("sec_fault_ueb");
if (pub == null || pub.equals(null))
@@ -154,7 +156,7 @@ public class TestEventProcessor {
DmaapPropertyReader dr;
EventPublisherHash eph = null;
- String testinput = "src/test/resources/testDmaapConfig.json";
+
Boolean flag = true;
dr = new DmaapPropertyReader(testinput);
eph = EventPublisherHash.getInstance();
@@ -162,7 +164,7 @@ public class TestEventProcessor {
EventProcessor ec = new EventProcessor();
ec.event=new org.json.JSONObject(ev);
- CommonStartup.cambriaConfigFile="src/test/resources/testDmaapConfig.json";
+ CommonStartup.cambriaConfigFile="src/test/resources/testDmaapConfig_ip.json";
eph.sendEvent(ec.event, "sec_fault_ueb");
assertEquals(true, flag);
@@ -170,4 +172,3 @@ public class TestEventProcessor {
}
}
-
diff --git a/src/test/java/org/onap/dcae/vestest/TestFetchConfig.java b/src/test/java/org/onap/dcae/vestest/TestFetchConfig.java
new file mode 100644
index 00000000..ed3e1086
--- /dev/null
+++ b/src/test/java/org/onap/dcae/vestest/TestFetchConfig.java
@@ -0,0 +1,90 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PROJECT
+ * ================================================================================
+ * Copyright (C) 2018 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.dcae.vestest;
+
+import static org.junit.Assert.*;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.FileReader;
+import java.io.IOException;
+import org.json.JSONObject;
+import com.google.gson.JsonParser;
+import com.google.gson.JsonObject;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dcae.commonFunction.CommonStartup;
+import org.onap.dcae.commonFunction.DmaapPropertyReader;
+import org.onap.dcae.commonFunction.EventProcessor;
+import org.onap.dcae.commonFunction.EventPublisherHash;
+import org.onap.dcae.controller.FetchDynamicConfig;
+
+
+public class TestFetchConfig {
+
+ JSONObject jsonObject;
+
+ @Before
+ public void setUp() throws Exception {
+
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+
+
+ @Test
+ public void testwritefile() {
+ Boolean flag = false;
+
+ FetchDynamicConfig fc = new FetchDynamicConfig();
+ FetchDynamicConfig.configFile = "src/test/resources/controller-config_formatted_op.json";
+
+
+
+ try{
+ JsonParser parser = new JsonParser();
+ FileReader fr = new FileReader ("src/test/resources/controller-config_singleline_ip.json" );
+ final JsonObject jo = (JsonObject) parser.parse (fr);
+ final String jsonText = jo.toString ();
+ jsonObject = new JSONObject ( jsonText );
+ fc.writefile(jsonObject.toString());
+ }
+ catch(Exception e){
+ System.out.println("Exception while opening the file");
+ e.printStackTrace();
+ }
+ if(jsonObject.has("streams_publishes"))
+ {
+ flag = true;
+ }
+
+ assertEquals(true, flag);
+
+ }
+
+
+}
+
diff --git a/src/test/java/org/onap/dcae/vestest/TestLoadDynamicConfig.java b/src/test/java/org/onap/dcae/vestest/TestLoadDynamicConfig.java
index 902add73..765d9c61 100644
--- a/src/test/java/org/onap/dcae/vestest/TestLoadDynamicConfig.java
+++ b/src/test/java/org/onap/dcae/vestest/TestLoadDynamicConfig.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* PROJECT
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018 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.
@@ -21,30 +21,29 @@ package org.onap.dcae.vestest;
import static org.junit.Assert.*;
-import java.io.File;
import java.io.FileReader;
-import java.net.URL;
-import java.util.Map;
-
-import org.json.simple.JSONObject;
+import org.json.JSONObject;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
+import org.onap.dcae.controller.FetchDynamicConfig;
import org.onap.dcae.controller.LoadDynamicConfig;
+import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
public class TestLoadDynamicConfig {
LoadDynamicConfig lc;
- String propop = "src/test/resources/testcollector.properties";
+ String propop = "src/test/resources/test_collector_ip_op.properties";
+
@Before
public void setUp() throws Exception {
-
+ lc = new LoadDynamicConfig();
}
@@ -55,18 +54,50 @@ public class TestLoadDynamicConfig {
@Test
public void testLoad() {
- // File file = new File(".");
- // for(String fileNames : file.list()) System.out.println(fileNames);
Boolean flag=false;
- lc = new LoadDynamicConfig();
- lc.propFile = "src/test/resources/testcollector.properties";
- lc.configFile = "src/test/resources/controller-config.json";
+
+
+ lc.propFile = "src/test/resources/test_collector_ip_op.properties";
+ lc.configFile = "src/test/resources/controller-config_dmaap_ip.json";
String data = LoadDynamicConfig.readFile(propop);
assertEquals(data.isEmpty(), flag);
}
+ @Test
+ public void testwrite() {
+
+
+ Boolean flag=false;
+
+ lc.propFile = "src/test/resources/test_collector_ip_op.properties";
+ lc.configFile = "src/test/resources/controller-config_dmaap_ip.json";
+ lc.dmaapoutputfile = "src/test/resources/DmaapConfig-op.json";
+
+ String data = LoadDynamicConfig.readFile(lc.configFile);
+ JSONObject jsonObject = new JSONObject(data);
+ lc.writeconfig(jsonObject);
+
+ try{
+ JsonParser parser = new JsonParser();
+ FileReader fr = new FileReader ( lc.dmaapoutputfile );
+ final JsonObject jo = (JsonObject) parser.parse (fr);
+ final String jsonText = jo.toString ();
+ jsonObject = new JSONObject ( jsonText );
+ }
+ catch(Exception e){
+ System.out.println("Exception while opening the file");
+ e.printStackTrace();
+ }
+ if(jsonObject.has("ves-fault-secondary"))
+ {
+ flag = true;
+ }
+
+ assertEquals(true, flag);
+
+ }
}
diff --git a/src/test/java/org/onap/dcae/vestest/TestSchemaValidation.java b/src/test/java/org/onap/dcae/vestest/TestSchemaValidation.java
index a34b3336..af8a62f3 100644
--- a/src/test/java/org/onap/dcae/vestest/TestSchemaValidation.java
+++ b/src/test/java/org/onap/dcae/vestest/TestSchemaValidation.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* PROJECT
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -83,30 +83,22 @@ public class TestSchemaValidation {
}
-
+/*
@Test
public void testeventReceipt() {
- //com.att.nsa.drumlin.service.framework.context.DrumlinRequestContext.DrumlinRequestContext(DrumlinServlet webServlet,
- //HttpServletRequest req, HttpServletResponse resp, DrumlinConnection s, Map<String, Object> objects, DrumlinRequestRouter router)
- //HttpServletRequest req = new HttpServletRequest();
- //HttpServletResponse res = new HttpServletResponse();
DrumlinServlet webServlet = new DrumlinServlet();
- //webServlet.addToBaseContext(key, o);
- //Map<String,Object> mp = new Map<String, Object>();
DrumlinRequestContext ctx = new DrumlinRequestContext(webServlet, null, null, null, null, null);
EventReceipt er= new EventReceipt();
try {
EventReceipt.receiveVESEvent(null);
} catch ( NullPointerException e) {
- // TODO Auto-generated catch block
-
+
+ e.printStackTrace();
}
-
-
Assert.assertEquals("true", "true");
- }
+ }*/
@Test
public void testsafeclosefr() {
diff --git a/src/test/java/org/onap/dcae/vestest/TestVESLogger.java b/src/test/java/org/onap/dcae/vestest/TestVESLogger.java
new file mode 100644
index 00000000..3d41eed6
--- /dev/null
+++ b/src/test/java/org/onap/dcae/vestest/TestVESLogger.java
@@ -0,0 +1,115 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PROJECT
+ * ================================================================================
+ * Copyright (C) 2018 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.dcae.vestest;
+
+import static org.junit.Assert.*;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.UUID;
+
+import org.json.JSONObject;
+import com.google.gson.JsonParser;
+import com.att.nsa.logging.LoggingContext;
+import com.google.gson.JsonObject;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dcae.commonFunction.CommonStartup;
+import org.onap.dcae.commonFunction.DmaapPropertyReader;
+import org.onap.dcae.commonFunction.EventProcessor;
+import org.onap.dcae.commonFunction.EventPublisherHash;
+import org.onap.dcae.commonFunction.VESLogger;
+import org.onap.dcae.controller.FetchDynamicConfig;
+
+
+public class TestVESLogger {
+
+ LoggingContext threadLC;
+
+ @Before
+ public void setUp() throws Exception {
+
+ threadLC = null;
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+
+
+ @Test
+ public void testgetCommonLoggingContext() {
+ Boolean flag = false;
+ threadLC = VESLogger.getCommonLoggingContext();
+ if(!threadLC.equals(""))
+ {
+ flag = true;
+ }
+
+ assertEquals(true, flag);
+
+ }
+ @Test
+ public void testUuidgetLoggingContextForThread() {
+ Boolean flag = false;
+ final UUID uuid = UUID.randomUUID();
+ threadLC = VESLogger.getLoggingContextForThread(uuid);
+ //if(threadLC.get("REQUEST_ID", null) != null)
+ if(!threadLC.equals(""))
+ {
+ flag = true;
+ }
+
+ assertEquals(true, flag);
+
+
+ }
+ @Test
+ public void testStringgetLoggingContextForThread() {
+ Boolean flag = false;
+ final UUID uuid = UUID.randomUUID();
+ threadLC = VESLogger.getLoggingContextForThread(uuid.toString());
+ //if(threadLC.get("REQUEST_ID", null) != null)
+ if(!threadLC.equals(""))
+ {
+ flag = true;
+ }
+
+ assertEquals(true, flag);
+
+ }
+
+ @Test
+ public void testsetUpEcompLogging() {
+ Boolean flag = false;
+ VESLogger.setUpEcompLogging();
+
+
+ assertEquals(true, true);
+
+ }
+
+}
+