From 66f4403583a95007062d7d5b36ea8d2e9093f323 Mon Sep 17 00:00:00 2001 From: Harry Huang Date: Wed, 11 Oct 2017 10:39:13 +0800 Subject: Add ut for FileManage constructor Change-Id: I63a2f0f40854961f8444e1d09cc6860f9e7f3e79 Signed-off-by: Harry Huang Issue-Id: VNFSDK-85 --- .../src/test/filemanage/FileManageTest.java | 32 ++++++++++++++++++++-- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'vnfmarket-be/vnf-sdk-marketplace') diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/filemanage/FileManageTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/filemanage/FileManageTest.java index c2597ff1..2fbaf756 100644 --- a/vnfmarket-be/vnf-sdk-marketplace/src/test/filemanage/FileManageTest.java +++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/filemanage/FileManageTest.java @@ -18,13 +18,15 @@ package org.onap.vnfsdk.marketplace.filemanage; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; import java.io.File; import java.io.IOException; +import java.lang.reflect.Constructor; +import java.lang.reflect.Modifier; import org.junit.Before; import org.junit.Test; -import org.onap.vnfsdk.marketplace.filemanage.http.HttpFileManagerImpl; import org.onap.vnfsdk.marketplace.filemanage.http.ToolUtil; import mockit.Mock; @@ -45,6 +47,16 @@ public class FileManageTest { assertNull(manager); } + @Test + public void testFileManagerFactoryConstructor() { + try { + Constructor constructor = FileManagerFactory.class.getDeclaredConstructor(); + assertTrue(Modifier.isPrivate(constructor.getModifiers())); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } + } + @Before public void createTestFile() { @@ -58,7 +70,14 @@ public class FileManageTest { @Test public void testDelete() throws IOException { - HttpFileManagerImpl ManagerImpl = new HttpFileManagerImpl(); + new MockUp() { + @Mock + private FileManagerType getType() { + return FileManagerType.http; + } + }; + + FileManager ManagerImpl = FileManagerFactory.createFileManager(); String srcPath = "./srcPathForTest"; new MockUp() { @Mock @@ -78,7 +97,14 @@ public class FileManageTest { @Test public void testUpload() throws IOException { - HttpFileManagerImpl ManagerImpl = new HttpFileManagerImpl(); + new MockUp() { + @Mock + private FileManagerType getType() { + return FileManagerType.http; + } + }; + + FileManager ManagerImpl = FileManagerFactory.createFileManager(); String srcPath = "./srcPathForTest"; String dstPath = "./dstPathForTest"; new MockUp() { -- cgit 1.2.3-korg