|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjunit.framework.Assert
junit.framework.TestCase
org.hd.d.pg2k.test.dev.SimpleCacheTest
public final class SimpleCacheTest
Test the ExhibitSimpleDataCache.
| Nested Class Summary | |
|---|---|
(package private) static class |
SimpleCacheTest.DataConcurrencyAccessMonitor
Thread-safe monitor of data-read activity. |
static class |
SimpleCacheTest.DummyDataSource
Dummy data source. |
(package private) static class |
SimpleCacheTest.RawDataAccessMonitor
Thread-safe monitor of data-read activity. |
| Field Summary | |
|---|---|
private SimpleLoggerIF |
logger
|
private static java.util.Random |
rnd
Private source of OK pseudo-random numbers. |
private java.util.Timer |
t
Timer that we can use to run pipelines; never null during tests. |
private java.io.File |
tempDir
Temporary directory in which we build a cache; null if not needed. |
| Constructor Summary | |
|---|---|
SimpleCacheTest(java.lang.String name)
|
|
| Method Summary | |
|---|---|
private int |
checkCacheInstance(boolean firstRun,
int prevCachedCount,
java.util.List<SimpleCacheTest.RawDataAccessMonitor.GetRawDataEvent> eventsFromTestStart,
long stopBy)
Check behaviour of single cache instance, mainly for persistence. |
protected void |
setUp()
Do any setup needed for the tests. |
protected void |
tearDown()
Do any clear-up needed after the tests. |
void |
testBasicCacheBehaviour()
Check that we can construct a cache wrapped round a (dummy) source. |
void |
testCacheFileReadConcurrency()
Test that cache has indefinite (file read) concurrency. |
void |
testCachePersistence()
Test cacheing and resilience after restart. |
void |
testCacheVarHandling()
Test that variables work properly with the cache. |
static void |
testDummyDataSource()
Internal test that DummyDataSource behaves as expected. |
| 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 |
|---|
private final SimpleLoggerIF logger
private java.io.File tempDir
private java.util.Timer t
private static final java.util.Random rnd
| Constructor Detail |
|---|
public SimpleCacheTest(java.lang.String name)
| Method Detail |
|---|
protected void setUp()
setUp in class junit.framework.TestCaseprotected void tearDown()
tearDown in class junit.framework.TestCase
public static void testDummyDataSource()
throws java.lang.Exception
java.lang.Exception
public void testBasicCacheBehaviour()
throws java.lang.Exception
Look elsewhere for a thorough test to behaviour.
java.lang.Exception
public void testCacheVarHandling()
throws java.lang.Exception
java.lang.Exception
public void testCachePersistence()
throws java.lang.Exception
This relies on the test data set being present and being easily small enough to fit into cache.
java.lang.Exception
private int checkCacheInstance(boolean firstRun,
int prevCachedCount,
java.util.List<SimpleCacheTest.RawDataAccessMonitor.GetRawDataEvent> eventsFromTestStart,
long stopBy)
throws java.io.IOException,
java.lang.InterruptedException
The number of exhibits partially or fully cached must not go down and must be greater than zero when we return if there are exhibits.
This tests the cache's use of its upstream data source knowing that this should read and cache exhibit prefixes (ie it will/may only cache activity that reads starting at the beginning of an exhibit, as a normal download should), and that having read such a prefix it should never have to go back to the underlying source for anything within that prefix again, even when the cache is shut down an restarted, assuming that our cache area is big enough to hold all the exhibits.
firstRun - if true, this is the first run on a new cache areaprevCachedCount - number of exhibits previously cached;
non-negativeeventsFromTestStart - List of events collected so far in order;
we will append to this (the content is opaque to the caller);
must be non-null and appendable-tostopBy - target time to stop by
java.io.IOException
java.lang.InterruptedException
public void testCacheFileReadConcurrency()
throws java.lang.Exception
java.lang.Exception
|
DHD Multimedia Gallery V1.57.21 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||