Search in sources :

Example 6 with DelegatingScheduledFutureStripper

use of com.hazelcast.scheduledexecutor.impl.DelegatingScheduledFutureStripper in project hazelcast by hazelcast.

the class DelegatingScheduledFutureStripperTest method isCancelled.

@Test
public void isCancelled() throws ExecutionException, InterruptedException {
    ScheduledFuture outter = mock(ScheduledFuture.class);
    ScheduledFuture inner = mock(ScheduledFuture.class);
    when(outter.get()).thenReturn(inner);
    when(outter.isCancelled()).thenReturn(false);
    when(inner.isCancelled()).thenReturn(false);
    assertFalse(new DelegatingScheduledFutureStripper(outter).isCancelled());
    when(outter.isCancelled()).thenReturn(true);
    when(inner.isCancelled()).thenReturn(false);
    assertTrue(new DelegatingScheduledFutureStripper(outter).isCancelled());
    when(outter.isCancelled()).thenReturn(false);
    when(inner.isCancelled()).thenReturn(true);
    assertTrue(new DelegatingScheduledFutureStripper(outter).isCancelled());
}
Also used : ScheduledFuture(java.util.concurrent.ScheduledFuture) DelegatingScheduledFutureStripper(com.hazelcast.scheduledexecutor.impl.DelegatingScheduledFutureStripper) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 7 with DelegatingScheduledFutureStripper

use of com.hazelcast.scheduledexecutor.impl.DelegatingScheduledFutureStripper in project hazelcast by hazelcast.

the class DelegatingScheduledFutureStripperTest method isDone.

@Test
public void isDone() throws ExecutionException, InterruptedException {
    ScheduledFuture outter = mock(ScheduledFuture.class);
    ScheduledFuture inner = mock(ScheduledFuture.class);
    when(outter.get()).thenReturn(inner);
    when(outter.isDone()).thenReturn(true);
    when(inner.isDone()).thenReturn(false);
    assertFalse(new DelegatingScheduledFutureStripper(outter).isDone());
    when(outter.isDone()).thenReturn(true);
    when(inner.isDone()).thenReturn(true);
    assertTrue(new DelegatingScheduledFutureStripper(outter).isDone());
}
Also used : ScheduledFuture(java.util.concurrent.ScheduledFuture) DelegatingScheduledFutureStripper(com.hazelcast.scheduledexecutor.impl.DelegatingScheduledFutureStripper) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 8 with DelegatingScheduledFutureStripper

use of com.hazelcast.scheduledexecutor.impl.DelegatingScheduledFutureStripper in project hazelcast by hazelcast.

the class DelegatingScheduledFutureStripperTest method get_interrupted.

@Test(expected = InterruptedException.class)
public void get_interrupted() throws ExecutionException, InterruptedException {
    ScheduledFuture outter = mock(ScheduledFuture.class);
    ScheduledFuture inner = mock(ScheduledFuture.class);
    when(outter.get()).thenThrow(new InterruptedException());
    when(inner.get()).thenReturn(2);
    new DelegatingScheduledFutureStripper(outter).get();
}
Also used : ScheduledFuture(java.util.concurrent.ScheduledFuture) DelegatingScheduledFutureStripper(com.hazelcast.scheduledexecutor.impl.DelegatingScheduledFutureStripper) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 9 with DelegatingScheduledFutureStripper

use of com.hazelcast.scheduledexecutor.impl.DelegatingScheduledFutureStripper in project hazelcast by hazelcast.

the class DelegatingScheduledFutureStripperTest method get_executionExc.

@Test(expected = ExecutionException.class)
public void get_executionExc() throws ExecutionException, InterruptedException {
    ScheduledFuture outter = mock(ScheduledFuture.class);
    ScheduledFuture inner = mock(ScheduledFuture.class);
    when(outter.get()).thenThrow(new ExecutionException(new NullPointerException()));
    when(inner.get()).thenReturn(2);
    new DelegatingScheduledFutureStripper(outter).get();
}
Also used : ExecutionException(java.util.concurrent.ExecutionException) ScheduledFuture(java.util.concurrent.ScheduledFuture) DelegatingScheduledFutureStripper(com.hazelcast.scheduledexecutor.impl.DelegatingScheduledFutureStripper) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

DelegatingScheduledFutureStripper (com.hazelcast.scheduledexecutor.impl.DelegatingScheduledFutureStripper)9 ParallelTest (com.hazelcast.test.annotation.ParallelTest)9 QuickTest (com.hazelcast.test.annotation.QuickTest)9 ScheduledFuture (java.util.concurrent.ScheduledFuture)9 Test (org.junit.Test)9 ExecutionException (java.util.concurrent.ExecutionException)1 Future (java.util.concurrent.Future)1