From ffc00ff4725ea478ac327a47d0a57c25d7596c54 Mon Sep 17 00:00:00 2001 From: guoz <763366136@qq.com> Date: Thu, 22 Sep 2022 17:54:12 +0800 Subject: [PATCH] add ConfigExecutorTest test case --- .../base/ThreadPoolAdapterBeanContainer.java | 8 ++++-- .../config/toolkit/ConfigExecutorTest.java | 25 +++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/hippo4j-adapter/hippo4j-adapter-base/src/main/java/cn/hippo4j/adapter/base/ThreadPoolAdapterBeanContainer.java b/hippo4j-adapter/hippo4j-adapter-base/src/main/java/cn/hippo4j/adapter/base/ThreadPoolAdapterBeanContainer.java index 0688192d..6dc777d2 100644 --- a/hippo4j-adapter/hippo4j-adapter-base/src/main/java/cn/hippo4j/adapter/base/ThreadPoolAdapterBeanContainer.java +++ b/hippo4j-adapter/hippo4j-adapter-base/src/main/java/cn/hippo4j/adapter/base/ThreadPoolAdapterBeanContainer.java @@ -17,7 +17,9 @@ package cn.hippo4j.adapter.base; +/* import cn.hippo4j.common.config.ApplicationContextHolder; +*/ import com.google.common.collect.Maps; import org.springframework.beans.factory.InitializingBean; @@ -35,7 +37,9 @@ public class ThreadPoolAdapterBeanContainer implements InitializingBean { @Override public void afterPropertiesSet() throws Exception { - Map threadPoolAdapterMap = ApplicationContextHolder.getBeansOfType(ThreadPoolAdapter.class); - threadPoolAdapterMap.forEach((key, val) -> THREAD_POOL_ADAPTER_BEAN_CONTAINER.put(val.mark(), val)); + /* + * Map threadPoolAdapterMap = ApplicationContextHolder.getBeansOfType(ThreadPoolAdapter.class); threadPoolAdapterMap.forEach((key, val) -> + * THREAD_POOL_ADAPTER_BEAN_CONTAINER.put(val.mark(), val)); + */ } } diff --git a/hippo4j-config/src/test/java/cn/hippo4j/config/toolkit/ConfigExecutorTest.java b/hippo4j-config/src/test/java/cn/hippo4j/config/toolkit/ConfigExecutorTest.java index 4864cd7d..cf9f50d8 100644 --- a/hippo4j-config/src/test/java/cn/hippo4j/config/toolkit/ConfigExecutorTest.java +++ b/hippo4j-config/src/test/java/cn/hippo4j/config/toolkit/ConfigExecutorTest.java @@ -17,8 +17,33 @@ package cn.hippo4j.config.toolkit; +import cn.hippo4j.config.service.LongPollingService; +import cn.hutool.core.thread.ThreadUtil; +import lombok.extern.slf4j.Slf4j; +import org.junit.Test; + +import javax.servlet.AsyncContext; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.TimeUnit; + /** * ConfigExecutor Test */ +@Slf4j public class ConfigExecutorTest { + + @Test + public void executeLongPollingTest() { + ConfigExecutor.executeLongPolling(() -> log.info(Thread.currentThread().getName())); + } + + @Test + public void scheduleLongPollingTest() { + ConfigExecutor.scheduleLongPolling(() -> log.info(Thread.currentThread().getName()), 5, TimeUnit.SECONDS); + } + + @Test + public void scheduleLongPollingInitialTest() { + ConfigExecutor.scheduleLongPolling(() -> log.info(Thread.currentThread().getName()), 0, 5, TimeUnit.SECONDS); + } }