From 2c0b22e035bf88b70ef17a7f0f59706b66c9c86e Mon Sep 17 00:00:00 2001 From: felmer <felmer> Date: Mon, 9 Nov 2009 15:07:52 +0000 Subject: [PATCH] LMS-1249 bug fixed SVN: 13280 --- .../cisd/etlserver/utils/FileScanner.java | 4 ++-- .../cisd/etlserver/utils/FileScannerTest.java | 20 ++++++++++++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/datastore_server/source/java/ch/systemsx/cisd/etlserver/utils/FileScanner.java b/datastore_server/source/java/ch/systemsx/cisd/etlserver/utils/FileScanner.java index ce9d834551f..3031aa3eed1 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/etlserver/utils/FileScanner.java +++ b/datastore_server/source/java/ch/systemsx/cisd/etlserver/utils/FileScanner.java @@ -36,8 +36,8 @@ public class FileScanner { String patternAsRegEx = pattern.replace("$", "\\$"); patternAsRegEx = patternAsRegEx.replace(".", "\\."); - patternAsRegEx = patternAsRegEx.replace("*", ".*"); - patternAsRegEx = patternAsRegEx.replace(".*.*/", "(.+/)*"); + patternAsRegEx = patternAsRegEx.replace("**/", "(.+/){0,}"); + patternAsRegEx = patternAsRegEx.replace("*", "[^/]*"); patternAsRegEx = patternAsRegEx.replace("?", "."); pathRegex = Pattern.compile("/" + patternAsRegEx); } diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/utils/FileScannerTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/utils/FileScannerTest.java index d28e11d4be1..15bce1eedbe 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/utils/FileScannerTest.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/utils/FileScannerTest.java @@ -54,6 +54,7 @@ public class FileScannerTest extends AbstractFileSystemTestCase } beta = dir(root, "beta"); { + file(beta, "b.txt"); File one = dir(beta, "1"); { hi = file(one, "hi.txt"); @@ -107,10 +108,10 @@ public class FileScannerTest extends AbstractFileSystemTestCase @Test public void testFindAll() { - FileScanner scanner = new FileScanner("*"); + FileScanner scanner = new FileScanner("**/*"); List<File> files = scanner.scan(beta); - assertEquals(3, files.size()); + assertEquals(4, files.size()); files = scanner.scan(hi); assertEquals(hi, files.get(0)); @@ -127,7 +128,20 @@ public class FileScannerTest extends AbstractFileSystemTestCase Collections.sort(files); assertEquals(hello, files.get(0)); assertEquals(hi, files.get(1)); - assertEquals(2, files.size()); + assertEquals("b.txt", files.get(2).getName()); + assertEquals(3, files.size()); + } + + @Test + public void testFindTopLevelTextFiles() + { + FileScanner scanner = new FileScanner("*.txt"); + + List<File> files = scanner.scan(beta); + + Collections.sort(files); + assertEquals("b.txt", files.get(0).getName()); + assertEquals(1, files.size()); } @Test -- GitLab