Try with resource in storetest

This commit is contained in:
Adam
2015-10-16 12:42:59 -04:00
parent 4752eb160c
commit bd5d57e94c

View File

@@ -20,29 +20,31 @@ public class StoreTest
} }
@Test @Test
public void test() throws IOException public void testOneFile() throws IOException
{
File file;
try (Store store = new Store(folder.getRoot()))
{ {
Store store = new Store(folder.getRoot());
Index index = store.addIndex(0); Index index = store.addIndex(0);
Archive archive = index.addArchive(0); Archive archive = index.addArchive(0);
File file = archive.addFile(0); file = archive.addFile(0);
file.setContents("test".getBytes()); file.setContents("test".getBytes());
store.save(); store.save();
}
store.close(); try (Store store = new Store(folder.getRoot()))
{
store = new Store(folder.getRoot());
store.load(); store.load();
List<Index> indexes = store.getIndexes(); List<Index> indexes = store.getIndexes();
Assert.assertEquals(1, indexes.size()); Assert.assertEquals(1, indexes.size());
index = indexes.get(0); Index index = indexes.get(0);
List<Archive> archives = index.getArchives(); List<Archive> archives = index.getArchives();
Assert.assertEquals(1, archives.size()); Assert.assertEquals(1, archives.size());
archive = archives.get(0); Archive archive = archives.get(0);
List<File> files = archive.getFiles(); List<File> files = archive.getFiles();
// XXX just use equals methods on store duh // XXX just use equals methods on store duh
//archive. //archive.
@@ -50,7 +52,6 @@ public class StoreTest
File file2 = files.get(0); File file2 = files.get(0);
Assert.assertArrayEquals(file.getContents(), file2.getContents()); Assert.assertArrayEquals(file.getContents(), file2.getContents());
}
System.out.println(store);
} }
} }