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