From ec5e47d58ebbc95d56ea98d84ca2fc2290b4b398 Mon Sep 17 00:00:00 2001 From: Kanagaraj Manickam k00365106 Date: Mon, 24 Sep 2018 10:46:14 +0530 Subject: VTP: Validate Throw exception while VTP-TC failed Issue-ID: VNFSDK-304 Change-Id: I8c9a67687ddaa62149035b3b55fba1f846b923c1 Signed-off-by: Kanagaraj Manickam k00365106 --- .../marketplace/resource/VTPResourceTest.java | 58 ++++++++++++++++++++++ 1 file changed, 58 insertions(+) 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 @@ -79,6 +79,20 @@ public class VTPResourceTest { assertEquals(500, result.getStatus()); } + @Test + public void testVtpGetTestsFailure2() throws Exception { + new MockUp() { + + @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() { @@ -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() { + + @Mock + public Result run(String[] args) throws Exception { + throw new Exception(); + } + }; + + MockUp mockReq = new MockUp() { + + @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()); + } } -- cgit 1.2.3-korg From d50329d39901f18a7f410f0df3dc943d5180ea66 Mon Sep 17 00:00:00 2001 From: Kanagaraj Manickam k00365106 Date: Mon, 24 Sep 2018 12:36:28 +0530 Subject: Fix the File manager to pick the correct handler Issue-ID: VNFSDK-304 Change-Id: Ife3d5814114d7e88af23a26b20b06432fbffe599 Signed-off-by: Kanagaraj Manickam k00365106 --- .../java/org/onap/vnfsdk/marketplace/filemanage/FileManagerFactory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; -- cgit 1.2.3-korg From a53c8b9d59eb61ab20808442330e512539daa57c Mon Sep 17 00:00:00 2001 From: Kanagaraj Manickam k00365106 Date: Mon, 24 Sep 2018 13:12:01 +0530 Subject: update sample casr with csar.meta Issue-ID: VNFSDK-304 Change-Id: Ic2edca798975f4ab0ad4f8d17f76ce335d1ca818 Signed-off-by: Kanagaraj Manickam k00365106 --- .../marketplace/resource/PackageResourceTest.java | 24 --------------------- .../src/test/resources/clearwater_ns.csar | Bin 4622 -> 4799 bytes 2 files changed, 24 deletions(-) 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() { - - @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() { @Mock 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 index 0960b20a..5f5762b3 100644 Binary files a/vnfmarket-be/vnf-sdk-marketplace/src/test/resources/clearwater_ns.csar and b/vnfmarket-be/vnf-sdk-marketplace/src/test/resources/clearwater_ns.csar differ -- cgit 1.2.3-korg