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 import java.util.Properties;
17
18 import mockit.Expectations;
19 import mockit.Mocked;
20
21 import oracle.jdbc.pool.OracleDataSource;
22
23 import org.junit.jupiter.api.Assertions;
24 import org.junit.jupiter.api.BeforeEach;
25 import org.junit.jupiter.api.Test;
26
27
28
29
30 class OracleDatasourceAccessorTest {
31
32
33 OracleDatasourceAccessor accessor;
34
35
36 @Mocked
37 OracleDataSource source;
38
39
40 HikariDataSource badSource;
41
42
43
44
45
46
47 @BeforeEach
48 void before() throws SQLException {
49 accessor = new OracleDatasourceAccessor();
50 badSource = new HikariDataSource();
51 }
52
53
54
55
56 @Test
57 void canMapTest() {
58 Assertions.assertTrue(accessor.canMap(source));
59 }
60
61
62
63
64 @Test
65 void cannotMapTest() {
66 Assertions.assertFalse(accessor.canMap(badSource));
67 }
68
69
70
71
72
73
74 @Test
75 void getInfoTest() throws SQLException {
76 new Expectations() {
77 {
78 source.getConnectionCacheProperties();
79 result = new Properties();
80 }
81 };
82 Assertions.assertNotNull(accessor.getInfo(source));
83 }
84
85 }