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  
17  import mockit.Mocked;
18  
19  import org.junit.jupiter.api.Assertions;
20  import org.junit.jupiter.api.BeforeEach;
21  import org.junit.jupiter.api.Test;
22  import org.vibur.dbcp.ViburDBCPDataSource;
23  
24  /**
25   * The Class HikariCpDatasourceAccessorTest.
26   */
27  class HikariCpDatasourceAccessorTest {
28  
29    /** The accessor. */
30    HikariCpDatasourceAccessor accessor;
31  
32    /** The source. */
33    @Mocked
34    HikariDataSource source;
35  
36    /** The bad source. */
37    ViburDBCPDataSource badSource;
38  
39    /**
40     * Before.
41     */
42    @BeforeEach
43    void before() {
44      accessor = new HikariCpDatasourceAccessor();
45      badSource = new ViburDBCPDataSource();
46    }
47  
48    /**
49     * Can map test.
50     */
51    @Test
52    void canMapTest() {
53      Assertions.assertTrue(accessor.canMap(source));
54    }
55  
56    /**
57     * Cannot map test.
58     */
59    @Test
60    void cannotMapTest() {
61      Assertions.assertFalse(accessor.canMap(badSource));
62    }
63  
64    /**
65     * Gets the info test.
66     *
67     * @throws SQLException the sql exception
68     */
69    @Test
70    void getInfoTest() throws SQLException {
71      Assertions.assertNotNull(accessor.getInfo(source));
72    }
73  
74  }