Search in sources :

Example 6 with DeleteTask

use of org.commonjava.maven.galley.cache.iotasks.DeleteTask in project galley by Commonjava.

the class FastLocalCacheProviderConcurrentIOTest method testDeleteWhenWriteCompleted.

@Test
@BMScript("TryToDeleteWhileWritingCompleted.btm")
public void testDeleteWhenWriteCompleted() throws Exception {
    final ConcreteResource resource = createTestResource("file_delete_write_completed.txt");
    final Future<Boolean> deleteFuture = testPool.submit((Callable<Boolean>) new DeleteTask(provider, content, resource, latch));
    testPool.execute(new WriteTask(provider, content, resource, latch));
    assertLatchWait();
    final Boolean deleted = deleteFuture.get();
    assertThat(deleted, equalTo(true));
    assertThat(provider.exists(resource), equalTo(false));
}
Also used : ConcreteResource(org.commonjava.maven.galley.model.ConcreteResource) WriteTask(org.commonjava.maven.galley.cache.iotasks.WriteTask) DeleteTask(org.commonjava.maven.galley.cache.iotasks.DeleteTask) Test(org.junit.Test) BMScript(org.jboss.byteman.contrib.bmunit.BMScript)

Example 7 with DeleteTask

use of org.commonjava.maven.galley.cache.iotasks.DeleteTask in project galley by Commonjava.

the class FastLocalCacheProviderConcurrentIOTest method testDeleteWhenWriteNotCompleted.

@Test
@BMScript("TryToDeleteWhileWritingNotCompleted.btm")
public void testDeleteWhenWriteNotCompleted() throws Exception {
    final ConcreteResource resource = createTestResource("file_delete_write_not_completed.txt");
    final Future<Boolean> deleteFuture = testPool.submit((Callable<Boolean>) new DeleteTask(provider, content, resource, latch));
    testPool.execute(new WriteTask(provider, content, resource, latch, 1000));
    assertLatchWait();
    final Boolean deleted = deleteFuture.get();
    assertThat(deleted, equalTo(false));
    assertThat(provider.exists(resource), equalTo(true));
}
Also used : ConcreteResource(org.commonjava.maven.galley.model.ConcreteResource) WriteTask(org.commonjava.maven.galley.cache.iotasks.WriteTask) DeleteTask(org.commonjava.maven.galley.cache.iotasks.DeleteTask) Test(org.junit.Test) BMScript(org.jboss.byteman.contrib.bmunit.BMScript)

Example 8 with DeleteTask

use of org.commonjava.maven.galley.cache.iotasks.DeleteTask in project galley by Commonjava.

the class FastLocalCacheProviderConcurrentIOTest 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));
    assertLatchWait();
    final Boolean deleted = deleteFuture.get();
    assertThat(deleted, equalTo(true));
    assertThat(provider.exists(resource), equalTo(true));
}
Also used : ConcreteResource(org.commonjava.maven.galley.model.ConcreteResource) WriteTask(org.commonjava.maven.galley.cache.iotasks.WriteTask) DeleteTask(org.commonjava.maven.galley.cache.iotasks.DeleteTask) Test(org.junit.Test) BMScript(org.jboss.byteman.contrib.bmunit.BMScript)

Aggregations

DeleteTask (org.commonjava.maven.galley.cache.iotasks.DeleteTask)8 ConcreteResource (org.commonjava.maven.galley.model.ConcreteResource)8 Test (org.junit.Test)8 BMScript (org.jboss.byteman.contrib.bmunit.BMScript)7 ReadTask (org.commonjava.maven.galley.cache.iotasks.ReadTask)4 WriteTask (org.commonjava.maven.galley.cache.iotasks.WriteTask)3