use of org.commonjava.maven.galley.cache.iotasks.ReadTask in project galley by Commonjava.
the class FastLocalCacheProviderConcurrentIOTest method testWriteReadWithNFS.
@Test
@BMScript("TryToWriteWhileReading.btm")
public void testWriteReadWithNFS() throws Exception {
final ConcreteResource resource = createTestResource("file_write_read_has_only_NFS.txt");
prepareNFSResource(resource, content);
testPool.execute(new WriteTask(provider, diffContent, 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();
assertThat(readingResult, equalTo(content));
final String changedResult = readLocalResource(resource);
assertThat(changedResult, equalTo(diffContent));
}
use of org.commonjava.maven.galley.cache.iotasks.ReadTask in project galley by Commonjava.
the class FastLocalCacheProviderConcurrentIOTest method testBothReadWithNFS.
@Test
public void testBothReadWithNFS() throws Exception {
final ConcreteResource resource = createTestResource("file_both_read_has_only_NFS.txt");
prepareNFSResource(resource, content);
final Future<String> readingFuture1 = testPool.submit((Callable<String>) new ReadTask(provider, content, resource, latch));
final Future<String> readingFuture2 = testPool.submit((Callable<String>) new ReadTask(provider, content, resource, latch));
assertLatchWait();
final String readingResult1 = readingFuture1.get();
assertThat(readingResult1, equalTo(content));
final String readingResult2 = readingFuture2.get();
assertThat(readingResult2, equalTo(content));
}
use of org.commonjava.maven.galley.cache.iotasks.ReadTask 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));
}
Aggregations