From 60abd563057c5d172957cddec1622d630cfa85c6 Mon Sep 17 00:00:00 2001 From: Nikita Date: Wed, 10 Jan 2018 15:35:53 +0300 Subject: [PATCH] testTaskResume added. #1231 --- .../RedissonScheduledExecutorServiceTest.java | 42 +++++++++---------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/redisson/src/test/java/org/redisson/executor/RedissonScheduledExecutorServiceTest.java b/redisson/src/test/java/org/redisson/executor/RedissonScheduledExecutorServiceTest.java index 569278ee4..36c920b65 100644 --- a/redisson/src/test/java/org/redisson/executor/RedissonScheduledExecutorServiceTest.java +++ b/redisson/src/test/java/org/redisson/executor/RedissonScheduledExecutorServiceTest.java @@ -12,14 +12,11 @@ import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; import org.junit.After; -import org.junit.AfterClass; import org.junit.Assert; import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Test; import org.redisson.BaseTest; import org.redisson.RedissonNode; -import org.redisson.RedissonRuntimeEnvironment; import org.redisson.api.CronSchedule; import org.redisson.api.RScheduledExecutorService; import org.redisson.api.RScheduledFuture; @@ -30,26 +27,6 @@ public class RedissonScheduledExecutorServiceTest extends BaseTest { private static RedissonNode node; - @BeforeClass - public static void beforeClass() throws IOException, InterruptedException { - if (!RedissonRuntimeEnvironment.isTravis) { - BaseTest.beforeClass(); - Config config = createConfig(); - RedissonNodeConfig nodeConfig = new RedissonNodeConfig(config); - nodeConfig.setExecutorServiceWorkers(Collections.singletonMap("test", 1)); - node = RedissonNode.create(nodeConfig); - node.start(); - } - } - - @AfterClass - public static void afterClass() throws IOException, InterruptedException { - if (!RedissonRuntimeEnvironment.isTravis) { - BaseTest.afterClass(); - node.shutdown(); - } - } - @Before @Override public void before() throws IOException, InterruptedException { @@ -68,6 +45,25 @@ public class RedissonScheduledExecutorServiceTest extends BaseTest { node.shutdown(); } + @Test(timeout = 7000) + public void testTaskResume() throws InterruptedException, ExecutionException { + RScheduledExecutorService executor = redisson.getExecutorService("test"); + ScheduledFuture future1 = executor.schedule(new ScheduledCallableTask(), 5, TimeUnit.SECONDS); + ScheduledFuture future2 = executor.schedule(new ScheduledCallableTask(), 5, TimeUnit.SECONDS); + ScheduledFuture future3 = executor.schedule(new ScheduledCallableTask(), 5, TimeUnit.SECONDS); + + node.shutdown(); + + RedissonNodeConfig nodeConfig = new RedissonNodeConfig(redisson.getConfig()); + nodeConfig.setExecutorServiceWorkers(Collections.singletonMap("test", 1)); + node = RedissonNode.create(nodeConfig); + node.start(); + + assertThat(future1.get()).isEqualTo(100); + assertThat(future2.get()).isEqualTo(100); + assertThat(future3.get()).isEqualTo(100); + } + @Test public void testLoad() { Config config = createConfig();