use of org.jboss.byteman.contrib.bmunit.BMScript in project galley by Commonjava.
the class FastLocalCacheProviderConcurrentTest method testDeleteWhenReadNotCompletedWithNFS.
@Test
@BMScript("TryToDeleteWhileReadingNotCompleted.btm")
public void testDeleteWhenReadNotCompletedWithNFS() throws Exception {
final ConcreteResource resource = createTestResource("file_delete_read_not_completed_nfs_only.txt");
prepareNFSResource(resource, content);
final Future<Boolean> deleteFuture = testPool.submit((Callable<Boolean>) new DeleteTask(provider, content, resource, latch));
final Future<String> readingFuture = testPool.submit((Callable<String>) new ReadTask(provider, content, resource, latch, 1000));
latchWait(latch);
final Boolean deleted = deleteFuture.get();
final String readingResult = readingFuture.get();
assertThat(readingResult, equalTo(content));
assertThat(deleted, equalTo(false));
assertThat(provider.exists(resource), equalTo(true));
}
use of org.jboss.byteman.contrib.bmunit.BMScript in project galley by Commonjava.
the class FastLocalCacheProviderConcurrentTest 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));
latchWait(latch);
final Boolean deleted = deleteFuture.get();
assertThat(deleted, equalTo(true));
assertThat(provider.exists(resource), equalTo(true));
}
use of org.jboss.byteman.contrib.bmunit.BMScript in project galley by Commonjava.
the class FastLocalCacheProviderConcurrentTest method tesWriteReadWithLocal.
@Test
@BMScript("TryToWriteWhileReading.btm")
public void tesWriteReadWithLocal() throws Exception {
final ConcreteResource resource = createTestResource("file_write_read.txt");
prepareBothResource(resource, content);
testPool.execute(new WriteTask(provider, diffContent, 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));
final String changedResult = readLocalResource(resource);
assertThat(changedResult, equalTo(diffContent));
}
use of org.jboss.byteman.contrib.bmunit.BMScript in project galley by Commonjava.
the class FastLocalCacheProviderConcurrentTest method testDeleteWhenReadNotCompleted.
@Test
@BMScript("TryToDeleteWhileReadingNotCompleted.btm")
public void testDeleteWhenReadNotCompleted() throws Exception {
final ConcreteResource resource = createTestResource("file_delete_read_not_completed.txt");
prepareBothResource(resource, content);
final Future<Boolean> deleteFuture = testPool.submit((Callable<Boolean>) new DeleteTask(provider, content, resource, latch));
final Future<String> readingFuture = testPool.submit((Callable<String>) new ReadTask(provider, content, resource, latch, 1000));
latchWait(latch);
final Boolean deleted = deleteFuture.get();
final String readingResult = readingFuture.get();
assertThat(readingResult, equalTo(content));
assertThat(deleted, equalTo(false));
assertThat(provider.exists(resource), equalTo(true));
}
use of org.jboss.byteman.contrib.bmunit.BMScript in project galley by Commonjava.
the class FastLocalCacheProviderConcurrentTest method testWriteWhenReadOpenWithNFS.
@Test
@BMScript("TryToWriteThenWaitReadingStreamOpen.btm")
public void testWriteWhenReadOpenWithNFS() throws Exception {
final ConcreteResource resource = createTestResource("file_write_wait_read_has_only_NFS.txt");
prepareNFSResource(resource, content);
testPool.execute(new WriteTask(provider, diffContent, resource, latch));
//make sure write task execute first
Thread.sleep(500);
final Future<String> readingFuture = testPool.submit((Callable<String>) new ReadTask(provider, content, resource, latch, 500));
latchWait(latch);
final String readingResult = readingFuture.get();
assertThat(readingResult, equalTo(diffContent));
final String changedResult = readLocalResource(resource);
assertThat(changedResult, equalTo(diffContent));
}
Aggregations