Search in sources :

Example 16 with BMScript

use of org.jboss.byteman.contrib.bmunit.BMScript in project galley by Commonjava.

the class FastLocalCacheProviderConcurrentTest method testReadWrite.

@Test
@BMScript("TryToReadWhileWriting.btm")
public void testReadWrite() throws Exception {
    final ConcreteResource resource = createTestResource("file_read_write.txt");
    testPool.execute(new WriteTask(provider, content, resource, latch, 1000));
    final Future<String> readingFuture = testPool.submit((Callable<String>) new ReadTask(provider, content, resource, latch));
    latchWait(latch);
    final String readingResult = readingFuture.get();
    assertThat(readingResult, equalTo(content));
    assertThat(provider.exists(resource), equalTo(true));
    assertThat(readLocalResource(resource), equalTo(content));
    assertThat(readNFSResource(resource), equalTo(content));
}
Also used : ConcreteResource(org.commonjava.maven.galley.model.ConcreteResource) Test(org.junit.Test) BMScript(org.jboss.byteman.contrib.bmunit.BMScript)

Example 17 with BMScript

use of org.jboss.byteman.contrib.bmunit.BMScript in project galley by Commonjava.

the class FastLocalCacheProviderConcurrentTest 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));
    latchWait(latch);
    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) Test(org.junit.Test) BMScript(org.jboss.byteman.contrib.bmunit.BMScript)

Aggregations

BMScript (org.jboss.byteman.contrib.bmunit.BMScript)17 Test (org.junit.Test)17 ConcreteResource (org.commonjava.maven.galley.model.ConcreteResource)15 CountDownLatch (java.util.concurrent.CountDownLatch)5 Location (org.commonjava.maven.galley.model.Location)5 SimpleLocation (org.commonjava.maven.galley.model.SimpleLocation)5 HashSet (java.util.HashSet)1