Fixed bug in getKeys() method (thanks Didier).

This commit is contained in:
Christian P. MOMON 2018-02-28 00:36:34 +01:00
parent d0f0f68ff7
commit 71c9bb563a
2 changed files with 6 additions and 12 deletions

View file

@ -27,9 +27,9 @@ import org.joda.time.format.ISODateTimeFormat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.sikevadb.core.Archiver;
import fr.devinsy.sikevadb.core.Element;
import fr.devinsy.sikevadb.core.Elements;
import fr.devinsy.sikevadb.core.Archiver;
import fr.devinsy.sikevadb.core.SikevaDB;
import fr.devinsy.sikevadb.core.SikevaDBException;
import fr.devinsy.util.strings.StringList;
@ -57,8 +57,8 @@ public class FileTreeSikevaDB implements SikevaDB
CLOSED
};
private final Logger logger = LoggerFactory.getLogger(FileTreeSikevaDB.class);
private static final DateTimeFormatter ISOFormatter = ISODateTimeFormat.dateHourMinuteSecondMillis();
private final Logger logger = LoggerFactory.getLogger(FileTreeSikevaDB.class);
private Status status;
private String login;
@ -413,15 +413,7 @@ public class FileTreeSikevaDB implements SikevaDB
}
else if (file.isDirectory())
{
File[] subFiles = file.listFiles();
for (File subFile : subFiles)
{
if (file.isFile())
{
result.add(subFile.getName());
}
}
result.add(file.getName());
}
}

View file

@ -70,6 +70,7 @@ public class TreeFileSikevaDBTest
database.put("alpha01s", "bravo5", "qlskjfmlqj");
Assert.assertEquals(0, database.getSubkeys("none").size());
Assert.assertEquals(5, database.getSubkeys("alpha01s").size());
//
logger.debug("===== test done.");
@ -101,10 +102,11 @@ public class TreeFileSikevaDBTest
StringList keys = database.getKeys();
Assert.assertEquals(5, keys.size());
Assert.assertEquals(6, keys.size());
Assert.assertTrue(keys.contains("alpha03"));
Assert.assertEquals(0, database.getSubkeys("alpha03s").size());
Assert.assertEquals(5, database.getSubkeys("alpha01s").size());
Assert.assertFalse(keys.contains("bravo4"));
//
logger.debug("===== test done.");