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