View Javadoc
1   package org.apache.commons.jcs.auxiliary.disk.indexed;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import junit.extensions.ActiveTestSuite;
23  import junit.framework.Test;
24  import junit.framework.TestCase;
25  import junit.textui.TestRunner;
26  import org.apache.commons.jcs.JCS;
27  import org.apache.commons.jcs.engine.control.CompositeCacheManager;
28  
29  /**
30   * Test which exercises the indexed disk cache. Runs three threads against the
31   * same region.
32   *
33   * @version $Id: TestDiskCacheConcurrentForDeadLock.java,v 1.2 2005/02/01
34   *          00:01:59 asmuts Exp $
35   */
36  public class IndexedDiskCacheConcurrentNoDeadLockUnitTest
37      extends TestCase
38  {
39      /**
40       * Constructor for the TestDiskCache object.
41       *
42       * @param testName
43       */
44      public IndexedDiskCacheConcurrentNoDeadLockUnitTest( String testName )
45      {
46          super( testName );
47      }
48  
49      /**
50       * Main method passes this test to the text test runner.
51       *
52       * @param args
53       */
54      public static void main( String args[] )
55      {
56          String[] testCaseName = { IndexedDiskCacheConcurrentNoDeadLockUnitTest.class.getName() };
57          TestRunner.main( testCaseName );
58      }
59  
60      /**
61       * A unit test suite for JUnit
62       *
63       * @return The test suite
64       */
65      public static Test suite()
66      {
67          ActiveTestSuite suite = new ActiveTestSuite();
68  
69          suite.addTest( new IndexedDiskCacheRandomConcurrentTestUtil( "testIndexedDiskCache1" )
70          {
71              @Override
72              public void runTest()
73                  throws Exception
74              {
75                  this.runTestForRegion( "indexedRegion4", 1, 200, 1 );
76              }
77          } );
78  
79          suite.addTest( new IndexedDiskCacheRandomConcurrentTestUtil( "testIndexedDiskCache2" )
80          {
81              @Override
82              public void runTest()
83                  throws Exception
84              {
85                  this.runTestForRegion( "indexedRegion4", 10000, 50000, 2 );
86              }
87          } );
88  
89          suite.addTest( new IndexedDiskCacheRandomConcurrentTestUtil( "testIndexedDiskCache3" )
90          {
91              @Override
92              public void runTest()
93                  throws Exception
94              {
95                  this.runTestForRegion( "indexedRegion4", 10000, 50000, 3 );
96              }
97          } );
98  
99          suite.addTest( new IndexedDiskCacheRandomConcurrentTestUtil( "testIndexedDiskCache4" )
100         {
101             @Override
102             public void runTest()
103                 throws Exception
104             {
105                 this.runTestForRegion( "indexedRegion4", 10000, 50000, 4 );
106             }
107         } );
108 
109         suite.addTest( new IndexedDiskCacheRandomConcurrentTestUtil( "testIndexedDiskCache5" )
110         {
111             @Override
112             public void runTest()
113                 throws Exception
114             {
115                 this.runTestForRegion( "indexedRegion4", 10000, 50000, 5 );
116             }
117         } );
118 
119         return suite;
120     }
121 
122     /**
123      * Test setup
124      */
125     @Override
126     public void setUp()
127     {
128         JCS.setConfigFilename( "/TestDiskCacheCon.ccf" );
129     }
130 
131     /**
132      * Test tearDown. Dispose of the cache.
133      */
134     @Override
135     public void tearDown()
136     {
137         try
138         {
139             CompositeCacheManager cacheMgr = CompositeCacheManager.getInstance();
140             cacheMgr.shutDown();
141         }
142         catch ( Exception e )
143         {
144             // log.error(e);
145         }
146     }
147 
148 }