CommonEntryCacheTestCase.java revision 2efcb9667318c099d8723dd578f198c16b4a22c4
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at
* trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the fields enclosed
* by brackets "[]" replaced with your own identifying information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2008 Sun Microsystems, Inc.
*/
/**
* A common set of test cases for all entry cache implementations.
*/
public abstract class CommonEntryCacheTestCase
extends ExtensionsTestCase
{
/**
* Number of unique dummy test entries.
* Note that the value affects MAXENTRIES.
*/
protected int NUMTESTENTRIES = 30;
/**
* Maximum number of entries the cache can hold.
* Note that the value depends on NUMTESTENTRIES.
*/
protected int MAXENTRIES = 10;
/**
* Number of loops for each concurrency test.
*/
protected int CONCURRENCYLOOPS = 100;
/**
* Dummy test entries.
* Note that this list should contain at least two entry
* elements for the following tests to function properly.
*/
/**
* Cache implementation instance.
*/
protected EntryCache cache;
/**
* Entry cache configuration instance.
*/
protected EntryCacheCfg configuration;
/**
* Reflection of the toVerboseString implementation method.
*/
protected String toVerboseString()
throws Exception
{
final Method[] cacheMethods =
cacheMethods[i].setAccessible(true);
return (String) verboseString;
}
}
return null;
}
/**
* Tests the <CODE>containsEntry</CODE> method.
*
* @throws Exception If an unexpected problem occurs.
*/
public void testContainsEntry()
throws Exception
{
toVerboseString());
TestCaseUtils.initializeTestBackend(false);
toVerboseString());
toVerboseString());
// Clear the cache so that other tests can start from scratch.
}
/**
* Tests the first <CODE>getEntry</CODE> method, which takes a single DN
* argument.
*
* @throws Exception If an unexpected problem occurs.
*/
public void testGetEntry1()
throws Exception
{
toVerboseString());
TestCaseUtils.initializeTestBackend(false);
toVerboseString());
toVerboseString());
// Clear the cache so that other tests can start from scratch.
}
/**
* Tests the second <CODE>getEntry</CODE> method, which takes a DN, lock type,
* and list attributes.
*
* @throws Exception If an unexpected problem occurs.
*/
@SuppressWarnings("unchecked")
public void testGetEntry2()
throws Exception
{
toVerboseString());
TestCaseUtils.initializeTestBackend(false);
toVerboseString());
toVerboseString());
// Clear the cache so that other tests can start from scratch.
}
/**
* Tests the third <CODE>getEntry</CODE> method, which takes a backend, entry
* ID, lock type, and list attributes.
*
* @throws Exception If an unexpected problem occurs.
*/
@SuppressWarnings("unchecked")
public void testGetEntry3()
throws Exception
{
toVerboseString());
TestCaseUtils.initializeTestBackend(false);
toVerboseString());
toVerboseString());
// Clear the cache so that other tests can start from scratch.
}
/**
* Tests the <CODE>getEntryID</CODE> method.
*
* @throws Exception If an unexpected problem occurs.
*/
public void testGetEntryID()
throws Exception
{
toVerboseString());
TestCaseUtils.initializeTestBackend(false);
toVerboseString());
toVerboseString());
// Clear the cache so that other tests can start from scratch.
}
/**
* Tests the <CODE>putEntry</CODE> method.
*
* @throws Exception If an unexpected problem occurs.
*/
@SuppressWarnings("unchecked")
public void testPutEntry()
throws Exception
{
toVerboseString());
TestCaseUtils.initializeTestBackend(false);
toVerboseString());
toVerboseString());
// Clear the cache so that other tests can start from scratch.
}
/**
* Tests the <CODE>putEntryIfAbsent</CODE> method.
*
* @throws Exception If an unexpected problem occurs.
*/
@SuppressWarnings("unchecked")
public void testPutEntryIfAbsent()
throws Exception
{
toVerboseString());
TestCaseUtils.initializeTestBackend(false);
toVerboseString());
toVerboseString());
toVerboseString());
toVerboseString());
// Clear the cache so that other tests can start from scratch.
}
/**
* Tests the <CODE>removeEntry</CODE> method.
*
* @throws Exception If an unexpected problem occurs.
*/
@SuppressWarnings("unchecked")
public void testRemoveEntry()
throws Exception
{
toVerboseString());
TestCaseUtils.initializeTestBackend(false);
toVerboseString());
toVerboseString());
// Clear the cache so that other tests can start from scratch.
}
/**
* Tests the <CODE>clear</CODE> method.
*
* @throws Exception If an unexpected problem occurs.
*/
@SuppressWarnings("unchecked")
public void testClear()
throws Exception
{
toVerboseString());
TestCaseUtils.initializeTestBackend(false);
toVerboseString());
toVerboseString());
// Clear the cache so that other tests can start from scratch.
}
/**
* Tests the <CODE>clearBackend</CODE> method.
*
* @throws Exception If an unexpected problem occurs.
*/
@SuppressWarnings("unchecked")
public void testClearBackend()
throws Exception
{
toVerboseString());
TestCaseUtils.initializeTestBackend(false);
cache.clearBackend(b);
cache.clearBackend(b);
b.getBackendID() + " in the cache. Cache contents:" +
toVerboseString());
c.getBackendID() + " in the cache. Cache contents:" +
// Clear the cache so that other tests can start from scratch.
}
/**
* Tests the <CODE>clearSubtree</CODE> method.
*
* @throws Exception If an unexpected problem occurs.
*/
@SuppressWarnings("unchecked")
public void testClearSubtree()
throws Exception
{
toVerboseString());
TestCaseUtils.initializeTestBackend(false);
toVerboseString());
toVerboseString());
toVerboseString());
// Clear the cache so that other tests can start from scratch.
}
/**
* Tests the <CODE>handleLowMemory</CODE> method.
*
* @throws Exception If an unexpected problem occurs.
*/
public void testHandleLowMemory()
throws Exception
{
toVerboseString());
// Clear the cache so that other tests can start from scratch.
}
/**
* Tests the entry cache concurrency/threadsafety by executing
* core entry cache operations on several threads concurrently.
*
* @throws Exception If an unexpected problem occurs.
*/
@SuppressWarnings("unchecked")
public void testCacheConcurrency()
throws Exception
{
for(int i = 0; i < NUMTESTENTRIES; i++) {
}
}
}
/**
* Clear out references to save memory.
*/
public void clearReferences() {
}
}