use of org.commonjava.maven.galley.cache.iotasks.WriteTask in project galley by Commonjava.
the class FastLocalCacheProviderConcurrentIOTest method testDeleteWhenWriteNotCompleted.
@Test
@BMScript("TryToDeleteWhileWritingNotCompleted.btm")
public void testDeleteWhenWriteNotCompleted() throws Exception {
final ConcreteResource resource = createTestResource("file_delete_write_not_completed.txt");
final Future<Boolean> deleteFuture = testPool.submit((Callable<Boolean>) new DeleteTask(provider, content, resource, latch));
testPool.execute(new WriteTask(provider, content, resource, latch, 1000));
assertLatchWait();
final Boolean deleted = deleteFuture.get();
assertThat(deleted, equalTo(false));
assertThat(provider.exists(resource), equalTo(true));
}
use of org.commonjava.maven.galley.cache.iotasks.WriteTask in project galley by Commonjava.
the class FastLocalCacheProviderConcurrentIOTest method testWriteReadWithNoResource.
@Test
@BMScript("TryToWriteWhileReading.btm")
public void testWriteReadWithNoResource() throws Exception {
final ConcreteResource resource = createTestResource("file_write_read_no_both_resource.txt");
testPool.execute(new WriteTask(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 String readingResult = readingFuture.get();
assertNull(readingResult);
final String changedResult = readLocalResource(resource);
assertThat(changedResult, equalTo(content));
}
use of org.commonjava.maven.galley.cache.iotasks.WriteTask in project galley by Commonjava.
the class FastLocalCacheProviderConcurrentIOTest method testWriteWhenDeleteCompleted.
@Test
@BMScript("TryToWriteWhileDeleteCompleted.btm")
public void testWriteWhenDeleteCompleted() throws Exception {
final ConcreteResource resource = createTestResource("file_write_delete_completed.txt");
prepareBothResource(resource, content);
final Future<Boolean> deleteFuture = testPool.submit((Callable<Boolean>) new DeleteTask(provider, content, resource, latch));
testPool.execute(new WriteTask(provider, content, resource, latch));
assertLatchWait();
final Boolean deleted = deleteFuture.get();
assertThat(deleted, equalTo(true));
assertThat(provider.exists(resource), equalTo(true));
}
Aggregations