View Javadoc
1   /*
2    * Licensed under the GPL License. You may not use this file except in compliance with the License.
3    * You may obtain a copy of the License at
4    *
5    *   https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
6    *
7    * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
8    * WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
9    * PURPOSE.
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 oracle.jdbc.pool.OracleDataSource;
19  
20  import org.junit.jupiter.api.Assertions;
21  import org.junit.jupiter.api.BeforeEach;
22  import org.junit.jupiter.api.Test;
23  import org.junit.jupiter.api.extension.ExtendWith;
24  import org.mockito.Mock;
25  import org.mockito.Mockito;
26  import org.mockito.junit.jupiter.MockitoExtension;
27  
28  /**
29   * The Class OracleDatasourceAccessorTest.
30   */
31  @ExtendWith(MockitoExtension.class)
32  class OracleDatasourceAccessorTest {
33  
34    /** The accessor. */
35    OracleDatasourceAccessor accessor;
36  
37    /** The source. */
38    @Mock
39    OracleDataSource source;
40  
41    /** The bad source. */
42    HikariDataSource badSource;
43  
44    /**
45     * Before.
46     *
47     * @throws SQLException the SQL exception
48     */
49    @BeforeEach
50    void before() throws SQLException {
51      accessor = new OracleDatasourceAccessor();
52      badSource = new HikariDataSource();
53    }
54  
55    /**
56     * Can map test.
57     */
58    @Test
59    void canMapTest() {
60      Assertions.assertTrue(accessor.canMap(source));
61    }
62  
63    /**
64     * Cannot map test.
65     */
66    @Test
67    void cannotMapTest() {
68      Assertions.assertFalse(accessor.canMap(badSource));
69    }
70  
71    /**
72     * Gets the info test.
73     *
74     * @throws SQLException the sql exception
75     */
76    @Test
77    void getInfoTest() throws SQLException {
78      Mockito.when(source.getConnectionCacheProperties()).thenReturn(new Properties());
79      Assertions.assertNotNull(accessor.getInfo(source));
80    }
81  
82  }