mirror of https://github.com/apache/jclouds.git
Merge pull request #930 from andrewgaul/filesystem-test-teardown
Simplify FilesystemAsyncBlobStoreTest.tearDown
This commit is contained in:
commit
c5892ad522
|
@ -91,7 +91,6 @@ public class FilesystemAsyncBlobStoreTest {
|
||||||
|
|
||||||
private BlobStoreContext context = null;
|
private BlobStoreContext context = null;
|
||||||
private BlobStore blobStore = null;
|
private BlobStore blobStore = null;
|
||||||
private Set<File> resourcesToBeDeleted = new HashSet<File>();
|
|
||||||
|
|
||||||
@BeforeMethod
|
@BeforeMethod
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
|
@ -101,25 +100,13 @@ public class FilesystemAsyncBlobStoreTest {
|
||||||
context = ContextBuilder.newBuilder(PROVIDER).overrides(prop).build(BlobStoreContext.class);
|
context = ContextBuilder.newBuilder(PROVIDER).overrides(prop).build(BlobStoreContext.class);
|
||||||
// create a container in the default location
|
// create a container in the default location
|
||||||
blobStore = context.getBlobStore();
|
blobStore = context.getBlobStore();
|
||||||
|
new File(TestUtils.TARGET_BASE_DIR).mkdir();
|
||||||
resourcesToBeDeleted.add(new File(TestUtils.TARGET_BASE_DIR));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterMethod
|
@AfterMethod
|
||||||
protected void tearDown() {
|
protected void tearDown() throws IOException {
|
||||||
context.close();
|
context.close();
|
||||||
context = null;
|
FileUtils.forceDelete(new File(TestUtils.TARGET_BASE_DIR));
|
||||||
// freeing filesystem resources used for tests
|
|
||||||
Iterator<File> resourceToDelete = resourcesToBeDeleted.iterator();
|
|
||||||
while (resourceToDelete.hasNext()) {
|
|
||||||
File fileToDelete = resourceToDelete.next();
|
|
||||||
try {
|
|
||||||
FileUtils.forceDelete(fileToDelete);
|
|
||||||
} catch (IOException ex) {
|
|
||||||
System.err.println("Error deleting folder [" + fileToDelete.getName() + "].");
|
|
||||||
}
|
|
||||||
resourceToDelete.remove();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -515,9 +502,6 @@ public class FilesystemAsyncBlobStoreTest {
|
||||||
result = blobStore.containerExists(CONTAINER_NAME2);
|
result = blobStore.containerExists(CONTAINER_NAME2);
|
||||||
assertTrue(result, "Container doesn't exist");
|
assertTrue(result, "Container doesn't exist");
|
||||||
TestUtils.directoryExists(TestUtils.TARGET_BASE_DIR + CONTAINER_NAME2, true);
|
TestUtils.directoryExists(TestUtils.TARGET_BASE_DIR + CONTAINER_NAME2, true);
|
||||||
|
|
||||||
// clean the environment
|
|
||||||
FileUtils.forceDelete(new File(TARGET_CONTAINER_NAME2));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue