|
|
|
@ -23,22 +23,27 @@ public class FileOperationHelperTest {
|
|
|
|
|
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().isSubDirectory(sourceNode1, targetNode)); |
|
|
|
|
Assert.assertTrue(FileOperationHelper.getInstance().isSubDirectory(sourceNode2, targetNode)); |
|
|
|
|
Assert.assertFalse(FileOperationHelper.getInstance().isSubDirectory(sourceNode3, targetNode)); |
|
|
|
|
Assert.assertFalse(FileOperationHelper.getInstance().isSubDirectory(sourceNode4, targetNode)); |
|
|
|
|
Assert.assertTrue(FileOperationHelper.getInstance().isSubDirectory(sourceNode5, targetNode)); |
|
|
|
|
Assert.assertFalse(FileOperationHelper.getInstance().isSubDirectory(sourceNode6, targetNode)); |
|
|
|
|
Assert.assertFalse(FileOperationHelper.getInstance().isSubDirectory(sourceNode7, targetNode)); |
|
|
|
|
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().isSubDirectory(new ExpandMutableTreeNode[]{treeNode1, treeNode2, treeNode3}, targetNode)); |
|
|
|
|
Assert.assertFalse(FileOperationHelper.getInstance().isSubDirectory(new ExpandMutableTreeNode[]{treeNode3, treeNode4}, targetNode)); |
|
|
|
|
Assert.assertTrue(FileOperationHelper.getInstance().isSubDirectoryOrSame(new ExpandMutableTreeNode[]{treeNode1, treeNode2, treeNode3}, targetNode)); |
|
|
|
|
Assert.assertFalse(FileOperationHelper.getInstance().isSubDirectoryOrSame(new ExpandMutableTreeNode[]{treeNode3, treeNode4}, targetNode)); |
|
|
|
|
} |
|
|
|
|
} |