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));
}
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));
}
Aggregations