use of jodd.io.findfile.FindFile in project jodd by oblac.
the class FindFileTest method testTwoAccept.
@Test
public void testTwoAccept() {
FindFile ff = new WildcardFindFile().include("**/*file/a.png").include("**/*file/a.txt").setRecursive(true).setIncludeDirs(true).searchPath(dataRoot);
final MutableInteger countFiles = new MutableInteger();
final MutableInteger countDirs = new MutableInteger();
ff.find(new FileConsumer() {
@Override
public boolean onFile(File f) {
if (f.isDirectory()) {
countDirs.value++;
} else {
countFiles.value++;
String path = f.getAbsolutePath();
path = FileNameUtil.separatorsToUnix(path);
if (!path.startsWith("/")) {
path = '/' + path;
}
boolean matched = path.equals(dataRoot + "/file/a.png") || path.equals(dataRoot + "/file/a.txt");
assertTrue(matched);
}
return true;
}
});
assertEquals(0, countDirs.value);
assertEquals(2, countFiles.value);
}
use of jodd.io.findfile.FindFile in project jodd by oblac.
the class FindFileTest method testWildcardPath.
@Test
public void testWildcardPath() {
FindFile ff = new WildcardFindFile().include("**/file/*").setRecursive(true).setIncludeDirs(true).searchPath(dataRoot);
int countDirs = 0;
int countFiles = 0;
File f;
while ((f = ff.nextFile()) != null) {
if (f.isDirectory()) {
countDirs++;
} else {
countFiles++;
String path = f.getAbsolutePath();
path = FileNameUtil.separatorsToUnix(path);
if (!path.startsWith("/")) {
path = '/' + path;
}
boolean matched = path.equals(dataRoot + "/file/a.png") || path.equals(dataRoot + "/file/a.txt");
assertTrue(matched);
}
}
assertEquals(0, countDirs);
assertEquals(2, countFiles);
}
use of jodd.io.findfile.FindFile in project jodd by oblac.
the class FindFileTest method testRegexp.
@Test
public void testRegexp() {
FindFile ff = new RegExpFindFile().include(".*/a[.].*").setRecursive(true).setIncludeDirs(true).searchPath(dataRoot);
int countDirs = 0;
int countFiles = 0;
File f;
while ((f = ff.nextFile()) != null) {
if (f.isDirectory()) {
countDirs++;
} else {
countFiles++;
String path = f.getAbsolutePath();
path = FileNameUtil.separatorsToUnix(path);
if (!path.startsWith("/")) {
path = '/' + path;
}
boolean matched = path.equals(dataRoot + "/file/a.png") || path.equals(dataRoot + "/file/a.txt");
assertTrue(matched);
}
}
assertEquals(0, countDirs);
assertEquals(2, countFiles);
}
Aggregations