diff options
author | Murali-P <murali.p@huawei.com> | 2017-02-15 15:23:04 +0530 |
---|---|---|
committer | Murali-P <murali.p@huawei.com> | 2017-02-15 15:23:04 +0530 |
commit | 1b3e6286ab22c5a807e590e5d8188e5b34ae650d (patch) | |
tree | d69f6830d75e8cf7766fa6dcd77e8c7712894332 /vnf-sdk-function-test/src | |
parent | d0b8cbc046384f257ecebf3cec894fac91ae6d2b (diff) |
Fix Sonar issues
Resolved:VNFSDK-21
Function test base code
Change-Id: I8aefca4ba9f311e1bbcf87447d8326c6b181818c
Signed-off-by: Murali-P <murali.p@huawei.com>
Diffstat (limited to 'vnf-sdk-function-test/src')
6 files changed, 15 insertions, 17 deletions
diff --git a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/TaskExecution.java b/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/TaskExecution.java index c95acdf..aa89f30 100644 --- a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/TaskExecution.java +++ b/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/TaskExecution.java @@ -48,7 +48,7 @@ public class TaskExecution { mapValues = mapper.readValue(new FileInputStream(confDir + "robotMetaData.json"), Map.class); } catch(IOException e) { - LOGGER.error("Reading Json Meta data file failed or file do not exist" + e.getMessage()); + LOGGER.error("Reading Json Meta data file failed or file do not exist", e); return; } @@ -92,11 +92,11 @@ public class TaskExecution { process = Runtime.getRuntime().exec(command); inputStream = process.getInputStream(); while((ch = inputStream.read()) != -1) { - LOGGER.info("" + ch); + LOGGER.info("character ..." + Integer.toString(ch)); } } catch(Exception e) { - LOGGER.error("TaskExecution ... executeScript() ... [Exception] ..." + e.getMessage()); + LOGGER.error("TaskExecution ... executeScript() ... [Exception] ...", e); } } diff --git a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/VnfSdkFuncTestApp.java b/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/VnfSdkFuncTestApp.java index faca92e..b368f23 100644 --- a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/VnfSdkFuncTestApp.java +++ b/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/VnfSdkFuncTestApp.java @@ -81,7 +81,8 @@ public class VnfSdkFuncTestApp extends Application<VnfSdkFuncTestAppConfiguratio String basePath = simpleServerFactory.getApplicationContextPath(); String rootPath = simpleServerFactory.getJerseyRootPath(); rootPath = rootPath.substring(0, rootPath.indexOf("/*")); - basePath = basePath.equals("/") ? rootPath : (new StringBuilder()).append(basePath).append(rootPath).toString(); + basePath = + ("/").equals(rootPath) ? rootPath : (new StringBuilder()).append(basePath).append(rootPath).toString(); config.setBasePath(basePath); config.setScan(true); } diff --git a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/common/ServiceRegistration.java b/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/common/ServiceRegistration.java index a09fb63..ada7d78 100644 --- a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/common/ServiceRegistration.java +++ b/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/common/ServiceRegistration.java @@ -56,7 +56,7 @@ public class ServiceRegistration implements Runnable { try { Thread.sleep(second); } catch(InterruptedException error) { - LOG.error("thread sleep error.errorMsg:" + error.getMessage()); + LOG.error("thread sleep error.errorMsg:", error); } LOG.info("sleep end ."); } diff --git a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/resource/CommonManager.java b/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/resource/CommonManager.java index 81fa12e..3fef44e 100644 --- a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/resource/CommonManager.java +++ b/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/resource/CommonManager.java @@ -106,8 +106,7 @@ public class CommonManager { return response; } catch(IOException e) { - - e.printStackTrace(); + LOGGER.error("Upload the script and execute the script and run command", e); } return null; @@ -131,7 +130,7 @@ public class CommonManager { public String storeChunkFileInLocal(String dirName, String fileName, InputStream uploadedInputStream) throws IOException { File tmpDir = new File(dirName); - System.out.println("tmpdir = " + dirName); + LOGGER.info("tmpdir=" + dirName); if(!tmpDir.exists()) { tmpDir.mkdirs(); } diff --git a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/responsehandler/VnfFuncTestResponseHandler.java b/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/responsehandler/VnfFuncTestResponseHandler.java index 97f410d..9005ef8 100644 --- a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/responsehandler/VnfFuncTestResponseHandler.java +++ b/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/responsehandler/VnfFuncTestResponseHandler.java @@ -56,7 +56,7 @@ public class VnfFuncTestResponseHandler { return vnfFuncRspHandler; } - public void setConfigMap(Map<String, String> inMapConfigValues) { + public static void setConfigMap(Map<String, String> inMapConfigValues) { mapConfigValues = inMapConfigValues; } @@ -83,8 +83,7 @@ public class VnfFuncTestResponseHandler { try { new ZipCompressor(zipFileName).compress(fileName); } catch(IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + logger.error("getResponseByFuncTestId ", e); } /* @@ -103,7 +102,6 @@ public class VnfFuncTestResponseHandler { /* * Later will delete this file..FileUtil.deleteDirectory(fileName); */ - logger.warn("Resquested function Test result Sucess !!!"); return RestResponseUtil.getSuccessResponse(byteArrayFile); } else { @@ -120,7 +118,7 @@ public class VnfFuncTestResponseHandler { try { mapConfigValues = mapper.readValue(new FileInputStream(confDir + "robotMetaData.json"), Map.class); } catch(IOException e) { - logger.error("Reading Json Meta data file failed or file do not exist" + e.getMessage()); + logger.error("Reading Json Meta data file failed or file do not exist", e); return; } } diff --git a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/util/ZipCompressor.java b/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/util/ZipCompressor.java index 7f3562c..885a97a 100644 --- a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/util/ZipCompressor.java +++ b/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/util/ZipCompressor.java @@ -48,7 +48,7 @@ public class ZipCompressor { * @param pathName file path name * @throws Exception */ - public void compress(String... pathName) throws Exception { + public void compress(String... pathName) { ZipOutputStream out = null; FileOutputStream fileOutputStream = null; CheckedOutputStream cos = null; @@ -61,11 +61,11 @@ public class ZipCompressor { compress(new File(pathName[i]), out, basedir); } - } catch(Exception e1) { + } catch(FileNotFoundException e1) { try { throw new FileNotFoundException("Failed to find file: "); } catch(FileNotFoundException e) { - LOG.error("compress: " + e); + LOG.error("compress: ", e); } } finally { try { @@ -76,7 +76,7 @@ public class ZipCompressor { if(cos != null) cos.close(); } catch(Exception e1) { - throw new IOException(e1); + LOG.error("Error while closing stream: ", e1); } } } |