Try with resource in storetest
This commit is contained in:
@@ -20,37 +20,38 @@ public class StoreTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() throws IOException
|
public void testOneFile() throws IOException
|
||||||
{
|
{
|
||||||
Store store = new Store(folder.getRoot());
|
File file;
|
||||||
Index index = store.addIndex(0);
|
try (Store store = new Store(folder.getRoot()))
|
||||||
Archive archive = index.addArchive(0);
|
{
|
||||||
File file = archive.addFile(0);
|
Index index = store.addIndex(0);
|
||||||
file.setContents("test".getBytes());
|
Archive archive = index.addArchive(0);
|
||||||
|
file = archive.addFile(0);
|
||||||
|
file.setContents("test".getBytes());
|
||||||
|
|
||||||
|
store.save();
|
||||||
|
}
|
||||||
|
|
||||||
store.save();
|
try (Store store = new Store(folder.getRoot()))
|
||||||
|
{
|
||||||
store.close();
|
store.load();
|
||||||
|
|
||||||
store = new Store(folder.getRoot());
|
List<Index> indexes = store.getIndexes();
|
||||||
store.load();
|
Assert.assertEquals(1, indexes.size());
|
||||||
|
|
||||||
List<Index> indexes = store.getIndexes();
|
Index index = indexes.get(0);
|
||||||
Assert.assertEquals(1, indexes.size());
|
List<Archive> archives = index.getArchives();
|
||||||
|
Assert.assertEquals(1, archives.size());
|
||||||
index = indexes.get(0);
|
|
||||||
List<Archive> archives = index.getArchives();
|
Archive archive = archives.get(0);
|
||||||
Assert.assertEquals(1, archives.size());
|
List<File> files = archive.getFiles();
|
||||||
|
// XXX just use equals methods on store duh
|
||||||
archive = archives.get(0);
|
//archive.
|
||||||
List<File> files = archive.getFiles();
|
|
||||||
// XXX just use equals methods on store duh
|
File file2 = files.get(0);
|
||||||
//archive.
|
|
||||||
|
Assert.assertArrayEquals(file.getContents(), file2.getContents());
|
||||||
File file2 = files.get(0);
|
}
|
||||||
|
|
||||||
Assert.assertArrayEquals(file.getContents(), file2.getContents());
|
|
||||||
|
|
||||||
System.out.println(store);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user