1   package org.apache.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  
26  import org.apache.jcs.JCS;
27  import org.apache.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          junit.textui.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              public void runTest()
72                  throws Exception
73              {
74                  this.runTestForRegion( "indexedRegion4", 0, 200, 1 );
75              }
76          } );
77  
78          suite.addTest( new IndexedDiskCacheRandomConcurrentTestUtil( "testIndexedDiskCache2" )
79          {
80              public void runTest()
81                  throws Exception
82              {
83                  this.runTestForRegion( "indexedRegion4", 10000, 50000, 2 );
84              }
85          } );
86  
87          suite.addTest( new IndexedDiskCacheRandomConcurrentTestUtil( "testIndexedDiskCache3" )
88          {
89              public void runTest()
90                  throws Exception
91              {
92                  this.runTestForRegion( "indexedRegion4", 10000, 50000, 3 );
93              }
94          } );
95  
96          suite.addTest( new IndexedDiskCacheRandomConcurrentTestUtil( "testIndexedDiskCache4" )
97          {
98              public void runTest()
99                  throws Exception
100             {
101                 this.runTestForRegion( "indexedRegion4", 10000, 50000, 4 );
102             }
103         } );
104 
105         suite.addTest( new IndexedDiskCacheRandomConcurrentTestUtil( "testIndexedDiskCache5" )
106         {
107             public void runTest()
108                 throws Exception
109             {
110                 this.runTestForRegion( "indexedRegion4", 10000, 50000, 5 );
111             }
112         } );
113 
114         return suite;
115     }
116 
117     /***
118      * Test setup
119      */
120     public void setUp()
121     {
122         JCS.setConfigFilename( "/TestDiskCacheCon.ccf" );
123     }
124 
125     /***
126      * Test tearDown. Dispose of the cache.
127      */
128     public void tearDown()
129     {
130         try
131         {
132             CompositeCacheManager cacheMgr = CompositeCacheManager.getInstance();
133             cacheMgr.shutDown();
134         }
135         catch ( Exception e )
136         {
137             // log.error(e);
138         }
139     }
140 
141 }