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 static org.junit.jupiter.api.Assertions.assertEquals;
14  import static org.junit.jupiter.api.Assertions.assertFalse;
15  import static org.junit.jupiter.api.Assertions.assertNull;
16  
17  import java.sql.SQLException;
18  
19  import org.apache.tomcat.dbcp.dbcp2.BasicDataSource;
20  import org.junit.jupiter.api.Test;
21  
22  /**
23   * The Class Tomcat11DbcpDatasourceAccessorTest.
24   */
25  class Tomcat11DbcpDatasourceAccessorTest {
26  
27    /**
28     * Tomcat 11 dbcp datasource accessor.
29     *
30     * @throws SQLException the sql exception
31     */
32    @Test
33    void Tomcat11DbcpDatasourceAccessor() throws SQLException {
34      Tomcat11DbcpDatasourceAccessor accessor = new Tomcat11DbcpDatasourceAccessor();
35      try (BasicDataSource source = new BasicDataSource()) {
36        assertEquals("tomcat-dbcp2", accessor.getInfo(source).getType());
37      }
38    }
39  
40    /**
41     * Tomcat 11 dbcp datasource accessor invalid.
42     *
43     * @throws SQLException the sql exception
44     */
45    @Test
46    void Tomcat11DbcpDatasourceAccessorInvalid() throws SQLException {
47      Tomcat11DbcpDatasourceAccessor accessor = new Tomcat11DbcpDatasourceAccessor();
48      assertNull(accessor.getInfo(new Object()));
49    }
50  
51    /**
52     * Reset.
53     */
54    @Test
55    void reset() {
56      Tomcat11DbcpDatasourceAccessor accessor = new Tomcat11DbcpDatasourceAccessor();
57      assertFalse(accessor.reset(new Object()));
58    }
59  
60  }