org.apache.jcs
Class JCSThrashTest

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.apache.jcs.JCSThrashTest
All Implemented Interfaces:
junit.framework.Test

public class JCSThrashTest
extends junit.framework.TestCase

This is based on a test that was posted to the user's list:

http://www.opensubscriber.com/message/jcs-users@jakarta.apache.org/2435965.html


Nested Class Summary
protected static interface JCSThrashTest.Executable
          A runnable, that can throw an exception.
 
Field Summary
protected  JCS<String,Serializable> jcs
          the cache instance
 
Constructor Summary
JCSThrashTest(String arg0)
           
 
Method Summary
static void main(String[] args)
           
protected  long measureMemoryUse()
          Measure memory used by the VM.
protected  void runThreads(List<JCSThrashTest.Executable> executables)
          Runs a set of threads, for a fixed amount of time.
protected  void setUp()
          Sets up the test
protected  void tearDown()
           
 void testForMemoryLeaks()
          This does a bunch of work and then verifies that the memory has not grown by much.
 void testPut()
          Tests adding an entry.
 void testRemove()
          Test elements can be removed from the store
protected  long thrashCache()
           
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

jcs

protected JCS<String,Serializable> jcs
the cache instance

Constructor Detail

JCSThrashTest

public JCSThrashTest(String arg0)
Parameters:
arg0 -
Method Detail

main

public static void main(String[] args)
Parameters:
args -

setUp

protected void setUp()
              throws Exception
Sets up the test

Overrides:
setUp in class junit.framework.TestCase
Throws:
Exception

tearDown

protected void tearDown()
                 throws Exception
Overrides:
tearDown in class junit.framework.TestCase
Throws:
Exception

testPut

public void testPut()
             throws Exception
Tests adding an entry.

Throws:
Exception

testRemove

public void testRemove()
                throws Exception
Test elements can be removed from the store

Throws:
Exception

testForMemoryLeaks

public void testForMemoryLeaks()
                        throws Exception
This does a bunch of work and then verifies that the memory has not grown by much. Most of the time the amount of memory used after the test is less.

Throws:
Exception

thrashCache

protected long thrashCache()
                    throws Exception
Returns:
time
Throws:
Exception

runThreads

protected void runThreads(List<JCSThrashTest.Executable> executables)
                   throws Exception
Runs a set of threads, for a fixed amount of time.

Parameters:
executables -
Throws:
Exception

measureMemoryUse

protected long measureMemoryUse()
                         throws InterruptedException
Measure memory used by the VM.

Returns:
bytes
Throws:
InterruptedException


Copyright © 2002-2013 The Apache Software Foundation. All Rights Reserved.