add ConfigExecutorTest test case

pull/714/head
guoz 2 years ago
parent 330ba13c3b
commit ffc00ff472

@ -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<String, ThreadPoolAdapter> threadPoolAdapterMap = ApplicationContextHolder.getBeansOfType(ThreadPoolAdapter.class);
threadPoolAdapterMap.forEach((key, val) -> THREAD_POOL_ADAPTER_BEAN_CONTAINER.put(val.mark(), val));
/*
* Map<String, ThreadPoolAdapter> threadPoolAdapterMap = ApplicationContextHolder.getBeansOfType(ThreadPoolAdapter.class); threadPoolAdapterMap.forEach((key, val) ->
* THREAD_POOL_ADAPTER_BEAN_CONTAINER.put(val.mark(), val));
*/
}
}

@ -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);
}
}

Loading…
Cancel
Save