test modification
@@ -403,17 +403,19 @@ public class AzureArchiveManagerTest {
@Test
public void testCollectBlobReferencesForReadOnlyFileStore() throws URISyntaxException, InvalidFileStoreVersionException, IOException, CommitFailedException, StorageException {
AzurePersistence rwPersistence = new AzurePersistence(container.getDirectoryReference("oak"));
- FileStore rwFileStore = FileStoreBuilder.fileStoreBuilder(new File("target")).withCustomPersistence(rwPersistence).build();
+ try (FileStore rwFileStore = FileStoreBuilder.fileStoreBuilder(new File("target")).withCustomPersistence(rwPersistence).build()) {
SegmentNodeStore segmentNodeStore = SegmentNodeStoreBuilders.builder(rwFileStore).build();
NodeBuilder builder = segmentNodeStore.getRoot().builder();
builder.setProperty("foo", "bar");
segmentNodeStore.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
rwFileStore.flush();
- assertTrue(container.getDirectoryReference("oak/data00000a.tar").listBlobs().iterator().hasNext());
+ // file with binary references has been created
+
+ assertTrue(container.getDirectoryReference("oak/data00000a.tar").getBlockBlobReference("data00000a.tar.brf").exists());
// create read-only FS
AzurePersistence roPersistence = new AzurePersistence(container.getDirectoryReference("oak"));
- ReadOnlyFileStore roFileStore = FileStoreBuilder.fileStoreBuilder(new File("target")).withCustomPersistence(roPersistence).buildReadOnly();
+ try (ReadOnlyFileStore roFileStore = FileStoreBuilder.fileStoreBuilder(new File("target")).withCustomPersistence(roPersistence).buildReadOnly()) {
PropertyState fooProperty = SegmentNodeStoreBuilders.builder(roFileStore).build()
.getRoot()
@@ -422,16 +424,11 @@ public class AzureArchiveManagerTest {
assertThat(fooProperty, not(nullValue()));
assertThat(fooProperty.getValue(Type.STRING), equalTo("bar"));
- //exception should not be thrown
- try {
- roFileStore.collectBlobReferences(s -> {});
- } catch (Exception e){
- fail();
- }
-
- roFileStore.close();
+ roFileStore.collectBlobReferences(s -> {
+ });
- rwFileStore.close();
+ }
+ }
}
private PersistentCache createPersistenceCache() {
