    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.DataSourceFactory).
    19   *
    20   * @author <a href="mailto:founder_chen@yahoo.com">Peter Cheng </a>
    21   * @version $Revision: 1.1 $ $Date: 2004/10/28 15:43:06 $
    22   * @version Revision: 1.0
    23   */
    24
    25  public class DataSourceFactoryTest extends TestCase {
    26
    27      /***
    28       * @see TestCase#setUp()
    29       */
    30      protected void setUp() throws Exception {
    31          super.setUp();
    32      }
    33
    34      /***
    35       * @see TestCase#tearDown()
    36       */
    37      protected void tearDown() throws Exception {
    38          super.tearDown();
    39      }
    40
    41      /***
    42       * Test for method: DataSourceFactory()
    43       *
    44       * @see DataSourceFactory#DataSourceFactory()
    45       */
    46      public void testDataSourceFactory() {
    47          //TODO Implement DataSourceFactory().
    48      }
    49
    50      /***
    51       * Test for method: getInstance()
    52       *
    53       * @see DataSourceFactory#getInstance()
    54       */
    55      public void testGetInstance() {
    56          assertNotNull(DataSourceFactory.getFactory().getInstance());
    57      }
    58
    59      /***
    60       * Test for method: removeAttribute()
    61       *
    62       * @see DataSourceFactory#removeAttribute()
    63       */
    64      public void testRemoveAttribute() {
    65          //TODO Implement removeAttribute().
    66      }
    67
    68      /***
    69       * Test for method: setAttribute()
    70       *
    71       * @see DataSourceFactory#setAttribute()
    72       */
    73      public void testSetAttribute() {
    74          //TODO Implement setAttribute().
    75      }
    76
    77      /***
    78       * Test for method: getFactory()
    79       *
    80       * @see DataSourceFactory#getInstance()
    81       */
    82      public void testGetFactory() {
    83          boolean result = false;
    84          if (DataSourceFactory.getFactory() instanceof C3P0DataSourceFactory) {
    85              result = true;
    86          }
    87          assertTrue(result);
    88      }
    89
    90      /***
    91       * Test for method: newFactory()
    92       *
    93       * @see DataSourceFactory#getInstance()
    94       */
    95      public void testNewFactory() {
    96          boolean result = false;
    97          String newClass = "org.huihoo.jfox.soaf.services.jdbc.C3P0DataSourceFactory";
    98          if (DataSourceFactory.newFactory(newClass, this.getClass()
    99                  .getClassLoader()) instanceof C3P0DataSourceFactory) {
    100             result = true;
    101         }
    102         assertTrue(result);
    103     }
    104
    105     /***
    106      * Test for method: getDataSource()
    107      *
    108      * @see DataSourceFactory#getInstance()
    109      */
    110     public void testGetDataSource() {
    111         DataSource ds = DataSourceFactory.getDataSource();
    112         assertNotNull(ds);
    113     }
    114
    115 }