1
2
3
4
5
6
7
8
9
10
11 package psiprobe.beans.accessors;
12
13 import com.zaxxer.hikari.HikariDataSource;
14
15 import java.sql.SQLException;
16
17 import mockit.Mocked;
18
19 import org.apache.tomcat.jdbc.pool.DataSource;
20 import org.junit.jupiter.api.Assertions;
21 import org.junit.jupiter.api.BeforeEach;
22 import org.junit.jupiter.api.Test;
23
24
25
26
27 class TomcatJdbcPoolDatasourceAccessorTest {
28
29
30 TomcatJdbcPoolDatasourceAccessor accessor;
31
32
33 @Mocked
34 DataSource source;
35
36
37 HikariDataSource badSource;
38
39
40
41
42 @BeforeEach
43 void before() {
44 accessor = new TomcatJdbcPoolDatasourceAccessor();
45 badSource = new HikariDataSource();
46 }
47
48
49
50
51 @Test
52 void canMapTest() {
53 Assertions.assertTrue(accessor.canMap(source));
54 }
55
56
57
58
59 @Test
60 void cannotMapTest() {
61 Assertions.assertFalse(accessor.canMap(badSource));
62 }
63
64
65
66
67
68
69 @Test
70 void getInfoTest() throws SQLException {
71 Assertions.assertNotNull(accessor.getInfo(source));
72 }
73
74 }