Browse Source
* commit '65e3a0c43f47f85e5c6d015a56d1fa1490824ecb': REPORT-96012 移动文件夹到自己文件夹下,文件夹丢失 REPORT-96012 移动文件夹到自己文件夹下,文件夹丢失 优化代码 REPORT-96012 移动文件夹到自己文件夹下,文件夹丢失bugfix/11.0
superman
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