use of org.commonjava.maven.galley.cache.iotasks.DeleteTask in project galley by Commonjava.
the class FastLocalCacheProviderConcurrentIOTest method testDeleteWhenReadNotCompletedWithNFS.
@Test
@BMScript("TryToDeleteWhileReadingNotCompleted.btm")
public void testDeleteWhenReadNotCompletedWithNFS() throws Exception {
final ConcreteResource resource = createTestResource("file_delete_read_not_completed_nfs_only.txt");
prepareNFSResource(resource, content);
final Future<Boolean> deleteFuture = testPool.submit((Callable<Boolean>) new DeleteTask(provider, content, resource, latch));
final Future<String> readingFuture = testPool.submit((Callable<String>) new ReadTask(provider, content, resource, latch, 1000));
assertLatchWait();
final Boolean deleted = deleteFuture.get();
final String readingResult = readingFuture.get();
assertThat(readingResult, equalTo(content));
assertThat(deleted, equalTo(false));
assertThat(provider.exists(resource), equalTo(true));
}
use of org.commonjava.maven.galley.cache.iotasks.DeleteTask in project galley by Commonjava.
the class FastLocalCacheProviderConcurrentIOTest method testDeleteWhenReadNotCompleted.
@Test
@BMScript("TryToDeleteWhileReadingNotCompleted.btm")
public void testDeleteWhenReadNotCompleted() throws Exception {
final ConcreteResource resource = createTestResource("file_delete_read_not_completed.txt");
prepareBothResource(resource, content);
final Future<Boolean> deleteFuture = testPool.submit((Callable<Boolean>) new DeleteTask(provider, content, resource, latch));
final Future<String> readingFuture = testPool.submit((Callable<String>) new ReadTask(provider, content, resource, latch, 1000));
assertLatchWait();
final Boolean deleted = deleteFuture.get();
final String readingResult = readingFuture.get();
assertThat(readingResult, equalTo(content));
assertThat(deleted, equalTo(false));
assertThat(provider.exists(resource), equalTo(true));
}
use of org.commonjava.maven.galley.cache.iotasks.DeleteTask in project galley by Commonjava.
the class FastLocalCacheProviderConcurrentIOTest method testDeleteWhenReadCompleted.
@Test
@BMScript("TryToDeleteWhileReadingCompleted.btm")
public void testDeleteWhenReadCompleted() throws Exception {
final ConcreteResource resource = createTestResource("file_delete_read.txt");
prepareBothResource(resource, content);
final Future<Boolean> deleteFuture = testPool.submit((Callable<Boolean>) new DeleteTask(provider, content, resource, latch));
final Future<String> readingFuture = testPool.submit((Callable<String>) new ReadTask(provider, content, resource, latch));
if (!TestIOUtils.latchWait(latch, WAIT_TIMEOUT_SECONDS, TimeUnit.SECONDS)) {
fail("I/O timeout");
}
final Boolean deleted = deleteFuture.get();
final String readingResult = readingFuture.get();
assertThat(readingResult, equalTo(content));
assertThat(deleted, equalTo(true));
assertThat(provider.exists(resource), equalTo(false));
}
use of org.commonjava.maven.galley.cache.iotasks.DeleteTask in project galley by Commonjava.
the class FastLocalCacheProviderConcurrentIOTest method testBothDelete.
@Test
public void testBothDelete() throws Exception {
final ConcreteResource resource = createTestResource("file_both_delete.txt");
prepareBothResource(resource, content);
final Future<Boolean> deleteFurture1 = testPool.submit((Callable<Boolean>) new DeleteTask(provider, content, resource, latch));
final Future<Boolean> deleteFurture2 = testPool.submit((Callable<Boolean>) new DeleteTask(provider, content, resource, latch));
assertLatchWait();
final Boolean deleted1 = deleteFurture1.get();
final Boolean deleted2 = deleteFurture2.get();
assertThat(deleted1 && deleted2, equalTo(false));
assertThat(deleted1 || deleted2, equalTo(true));
assertThat(provider.exists(resource), equalTo(false));
}
use of org.commonjava.maven.galley.cache.iotasks.DeleteTask in project galley by Commonjava.
the class FastLocalCacheProviderConcurrentIOTest method testReadWhileDeleteCompleted.
@Test
@BMScript("TryToReadWhileDeleteCompleted.btm")
public void testReadWhileDeleteCompleted() throws Exception {
final ConcreteResource resource = createTestResource("file_read_delete_completed.txt");
prepareBothResource(resource, content);
final Future<Boolean> deleteFuture = testPool.submit((Callable<Boolean>) new DeleteTask(provider, content, resource, latch));
final Future<String> readingFuture = testPool.submit((Callable<String>) new ReadTask(provider, content, resource, latch));
assertLatchWait();
final Boolean deleted = deleteFuture.get();
final String readingResult = readingFuture.get();
assertThat(readingResult, equalTo(null));
assertThat(deleted, equalTo(true));
assertThat(provider.exists(resource), equalTo(false));
}
Aggregations