Skip to content

Commit b026481

Browse files
committed
Simplified test
1 parent 7b508b0 commit b026481

File tree

1 file changed

+5
-27
lines changed

1 file changed

+5
-27
lines changed

ebean-datasource/src/test/java/io/ebean/datasource/pool/ConnectionPoolRecoverTest.java

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@
1515

1616
public class ConnectionPoolRecoverTest {
1717

18-
private int success;
19-
private int failure;
20-
2118
@Test
2219
void testHeavyLoadPool() throws Exception {
2320
DataSourcePool pool = DataSourceBuilder.create()
@@ -31,35 +28,16 @@ void testHeavyLoadPool() throws Exception {
3128
// .heartbeatMaxPoolExhaustedCount(1)
3229
.failOnStart(false)
3330
.build();
34-
ExecutorService executorService = Executors.newCachedThreadPool();
3531
try {
36-
List<Future<?>> futures = new ArrayList<>();
37-
for (int i = 0; i < 2; i++) {
38-
futures.add(executorService.submit(() -> doSomeWork(pool)));
39-
}
40-
41-
for (Future<?> future : futures) {
42-
future.get();
32+
for (int i = 0; i < 5; i++) {
33+
try (Connection conn = pool.getConnection()) {
34+
Thread.sleep(2000);
35+
conn.rollback();
36+
}
4337
}
44-
assertThat(success).isGreaterThan(1);
4538
} finally {
46-
executorService.shutdownNow();
4739
pool.shutdown();
4840
}
49-
50-
}
51-
52-
private void doSomeWork(DataSourcePool pool) {
53-
for (int i = 0; i < 20; i++) {
54-
System.out.println("Success: " + success + " failure: " + failure);
55-
try (Connection conn = pool.getConnection()) {
56-
Thread.sleep(2000);
57-
success++;
58-
} catch (Exception e) {
59-
// nop
60-
failure++;
61-
}
62-
}
6341
}
6442

6543
}

0 commit comments

Comments
 (0)