    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.cache;
    11
    12  import junit.framework.TestCase;
    13
    14  /***
    15   * JUnit test case for the
    16   * {@link org.huihoo.jfox.soaf.services.logging.LoggingServiceImpl).
    17   *
    18   * @author <a href="mailto:founder_chen@yahoo.com">Peter Cheng </a>
    19   * @version $Revision: 1.3 $ $Date: 2004/10/25 11:10:28 $
    20   * @version Revision: 1.0
    21   */
    22
    23  public class SimpleCacheServiceImplTest extends TestCase {
    24
    25      String cache = "simple cache service";
    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: put()
    44       *
    45       * @see SimpleCacheServiceService#put()
    46       */
    47      public void testPut() {
    48          SimpleCacheService simpleCacheService = new SimpleCacheServiceImpl();
    49          try {
    50              simpleCacheService.put("SimpleCache", cache);
    51          } catch (Exception e) {
    52              e.printStackTrace();
    53          }
    54      }
    55
    56      /***
    57       * Test for method: get()
    58       *
    59       * @see SimpleCacheServiceService#get()
    60       */
    61      public void testGet() {
    62          SimpleCacheService simpleCacheService = new SimpleCacheServiceImpl();
    63          try {
    64              simpleCacheService.put("SimpleCache", cache);
    65              assertEquals(simpleCacheService.get("SimpleCache"),
    66                      "simple cache service");
    67          } catch (Exception e) {
    68              e.printStackTrace();
    69          }
    70      }
    71
    72      /***
    73       * Test for method: remove()
    74       *
    75       * @see SimpleCacheServiceService#remove()
    76       */
    77      public void testRemove() {
    78          SimpleCacheService simpleCacheService = new SimpleCacheServiceImpl();
    79          try {
    80              simpleCacheService.remove("SimpleCache");
    81              assertEquals(simpleCacheService.get("SimpleCache"), null);
    82          } catch (Exception e) {
    83              e.printStackTrace();
    84          }
    85      }
    86
    87      /***
    88       * Test for method: remove()
    89       *
    90       * @see SimpleCacheServiceService#clear()
    91       */
    92      public void testClear() {
    93          SimpleCacheService simpleCacheService = new SimpleCacheServiceImpl();
    94          try {
    95              simpleCacheService.put("SimpleCache", cache);
    96              assertEquals(simpleCacheService.size(), 1);
    97              simpleCacheService.clear();
    98              assertEquals(simpleCacheService.size(), 0);
    99          } catch (Exception e) {
    100             e.printStackTrace();
    101         }
    102     }
    103
    104     /***
    105      * Test for method: size()
    106      *
    107      * @see SimpleCacheServiceService#size()
    108      */
    109     public void testSize() {
    110         SimpleCacheService simpleCacheService = new SimpleCacheServiceImpl();
    111         assertEquals(simpleCacheService.size(), 0);
    112     }
    113
    114 }