diff options
author | Harry Huang <huangxiangyu5@huawei.com> | 2017-10-12 18:47:08 +0800 |
---|---|---|
committer | Harry Huang <huangxiangyu5@huawei.com> | 2017-10-12 20:28:13 +0800 |
commit | 916a1cec4f97d4ca9e8a1b337ab2f9f3c8fcb380 (patch) | |
tree | c955b3d5dc195515bec654933ebd72d4b83ac090 /vnfmarket-be/vnf-sdk-marketplace/src | |
parent | 9f51f2b1be71e42abc181724a27d99b8d2631bf2 (diff) |
modify filemanage unit test
Change-Id: I642053e6f03e8a45028f685c57e19c5aee6a7d48
Signed-off-by: Harry Huang <huangxiangyu5@huawei.com>
Issue-Id: VNFSDK-85
Diffstat (limited to 'vnfmarket-be/vnf-sdk-marketplace/src')
-rw-r--r-- | vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/filemanage/FileManageTest.java (renamed from vnfmarket-be/vnf-sdk-marketplace/src/test/filemanage/FileManageTest.java) | 48 |
1 files changed, 20 insertions, 28 deletions
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/filemanage/FileManageTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/filemanage/FileManageTest.java index 2fbaf756..901251c3 100644 --- a/vnfmarket-be/vnf-sdk-marketplace/src/test/filemanage/FileManageTest.java +++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/filemanage/FileManageTest.java @@ -58,14 +58,17 @@ public class FileManageTest { } @Before - public void createTestFile() + public void createTestFile() throws IOException { - String srcPath = "./srcPathForTest"; - String dstPath = "./dstPathForTest"; + String srcPath = "." + File.separator + "srcPathForTest"; + String dstPath = "." + File.separator + "dstPathForTest"; + String testFilePath = srcPath + File.separator + "fileForTest"; File src = new File(srcPath); File dst = new File(dstPath); + File testFile = new File(testFilePath); src.mkdir(); dst.mkdir(); + testFile.createNewFile(); } @Test @@ -76,23 +79,17 @@ public class FileManageTest { return FileManagerType.http; } }; - - FileManager ManagerImpl = FileManagerFactory.createFileManager(); - String srcPath = "./srcPathForTest"; new MockUp<ToolUtil>() { @Mock private String getHttpServerAbsolutePath() { - return null; - } - }; - new MockUp<ToolUtil>() { - @Mock - private boolean deleteDir(File dir) { - return true; + return ""; } }; - assertEquals(ManagerImpl.delete(srcPath), true); + FileManager ManagerImpl = FileManagerFactory.createFileManager(); + String dstPath = "./dstPathForTest"; + + assertEquals(ManagerImpl.delete(dstPath), true); } @Test @@ -103,28 +100,23 @@ public class FileManageTest { return FileManagerType.http; } }; - - FileManager ManagerImpl = FileManagerFactory.createFileManager(); - String srcPath = "./srcPathForTest"; - String dstPath = "./dstPathForTest"; new MockUp<ToolUtil>() { @Mock private String getHttpServerAbsolutePath() { - return null; - } - }; - new MockUp<ToolUtil>() { - @Mock - private boolean copyDirectory(String srcDirName, String destDirName, boolean overlay) { - return true; + return ""; } }; + + FileManager ManagerImpl = FileManagerFactory.createFileManager(); + String srcPath = "./srcPathForTest"; + String dstPath = "./dstPathForTest"; + assertEquals(ManagerImpl.upload(srcPath, dstPath), true); - File src = new File(srcPath); - if (src.exists()) + File srcDir = new File(srcPath); + if (srcDir.exists()) { - src.delete(); + ManagerImpl.delete(srcPath); } assertEquals(ManagerImpl.upload(srcPath, dstPath), false); |