From 161df8a94bb3b0c34ed16fd4fdba078bd1eeef9a Mon Sep 17 00:00:00 2001 From: Patrick Brady Date: Wed, 13 Dec 2017 11:14:21 -0800 Subject: Second part of onap rename This is the second commit of the rename. The folder structure is renamed for appc-adapters and appc-config in this commit. Change-Id: Iaa2b8c937ff1ca1b5d1178128961fb115ee65d9b Signed-off-by: Patrick Brady Issue-ID: APPC-13 --- .../appc/ccadaptor/ConfigComponentAdaptorTest.java | 251 +++++++++++++++++++++ .../java/org/onap/appc/ccadaptor/DebugLogTest.java | 38 ++++ .../onap/appc/ccadaptor/EncryptionToolTest.java | 46 ++++ .../onap/appc/ccadaptor/SshJcraftWrapperTest.java | 105 +++++++++ .../java/org/onap/appc/ccadaptor/XmlUtilTest.java | 42 ++++ .../appc/ccadaptor/ConfigComponentAdaptorTest.java | 251 --------------------- .../org/openecomp/appc/ccadaptor/DebugLogTest.java | 38 ---- .../appc/ccadaptor/EncryptionToolTest.java | 46 ---- .../appc/ccadaptor/SshJcraftWrapperTest.java | 105 --------- .../org/openecomp/appc/ccadaptor/XmlUtilTest.java | 42 ---- 10 files changed, 482 insertions(+), 482 deletions(-) create mode 100644 appc-config/appc-config-adaptor/provider/src/test/java/org/onap/appc/ccadaptor/ConfigComponentAdaptorTest.java create mode 100644 appc-config/appc-config-adaptor/provider/src/test/java/org/onap/appc/ccadaptor/DebugLogTest.java create mode 100644 appc-config/appc-config-adaptor/provider/src/test/java/org/onap/appc/ccadaptor/EncryptionToolTest.java create mode 100644 appc-config/appc-config-adaptor/provider/src/test/java/org/onap/appc/ccadaptor/SshJcraftWrapperTest.java create mode 100644 appc-config/appc-config-adaptor/provider/src/test/java/org/onap/appc/ccadaptor/XmlUtilTest.java delete mode 100644 appc-config/appc-config-adaptor/provider/src/test/java/org/openecomp/appc/ccadaptor/ConfigComponentAdaptorTest.java delete mode 100644 appc-config/appc-config-adaptor/provider/src/test/java/org/openecomp/appc/ccadaptor/DebugLogTest.java delete mode 100644 appc-config/appc-config-adaptor/provider/src/test/java/org/openecomp/appc/ccadaptor/EncryptionToolTest.java delete mode 100644 appc-config/appc-config-adaptor/provider/src/test/java/org/openecomp/appc/ccadaptor/SshJcraftWrapperTest.java delete mode 100644 appc-config/appc-config-adaptor/provider/src/test/java/org/openecomp/appc/ccadaptor/XmlUtilTest.java (limited to 'appc-config/appc-config-adaptor/provider/src/test/java/org') diff --git a/appc-config/appc-config-adaptor/provider/src/test/java/org/onap/appc/ccadaptor/ConfigComponentAdaptorTest.java b/appc-config/appc-config-adaptor/provider/src/test/java/org/onap/appc/ccadaptor/ConfigComponentAdaptorTest.java new file mode 100644 index 000000000..4cd3934ae --- /dev/null +++ b/appc-config/appc-config-adaptor/provider/src/test/java/org/onap/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.onap.appc.ccadaptor; + +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +import org.junit.Assert; +import org.junit.Test; +import org.onap.ccsdk.sli.core.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 parameters = new HashMap(); + 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 parameters = new HashMap(); + 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 parameters = new HashMap(); + 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 parameters = new HashMap(); + 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 parameters = new HashMap(); + 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 parameters = new HashMap(); + 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 parameters = new HashMap(); + 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 parameters = new HashMap(); + 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 param = new HashMap(); + 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/onap/appc/ccadaptor/DebugLogTest.java b/appc-config/appc-config-adaptor/provider/src/test/java/org/onap/appc/ccadaptor/DebugLogTest.java new file mode 100644 index 000000000..6fcb62675 --- /dev/null +++ b/appc-config/appc-config-adaptor/provider/src/test/java/org/onap/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.onap.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/onap/appc/ccadaptor/EncryptionToolTest.java b/appc-config/appc-config-adaptor/provider/src/test/java/org/onap/appc/ccadaptor/EncryptionToolTest.java new file mode 100644 index 000000000..afa9137db --- /dev/null +++ b/appc-config/appc-config-adaptor/provider/src/test/java/org/onap/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.onap.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/onap/appc/ccadaptor/SshJcraftWrapperTest.java b/appc-config/appc-config-adaptor/provider/src/test/java/org/onap/appc/ccadaptor/SshJcraftWrapperTest.java new file mode 100644 index 000000000..ef1bf7d7f --- /dev/null +++ b/appc-config/appc-config-adaptor/provider/src/test/java/org/onap/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.onap.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/onap/appc/ccadaptor/XmlUtilTest.java b/appc-config/appc-config-adaptor/provider/src/test/java/org/onap/appc/ccadaptor/XmlUtilTest.java new file mode 100644 index 000000000..59cabc26f --- /dev/null +++ b/appc-config/appc-config-adaptor/provider/src/test/java/org/onap/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.onap.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 varmap = new HashMap(); + varmap.put("network.data", "test"); + String xmlData = XmlUtil.getXml(varmap, "network"); + Assert.assertEquals("test\n", xmlData); + } +} \ No newline at end of file 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 deleted file mode 100644 index 4cd3934ae..000000000 --- a/appc-config/appc-config-adaptor/provider/src/test/java/org/openecomp/appc/ccadaptor/ConfigComponentAdaptorTest.java +++ /dev/null @@ -1,251 +0,0 @@ -/*- - * ============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.onap.appc.ccadaptor; - -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; - -import org.junit.Assert; -import org.junit.Test; -import org.onap.ccsdk.sli.core.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 parameters = new HashMap(); - 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 parameters = new HashMap(); - 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 parameters = new HashMap(); - 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 parameters = new HashMap(); - 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 parameters = new HashMap(); - 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 parameters = new HashMap(); - 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 parameters = new HashMap(); - 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 parameters = new HashMap(); - 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 param = new HashMap(); - 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 deleted file mode 100644 index 6fcb62675..000000000 --- a/appc-config/appc-config-adaptor/provider/src/test/java/org/openecomp/appc/ccadaptor/DebugLogTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/*- - * ============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.onap.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 deleted file mode 100644 index afa9137db..000000000 --- a/appc-config/appc-config-adaptor/provider/src/test/java/org/openecomp/appc/ccadaptor/EncryptionToolTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * ============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.onap.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 deleted file mode 100644 index ef1bf7d7f..000000000 --- a/appc-config/appc-config-adaptor/provider/src/test/java/org/openecomp/appc/ccadaptor/SshJcraftWrapperTest.java +++ /dev/null @@ -1,105 +0,0 @@ -/*- - * ============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.onap.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 deleted file mode 100644 index 59cabc26f..000000000 --- a/appc-config/appc-config-adaptor/provider/src/test/java/org/openecomp/appc/ccadaptor/XmlUtilTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/*- - * ============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.onap.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 varmap = new HashMap(); - varmap.put("network.data", "test"); - String xmlData = XmlUtil.getXml(varmap, "network"); - Assert.assertEquals("test\n", xmlData); - } -} \ No newline at end of file -- cgit 1.2.3-korg