    1   /***
    2    * JFoxSOAF, Service-Oriented Application Framework
    3    *
    4    * Copyright (C) www.huihoo.org
    5    *
    6    * Distributable under GNU LGPL For more information, please visit:
    7    * http://www.huihoo.org/jfox/jfoxsoaf
    8    */
    9
    10  package org.huihoo.jfox.soaf.services.jdbc;
    11
    12  import javax.sql.DataSource;
    13
    14  import junit.framework.TestCase;
    15
    16  /***
    17   * JUnit test case for the
    18   * {@link org.huihoo.jfox.soaf.services.jdbc.C3P0DataSourceFactory).
    19   *
    20   * @author <a href="mailto:founder_chen@yahoo.com">Peter Cheng </a>
    21   * @version $Revision: 1.1 $ $Date: 2004/10/28 15:28:08 $
    22   * @version Revision: 1.0
    23   */
    24
    25  public class C3P0DataSourceFactoryTest extends TestCase {
    26
    27      /***
    28       * @see TestCase#setUp()
    29       */
    30      protected void setUp() throws Exception {
    31          super.setUp();
    32
    33      }
    34
    35      /***
    36       * @see TestCase#tearDown()
    37       */
    38      protected void tearDown() throws Exception {
    39          super.tearDown();
    40      }
    41
    42      /***
    43       * Test for method: getInstance()
    44       *
    45       * @see C3P0DataSourceFactory#getInstance()
    46       */
    47      public void testGetInstance() {
    48          C3P0DataSourceFactory c3p0DSFactory = new C3P0DataSourceFactory();
    49          DataSource ds = DataSourceFactory.getDataSource();
    50          assertNotNull(ds);
    51      }
    52
    53      /***
    54       * Test for method: removeAttribute()
    55       *
    56       * @see C3P0DataSourceFactory#removeAttribute()
    57       */
    58      public void testRemoveAttribute() {
    59          C3P0DataSourceFactory c3p0DSFactory = new C3P0DataSourceFactory();
    60          c3p0DSFactory.setAttribute(DatabaseConstant.JDBC_INIT_POOL_SIZE, "1");
    61          c3p0DSFactory.removeAttribute(DatabaseConstant.JDBC_INIT_POOL_SIZE);
    62          assertNull(c3p0DSFactory
    63                  .getAttribute(DatabaseConstant.JDBC_INIT_POOL_SIZE));
    64      }
    65
    66      /***
    67       * Test for method: setAttribute()
    68       *
    69       * @see C3P0DataSourceFactory#setAttribute()
    70       */
    71      public void testSetAttribute() {
    72          C3P0DataSourceFactory c3p0DSFactory = new C3P0DataSourceFactory();
    73          c3p0DSFactory.setAttribute(DatabaseConstant.JDBC_INIT_POOL_SIZE, "1");
    74          assertEquals("1", c3p0DSFactory
    75                  .getAttribute(DatabaseConstant.JDBC_INIT_POOL_SIZE));
    76      }
    77
    78      /***
    79       * Test for method: getAttribute()
    80       *
    81       * @see C3P0DataSourceFactory#getAttribute()
    82       */
    83      public void testGetAttribute() {
    84          C3P0DataSourceFactory c3p0DSFactory = new C3P0DataSourceFactory();
    85          assertNull(c3p0DSFactory.getAttribute("jdbc.databaseFactory"));
    86      }
    87
    88  }