diff options
author | Gao Weitao <victor.gao@huawei.com> | 2018-09-24 12:26:51 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-09-24 12:26:51 +0000 |
commit | f403658a192914866f8f1410e33f9c2788becad4 (patch) | |
tree | d9e926b307cd923016c01d724e35c6cef7f50523 | |
parent | 24498e4698ce68d8c9e853cad3d4e19d67aeb23c (diff) | |
parent | a53c8b9d59eb61ab20808442330e512539daa57c (diff) |
Merge changes Ic2edca79,Ife3d5814,I8c9a6768
* changes:
update sample casr with csar.meta
Fix the File manager to pick the correct handler
VTP: Validate Throw exception while VTP-TC failed
4 files changed, 59 insertions, 25 deletions
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/filemanage/FileManagerFactory.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/filemanage/FileManagerFactory.java index b23bcac4..e35e0fe0 100644 --- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/filemanage/FileManagerFactory.java +++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/filemanage/FileManagerFactory.java @@ -48,7 +48,7 @@ public class FileManagerFactory { private static FileManagerType getType() { String type = System.getenv("useFtp"); logger.info("read environment varibale uesFtp:" + type); - if (type != null && "true".equals(type)) { + if ((type != null) && "true".equals(type)) { return FileManagerType.ftp; } else { return FileManagerType.http; diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/resource/PackageResourceTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/resource/PackageResourceTest.java index 92b5b525..dcd3c4c4 100644 --- a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/resource/PackageResourceTest.java +++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/resource/PackageResourceTest.java @@ -685,30 +685,6 @@ public class PackageResourceTest { } }; - new MockUp<PackageWrapperUtil>() { - - @Mock - public PackageData getPackageData(PackageMeta meta) { - PackageData packageData = new PackageData(); - packageData.setCreateTime("25-3-2017 15:26:00"); - packageData.setDeletionPending("deletion"); - packageData.setDownloadUri("downloaduri"); - packageData.setFormat("format"); - packageData.setModifyTime("time"); - packageData.setName("name"); - packageData.setCsarId("csarid"); - packageData.setProvider("huawei"); - String fileSize = "10 mb"; - packageData.setSize(fileSize); - packageData.setType("type"); - packageData.setVersion("v2.0"); - packageData.setDetails("details"); - packageData.setShortDesc("description"); - packageData.setRemarks("remarks"); - return packageData; - } - }; - new MockUp<PackageHandler>() { @Mock diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/resource/VTPResourceTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/resource/VTPResourceTest.java index 19fba962..2d2bed08 100644 --- a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/resource/VTPResourceTest.java +++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/resource/VTPResourceTest.java @@ -80,6 +80,20 @@ public class VTPResourceTest { } @Test + public void testVtpGetTestsFailure2() throws Exception { + new MockUp<OpenRemoteCli>() { + + @Mock + public Result run(String[] args) throws Exception { + throw new Exception(); + } + }; + + Response result = vtpResource.listTests(); + assertEquals(500, result.getStatus()); + } + + @Test public void testVtpRunTests() throws Exception { new MockUp<OpenRemoteCli>() { @@ -175,4 +189,48 @@ public class VTPResourceTest { Response result = vtpResource.runTest("csar-validate", (HttpServletRequest) mockReq.getMockInstance()); assertEquals(500, result.getStatus()); } + + @Test + public void testVtpRunTestsFailure2() throws Exception { + new MockUp<OpenRemoteCli>() { + + @Mock + public Result run(String[] args) throws Exception { + throw new Exception(); + } + }; + + MockUp mockReq = new MockUp<HttpServletRequest>() { + + @Mock + public ServletInputStream getInputStream() throws IOException { + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( + "{\"csar\"=\"VoLTE.csar\"}".getBytes()); + + return new ServletInputStream(){ + public int read() throws IOException { + return byteArrayInputStream.read(); + } + + @Override + public boolean isFinished() { + return true; + } + + @Override + public boolean isReady() { + return true; + } + + @Override + public void setReadListener(ReadListener arg0) { + } + }; + } + + }; + + Response result = vtpResource.runTest("csar-validate", (HttpServletRequest) mockReq.getMockInstance()); + assertEquals(500, result.getStatus()); + } } diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/resources/clearwater_ns.csar b/vnfmarket-be/vnf-sdk-marketplace/src/test/resources/clearwater_ns.csar Binary files differindex 0960b20a..5f5762b3 100644 --- a/vnfmarket-be/vnf-sdk-marketplace/src/test/resources/clearwater_ns.csar +++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/resources/clearwater_ns.csar |