Browse Source
Merge in DESIGN/design from ~LEVY.XIE/design:release/11.0 to release/11.0 * commit 'd0d89d77f071e923a4f71f6267c42686b4634456': REPORT-96012 移动文件夹到自己文件夹下,文件夹丢失 REPORT-96012 移动文件夹到自己文件夹下,文件夹丢失 优化代码 REPORT-96012 移动文件夹到自己文件夹下,文件夹丢失newui
Levy.Xie-解安森
2 years ago
3 changed files with 109 additions and 10 deletions
@ -0,0 +1,49 @@
|
||||
package com.fr.design.file; |
||||
|
||||
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; |
||||
import com.fr.file.filetree.FileNode; |
||||
import org.junit.Assert; |
||||
import org.junit.Test; |
||||
|
||||
|
||||
/** |
||||
* |
||||
* @author Levy.Xie |
||||
* @version 11.0 |
||||
* Created by Levy.Xie on 2023/05/23 |
||||
*/ |
||||
public class FileOperationHelperTest { |
||||
|
||||
@Test |
||||
public void testIsSubDirectory() { |
||||
FileNode sourceNode1 = new FileNode("/usr/local/webroot/reportlets", true); |
||||
FileNode sourceNode2 = new FileNode("/usr/local/webroot/reportlets/demo", true); |
||||
FileNode sourceNode3 = new FileNode("/usr/local/webroot/reportlets/doc", true); |
||||
FileNode sourceNode4 = new FileNode("/usr/local/webroot/reportlets/doc/1.cpt", false); |
||||
FileNode sourceNode5 = new FileNode("/usr/local/webroot/reportlets/demo/test", true); |
||||
FileNode sourceNode6 = new FileNode("/usr/local/webroot/reportlets/demo/test", false); |
||||
FileNode sourceNode7 = new FileNode("/usr/local/webroot/reportlets/demo/test123", true); |
||||
FileNode sourceNode8 = new FileNode("/usr/local/webroot/reportlets/../reportlets/demo/test", true); |
||||
FileNode sourceNode9 = new FileNode("/usr/local/webroot/reportlets/../reportlets/demo/test/c", true); |
||||
|
||||
FileNode targetNode = new FileNode("/usr/local/webroot/reportlets/demo/test", true); |
||||
|
||||
Assert.assertTrue(FileOperationHelper.getInstance().isSubDirectoryOrSame(sourceNode1, targetNode)); |
||||
Assert.assertTrue(FileOperationHelper.getInstance().isSubDirectoryOrSame(sourceNode2, targetNode)); |
||||
Assert.assertFalse(FileOperationHelper.getInstance().isSubDirectoryOrSame(sourceNode3, targetNode)); |
||||
Assert.assertFalse(FileOperationHelper.getInstance().isSubDirectoryOrSame(sourceNode4, targetNode)); |
||||
Assert.assertTrue(FileOperationHelper.getInstance().isSubDirectoryOrSame(sourceNode5, targetNode)); |
||||
Assert.assertFalse(FileOperationHelper.getInstance().isSubDirectoryOrSame(sourceNode6, targetNode)); |
||||
Assert.assertFalse(FileOperationHelper.getInstance().isSubDirectoryOrSame(sourceNode7, targetNode)); |
||||
Assert.assertTrue(FileOperationHelper.getInstance().isSubDirectoryOrSame(sourceNode8, targetNode)); |
||||
Assert.assertFalse(FileOperationHelper.getInstance().isSubDirectoryOrSame(sourceNode9, targetNode)); |
||||
|
||||
|
||||
ExpandMutableTreeNode treeNode1 = new ExpandMutableTreeNode(sourceNode1); |
||||
ExpandMutableTreeNode treeNode2 = new ExpandMutableTreeNode(sourceNode2); |
||||
ExpandMutableTreeNode treeNode3 = new ExpandMutableTreeNode(sourceNode3); |
||||
ExpandMutableTreeNode treeNode4 = new ExpandMutableTreeNode(sourceNode4); |
||||
Assert.assertTrue(FileOperationHelper.getInstance().isSubDirectoryOrSame(new ExpandMutableTreeNode[]{treeNode1, treeNode2, treeNode3}, targetNode)); |
||||
Assert.assertFalse(FileOperationHelper.getInstance().isSubDirectoryOrSame(new ExpandMutableTreeNode[]{treeNode3, treeNode4}, targetNode)); |
||||
} |
||||
} |
Loading…
Reference in new issue