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