freemarker.testcase
Class TestCacheThreaded

java.lang.Object
  |
  +--freemarker.testcase.TestCacheThreaded
All Implemented Interfaces:
CacheListener, java.util.EventListener

public final class TestCacheThreaded
extends java.lang.Object
implements CacheListener

Simple class (JUnit agnostic) to test cache implementation. This implementation creates multiple threads, each with a different template to retrieve, and counts how many templates were retrieved in a given period. In addition, it also collects statistics of the various events that were fired during the test, and outputs them at the end.

Version:
$Id: TestCacheThreaded.java,v 1.12 2003/11/08 01:42:11 run2000 Exp $
Author:
Nicholas Cull
See Also:
CacheThread, CacheThread2, CacheThread3, CacheThread4, CacheThread5

Constructor Summary
TestCacheThreaded()
          Creates new TestCacheThreaded
 
Method Summary
 void cacheUnavailable(CacheEvent e)
          Called when a cache cannot be updated.
 void elementRemoved(CacheEvent e)
          Called when an element is removed from the cache.
 void elementUpdated(CacheEvent e)
          Called when a cache element updates successfully.
 void elementUpdateFailed(CacheEvent e)
          Called when a cache element fails to update.
protected  java.lang.String getTestcasePath()
          Retrieve the root path of the FM-Classic distribution from a properties file.
static void main(java.lang.String[] args)
          Main code for running the test.
 void test()
          Performs the test.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TestCacheThreaded

public TestCacheThreaded()
Creates new TestCacheThreaded
Method Detail

test

public void test()
          throws java.lang.Exception
Performs the test. The test results are sent to System.out.

elementRemoved

public void elementRemoved(CacheEvent e)
Called when an element is removed from the cache.
Specified by:
elementRemoved in interface CacheListener
Parameters:
e - the CacheEvent fired.

elementUpdateFailed

public void elementUpdateFailed(CacheEvent e)
Called when a cache element fails to update. The event fired contains the Exception object.
Specified by:
elementUpdateFailed in interface CacheListener
Parameters:
e - the CacheEvent fired.

cacheUnavailable

public void cacheUnavailable(CacheEvent e)
Called when a cache cannot be updated. The event fired contains the Exception object.
Specified by:
cacheUnavailable in interface CacheListener
Parameters:
e - the CacheEvent fired.

elementUpdated

public void elementUpdated(CacheEvent e)
Called when a cache element updates successfully.
Specified by:
elementUpdated in interface CacheListener
Parameters:
e - the CacheEvent fired.

getTestcasePath

protected java.lang.String getTestcasePath()
                                    throws java.io.IOException
Retrieve the root path of the FM-Classic distribution from a properties file. This is used to set the root of the FM-Classic cache, which in turn is used to find the example source code.
Returns:
the path to the root of the FM-Classic distribution.

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Main code for running the test.