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 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   * The Class OracleDatasourceAccessorTest.
29   */
30  class OracleDatasourceAccessorTest {
31  
32    /** The accessor. */
33    OracleDatasourceAccessor accessor;
34  
35    /** The source. */
36    @Mocked
37    OracleDataSource source;
38  
39    /** The bad source. */
40    HikariDataSource badSource;
41  
42    /**
43     * Before.
44     *
45     * @throws SQLException the SQL exception
46     */
47    @BeforeEach
48    void before() throws SQLException {
49      accessor = new OracleDatasourceAccessor();
50      badSource = new HikariDataSource();
51    }
52  
53    /**
54     * Can map test.
55     */
56    @Test
57    void canMapTest() {
58      Assertions.assertTrue(accessor.canMap(source));
59    }
60  
61    /**
62     * Cannot map test.
63     */
64    @Test
65    void cannotMapTest() {
66      Assertions.assertFalse(accessor.canMap(badSource));
67    }
68  
69    /**
70     * Gets the info test.
71     *
72     * @throws SQLException the sql exception
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  }