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 java.sql.SQLException;
14  import java.util.Properties;
15  
16  import org.junit.jupiter.api.Assertions;
17  import org.junit.jupiter.api.BeforeEach;
18  import org.junit.jupiter.api.Test;
19  
20  import com.mchange.v2.c3p0.ComboPooledDataSource;
21  
22  import mockit.Expectations;
23  import mockit.Mocked;
24  import oracle.jdbc.pool.OracleDataSource;
25  
26  /**
27   * The Class OracleDatasourceAccessorTest.
28   */
29  public class OracleDatasourceAccessorTest {
30  
31      /** The accessor. */
32      OracleDatasourceAccessor accessor;
33  
34      /** The source. */
35      @Mocked
36      OracleDataSource source;
37  
38      /** The bad source. */
39      ComboPooledDataSource badSource;
40  
41      /**
42       * Before.
43       *
44       * @throws SQLException the SQL exception
45       */
46      @BeforeEach
47      public void before() throws SQLException {
48          accessor = new OracleDatasourceAccessor();
49          badSource = new ComboPooledDataSource();
50      }
51  
52      /**
53       * Can map test.
54       */
55      @Test
56      public void canMapTest() {
57          Assertions.assertTrue(accessor.canMap(source));
58      }
59  
60      /**
61       * Cannot map test.
62       */
63      @Test
64      public void cannotMapTest() {
65          Assertions.assertFalse(accessor.canMap(badSource));
66      }
67  
68      /**
69       * Gets the info test.
70       *
71       * @throws Exception the exception
72       */
73      @Test
74      public void getInfoTest() throws Exception {
75          new Expectations() {
76              {
77                  source.getConnectionCacheProperties();
78                  result = new Properties();
79              }
80          };
81          accessor.getInfo(source);
82      }
83  
84  }