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