summaryrefslogtreecommitdiffstats
path: root/appc-config/appc-config-adaptor/provider/src
diff options
context:
space:
mode:
authorChaturvedi, Anand (ac204h) <ac204h@att.com>2017-09-01 15:35:26 -0400
committerChaturvedi, Anand (ac204h) <ac204h@att.com>2017-09-01 16:06:56 -0400
commit50fdfca221554d0433b7608777285ec94b7a1b62 (patch)
tree067f855222ebc6abf4e13b90bbceb6e41ea572b6 /appc-config/appc-config-adaptor/provider/src
parent48f77d60c3a7a9fcfb6f13b6da1fa48b7dd4ff34 (diff)
Junit Cases for Application Controller.
Issue-ID: APPC-168 Change-Id: Iacfc853bef0b641599c60055ac05b1fd090ee3f8 Signed-off-by: Chaturvedi, Anand (ac204h) <ac204h@att.com>
Diffstat (limited to 'appc-config/appc-config-adaptor/provider/src')
-rw-r--r--appc-config/appc-config-adaptor/provider/src/test/java/org/openecomp/appc/ccadaptor/ConfigComponentAdaptorTest.java251
-rw-r--r--appc-config/appc-config-adaptor/provider/src/test/java/org/openecomp/appc/ccadaptor/DebugLogTest.java38
-rw-r--r--appc-config/appc-config-adaptor/provider/src/test/java/org/openecomp/appc/ccadaptor/EncryptionToolTest.java46
-rw-r--r--appc-config/appc-config-adaptor/provider/src/test/java/org/openecomp/appc/ccadaptor/SshJcraftWrapperTest.java105
-rw-r--r--appc-config/appc-config-adaptor/provider/src/test/java/org/openecomp/appc/ccadaptor/XmlUtilTest.java42
5 files changed, 482 insertions, 0 deletions
diff --git a/appc-config/appc-config-adaptor/provider/src/test/java/org/openecomp/appc/ccadaptor/ConfigComponentAdaptorTest.java b/appc-config/appc-config-adaptor/provider/src/test/java/org/openecomp/appc/ccadaptor/ConfigComponentAdaptorTest.java
new file mode 100644
index 000000000..17331eea4
--- /dev/null
+++ b/appc-config/appc-config-adaptor/provider/src/test/java/org/openecomp/appc/ccadaptor/ConfigComponentAdaptorTest.java
@@ -0,0 +1,251 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.ccadaptor;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+import org.powermock.reflect.Whitebox;
+
+public class ConfigComponentAdaptorTest {
+
+
+ @Test
+ public void testGetCliRunningConfig(){
+ Properties props = null;
+ ConfigComponentAdaptor cca = new ConfigComponentAdaptor(props);
+ String Get_config_template = ("get_config_template");
+ String key = "GetCliRunningConfig";
+ Map<String, String> parameters = new HashMap<String, String>();
+ parameters.put("Host_ip_address", "test");
+ parameters.put("User_name", "test");
+ parameters.put("Password", "password");
+ parameters.put("Port_number", "22");
+ parameters.put("Get_config_template", Get_config_template);
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("service-data.vnf-config-parameters-list.vnf-config-parameters[0].update-configuration[0].block-key-name", "test");
+ cca.configure(key, parameters, ctx);
+ }
+
+ @Test
+ public void testDownloadCliConfig(){
+ Properties props = null;
+ ConfigComponentAdaptor cca = new ConfigComponentAdaptor(props);
+ String Get_config_template = ("get_config_template");
+ String key = "DownloadCliConfig";
+ Map<String, String> parameters = new HashMap<String, String>();
+ parameters.put("Host_ip_address", "test");
+ parameters.put("User_name", "test");
+ parameters.put("Password", "password");
+ parameters.put("Port_number", "22");
+ parameters.put("Get_config_template", Get_config_template);
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("service-data.vnf-config-parameters-list.vnf-config-parameters[0].update-configuration[0].block-key-name", "test");
+ cca.configure(key, parameters, ctx);
+ }
+
+ @Test
+ public void testXmlDownload(){
+ Properties props = null;
+ ConfigComponentAdaptor cca = new ConfigComponentAdaptor(props);
+ String Get_config_template = ("get_config_template");
+ String key = "xml-download";
+ Map<String, String> parameters = new HashMap<String, String>();
+ parameters.put("Host_ip_address", "test");
+ parameters.put("User_name", "test");
+ parameters.put("Password", "password");
+ parameters.put("Port_number", "22");
+ parameters.put("Get_config_template", Get_config_template);
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("service-data.vnf-config-parameters-list.vnf-config-parameters[0].update-configuration[0].block-key-name", "test");
+ cca.configure(key, parameters, ctx);
+ }
+
+ @Test
+ public void testXmlGetrunningconfig(){
+ Properties props = null;
+ ConfigComponentAdaptor cca = new ConfigComponentAdaptor(props);
+ String Get_config_template = ("get_config_template");
+ String key = "xml-getrunningconfig";
+ Map<String, String> parameters = new HashMap<String, String>();
+ parameters.put("Host_ip_address", "test");
+ parameters.put("User_name", "test");
+ parameters.put("Password", "password");
+ parameters.put("Port_number", "22");
+ parameters.put("Get_config_template", Get_config_template);
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("service-data.vnf-config-parameters-list.vnf-config-parameters[0].update-configuration[0].block-key-name", "test");
+ cca.configure(key, parameters, ctx);
+ }
+
+ @Test
+ public void testEscapeSql(){
+ Properties props = null;
+ ConfigComponentAdaptor cca = new ConfigComponentAdaptor(props);
+ String Get_config_template = ("get_config_template");
+ String key = "escapeSql";
+ Map<String, String> parameters = new HashMap<String, String>();
+ parameters.put("Host_ip_address", "test");
+ parameters.put("User_name", "test");
+ parameters.put("Password", "password");
+ parameters.put("Port_number", "22");
+ parameters.put("Get_config_template", Get_config_template);
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("service-data.vnf-config-parameters-list.vnf-config-parameters[0].update-configuration[0].block-key-name", "test");
+ cca.configure(key, parameters, ctx);
+ }
+
+ @Test
+ public void testAll(){
+ Properties props = null;
+ ConfigComponentAdaptor cca = new ConfigComponentAdaptor(props);
+ String Get_config_template = ("test");
+ String Download_config_template = ("test");
+ String key = "GetCliRunningConfig";
+ Map<String, String> parameters = new HashMap<String,String>();
+ parameters.put("Host_ip_address", "test");
+ parameters.put("User_name", "test");
+ parameters.put("Password", "password");
+ parameters.put("Port_number", "22");
+ parameters.put("Protocol", "netconf");
+ parameters.put("Contents", "Contents");
+ parameters.put("Get_config_template", Get_config_template);
+ parameters.put("Download_config_template", Download_config_template);
+ parameters.put("Config_contents", "test");
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("service-data.vnf-config-parameters-list.vnf-config-parameters[0].update-configuration[0].block-key-name", "test");
+ cca.configure(key, parameters, ctx);
+ }
+
+ @Test(expected=Exception.class)
+ public void testAll1(){
+ Properties props = null;
+ ConfigComponentAdaptor cca = new ConfigComponentAdaptor(props);
+ String key = "get";
+ Map<String, String> parameters = new HashMap<String,String>();
+ parameters.put("Host_ip_address", "test");
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("service-data.vnf-config-parameters-list.vnf-config-parameters[0].update-configuration[0].block-key-name", "test");
+ cca.configure(key, parameters, ctx);
+ }
+
+ @Test(expected=Exception.class)
+ public void testAll2(){
+ Properties props = null;
+ ConfigComponentAdaptor cca = new ConfigComponentAdaptor(props);
+ String key = "cli";
+ Map<String, String> parameters = new HashMap<String,String>();
+ parameters.put("Host_ip_address", "test");
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("service-data.vnf-config-parameters-list.vnf-config-parameters[0].update-configuration[0].block-key-name", "test");
+ cca.configure(key, parameters, ctx);
+ }
+
+ @Test
+ public void testGetStringBetweenQuotes() throws Exception{
+ Properties props = null;
+ ConfigComponentAdaptor cca = new ConfigComponentAdaptor(props);
+ String result =Whitebox.invokeMethod(cca, "getStringBetweenQuotes","\"testvalue\"");
+ Assert.assertEquals("testvalue", result);
+ }
+
+ @Test
+ public void testBuildXmlRequest() throws Exception{
+ Properties props = null;
+ ConfigComponentAdaptor cca = new ConfigComponentAdaptor(props);
+ Map<String, String> param = new HashMap<String,String>();
+ Whitebox.invokeMethod(cca, "buildXmlRequest",param,"template");
+ }
+
+ @Test
+ public void testTrimResponse() throws Exception{
+ Properties props = null;
+ ConfigComponentAdaptor cca = new ConfigComponentAdaptor(props);
+ String result =Whitebox.invokeMethod(cca, "trimResponse","testData");
+ Assert.assertEquals("", result);
+ }
+
+ @Test
+ public void testBuildNetworkData2() throws Exception{
+ Properties props = null;
+ ConfigComponentAdaptor cca = new ConfigComponentAdaptor(props);
+ SvcLogicContext ctx = new SvcLogicContext();
+ String result =Whitebox.invokeMethod(cca, "buildNetworkData2",ctx,"template","operation");
+ Assert.assertEquals("template", result);
+ }
+
+ //@Test
+ public void testGetLastFewLinesOfFile() throws Exception{
+ Properties props = null;
+ ConfigComponentAdaptor cca = new ConfigComponentAdaptor(props);
+ Whitebox.invokeMethod(cca, "readFile","test");
+ }
+
+ @Test
+ public void testConnect() throws Exception{
+ Properties props = null;
+ ConfigComponentAdaptor cca = new ConfigComponentAdaptor(props);
+ SvcLogicContext ctx = new SvcLogicContext();
+ cca.activate("key", ctx);
+
+ }
+
+ @Test(expected=Exception.class)
+ public void testActivate() throws Exception{
+ Properties props = null;
+ ConfigComponentAdaptor cca = new ConfigComponentAdaptor(props);
+ SvcLogicContext ctx = new SvcLogicContext();
+ String result =Whitebox.invokeMethod(cca, "activate",ctx,true);
+ Assert.assertEquals("template", result);
+ }
+
+ @Test(expected=Exception.class)
+ public void testAudit() throws Exception{
+ Properties props = null;
+ ConfigComponentAdaptor cca = new ConfigComponentAdaptor(props);
+ SvcLogicContext ctx = new SvcLogicContext();
+ String result =Whitebox.invokeMethod(cca, "audit",ctx,"test");
+ Assert.assertEquals("template", result);
+ }
+
+ @Test(expected=Exception.class)
+ public void testPrepare() throws Exception{
+ Properties props = null;
+ ConfigComponentAdaptor cca = new ConfigComponentAdaptor(props);
+ SvcLogicContext ctx = new SvcLogicContext();
+ String result =Whitebox.invokeMethod(cca, "prepare",ctx,"test","test");
+ Assert.assertEquals("template", result);
+ }
+}
diff --git a/appc-config/appc-config-adaptor/provider/src/test/java/org/openecomp/appc/ccadaptor/DebugLogTest.java b/appc-config/appc-config-adaptor/provider/src/test/java/org/openecomp/appc/ccadaptor/DebugLogTest.java
new file mode 100644
index 000000000..522c00279
--- /dev/null
+++ b/appc-config/appc-config-adaptor/provider/src/test/java/org/openecomp/appc/ccadaptor/DebugLogTest.java
@@ -0,0 +1,38 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.ccadaptor;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class DebugLogTest {
+
+ @Test
+ public void TestGetDateTime() {
+ String DateTime = DebugLog.getDateTime();
+ Assert.assertNotNull(DateTime);
+ }
+
+} \ No newline at end of file
diff --git a/appc-config/appc-config-adaptor/provider/src/test/java/org/openecomp/appc/ccadaptor/EncryptionToolTest.java b/appc-config/appc-config-adaptor/provider/src/test/java/org/openecomp/appc/ccadaptor/EncryptionToolTest.java
new file mode 100644
index 000000000..e352098db
--- /dev/null
+++ b/appc-config/appc-config-adaptor/provider/src/test/java/org/openecomp/appc/ccadaptor/EncryptionToolTest.java
@@ -0,0 +1,46 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.ccadaptor;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class EncryptionToolTest {
+
+ @Test
+ public void testEncrypt() {
+ EncryptionTool tool = EncryptionTool.getInstance();
+ String value = tool.encrypt("encrypt");
+ Assert.assertEquals("enc:JjEZHlg7VQ==", value);
+ }
+
+ @Test
+ public void testDecrypt() {
+ EncryptionTool tool = EncryptionTool.getInstance();
+ String value = tool.decrypt("enc:JjEZHlg7VQ==");
+ Assert.assertEquals("encrypt", value);
+ }
+
+} \ No newline at end of file
diff --git a/appc-config/appc-config-adaptor/provider/src/test/java/org/openecomp/appc/ccadaptor/SshJcraftWrapperTest.java b/appc-config/appc-config-adaptor/provider/src/test/java/org/openecomp/appc/ccadaptor/SshJcraftWrapperTest.java
new file mode 100644
index 000000000..64e338b58
--- /dev/null
+++ b/appc-config/appc-config-adaptor/provider/src/test/java/org/openecomp/appc/ccadaptor/SshJcraftWrapperTest.java
@@ -0,0 +1,105 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.ccadaptor;
+
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.net.URL;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class SshJcraftWrapperTest {
+
+ @Test
+ public void TestCheckIfReceivedStringMatchesDelimeter(){
+ SshJcraftWrapper wrapper = new SshJcraftWrapper();
+ wrapper.getTheDate();
+ boolean result = wrapper.checkIfReceivedStringMatchesDelimeter("#", "test#", "test#");
+ Assert.assertEquals(true, result);
+ }
+
+ @Test
+ public void testRemoveWhiteSpaceAndNewLineCharactersAroundString(){
+ SshJcraftWrapper wrapper = new SshJcraftWrapper();
+ String nameSpace = wrapper.removeWhiteSpaceAndNewLineCharactersAroundString("namespace ");
+ Assert.assertEquals("namespace", nameSpace);
+ }
+
+ @Test
+ public void testStripOffCmdFromRouterResponse(){
+ SshJcraftWrapper wrapper = new SshJcraftWrapper();
+ String result = wrapper.stripOffCmdFromRouterResponse("test\nsuccess");
+ Assert.assertEquals("success\n", result);
+ }
+
+ //@Test
+ public void testGetLastFewLinesOfFile() throws FileNotFoundException, IOException{
+ SshJcraftWrapper wrapper = new SshJcraftWrapper();
+ URL path = SshJcraftWrapperTest.class.getResource("Test");
+ File file = new File(path.getFile());
+ String value = wrapper.getLastFewLinesOfFile(file,1);
+ Assert.assertEquals("\nTest data 3", value);
+ }
+
+ @Test(expected=Exception.class)
+ public void testSetRouterCommandType() throws IOException{
+ SshJcraftWrapper wrapper = new SshJcraftWrapper();
+ wrapper.setRouterCommandType("test");
+ wrapper.receiveUntil("test", 2, "test");
+ }
+
+ @Test
+ public void testValues() throws IOException{
+ SshJcraftWrapper wrapper = new SshJcraftWrapper();
+ wrapper.setEquipNameCode("testcode");
+ wrapper.setRouterCommandType("testcommand");
+ String equipName =wrapper.getEquipNameCode();
+ wrapper.getHostName();
+ wrapper.getPassWord();
+ wrapper.getRouterName();
+ wrapper.getUserName();
+ wrapper.getTheDate();
+ Assert.assertEquals("testcode", equipName);
+ }
+
+ @Test(expected=Exception.class)
+ public void testSetRouterCommandType2() throws IOException{
+ SshJcraftWrapper wrapper = new SshJcraftWrapper();
+ wrapper.appendToRouterFile("test", 2);
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("test");
+ wrapper.appendToRouterFile("Test.txt", buffer);
+ wrapper.receiveUntilBufferFlush(3, 4, "test");
+ }
+
+ @Test(expected=Exception.class)
+ public void testSetRouterCommandType3() throws IOException{
+ SshJcraftWrapper wrapper = new SshJcraftWrapper();
+ wrapper.checkIfReceivedStringMatchesDelimeter(3, "test");
+ }
+}
diff --git a/appc-config/appc-config-adaptor/provider/src/test/java/org/openecomp/appc/ccadaptor/XmlUtilTest.java b/appc-config/appc-config-adaptor/provider/src/test/java/org/openecomp/appc/ccadaptor/XmlUtilTest.java
new file mode 100644
index 000000000..5621a3d7d
--- /dev/null
+++ b/appc-config/appc-config-adaptor/provider/src/test/java/org/openecomp/appc/ccadaptor/XmlUtilTest.java
@@ -0,0 +1,42 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.ccadaptor;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class XmlUtilTest {
+
+ @Test
+ public void testXml() {
+ Map<String, String> varmap = new HashMap<String, String>();
+ varmap.put("network.data", "test");
+ String xmlData = XmlUtil.getXml(varmap, "network");
+ Assert.assertEquals("<data>test</data>\n", xmlData);
+ }
+} \ No newline at end of file