Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[alerter] add AlerterWorkerPoolTest (#443) #565

Merged
merged 1 commit into from
Jan 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions alerter/src/test/java/com/usthe/alert/AlerterWorkerPoolTest.java
Original file line number Diff line number Diff line change
@@ -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... ");
}
}