1
1
/*
2
- * Copyright 2009-2023 the original author or authors.
2
+ * Copyright 2009-2024 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
18
18
import java .io .Reader ;
19
19
import java .util .concurrent .ExecutorService ;
20
20
import java .util .concurrent .Executors ;
21
+ import java .util .concurrent .TimeUnit ;
21
22
22
23
import org .apache .ibatis .BaseDataTest ;
23
24
import org .apache .ibatis .io .Resources ;
24
25
import org .apache .ibatis .session .SqlSession ;
25
26
import org .apache .ibatis .session .SqlSessionFactory ;
26
27
import org .apache .ibatis .session .SqlSessionFactoryBuilder ;
27
- import org .junit . jupiter .api .Assertions ;
28
+ import org .assertj . core .api .Assertions ;
28
29
import org .junit .jupiter .api .BeforeEach ;
29
30
import org .junit .jupiter .api .Test ;
30
31
@@ -47,7 +48,7 @@ void setUp() throws Exception {
47
48
}
48
49
49
50
@ Test
50
- void testBlockingCache () {
51
+ void testBlockingCache () throws InterruptedException {
51
52
ExecutorService defaultThreadPool = Executors .newFixedThreadPool (2 );
52
53
53
54
long init = System .currentTimeMillis ();
@@ -57,13 +58,12 @@ void testBlockingCache() {
57
58
}
58
59
59
60
defaultThreadPool .shutdown ();
60
-
61
- while (!defaultThreadPool .isTerminated ()) {
62
- continue ;
61
+ if (!defaultThreadPool .awaitTermination (5 , TimeUnit .SECONDS )) {
62
+ defaultThreadPool .shutdownNow ();
63
63
}
64
64
65
65
long totalTime = System .currentTimeMillis () - init ;
66
- Assertions .assertTrue (totalTime > 1000 );
66
+ Assertions .assertThat (totalTime ). isGreaterThanOrEqualTo ( 1000 );
67
67
}
68
68
69
69
private void accessDB () {
0 commit comments