1   /***
2    * @(#)C3P0DataSourceFactoryTest.java
3    * 
4    * JFoxSOAF, Service-Oriented Application Framework
5    * 
6    * Copyright(c) JFoxSOAF Team
7    * 
8    * Licensed under the GNU LGPL, Version 2.1 (the "License"); 
9    * you may not use this file except in compliance with the License. 
10   * You may obtain a copy of the License at  
11   * 
12   * http://www.gnu.org/copyleft/lesser.html
13   * 
14   * Unless required by applicable law or agreed to in writing, software
15   * distributed under the License is distributed on an "AS IS" BASIS, 
16   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
17   * See the License for the specific language governing permissions and 
18   * limitations under the License. 
19   * 
20   * For more information, please visit:
21   * http://www.jfox.cn/confluence/display/JFoxSOAF/Home
22   * http://www.huihoo.org/jfox/jfoxsoaf
23   */
24  
25  package org.huihoo.jfox.soaf.services.jdbc;
26  
27  import javax.sql.DataSource;
28  
29  import junit.framework.TestCase;
30  
31  /***
32   * JUnit test case for the
33   * {@link org.huihoo.jfox.soaf.services.jdbc.C3P0DataSourceFactory).
34   * 
35   * @author <a href="mailto:founder_chen@yahoo.com">Peter Cheng </a>
36   * @version $Revision: 1.4 $ $Date: 2005/01/17 14:12:05 $
37   * @version Revision: 1.0
38   */
39  
40  public class C3P0DataSourceFactoryTest extends TestCase {
41  
42      /***
43       * @see TestCase#setUp()
44       */
45      protected void setUp() throws Exception {
46          super.setUp();
47  
48      }
49  
50      /***
51       * @see TestCase#tearDown()
52       */
53      protected void tearDown() throws Exception {
54          super.tearDown();
55      }
56  
57      /***
58       * Test for method: getInstance()
59       * 
60       * @see C3P0DataSourceFactory#getInstance()
61       */
62      public void testGetInstance() {
63          DataSource ds = DataSourceFactory.getDataSource();
64          assertNotNull(ds);
65      }
66  
67      /***
68       * Test for method: removeAttribute()
69       * 
70       * @see C3P0DataSourceFactory#removeAttribute()
71       */
72      public void testRemoveAttribute() {
73          C3P0DataSourceFactory c3p0DSFactory = new C3P0DataSourceFactory();
74          c3p0DSFactory.setAttribute(DatabaseConstant.JDBC_INIT_POOL_SIZE, "1");
75          c3p0DSFactory.removeAttribute(DatabaseConstant.JDBC_INIT_POOL_SIZE);
76          assertNull(c3p0DSFactory
77                  .getAttribute(DatabaseConstant.JDBC_INIT_POOL_SIZE));
78      }
79  
80      /***
81       * Test for method: setAttribute()
82       * 
83       * @see C3P0DataSourceFactory#setAttribute()
84       */
85      public void testSetAttribute() {
86          C3P0DataSourceFactory c3p0DSFactory = new C3P0DataSourceFactory();
87          c3p0DSFactory.setAttribute(DatabaseConstant.JDBC_INIT_POOL_SIZE, "1");
88          assertEquals("1", c3p0DSFactory
89                  .getAttribute(DatabaseConstant.JDBC_INIT_POOL_SIZE));
90      }
91  
92      /***
93       * Test for method: getAttribute()
94       * 
95       * @see C3P0DataSourceFactory#getAttribute()
96       */
97      public void testGetAttribute() {
98          C3P0DataSourceFactory c3p0DSFactory = new C3P0DataSourceFactory();
99          assertNull(c3p0DSFactory.getAttribute("jdbc.databaseFactory"));
100     }
101 
102 }