Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .github/linters/codespell.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ afile
afterall
aline
atleast
atmost
bais
bu
crypted
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.time.Duration;
import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;

@SuppressWarnings("checkstyle:MagicNumber")
public class ExecutorServiceSessionValidationSchedulerTest {
Expand All @@ -47,8 +49,9 @@ void timeoutSessionValidate() throws InterruptedException {
Session session = new SimpleSession();
session.setTimeout(2000L);
defaultSessionManager.create(session);
Thread.sleep(5000L);
assertThat(defaultSessionManager.getActiveSessions()).isEmpty();
await().atMost(Duration.ofSeconds(10))
.pollInterval(Duration.ofMillis(100))
.untilAsserted(() -> assertThat(defaultSessionManager.getActiveSessions()).isEmpty());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to read up on awaitatility. Nice!

assertThat(executorServiceSessionValidationScheduler.isEnabled()).isTrue();
}

Expand All @@ -59,8 +62,9 @@ void stopSessionValidate() throws InterruptedException {
defaultSessionManager.create(session);
Thread.sleep(1000L);
session.stop();
Thread.sleep(3000L);
assertThat(defaultSessionManager.getActiveSessions()).isEmpty();
await().atMost(Duration.ofSeconds(10))
.pollInterval(Duration.ofMillis(100))
.untilAsserted(() -> assertThat(defaultSessionManager.getActiveSessions()).isEmpty());
assertThat(executorServiceSessionValidationScheduler.isEnabled()).isTrue();
}

Expand Down Expand Up @@ -88,8 +92,9 @@ void threadException() throws InterruptedException {
defaultSessionManager.create(session);
Thread.sleep(2000L);
session.stop();
Thread.sleep(2000L);
assertThat(defaultSessionManager.getActiveSessions()).isNotEmpty();
await().atMost(Duration.ofSeconds(10))
.pollInterval(Duration.ofMillis(100))
.untilAsserted(() -> assertThat(defaultSessionManager.getActiveSessions()).isNotEmpty());
assertThat(executorServiceSessionValidationScheduler.isEnabled()).isTrue();
}

Expand Down
Loading