1   /**
2    * Copyright 2005-2006 the original author or authors.
3    *
4    * Licensed under the Gnu General Pubic License, Version 2.0 (the
5    * "License"); you may not use this file except in compliance with
6    * the License. You may obtain a copy of the License at
7    *
8    *      http://www.opensource.org/licenses/gpl-license.php
9    *
10   * This program is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13   * See the Gnu General Public License for more details.
14   */
15  package org.figure8.join.services.cache;
16  
17  import junit.framework.Test;
18  import junit.framework.TestCase;
19  import junit.framework.TestSuite;
20  /**
21   * JUnit test for EhCacheManager.
22   * @author <a href="mailto:laurent.broudoux@free.fr">Laurent Broudoux</a>
23   * @version $Revision: 1.2 $
24   */
25  public class EhCacheManagerTest extends TestCase{
26  
27     // Constructors -------------------------------------------------------------
28  
29     /** Default constructor. Build a test case using a name. */
30     public EhCacheManagerTest(String testName){
31        super(testName);
32     }
33  
34  
35     // Override of TestCase -----------------------------------------------------
36  
37     /**
38      * Make this class a TestSuite.
39      * @return A TestSuite containing this TestCase.
40      */
41     public static Test suite(){
42        TestSuite suite = new TestSuite(EhCacheManagerTest.class);
43        return suite;
44     }
45  
46  
47     // Public -------------------------------------------------------------------
48  
49     /** Test the caches creation */
50     public void testCreateCaches(){
51        // Create a manager and its caches
52        EhCacheManager manager = new EhCacheManager();
53        try{
54           manager.createCaches();
55           // Retrieve eternal caches and assert.
56           Cache steCache = manager.getCache(EternalCacheKeys.STEP_ID_TO_STEP_KEY);
57           Cache relCache = manager.getCache(EternalCacheKeys.RELEASE_NAME_TO_RELEASE_KEY);
58           Cache delCache = manager.getCache(EternalCacheKeys.DELTYPE_KEY_TO_DELTYPE_KEY);
59           assertNotNull("Step cache has been created", steCache);
60           assertNotNull("Releases cache has been created", relCache);
61           assertNotNull("DeliverableTypes cache has been created", delCache);
62        }
63        catch (CacheException ce){
64           fail("CacheException while creating Eh caches: " + ce.getCause().getMessage());
65        }
66     }
67  }