|
@@ -35,6 +35,7 @@ import java.util.Collections;
|
|
|
import java.util.List;
|
|
|
|
|
|
import static org.junit.Assert.assertNotEquals;
|
|
|
+import static org.junit.Assert.fail;
|
|
|
import static org.mockito.Mockito.mock;
|
|
|
|
|
|
public class TestFsVolumeList {
|
|
@@ -101,4 +102,22 @@ public class TestFsVolumeList {
|
|
|
// checkDirs() should ignore the 2nd volume since it is closed.
|
|
|
volumeList.checkDirs();
|
|
|
}
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void testReleaseVolumeRefIfNoBlockScanner() throws IOException {
|
|
|
+ FsVolumeList volumeList = new FsVolumeList(
|
|
|
+ Collections.<VolumeFailureInfo>emptyList(), null, blockChooser);
|
|
|
+ File volDir = new File(baseDir, "volume-0");
|
|
|
+ volDir.mkdirs();
|
|
|
+ FsVolumeImpl volume = new FsVolumeImpl(dataset, "storage-id", volDir,
|
|
|
+ conf, StorageType.DEFAULT);
|
|
|
+ FsVolumeReference ref = volume.obtainReference();
|
|
|
+ volumeList.addVolume(ref);
|
|
|
+ try {
|
|
|
+ ref.close();
|
|
|
+ fail("Should throw exception because the reference is closed in "
|
|
|
+ + "VolumeList#addVolume().");
|
|
|
+ } catch (IllegalStateException e) {
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|