use of org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles in project neo4j by neo4j.
the class PhysicalLogFilesTest method shouldGetTheFileNameForAGivenVersion.
@Test
public void shouldGetTheFileNameForAGivenVersion() {
// given
final PhysicalLogFiles files = new PhysicalLogFiles(tmpDirectory, filename, fs);
final int version = 12;
// when
final File versionFileName = files.getLogFileForVersion(version);
// then
final File expected = new File(tmpDirectory, filename + DEFAULT_VERSION_SUFFIX + version);
assertEquals(expected, versionFileName);
}
use of org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles in project neo4j by neo4j.
the class PhysicalLogFilesTest method shouldVisitEachLofFile.
@Test
public void shouldVisitEachLofFile() {
// given
PhysicalLogFiles files = new PhysicalLogFiles(tmpDirectory, filename, fs);
final File[] filesOnDisk = new File[] { new File(tmpDirectory, filename + DEFAULT_VERSION_SUFFIX + "1"), new File(tmpDirectory, "crap" + DEFAULT_VERSION_SUFFIX + "2"), new File(tmpDirectory, filename + DEFAULT_VERSION_SUFFIX + "3"), new File(tmpDirectory, filename) };
when(fs.listFiles(tmpDirectory)).thenReturn(filesOnDisk);
// when
final List<File> seenFiles = new ArrayList<>();
final List<Long> seenVersions = new ArrayList<>();
files.accept(new PhysicalLogFiles.LogVersionVisitor() {
@Override
public void visit(File file, long logVersion) {
seenFiles.add(file);
seenVersions.add(logVersion);
}
});
// then
assertEquals(Arrays.asList(new File(tmpDirectory, filename + DEFAULT_VERSION_SUFFIX + "1"), new File(tmpDirectory, filename + DEFAULT_VERSION_SUFFIX + "3")), seenFiles);
assertEquals(Arrays.asList(1L, 3L), seenVersions);
}
Aggregations