logo       


cvs commit: jakarta-turbine-jcs/src/test/org/apache/jcs TestDiskCacheConcur: msg#00045

Subject: cvs commit: jakarta-turbine-jcs/src/test/org/apache/jcs TestDiskCacheConcurrentRandom.java TestDiskCacheConcurrentForDeadLock.java
asmuts      2004/07/13 20:30:32

  Added:       src/test/org/apache/jcs TestDiskCacheConcurrentRandom.java
                        TestDiskCacheConcurrentForDeadLock.java
  Log:
  New test and worker using the new TestCacheAccess methods to stress the disk 
cache under concurrent load with random operations.
  
  Revision  Changes    Path
  1.1                  
jakarta-turbine-jcs/src/test/org/apache/jcs/TestDiskCacheConcurrentRandom.java
  
  Index: TestDiskCacheConcurrentRandom.java
  ===================================================================
  package org.apache.jcs;
  
  import junit.framework.*;
  
  import org.apache.jcs.access.TestCacheAccess;
  
  public class TestDiskCacheConcurrentRandom
      extends TestCase {
  
    /**
     * Constructor for the TestDiskCache object.
     */
    public TestDiskCacheConcurrentRandom(String testName) {
      super(testName);
    }
  
    /**
     * Randomly adds items to cache, gets them, and removes them.
     * The range count is more than the size of the memory cache,
     * so items should spool to disk.
     *
     * @param region Name of the region to access
     *
     * @exception Exception If an error occurs
     */
    public void runTestForRegion( String region, int range, int numOps, int 
testNum )
        throws Exception
    {
        // run a rondom operation test to detect deadlocks
        TestCacheAccess tca = new TestCacheAccess( "/TestDiskCacheCon.ccf" );
        tca.setRegion( region );
        tca.random( range, numOps);
  
        // make sure a simple put then get works
        // this may fail if the other tests are flooding the disk cache
        JCS jcs = JCS.getInstance( region );
        String key = "testKey" + testNum;
        String data = "testData" + testNum;
        jcs.put( key, data );
        String value = ( String ) jcs.get( key );
        this.assertEquals( data, value );
  
    }
  
  
    /**
     * Test setup
     */
    public void setUp() {
      JCS.setConfigFilename("/TestDiskCacheCon.ccf");
    }
  
  }
  
  
  
  1.1                  
jakarta-turbine-jcs/src/test/org/apache/jcs/TestDiskCacheConcurrentForDeadLock.java
  
  Index: TestDiskCacheConcurrentForDeadLock.java
  ===================================================================
  package org.apache.jcs;
  
  
  /*
   * Copyright 2001-2004 The Apache Software Foundation.
   *
   * Licensed under the Apache License, Version 2.0 (the "License")
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  
  import junit.extensions.ActiveTestSuite;
  import junit.framework.Test;
  import junit.framework.TestCase;
  
  import org.apache.jcs.engine.control.CompositeCacheManager;
  
  /**
   * Test which exercises the indexed disk cache. Runs three threads against the
   * same region.
   *
   * @version $Id: TestDiskCacheConcurrentForDeadLock.java,v 1.1 2004/07/14 
03:30:32 asmuts Exp $
   */
  public class TestDiskCacheConcurrentForDeadLock extends TestCase
  {
      /**
       * Constructor for the TestDiskCache object.
       */
      public TestDiskCacheConcurrentForDeadLock( String testName )
      {
          super( testName );
      }
  
      /**
       * Main method passes this test to the text test runner.
       */
      public static void main( String args[] )
      {
          String[] testCaseName = 
{TestDiskCacheConcurrentForDeadLock.class.getName()};
          junit.textui.TestRunner.main( testCaseName );
      }
  
      /**
       * A unit test suite for JUnit
       *
       * @return    The test suite
       */
      public static Test suite()
      {
          ActiveTestSuite suite = new ActiveTestSuite();
  
          suite.addTest( new TestDiskCacheConcurrentRandom( 
"testIndexedDiskCache1" )
          {
              public void runTest() throws Exception
              {
                  this.runTestForRegion( "indexedRegion4", 0, 200, 1 );
              }
          } );
  
          suite.addTest( new TestDiskCacheConcurrentRandom( 
"testIndexedDiskCache2" )
          {
              public void runTest() throws Exception
              {
                  this.runTestForRegion( "indexedRegion4", 10000, 50000, 2 );
              }
          } );
  
          suite.addTest( new TestDiskCacheConcurrentRandom( 
"testIndexedDiskCache3" )
          {
              public void runTest() throws Exception
              {
                  this.runTestForRegion( "indexedRegion4", 10000, 50000, 3 );
              }
          });
  
          suite.addTest( new TestDiskCacheConcurrentRandom( 
"testIndexedDiskCache4" )
          {
              public void runTest() throws Exception
              {
                  this.runTestForRegion( "indexedRegion4", 10000, 50000, 4 );
              }
          });
  
          suite.addTest( new TestDiskCacheConcurrentRandom( 
"testIndexedDiskCache5" )
          {
              public void runTest() throws Exception
              {
                  this.runTestForRegion( "indexedRegion4", 10000, 50000, 5 );
              }
          });
  
  
          return suite;
      }
  
      /**
       * Test setup
       */
      public void setUp()
      {
          JCS.setConfigFilename( "/TestDiskCacheCon.ccf" );
      }
  
      /**
       * Test tearDown.  Dispose of the cache.
       */
      public void tearDown() {
        try {
          CompositeCacheManager cacheMgr = CompositeCacheManager.getInstance();
          cacheMgr.shutDown();
        }
        catch (Exception e) {
          //log.error(e);
        }
      }
  
  
  
  }


Ruby Jobs
Java Jobs
Jobs in California
more...
what
job title, keywords
where
city, state, zip
jobs by job search
Search:
Java, servers, webhosting, windows, cisco ...
more...
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
encryption.gpg....    ietf.rfc822/199...    freebsd.devel.i...    lang.haskell.li...    mail.squirrelma...    web.zope.plone....    yellowdog.gener...    text.xml.xalan....    recreation.phot...    kde.devel.educa...    hardware.bus.ca...    printing.ghosts...    voip.peering/20...    assembly/2006-0...    org.user-groups...    culture.interne...    network.i2p/200...    boot-loaders.ya...    xfree86.render/...    qnx.openqnx.dev...    jakarta.velocit...    user-groups.pal...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe