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