|
|
|
@ -4,18 +4,21 @@ import mockit.Invocation;
|
|
|
|
|
import mockit.Mock;
|
|
|
|
|
import mockit.MockUp;
|
|
|
|
|
import org.awaitility.Awaitility;
|
|
|
|
|
import org.joor.Reflect;
|
|
|
|
|
import org.junit.jupiter.api.*;
|
|
|
|
|
import org.redisson.RedisDockerTest;
|
|
|
|
|
import org.redisson.Redisson;
|
|
|
|
|
import org.redisson.RedissonNode;
|
|
|
|
|
import org.redisson.RedissonTopic;
|
|
|
|
|
import org.redisson.api.*;
|
|
|
|
|
import org.redisson.api.annotation.RInject;
|
|
|
|
|
import org.redisson.api.executor.TaskFinishedListener;
|
|
|
|
|
import org.redisson.api.executor.TaskStartedListener;
|
|
|
|
|
import org.redisson.api.listener.MessageListener;
|
|
|
|
|
import org.redisson.client.codec.LongCodec;
|
|
|
|
|
import org.redisson.config.Config;
|
|
|
|
|
import org.redisson.config.RedissonNodeConfig;
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.Serializable;
|
|
|
|
|
import java.time.Duration;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
@ -670,4 +673,25 @@ public class RedissonExecutorServiceTest extends RedisDockerTest {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testTaskDelay4TaskService() throws IllegalAccessException, NoSuchFieldException, InterruptedException {
|
|
|
|
|
RScheduledExecutorService test = redisson.getExecutorService("test");
|
|
|
|
|
String topicName = Reflect.on(test).get("schedulerChannelName");
|
|
|
|
|
RedissonTopic topic = RedissonTopic.createRaw(LongCodec.INSTANCE, ((Redisson) redisson).getCommandExecutor(), topicName);
|
|
|
|
|
|
|
|
|
|
AtomicInteger counter = new AtomicInteger();
|
|
|
|
|
|
|
|
|
|
topic.addListener(Long.class, new MessageListener<Long>() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onMessage(CharSequence channel, Long msg) {
|
|
|
|
|
counter.incrementAndGet();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test.submitAsync(new DelayedTask(10000, "test-counter"));
|
|
|
|
|
Thread.sleep(2000);
|
|
|
|
|
|
|
|
|
|
assertThat(counter.get()).isGreaterThan(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|