From 64a22d4c128995e2b4d307dc3bc0d3f6ffa0d203 Mon Sep 17 00:00:00 2001 From: sunxinbo <898349230@qq.com> Date: Wed, 11 Jan 2023 23:14:19 +0800 Subject: [PATCH] [alerter] add AlerterWorkerPoolTest (#443) --- .../com/usthe/alert/AlerterWorkerPoolTest.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/alerter/src/test/java/com/usthe/alert/AlerterWorkerPoolTest.java b/alerter/src/test/java/com/usthe/alert/AlerterWorkerPoolTest.java index 910de972fd1..928975de6ac 100644 --- a/alerter/src/test/java/com/usthe/alert/AlerterWorkerPoolTest.java +++ b/alerter/src/test/java/com/usthe/alert/AlerterWorkerPoolTest.java @@ -1,21 +1,34 @@ package com.usthe.alert; -import com.usthe.alert.controller.AlertDefineController; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.*; /** * Test case for {@link AlerterWorkerPool} */ class AlerterWorkerPoolTest { + private AlerterWorkerPool pool ; + @BeforeEach void setUp() { + pool = new AlerterWorkerPool(); } @Test void executeJob() { + for (int i = 1; i <= 10; i++) { + int c = i; + pool.executeJob(() -> { + System.out.println("currentTIme ==> " + System.currentTimeMillis() + " threadName " + " ==> " + Thread.currentThread() + " current = " + c); + }); + } + try { + Thread.sleep(500); + } catch (InterruptedException e) { + e.printStackTrace(); + } + System.out.println("currentTIme ==> " + System.currentTimeMillis() + " threadName " + " ==> " + Thread.currentThread() + " done... "); } } \ No newline at end of file