Search in sources :

Example 11 with ReadTask

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));
}
Also used : ConcreteResource(org.commonjava.maven.galley.model.ConcreteResource) WriteTask(org.commonjava.maven.galley.cache.iotasks.WriteTask) ReadTask(org.commonjava.maven.galley.cache.iotasks.ReadTask) Test(org.junit.Test) BMScript(org.jboss.byteman.contrib.bmunit.BMScript)

Example 12 with ReadTask

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));
}
Also used : ConcreteResource(org.commonjava.maven.galley.model.ConcreteResource) ReadTask(org.commonjava.maven.galley.cache.iotasks.ReadTask) Test(org.junit.Test)

Example 13 with ReadTask

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));
}
Also used : ConcreteResource(org.commonjava.maven.galley.model.ConcreteResource) WriteTask(org.commonjava.maven.galley.cache.iotasks.WriteTask) ReadTask(org.commonjava.maven.galley.cache.iotasks.ReadTask) Test(org.junit.Test) BMScript(org.jboss.byteman.contrib.bmunit.BMScript)

Aggregations

ReadTask (org.commonjava.maven.galley.cache.iotasks.ReadTask)13 ConcreteResource (org.commonjava.maven.galley.model.ConcreteResource)13 Test (org.junit.Test)13 BMScript (org.jboss.byteman.contrib.bmunit.BMScript)12 WriteTask (org.commonjava.maven.galley.cache.iotasks.WriteTask)8 DeleteTask (org.commonjava.maven.galley.cache.iotasks.DeleteTask)4 FileInputStream (java.io.FileInputStream)2