Test multiple indexes/archives

This commit is contained in:
Adam
2015-10-16 19:44:42 -04:00
parent 7e580f0f0b
commit 2cc48ae9b0

View File

@@ -52,6 +52,8 @@ public class StoreTest
{
Index index = store.addIndex(0);
Archive archive = index.addArchive(0);
archive.setNameHash(random.nextInt());
for (int i = 0; i < NUMBER_OF_FILES; ++i)
{
File file = archive.addFile(i);
@@ -71,4 +73,59 @@ public class StoreTest
}
}
}
@Test
public void testMultipleArchives() throws IOException
{
Random random = new Random(43L);
try (Store store = new Store(folder.getRoot()))
{
Index index = store.addIndex(0);
Index index2 = store.addIndex(1);
Archive archive = index.addArchive(0);
archive.setNameHash(random.nextInt());
Archive archive2 = index.addArchive(1);
Archive archive3 = index2.addArchive(0);
for (int i = 0; i < NUMBER_OF_FILES; ++i)
{
File file = archive.addFile(i);
file.setNameHash(random.nextInt());
byte[] data = new byte[random.nextInt(1024)];
random.nextBytes(data);
file.setContents(data);
}
for (int i = 0; i < NUMBER_OF_FILES; ++i)
{
File file = archive2.addFile(i);
file.setNameHash(random.nextInt());
byte[] data = new byte[random.nextInt(1024)];
random.nextBytes(data);
file.setContents(data);
}
for (int i = 0; i < NUMBER_OF_FILES; ++i)
{
File file = archive3.addFile(i);
file.setNameHash(random.nextInt());
byte[] data = new byte[random.nextInt(1024)];
random.nextBytes(data);
file.setContents(data);
}
store.save();
try (Store store2 = new Store(folder.getRoot()))
{
store2.load();
Assert.assertEquals(store, store2);
}
}
}
}