testTaskResume added. #1231

pull/1249/head
Nikita 7 years ago
parent d08290233a
commit 60abd56305

@ -12,14 +12,11 @@ import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.junit.After; import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.redisson.BaseTest; import org.redisson.BaseTest;
import org.redisson.RedissonNode; import org.redisson.RedissonNode;
import org.redisson.RedissonRuntimeEnvironment;
import org.redisson.api.CronSchedule; import org.redisson.api.CronSchedule;
import org.redisson.api.RScheduledExecutorService; import org.redisson.api.RScheduledExecutorService;
import org.redisson.api.RScheduledFuture; import org.redisson.api.RScheduledFuture;
@ -30,26 +27,6 @@ public class RedissonScheduledExecutorServiceTest extends BaseTest {
private static RedissonNode node; 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 @Before
@Override @Override
public void before() throws IOException, InterruptedException { public void before() throws IOException, InterruptedException {
@ -68,6 +45,25 @@ public class RedissonScheduledExecutorServiceTest extends BaseTest {
node.shutdown(); node.shutdown();
} }
@Test(timeout = 7000)
public void testTaskResume() throws InterruptedException, ExecutionException {
RScheduledExecutorService executor = redisson.getExecutorService("test");
ScheduledFuture<Long> future1 = executor.schedule(new ScheduledCallableTask(), 5, TimeUnit.SECONDS);
ScheduledFuture<Long> future2 = executor.schedule(new ScheduledCallableTask(), 5, TimeUnit.SECONDS);
ScheduledFuture<Long> 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 @Test
public void testLoad() { public void testLoad() {
Config config = createConfig(); Config config = createConfig();

Loading…
Cancel
Save