Search in sources :

Example 1 with DelegatingScheduledFutureStripper

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

the class DelegatingScheduledFutureStripperTest method get_unsupported.

@Test(expected = UnsupportedOperationException.class)
public void get_unsupported() throws ExecutionException, InterruptedException, TimeoutException {
    ScheduledFuture future = scheduler.schedule(new SimpleCallableTestTask(), 0, TimeUnit.SECONDS);
    new DelegatingScheduledFutureStripper(future).get(1, TimeUnit.SECONDS);
}
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 2 with DelegatingScheduledFutureStripper

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

the class DelegatingScheduledFutureStripperTest method get.

@Test
public void get() throws ExecutionException, InterruptedException {
    ScheduledFuture original = taskScheduler.schedule(new SimpleCallableTestTask(), 0, TimeUnit.SECONDS);
    ScheduledFuture stripper = new DelegatingScheduledFutureStripper(original);
    assertTrue(original.get() instanceof Future);
    assertEquals(5, stripper.get());
}
Also used : ScheduledFuture(java.util.concurrent.ScheduledFuture) Future(java.util.concurrent.Future) 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 3 with DelegatingScheduledFutureStripper

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

the class DelegatingScheduledFutureStripperTest method equals.

@Test
public void equals() {
    ScheduledFuture original = taskScheduler.schedule(new SimpleCallableTestTask(), 0, TimeUnit.SECONDS);
    ScheduledFuture joker = taskScheduler.schedule(new SimpleCallableTestTask(), 1, TimeUnit.SECONDS);
    ScheduledFuture testA = new DelegatingScheduledFutureStripper(original);
    ScheduledFuture testB = new DelegatingScheduledFutureStripper(original);
    ScheduledFuture testC = new DelegatingScheduledFutureStripper(joker);
    assertTrue(testA.equals(testA));
    assertTrue(testA.equals(testB));
    assertFalse(testA.equals(null));
    assertFalse(testA.equals(testC));
}
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 4 with DelegatingScheduledFutureStripper

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

the class DelegatingScheduledFutureStripperTest method cancel.

@Test
public void cancel() throws ExecutionException, InterruptedException {
    ScheduledFuture outter = mock(ScheduledFuture.class);
    ScheduledFuture inner = mock(ScheduledFuture.class);
    when(outter.get()).thenReturn(inner);
    new DelegatingScheduledFutureStripper(outter).cancel(true);
    verify(inner).cancel(eq(true));
}
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 5 with DelegatingScheduledFutureStripper

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

the class DelegatingScheduledFutureStripperTest method cancel_twice.

@Test
public void cancel_twice() throws ExecutionException, InterruptedException, TimeoutException {
    ScheduledFuture original = taskScheduler.schedule(new SimpleCallableTestTask(), 10, TimeUnit.SECONDS);
    ScheduledFuture stripper = new DelegatingScheduledFutureStripper(original);
    stripper.cancel(true);
    stripper.cancel(true);
}
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)

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