You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jcs-dev@jakarta.apache.org by as...@apache.org on 2008/09/10 21:43:03 UTC
svn commit: r693951 [2/2] - in /jakarta/jcs/trunk/src:
java/org/apache/jcs/engine/memory/
java/org/apache/jcs/engine/memory/behavior/
java/org/apache/jcs/engine/memory/fifo/
java/org/apache/jcs/engine/memory/lru/
java/org/apache/jcs/engine/memory/mru/ ...
Modified: jakarta/jcs/trunk/src/test/org/apache/jcs/engine/memory/mru/MRUMemoryCacheUnitTest.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/engine/memory/mru/MRUMemoryCacheUnitTest.java?rev=693951&r1=693950&r2=693951&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/engine/memory/mru/MRUMemoryCacheUnitTest.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/engine/memory/mru/MRUMemoryCacheUnitTest.java Wed Sep 10 12:43:02 2008
@@ -33,29 +33,23 @@
import org.apache.jcs.engine.control.CompositeCacheManager;
/**
- * Tests for the test MRU implementation that uses the java linked list class.
- * This is more a set of tests for the hub than for the MRU, since we don't care
- * about the MRU.
- *
+ * Tests for the test MRU implementation.
+ * <p>
* @author Aaron Smuts
- *
*/
public class MRUMemoryCacheUnitTest
extends TestCase
{
-
- /**
- * Test setup
- */
+ /** Test setup */
public void setUp()
{
JCS.setConfigFilename( "/TestMRUCache.ccf" );
}
/**
- * Verify that the mru gets used by a non-defined region when it is set as
- * the defualt in the default region.
- *
+ * Verify that the mru gets used by a non-defined region when it is set as the default in the
+ * default region.
+ * <p>
* @throws CacheException
*/
public void testLoadFromCCF()
@@ -67,9 +61,8 @@
}
/**
- * put twice as many as the max. verify that the second half is in the
- * cache.
- *
+ * put twice as many as the max. verify that the second half is in the cache.
+ * <p>
* @throws CacheException
*/
public void testPutGetThroughHub()
@@ -86,10 +79,10 @@
}
// Test that first items are not in the cache
- for ( int i = max; i >= 0; i-- )
+ for ( int i = max -1; i >= 0; i-- )
{
String value = (String) cache.get( i + ":key" );
- assertNull( "Should not have value for key [" + i + ":key" + "] in the cache.", value );
+ assertNull( "Should not have value for key [" + i + ":key" + "] in the cache." + cache.getStats(), value );
}
// Test that last items are in cache
@@ -108,9 +101,9 @@
}
Map elements = cache.getCacheElements( keys );
- for ( int i = max; i >= 0; i-- )
+ for ( int i = max-1; i >= 0; i-- )
{
- assertNull( elements.get( i + ":key" ) );
+ assertNull( "Should not have value for key [" + i + ":key" + "] in the cache." + cache.getStats(), elements.get( i + ":key" ) );
}
for ( int i = max + 2; i < items; i++ )
{
@@ -121,9 +114,8 @@
}
/**
- * Put twice as many as the max, twice. verify that the second half is in
- * the cache.
- *
+ * Put twice as many as the max, twice. verify that the second half is in the cache.
+ * <p>
* @throws CacheException
*/
public void testPutGetThroughHubTwice()
@@ -163,7 +155,7 @@
/**
* put the max and remove each. verify that they are all null.
- *
+ * <p>
* @throws CacheException
*/
public void testPutRemoveThroughHub()
@@ -194,7 +186,7 @@
/**
* put the max and clear. verify that no elements remain.
- *
+ * <p>
* @throws CacheException
*/
public void testClearThroughHub()
@@ -221,8 +213,8 @@
}
/**
- * put twice the max and clear. verify that no elements remain.
- *
+ * Get stats.
+ * <p>
* @throws CacheException
*/
public void testGetStatsThroughHub()
@@ -247,9 +239,9 @@
}
/**
- * Put half the max and clear. get the key array and verify that it has the
- * correct number of items.
- *
+ * Put half the max and clear. get the key array and verify that it has the correct number of
+ * items.
+ * <p>
* @throws Exception
*/
public void testGetKeyArray()
@@ -278,9 +270,8 @@
}
/**
- * Add a few keys with the delimeter. Remove them.
- *
- *
+ * Add a few keys with the delimeter. Remove them.
+ * <p>
* @throws CacheException
*/
public void testRemovePartialThroughHub()
@@ -316,6 +307,5 @@
}
assertNotNull( "Other item should be in the cache.", cache.get( "test" ) );
-
}
}
Added: jakarta/jcs/trunk/src/test/org/apache/jcs/utils/struct/DoubleLinkedListUnitTest.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/utils/struct/DoubleLinkedListUnitTest.java?rev=693951&view=auto
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/utils/struct/DoubleLinkedListUnitTest.java (added)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/utils/struct/DoubleLinkedListUnitTest.java Wed Sep 10 12:43:02 2008
@@ -0,0 +1,104 @@
+package org.apache.jcs.utils.struct;
+
+import junit.framework.TestCase;
+
+/** Unit tests for the double linked list. */
+public class DoubleLinkedListUnitTest
+ extends TestCase
+{
+ /** verify that it's added last. */
+ public void testMakeLast_wasFirst()
+ {
+ // SETUP
+ DoubleLinkedList list = new DoubleLinkedList();
+
+ String payload1 = "payload1";
+ DoubleLinkedListNode node1 = new DoubleLinkedListNode( payload1 );
+
+ String payload2 = "payload2";
+ DoubleLinkedListNode node2 = new DoubleLinkedListNode( payload2 );
+
+ list.addFirst( node2 );
+ list.addFirst( node1 );
+
+ // DO WORK
+ list.makeLast( node1 );
+
+ // VERIFY
+ assertEquals( "Wrong size", 2, list.size() );
+ assertEquals( "Wrong last", node1, list.getLast() );
+ assertEquals( "Wrong first", node2, list.getFirst() );
+ }
+
+ /** verify that it's added last. */
+ public void testMakeLast_wasLast()
+ {
+ // SETUP
+ DoubleLinkedList list = new DoubleLinkedList();
+
+ String payload1 = "payload1";
+ DoubleLinkedListNode node1 = new DoubleLinkedListNode( payload1 );
+
+ String payload2 = "payload2";
+ DoubleLinkedListNode node2 = new DoubleLinkedListNode( payload2 );
+
+ list.addFirst( node1 );
+ list.addFirst( node2 );
+
+ // DO WORK
+ list.makeLast( node1 );
+
+ // VERIFY
+ assertEquals( "Wrong size", 2, list.size() );
+ assertEquals( "Wrong last", node1, list.getLast() );
+ assertEquals( "Wrong first", node2, list.getFirst() );
+ }
+
+ /** verify that it's added last. */
+ public void testMakeLast_wasAlone()
+ {
+ // SETUP
+ DoubleLinkedList list = new DoubleLinkedList();
+
+ String payload1 = "payload1";
+ DoubleLinkedListNode node1 = new DoubleLinkedListNode( payload1 );
+
+ list.addFirst( node1 );
+
+ // DO WORK
+ list.makeLast( node1 );
+
+ // VERIFY
+ assertEquals( "Wrong size", 1, list.size() );
+ assertEquals( "Wrong last", node1, list.getLast() );
+ assertEquals( "Wrong first", node1, list.getFirst() );
+ }
+
+ /** verify that it's added last. */
+ public void testMakeLast_wasInMiddle()
+ {
+ // SETUP
+ DoubleLinkedList list = new DoubleLinkedList();
+
+ String payload1 = "payload1";
+ DoubleLinkedListNode node1 = new DoubleLinkedListNode( payload1 );
+
+ String payload2 = "payload2";
+ DoubleLinkedListNode node2 = new DoubleLinkedListNode( payload2 );
+
+ String payload3 = "payload3";
+ DoubleLinkedListNode node3 = new DoubleLinkedListNode( payload3 );
+
+ list.addFirst( node2 );
+ list.addFirst( node1 );
+ list.addFirst( node3 );
+
+ // DO WORK
+ list.makeLast( node1 );
+
+ // VERIFY
+ assertEquals( "Wrong size", 3, list.size() );
+ assertEquals( "Wrong last", node1, list.getLast() );
+ assertEquals( "Wrong first", node3, list.getFirst() );
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: jcs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jcs-dev-help@jakarta.apache.org