summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarry Huang <huangxiangyu5@huawei.com>2017-10-11 10:39:13 +0800
committerHarry Huang <huangxiangyu5@huawei.com>2017-10-11 10:39:48 +0800
commit66f4403583a95007062d7d5b36ea8d2e9093f323 (patch)
treecf4cad9fac4c31418e75cea21609d1e2186dbad0
parent2d3c98c6b59e733e8be8405a29b3f09d1a2142f0 (diff)
Add ut for FileManage constructor
Change-Id: I63a2f0f40854961f8444e1d09cc6860f9e7f3e79 Signed-off-by: Harry Huang <huangxiangyu5@huawei.com> Issue-Id: VNFSDK-85
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/test/filemanage/FileManageTest.java32
1 files changed, 29 insertions, 3 deletions
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<FileManagerFactory> 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<FileManagerFactory>() {
+ @Mock
+ private FileManagerType getType() {
+ return FileManagerType.http;
+ }
+ };
+
+ FileManager ManagerImpl = FileManagerFactory.createFileManager();
String srcPath = "./srcPathForTest";
new MockUp<ToolUtil>() {
@Mock
@@ -78,7 +97,14 @@ public class FileManageTest {
@Test
public void testUpload() throws IOException {
- HttpFileManagerImpl ManagerImpl = new HttpFileManagerImpl();
+ new MockUp<FileManagerFactory>() {
+ @Mock
+ private FileManagerType getType() {
+ return FileManagerType.http;
+ }
+ };
+
+ FileManager ManagerImpl = FileManagerFactory.createFileManager();
String srcPath = "./srcPathForTest";
String dstPath = "./dstPathForTest";
new MockUp<ToolUtil>() {