aboutsummaryrefslogtreecommitdiffstats
path: root/appc-config
diff options
context:
space:
mode:
authorTomek Kaminski <tomasz.kaminski@nokia.com>2018-01-10 16:51:15 +0100
committerSkip Wonnell <skip@att.com>2018-01-10 10:07:56 -0600
commit40bae6d46b1fc0d91da8b16d07b145c86ecf7c0c (patch)
treee3a739635f9df04097442c03587732fb68a37e5b /appc-config
parentf5ae43c807a693e72d98bb4c3aa75f00234224ad (diff)
Fix sonar blockers
Fix https://sonar.onap.org/issues/search#issues=AWBUkk6L-08if2a6vTgG Change-Id: I5257f208b4df95129fcadfd5952988d8efdd8203 Issue-ID: APPC-383 Signed-off-by: Tomek Kaminski <tomasz.kaminski@nokia.com>
Diffstat (limited to 'appc-config')
-rw-r--r--appc-config/appc-config-adaptor/provider/src/main/java/org/onap/appc/ccadaptor/SshJcraftWrapper.java15
-rw-r--r--appc-config/appc-config-adaptor/provider/src/test/java/org/onap/appc/ccadaptor/ConfigComponentAdaptorTest.java55
2 files changed, 34 insertions, 36 deletions
diff --git a/appc-config/appc-config-adaptor/provider/src/main/java/org/onap/appc/ccadaptor/SshJcraftWrapper.java b/appc-config/appc-config-adaptor/provider/src/main/java/org/onap/appc/ccadaptor/SshJcraftWrapper.java
index 3b430bf68..1f161c3b0 100644
--- a/appc-config/appc-config-adaptor/provider/src/main/java/org/onap/appc/ccadaptor/SshJcraftWrapper.java
+++ b/appc-config/appc-config-adaptor/provider/src/main/java/org/onap/appc/ccadaptor/SshJcraftWrapper.java
@@ -1095,20 +1095,17 @@ public class SshJcraftWrapper {
ChannelSftp sftp = (ChannelSftp) sftpSession.openChannel("sftp");
debugLog.printRTAriDebug(fn, "Connecting....");
sftp.connect();
- InputStream in = null;
- in = sftp.get(fullFilePathName);
+ InputStream in = sftp.get(fullFilePathName);
String sftpFileString = readInputStreamAsString(in);
debugLog.printRTAriDebug(fn, "Retreived successfully");
- // debugLog.printRTAriDebug (fn, "sftpFileString="+sftpFileString);
- sftpSession.disconnect();
- sftpSession = null;
- return (sftpFileString);
+ return sftpFileString;
} catch (Exception e) {
debugLog.printRTAriDebug(fn, "Caught an Exception, e=" + e);
- sftpSession.disconnect();
- sftpSession = null;
- // dbLog.storeData("ErrorMsg= sftp threw an Exception. error is:"+e);
throw new IOException(e.toString());
+ } finally {
+ if(sftpSession != null) {
+ sftpSession.disconnect();
+ }
}
}
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
index 4cd3934ae..d767fdede 100644
--- 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
@@ -24,6 +24,7 @@
package org.onap.appc.ccadaptor;
+import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
@@ -34,8 +35,8 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.powermock.reflect.Whitebox;
public class ConfigComponentAdaptorTest {
-
-
+
+
@Test
public void testGetCliRunningConfig(){
Properties props = null;
@@ -51,9 +52,9 @@ public class ConfigComponentAdaptorTest {
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);
+ cca.configure(key, parameters, ctx);
}
-
+
@Test
public void testDownloadCliConfig(){
Properties props = null;
@@ -69,9 +70,9 @@ public class ConfigComponentAdaptorTest {
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);
+ cca.configure(key, parameters, ctx);
}
-
+
@Test
public void testXmlDownload(){
Properties props = null;
@@ -89,7 +90,7 @@ public class ConfigComponentAdaptorTest {
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;
@@ -105,9 +106,9 @@ public class ConfigComponentAdaptorTest {
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);
+ cca.configure(key, parameters, ctx);
}
-
+
@Test
public void testEscapeSql(){
Properties props = null;
@@ -125,7 +126,7 @@ public class ConfigComponentAdaptorTest {
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;
@@ -146,10 +147,10 @@ public class ConfigComponentAdaptorTest {
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);
+ cca.configure(key, parameters, ctx);
}
-
- @Test(expected=Exception.class)
+
+ @Test
public void testAll1(){
Properties props = null;
ConfigComponentAdaptor cca = new ConfigComponentAdaptor(props);
@@ -158,9 +159,9 @@ public class ConfigComponentAdaptorTest {
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);
+ cca.configure(key, parameters, ctx);
}
-
+
@Test(expected=Exception.class)
public void testAll2(){
Properties props = null;
@@ -170,9 +171,9 @@ public class ConfigComponentAdaptorTest {
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);
+ cca.configure(key, parameters, ctx);
}
-
+
@Test
public void testGetStringBetweenQuotes() throws Exception{
Properties props = null;
@@ -180,15 +181,15 @@ public class ConfigComponentAdaptorTest {
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");
+ Whitebox.invokeMethod(cca, "buildXmlRequest",param,"template");
}
-
+
@Test
public void testTrimResponse() throws Exception{
Properties props = null;
@@ -196,7 +197,7 @@ public class ConfigComponentAdaptorTest {
String result =Whitebox.invokeMethod(cca, "trimResponse","testData");
Assert.assertEquals("", result);
}
-
+
@Test
public void testBuildNetworkData2() throws Exception{
Properties props = null;
@@ -205,14 +206,14 @@ public class ConfigComponentAdaptorTest {
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");
+ Whitebox.invokeMethod(cca, "readFile","test");
}
-
+
@Test
public void testConnect() throws Exception{
Properties props = null;
@@ -221,7 +222,7 @@ public class ConfigComponentAdaptorTest {
cca.activate("key", ctx);
}
-
+
@Test(expected=Exception.class)
public void testActivate() throws Exception{
Properties props = null;
@@ -230,7 +231,7 @@ public class ConfigComponentAdaptorTest {
String result =Whitebox.invokeMethod(cca, "activate",ctx,true);
Assert.assertEquals("template", result);
}
-
+
@Test(expected=Exception.class)
public void testAudit() throws Exception{
Properties props = null;
@@ -239,7 +240,7 @@ public class ConfigComponentAdaptorTest {
String result =Whitebox.invokeMethod(cca, "audit",ctx,"test");
Assert.assertEquals("template", result);
}
-
+
@Test(expected=Exception.class)
public void testPrepare() throws Exception{
Properties props = null;