DefaultEntryCacheTestCase.java revision b1dce270ec218b8ad86ce6d745d295da038a5c88
/*
* 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 legal-notices/CDDLv1_0.txt
* 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 legal-notices/CDDLv1_0.txt.
* 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.
* Portions Copyright 2011-2014 ForgeRock AS
*/
/**
* A set of test cases for default entry cache implementation.
*/
public class DefaultEntryCacheTestCase
extends CommonEntryCacheTestCase<EntryCacheCfg>
{
// Entry cache implementations participating in this test.
// ... and their configuration entries.
// The entry cache order map sorted by the cache level.
EntryCache<? extends EntryCacheCfg>>();
// Dummy test entries for each participating implementation.
/**
* Initialize the entry cache test.
*
* @throws Exception If an unexpected problem occurs.
*/
@BeforeClass()
@SuppressWarnings("unchecked")
public void entryCacheTestInit()
throws Exception
{
// Ensure that the server is running.
// Get default cache.
// Configure and initialize all entry cache implementations.
softRefCache = new SoftReferenceEntryCache();
"dn: cn=Soft Reference,cn=Entry Caches,cn=config",
"objectClass: ds-cfg-soft-reference-entry-cache",
"objectClass: ds-cfg-entry-cache",
"objectClass: top",
"cn: Soft Reference",
"ds-cfg-cache-level: 1",
"ds-cfg-java-class: " +
"org.opends.server.extensions.SoftReferenceEntryCache",
"ds-cfg-enabled: true",
"ds-cfg-include-filter: uid=softref*",
"ds-cfg-include-filter: uid=test1*",
"ds-cfg-exclude-filter: uid=test0*");
fifoCache = new FIFOEntryCache();
"dn: cn=FIFO,cn=Entry Caches,cn=config",
"objectClass: ds-cfg-fifo-entry-cache",
"objectClass: ds-cfg-entry-cache",
"objectClass: top",
"cn: FIFO",
"ds-cfg-cache-level: 2",
"ds-cfg-java-class: org.opends.server.extensions.FIFOEntryCache",
"ds-cfg-enabled: true",
"ds-cfg-include-filter: uid=fifo*",
"ds-cfg-include-filter: uid=test2*",
"ds-cfg-include-filter: uid=test0*");
// Plug all cache implementations into default entry cache.
final Method[] defaultCacheMethods =
defaultCacheMethods[i].setAccessible(true);
}
}
// Make some dummy test entries.
for(int i = 0; i < super.NUMTESTENTRIES; i++ ) {
"objectClass: person",
"objectClass: inetorgperson",
"objectClass: top",
"objectClass: organizationalperson",
+ "@testdomain.net",
);
}
for(int i = 0; i < super.NUMTESTENTRIES; i++ ) {
"objectClass: person",
"objectClass: inetorgperson",
"objectClass: top",
"objectClass: organizationalperson",
);
}
for(int i = 0; i < super.NUMTESTENTRIES; i++ ) {
"objectClass: person",
"objectClass: inetorgperson",
"objectClass: top",
"objectClass: organizationalperson",
);
}
// Force GC to make sure we have enough memory for
// the cache capping constraints to work properly.
}
/**
* Finalize the entry cache test.
*
* @throws Exception If an unexpected problem occurs.
*/
@AfterClass()
public void entryCacheTestFini()
throws Exception
{
// Unplug all cache implementations from default entry cache.
EntryCache<? extends EntryCacheCfg>>();
final Method[] defaultCacheMethods =
defaultCacheMethods[i].setAccessible(true);
}
}
// Finilize all entry cache implementations.
}
}
/**
* {@inheritDoc}
*/
@Test()
public void testContainsEntry()
throws Exception
{
super.testContainsEntry();
}
/**
* {@inheritDoc}
*/
@Test()
public void testGetEntry1()
throws Exception
{
super.testGetEntry1();
}
/**
* {@inheritDoc}
*/
@Test()
public void testGetEntry2()
throws Exception
{
super.testGetEntry2();
}
/**
* {@inheritDoc}
*/
@Test()
public void testGetEntry3()
throws Exception
{
super.testGetEntry3();
}
/**
* {@inheritDoc}
*/
@Test()
public void testGetEntryID()
throws Exception
{
super.testGetEntryID();
}
/**
* {@inheritDoc}
*/
@Test()
public void testPutEntry()
throws Exception
{
super.testPutEntry();
}
/**
* {@inheritDoc}
*/
@Test()
public void testPutEntryIfAbsent()
throws Exception
{
super.testPutEntryIfAbsent();
}
/**
* {@inheritDoc}
*/
@Test()
public void testRemoveEntry()
throws Exception
{
super.testRemoveEntry();
}
/**
* {@inheritDoc}
*/
@Test()
public void testClear()
throws Exception
{
super.testClear();
}
/**
* {@inheritDoc}
*/
@Test()
public void testClearBackend()
throws Exception
{
super.testClearBackend();
}
/**
* {@inheritDoc}
*/
@Test()
public void testClearSubtree()
throws Exception
{
super.testClearSubtree();
}
/**
* {@inheritDoc}
*/
@Test()
public void testHandleLowMemory()
throws Exception
{
super.testHandleLowMemory();
}
/**
* Tests the entry cache level functionality where each set
* of entries land on a specific cache level by some form
* of selection criteria such as include / exclude filters.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testCacheLevels()
throws Exception
{
cache.toVerboseString());
TestCaseUtils.initializeTestBackend(false);
// Spread test entries among all cache levels via default cache.
for (int i = 0; i < NUMTESTENTRIES; i++) {
}
// Ensure all test entries are available via default cache.
for (int i = 0; i < NUMTESTENTRIES; i++) {
"Expected to find " +
" in the cache. Cache contents:" +
"Expected to find " +
" in the cache. Cache contents:" +
}
// Ensure all test entries landed on their levels.
for (int i = 0; i < NUMTESTENTRIES; i++) {
"Expected to find " +
" in the cache. Cache contents:" +
"Expected to find " +
" in the cache. Cache contents:" +
}
// Clear the cache so that other tests can start from scratch.
}
public void cacheConcurrencySetup()
throws Exception
{
cache.toVerboseString());
}
public void cacheConcurrencyCleanup()
throws Exception
{
// Clear the cache so that other tests can start from scratch.
}
/**
* {@inheritDoc}
*/
threadPoolSize = 10,
invocationCount = 10,
timeOut = 60000)
public void testCacheConcurrency()
throws Exception
{
super.testCacheConcurrency();
}
}