{
ArrayList<JournalFile> dataFiles = new ArrayList<JournalFile>();
for (int i = 0; i < 5; i++)
{
SequentialFile file = fileFactory.createSequentialFile("file-" + i + ".tst", 1);
dataFiles.add(new JournalFileImpl(file, 0, JournalImpl.FORMAT_VERSION));
}
ArrayList<JournalFile> newFiles = new ArrayList<JournalFile>();
for (int i = 0; i < 3; i++)
{
SequentialFile file = fileFactory.createSequentialFile("file-" + i + ".tst.new", 1);
newFiles.add(new JournalFileImpl(file, 0, JournalImpl.FORMAT_VERSION));
}
ArrayList<Pair<String, String>> renames = new ArrayList<Pair<String, String>>();
renames.add(new Pair<String, String>("a", "b"));
renames.add(new Pair<String, String>("c", "d"));
AbstractJournalUpdateTask.writeControlFile(fileFactory, dataFiles, newFiles, renames);
ArrayList<String> strDataFiles = new ArrayList<String>();
ArrayList<String> strNewFiles = new ArrayList<String>();
ArrayList<Pair<String, String>> renamesRead = new ArrayList<Pair<String, String>>();
Assert.assertNotNull(JournalCompactor.readControlFile(fileFactory, strDataFiles, strNewFiles, renamesRead));
Assert.assertEquals(dataFiles.size(), strDataFiles.size());
Assert.assertEquals(newFiles.size(), strNewFiles.size());
Assert.assertEquals(renames.size(), renamesRead.size());
Iterator<String> iterDataFiles = strDataFiles.iterator();
for (JournalFile file : dataFiles)
{
Assert.assertEquals(file.getFile().getFileName(), iterDataFiles.next());
}
Assert.assertFalse(iterDataFiles.hasNext());
Iterator<String> iterNewFiles = strNewFiles.iterator();
for (JournalFile file : newFiles)
{
Assert.assertEquals(file.getFile().getFileName(), iterNewFiles.next());
}
Assert.assertFalse(iterNewFiles.hasNext());
Iterator<Pair<String, String>> iterRename = renames.iterator();
for (Pair<String, String> rename : renamesRead)