commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t.@apache.org
Subject svn commit: r1344374 [14/14] - in /commons/proper/jcs/trunk: ./ auxiliary-builds/javagroups/src/java/org/apache/jcs/auxiliary/javagroups/ auxiliary-builds/jdk14/src/java/org/apache/jcs/auxiliary/javagroups/ auxiliary-builds/jdk14/src/java/org/apache/jc...
Date Wed, 30 May 2012 18:14:51 GMT
Modified: commons/proper/jcs/trunk/src/test/org/apache/jcs/engine/memory/shrinking/ShrinkerThreadUnitTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/test/org/apache/jcs/engine/memory/shrinking/ShrinkerThreadUnitTest.java?rev=1344374&r1=1344373&r2=1344374&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/test/org/apache/jcs/engine/memory/shrinking/ShrinkerThreadUnitTest.java
(original)
+++ commons/proper/jcs/trunk/src/test/org/apache/jcs/engine/memory/shrinking/ShrinkerThreadUnitTest.java
Wed May 30 18:14:43 2012
@@ -38,144 +38,144 @@ import org.apache.jcs.engine.memory.Mock
 public class ShrinkerThreadUnitTest
     extends TestCase
 {
-    /** verify the check for removal  
+    /** verify the check for removal
      * <p>
      * @throws IOException */
     public void testCheckForRemoval_Expired() throws IOException
     {
         // SETUP
-        MockMemoryCache memory = new MockMemoryCache();
+        MockMemoryCache<String, String> memory = new MockMemoryCache<String, String>();
         CompositeCacheAttributes cacheAttr = new CompositeCacheAttributes();
         cacheAttr.setMaxMemoryIdleTimeSeconds( 10 );
         cacheAttr.setMaxSpoolPerRun( 10 );
         memory.setCacheAttributes( cacheAttr );
-        
-        ShrinkerThread shrinker = new ShrinkerThread( memory );
-        
+
+        ShrinkerThread<String, String> shrinker = new ShrinkerThread<String, String>(
memory );
+
         String key = "key";
         String value = "value";
 
-        ICacheElement element = new CacheElement( "testRegion", key, value );
+        ICacheElement<String, String> element = new CacheElement<String, String>(
"testRegion", key, value );
         ElementAttributes elementAttr = new ElementAttributes();
         elementAttr.setIsEternal( false );
         element.setElementAttributes( elementAttr );
         element.getElementAttributes().setMaxLifeSeconds( 1 );
-        
+
         long now = System.currentTimeMillis();
         // add two seconds
         now += 2000;
-        
+
         // DO WORK
         boolean result = shrinker.checkForRemoval( element, now );
-        
+
         // VERIFY
         assertTrue( "Item should have expired.", result );
     }
-    
-    /** verify the check for removal  
+
+    /** verify the check for removal
      * <p>
      * @throws IOException */
     public void testCheckForRemoval_NotExpired() throws IOException
     {
         // SETUP
-        MockMemoryCache memory = new MockMemoryCache();
+        MockMemoryCache<String, String> memory = new MockMemoryCache<String, String>();
         CompositeCacheAttributes cacheAttr = new CompositeCacheAttributes();
         cacheAttr.setMaxMemoryIdleTimeSeconds( 10 );
         cacheAttr.setMaxSpoolPerRun( 10 );
         memory.setCacheAttributes( cacheAttr );
-        
-        ShrinkerThread shrinker = new ShrinkerThread( memory );
-        
+
+        ShrinkerThread<String, String> shrinker = new ShrinkerThread<String, String>(
memory );
+
         String key = "key";
         String value = "value";
 
-        ICacheElement element = new CacheElement( "testRegion", key, value );
+        ICacheElement<String, String> element = new CacheElement<String, String>(
"testRegion", key, value );
         ElementAttributes elementAttr = new ElementAttributes();
         elementAttr.setIsEternal( false );
         element.setElementAttributes( elementAttr );
         element.getElementAttributes().setMaxLifeSeconds( 1 );
-        
+
         long now = System.currentTimeMillis();
         // subtract two seconds
         now -= 2000;
-        
+
         // DO WORK
         boolean result = shrinker.checkForRemoval( element, now );
-        
+
         // VERIFY
         assertFalse( "Item should not have expired.", result );
     }
-    
-    /** verify the check for removal  
+
+    /** verify the check for removal
      * <p>
      * @throws IOException */
     public void testCheckForRemoval_IdleTooLong() throws IOException
     {
         // SETUP
-        MockMemoryCache memory = new MockMemoryCache();
+        MockMemoryCache<String, String> memory = new MockMemoryCache<String, String>();
         CompositeCacheAttributes cacheAttr = new CompositeCacheAttributes();
         cacheAttr.setMaxMemoryIdleTimeSeconds( 10 );
         cacheAttr.setMaxSpoolPerRun( 10 );
         memory.setCacheAttributes( cacheAttr );
-        
-        ShrinkerThread shrinker = new ShrinkerThread( memory );
-        
+
+        ShrinkerThread<String, String> shrinker = new ShrinkerThread<String, String>(
memory );
+
         String key = "key";
         String value = "value";
 
-        ICacheElement element = new CacheElement( "testRegion", key, value );
+        ICacheElement<String, String> element = new CacheElement<String, String>(
"testRegion", key, value );
         ElementAttributes elementAttr = new ElementAttributes();
         elementAttr.setIsEternal( false );
         element.setElementAttributes( elementAttr );
         element.getElementAttributes().setMaxLifeSeconds( 100 );
         element.getElementAttributes().setIdleTime( 1 );
-        
+
         long now = System.currentTimeMillis();
         // add two seconds
         now += 2000;
-        
+
         // DO WORK
         boolean result = shrinker.checkForRemoval( element, now );
-        
+
         // VERIFY
         assertTrue( "Item should have expired.", result );
     }
-    
-    /** verify the check for removal  
+
+    /** verify the check for removal
      * <p>
      * @throws IOException */
     public void testCheckForRemoval_NotIdleTooLong() throws IOException
     {
         // SETUP
-        MockMemoryCache memory = new MockMemoryCache();
+        MockMemoryCache<String, String> memory = new MockMemoryCache<String, String>();
         CompositeCacheAttributes cacheAttr = new CompositeCacheAttributes();
         cacheAttr.setMaxMemoryIdleTimeSeconds( 10 );
         cacheAttr.setMaxSpoolPerRun( 10 );
         memory.setCacheAttributes( cacheAttr );
-        
-        ShrinkerThread shrinker = new ShrinkerThread( memory );
-        
+
+        ShrinkerThread<String, String> shrinker = new ShrinkerThread<String, String>(
memory );
+
         String key = "key";
         String value = "value";
 
-        ICacheElement element = new CacheElement( "testRegion", key, value );
+        ICacheElement<String, String> element = new CacheElement<String, String>(
"testRegion", key, value );
         ElementAttributes elementAttr = new ElementAttributes();
         elementAttr.setIsEternal( false );
         element.setElementAttributes( elementAttr );
         element.getElementAttributes().setMaxLifeSeconds( 100 );
         element.getElementAttributes().setIdleTime( 1 );
-        
+
         long now = System.currentTimeMillis();
         // subtract two seconds
         now -= 2000;
-        
+
         // DO WORK
         boolean result = shrinker.checkForRemoval( element, now );
-        
+
         // VERIFY
         assertFalse( "Item should not have expired.", result );
     }
-    
+
     /**
      * Setup cache attributes in mock. Create the shrinker with the mock. Add some elements
into the
      * mock memory cache see that they get spooled.
@@ -186,7 +186,7 @@ public class ShrinkerThreadUnitTest
         throws Exception
     {
         // SETUP
-        MockMemoryCache memory = new MockMemoryCache();
+        MockMemoryCache<String, String> memory = new MockMemoryCache<String, String>();
 
         CompositeCacheAttributes cacheAttr = new CompositeCacheAttributes();
         cacheAttr.setMaxMemoryIdleTimeSeconds( 1 );
@@ -197,7 +197,7 @@ public class ShrinkerThreadUnitTest
         String key = "key";
         String value = "value";
 
-        ICacheElement element = new CacheElement( "testRegion", key, value );
+        ICacheElement<String, String> element = new CacheElement<String, String>(
"testRegion", key, value );
 
         ElementAttributes elementAttr = new ElementAttributes();
         elementAttr.setIsEternal( false );
@@ -205,21 +205,21 @@ public class ShrinkerThreadUnitTest
         element.getElementAttributes().setMaxLifeSeconds( 1 );
         memory.update( element );
 
-        ICacheElement returnedElement1 = memory.get( key );
+        ICacheElement<String, String> returnedElement1 = memory.get( key );
         assertNotNull( "We should have received an element", returnedElement1 );
 
         // set this to 2 seconds ago.
         elementAttr.lastAccessTime = System.currentTimeMillis() - 2000;
 
         // DO WORK
-        ShrinkerThread shrinker = new ShrinkerThread( memory );
+        ShrinkerThread<String, String> shrinker = new ShrinkerThread<String, String>(
memory );
         Thread runner = new Thread( shrinker );
         runner.run();
 
         Thread.sleep( 500 );
 
         // VERIFY
-        ICacheElement returnedElement2 = memory.get( key );
+        ICacheElement<String, String> returnedElement2 = memory.get( key );
         assertTrue( "Waterfall should have been called.", memory.waterfallCallCount >
0 );
         assertNull( "We not should have received an element.  It should have been spooled.",
returnedElement2 );
     }
@@ -229,11 +229,11 @@ public class ShrinkerThreadUnitTest
      * <p>
      * @throws Exception
      */
-    public void testSimpleShrinkMutiple()
+    public void testSimpleShrinkMultiple()
         throws Exception
     {
         // SETUP
-        MockMemoryCache memory = new MockMemoryCache();
+        MockMemoryCache<String, String> memory = new MockMemoryCache<String, String>();
 
         CompositeCacheAttributes cacheAttr = new CompositeCacheAttributes();
         cacheAttr.setMaxMemoryIdleTimeSeconds( 1 );
@@ -246,7 +246,7 @@ public class ShrinkerThreadUnitTest
             String key = "key" + i;
             String value = "value";
 
-            ICacheElement element = new CacheElement( "testRegion", key, value );
+            ICacheElement<String, String> element = new CacheElement<String, String>(
"testRegion", key, value );
 
             ElementAttributes elementAttr = new ElementAttributes();
             elementAttr.setIsEternal( false );
@@ -254,7 +254,7 @@ public class ShrinkerThreadUnitTest
             element.getElementAttributes().setMaxLifeSeconds( 1 );
             memory.update( element );
 
-            ICacheElement returnedElement1 = memory.get( key );
+            ICacheElement<String, String> returnedElement1 = memory.get( key );
             assertNotNull( "We should have received an element", returnedElement1 );
 
             // set this to 2 seconds ago.
@@ -262,7 +262,7 @@ public class ShrinkerThreadUnitTest
         }
 
         // DO WORK
-        ShrinkerThread shrinker = new ShrinkerThread( memory );
+        ShrinkerThread<String, String> shrinker = new ShrinkerThread<String, String>(
memory );
         Thread runner = new Thread( shrinker );
         runner.run();
 
@@ -279,11 +279,11 @@ public class ShrinkerThreadUnitTest
      * <p>
      * @throws Exception
      */
-    public void testSimpleShrinkMutipleWithEventHandler()
+    public void testSimpleShrinkMultipleWithEventHandler()
         throws Exception
     {
         // SETUP
-        MockMemoryCache memory = new MockMemoryCache();
+        MockMemoryCache<String, String> memory = new MockMemoryCache<String, String>();
 
         CompositeCacheAttributes cacheAttr = new CompositeCacheAttributes();
         cacheAttr.setMaxMemoryIdleTimeSeconds( 1 );
@@ -298,7 +298,7 @@ public class ShrinkerThreadUnitTest
             String key = "key" + i;
             String value = "value";
 
-            ICacheElement element = new CacheElement( "testRegion", key, value );
+            ICacheElement<String, String> element = new CacheElement<String, String>(
"testRegion", key, value );
 
             ElementAttributes elementAttr = new ElementAttributes();
             elementAttr.addElementEventHandler( handler );
@@ -307,7 +307,7 @@ public class ShrinkerThreadUnitTest
             element.getElementAttributes().setMaxLifeSeconds( 1 );
             memory.update( element );
 
-            ICacheElement returnedElement1 = memory.get( key );
+            ICacheElement<String, String> returnedElement1 = memory.get( key );
             assertNotNull( "We should have received an element", returnedElement1 );
 
             // set this to 2 seconds ago.
@@ -315,7 +315,7 @@ public class ShrinkerThreadUnitTest
         }
 
         // DO WORK
-        ShrinkerThread shrinker = new ShrinkerThread( memory );
+        ShrinkerThread<String, String> shrinker = new ShrinkerThread<String, String>(
memory );
         Thread runner = new Thread( shrinker );
         runner.run();
 

Modified: commons/proper/jcs/trunk/src/test/org/apache/jcs/utils/access/JCSWorkerUnitTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/test/org/apache/jcs/utils/access/JCSWorkerUnitTest.java?rev=1344374&r1=1344373&r2=1344374&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/test/org/apache/jcs/utils/access/JCSWorkerUnitTest.java (original)
+++ commons/proper/jcs/trunk/src/test/org/apache/jcs/utils/access/JCSWorkerUnitTest.java Wed
May 30 18:14:43 2012
@@ -42,7 +42,7 @@ public class JCSWorkerUnitTest
     public void testSimpleGet()
         throws Exception
     {
-        JCSWorker cachingWorker = new JCSWorker( "example region" );
+        JCSWorker<String, Long> cachingWorker = new JCSWorker<String, Long>(
"example region" );
 
         // This is the helper.
         JCSWorkerHelper helper = new AbstractJCSWorkerHelper()
@@ -58,11 +58,11 @@ public class JCSWorkerUnitTest
 
         String key = "abc";
 
-        Long result = (Long) cachingWorker.getResult( key, helper );
+        Long result = cachingWorker.getResult( key, helper );
         assertEquals( "Called the wrong number of times", Long.valueOf( 1 ), result );
 
-        // should get it fromthe cache.
-        Long result2 = (Long) cachingWorker.getResult( key, helper );
+        // should get it from the cache.
+        Long result2 = cachingWorker.getResult( key, helper );
         assertEquals( "Called the wrong number of times", Long.valueOf( 1 ), result2 );
 
     }

Modified: commons/proper/jcs/trunk/src/test/org/apache/jcs/utils/discovery/UDPDiscoverySenderUnitTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/test/org/apache/jcs/utils/discovery/UDPDiscoverySenderUnitTest.java?rev=1344374&r1=1344373&r2=1344374&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/test/org/apache/jcs/utils/discovery/UDPDiscoverySenderUnitTest.java
(original)
+++ commons/proper/jcs/trunk/src/test/org/apache/jcs/utils/discovery/UDPDiscoverySenderUnitTest.java
Wed May 30 18:14:43 2012
@@ -95,7 +95,8 @@ public class UDPDiscoverySenderUnitTest
         assertTrue( "unexpected crap received", obj instanceof UDPDiscoveryMessage );
 
         UDPDiscoveryMessage msg = (UDPDiscoveryMessage) obj;
-        assertEquals( "wrong host", SENDING_HOST, msg.getHost() );
+        // disabled test because of JCS-89
+        // assertEquals( "wrong host", SENDING_HOST, msg.getHost() );
         assertEquals( "wrong port", SENDING_PORT, msg.getPort() );
         assertEquals( "wrong message type", UDPDiscoveryMessage.PASSIVE_BROADCAST, msg.getMessageType()
);
     }
@@ -121,7 +122,8 @@ public class UDPDiscoverySenderUnitTest
         assertTrue( "unexpected crap received", obj instanceof UDPDiscoveryMessage );
 
         UDPDiscoveryMessage msg = (UDPDiscoveryMessage) obj;
-        assertEquals( "wrong host", SENDING_HOST, msg.getHost() );
+        // disabled test because of JCS-89
+        // assertEquals( "wrong host", SENDING_HOST, msg.getHost() );
         assertEquals( "wrong port", SENDING_PORT, msg.getPort() );
         assertEquals( "wrong message type", UDPDiscoveryMessage.REMOVE_BROADCAST, msg.getMessageType()
);
     }

Propchange: commons/proper/jcs/trunk/src/test/org/apache/jcs/utils/discovery/UDPDiscoveryUnitTest.java
            ('svn:mergeinfo' removed)

Modified: commons/proper/jcs/trunk/src/test/org/apache/jcs/utils/serialization/SerializationConversionUtilUnitTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/test/org/apache/jcs/utils/serialization/SerializationConversionUtilUnitTest.java?rev=1344374&r1=1344373&r2=1344374&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/test/org/apache/jcs/utils/serialization/SerializationConversionUtilUnitTest.java
(original)
+++ commons/proper/jcs/trunk/src/test/org/apache/jcs/utils/serialization/SerializationConversionUtilUnitTest.java
Wed May 30 18:14:43 2012
@@ -48,11 +48,11 @@ public class SerializationConversionUtil
     {
         // SETUP
         IElementSerializer elementSerializer = new StandardSerializer();
-        ICacheElement before = null;
+        ICacheElement<String, String> before = null;
 
         // DO WORK
-        ICacheElementSerialized result = SerializationConversionUtil.getSerializedCacheElement(
before,
-                                                                                        
       elementSerializer );
+        ICacheElementSerialized<String, String> result =
+            SerializationConversionUtil.getSerializedCacheElement( before, elementSerializer
);
 
         // VERIFY
         assertNull( "Should get null for null", result );
@@ -68,10 +68,11 @@ public class SerializationConversionUtil
     {
         // SETUP
         IElementSerializer elementSerializer = new StandardSerializer();
-        ICacheElementSerialized before = null;
+        ICacheElementSerialized<String, String> before = null;
 
         // DO WORK
-        ICacheElement result = SerializationConversionUtil.getDeSerializedCacheElement( before,
elementSerializer );
+        ICacheElement<String, String> result =
+            SerializationConversionUtil.getDeSerializedCacheElement( before, elementSerializer
);
 
         // VERIFY
         assertNull( "Should get null for null", result );
@@ -95,19 +96,20 @@ public class SerializationConversionUtil
         IElementAttributes attr = new ElementAttributes();
         attr.setMaxLifeSeconds( 34 );
 
-        ICacheElement before = new CacheElement( cacheName, key, value );
+        ICacheElement<String, String> before = new CacheElement<String, String>(
cacheName, key, value );
         before.setElementAttributes( attr );
 
         // DO WORK
-        ICacheElementSerialized serialized = SerializationConversionUtil.getSerializedCacheElement(
before,
-                                                                                        
           elementSerializer );
+        ICacheElementSerialized<String, String> serialized =
+            SerializationConversionUtil.getSerializedCacheElement( before, elementSerializer
);
 
         // VERIFY
         assertNotNull( "Should have a serialized object.", serialized );
         System.out.println( "testSimpleConversion, " + serialized );
 
         // DO WORK
-        ICacheElement after = SerializationConversionUtil.getDeSerializedCacheElement( serialized,
elementSerializer );
+        ICacheElement<String, String> after =
+            SerializationConversionUtil.getDeSerializedCacheElement( serialized, elementSerializer
);
 
         // VERIFY
         assertNotNull( "Should have a deserialized object.", after );
@@ -136,21 +138,22 @@ public class SerializationConversionUtil
         IElementAttributes attr = new ElementAttributes();
         attr.setMaxLifeSeconds( 34 );
 
-        ICacheElement before = new CacheElement( cacheName, key, value );
+        ICacheElement<String, String> before = new CacheElement<String, String>(
cacheName, key, value );
         before.setElementAttributes( attr );
 
         // DO WORK
-        ICacheElementSerialized alreadySerialized = SerializationConversionUtil
-            .getSerializedCacheElement( before, elementSerializer );
-        ICacheElementSerialized serialized = SerializationConversionUtil.getSerializedCacheElement(
alreadySerialized,
-                                                                                        
           elementSerializer );
+        ICacheElementSerialized<String, String> alreadySerialized =
+            SerializationConversionUtil.getSerializedCacheElement( before, elementSerializer
);
+        ICacheElementSerialized<String, String> serialized =
+            SerializationConversionUtil.getSerializedCacheElement( alreadySerialized, elementSerializer
);
 
         // VERIFY
         assertNotNull( "Should have a serialized object.", serialized );
         System.out.println( "testSimpleConversion, " + serialized );
 
         // DO WORK
-        ICacheElement after = SerializationConversionUtil.getDeSerializedCacheElement( serialized,
elementSerializer );
+        ICacheElement<String, String> after =
+            SerializationConversionUtil.getDeSerializedCacheElement( serialized, elementSerializer
);
 
         // VERIFY
         assertNotNull( "Should have a deserialized object.", after );
@@ -176,7 +179,7 @@ public class SerializationConversionUtil
         IElementAttributes attr = new ElementAttributes();
         attr.setMaxLifeSeconds( 34 );
 
-        ICacheElement before = new CacheElement( cacheName, key, value );
+        ICacheElement<String, String> before = new CacheElement<String, String>(
cacheName, key, value );
         before.setElementAttributes( attr );
 
         // DO WORK

Modified: commons/proper/jcs/trunk/src/test/org/apache/jcs/utils/struct/JCSvsCommonsLRUMapPerformanceTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/test/org/apache/jcs/utils/struct/JCSvsCommonsLRUMapPerformanceTest.java?rev=1344374&r1=1344373&r2=1344374&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/test/org/apache/jcs/utils/struct/JCSvsCommonsLRUMapPerformanceTest.java
(original)
+++ commons/proper/jcs/trunk/src/test/org/apache/jcs/utils/struct/JCSvsCommonsLRUMapPerformanceTest.java
Wed May 30 18:14:43 2012
@@ -113,7 +113,7 @@ public class JCSvsCommonsLRUMapPerforman
         try
         {
 
-            Map cache = new LRUMap( tries );
+            Map<String, String> cache = new LRUMap<String, String>( tries );
 
             for ( int j = 0; j < loops; j++ )
             {
@@ -144,7 +144,7 @@ public class JCSvsCommonsLRUMapPerforman
                 // /////////////////////////////////////////////////////////////
                 cache2Name = "Commons  ";
                 // or LRUMapJCS
-                Map cache2 = new org.apache.commons.collections.map.LRUMap( tries );
+                Map<String, String> cache2 = new org.apache.commons.collections.map.LRUMap(
tries );
                 // cache2Name = "Hashtable";
                 // Hashtable cache2 = new Hashtable();
                 start = System.currentTimeMillis();

Modified: commons/proper/jcs/trunk/src/test/org/apache/jcs/utils/struct/LRUMapConcurrentTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/test/org/apache/jcs/utils/struct/LRUMapConcurrentTest.java?rev=1344374&r1=1344373&r2=1344374&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/test/org/apache/jcs/utils/struct/LRUMapConcurrentTest.java
(original)
+++ commons/proper/jcs/trunk/src/test/org/apache/jcs/utils/struct/LRUMapConcurrentTest.java
Wed May 30 18:14:43 2012
@@ -63,7 +63,7 @@ public class LRUMapConcurrentTest
         TestSuite suite = new TestSuite( LRUMapConcurrentTest.class );
 
         // run concurrent tests
-        final LRUMap map = new LRUMap( 2000 );
+        final LRUMap<String, String> map = new LRUMap<String, String>( 2000 );
         suite.addTest( new LRUMapConcurrentTest( "conc1" )
         {
             @Override
@@ -94,7 +94,7 @@ public class LRUMapConcurrentTest
 
         // run more concurrent tests
         final int max2 = 20000;
-        final LRUMap map2 = new LRUMap( max2 );
+        final LRUMap<String, String> map2 = new LRUMap<String, String>( max2
);
         suite.addTest( new LRUMapConcurrentTest( "concB1" )
         {
             @Override
@@ -124,7 +124,7 @@ public class LRUMapConcurrentTest
     public void testSimpleLoad()
         throws Exception
     {
-        LRUMap map = new LRUMap( items );
+        LRUMap<String, String> map = new LRUMap<String, String>( items );
 
         for ( int i = 0; i < items; i++ )
         {
@@ -133,7 +133,7 @@ public class LRUMapConcurrentTest
 
         for ( int i = items - 1; i >= 0; i-- )
         {
-            String res = (String) map.get( i + ":key" );
+            String res = map.get( i + ":key" );
             assertNotNull( "[" + i + ":key] should not be null", res );
         }
 
@@ -151,7 +151,7 @@ public class LRUMapConcurrentTest
         throws Exception
     {
         int total = 10;
-        LRUMap map = new LRUMap( total );
+        LRUMap<String, String> map = new LRUMap<String, String>( total );
         map.setChunkSize( 1 );
 
         // put the max in
@@ -160,7 +160,7 @@ public class LRUMapConcurrentTest
             map.put( i + ":key", "data" + i );
         }
 
-        Iterator it = map.entrySet().iterator();
+        Iterator<?> it = map.entrySet().iterator();
         while ( it.hasNext() )
         {
             System.out.println( it.next() );
@@ -170,7 +170,7 @@ public class LRUMapConcurrentTest
         // get the max out backwards
         for ( int i = total - 1; i >= 0; i-- )
         {
-            String res = (String) map.get( i + ":key" );
+            String res = map.get( i + ":key" );
             assertNotNull( "[" + i + ":key] should not be null", res );
         }
 
@@ -190,7 +190,7 @@ public class LRUMapConcurrentTest
         throws Exception
     {
         int total = 10000;
-        LRUMap map = new LRUMap( total );
+        LRUMap<String, String> map = new LRUMap<String, String>( total );
         map.setChunkSize( 1 );
 
         // put the max in
@@ -199,7 +199,7 @@ public class LRUMapConcurrentTest
             map.put( i + ":key", "data" + i );
         }
 
-        // get the total number, these shoukld be null
+        // get the total number, these should be null
         for ( int i = total - 1; i >= 0; i-- )
         {
             assertNull( map.get( i + ":key" ) );
@@ -209,7 +209,7 @@ public class LRUMapConcurrentTest
         // get the total to total *2 items out, these should be foufn.
         for ( int i = ( total * 2 ) - 1; i >= total; i-- )
         {
-            String res = (String) map.get( i + ":key" );
+            String res = map.get( i + ":key" );
             assertNotNull( "[" + i + ":key] should not be null", res );
         }
 
@@ -223,7 +223,7 @@ public class LRUMapConcurrentTest
      * @param items
      * @throws Exception
      */
-    public void runConcurrentPutGetTests( LRUMap map, int items )
+    public void runConcurrentPutGetTests( LRUMap<String, String> map, int items )
         throws Exception
     {
         for ( int i = 0; i < items; i++ )
@@ -233,7 +233,7 @@ public class LRUMapConcurrentTest
 
         for ( int i = items - 1; i >= 0; i-- )
         {
-            String res = (String) map.get( i + ":key" );
+            String res = map.get( i + ":key" );
             assertNotNull( "[" + i + ":key] should not be null", res );
         }
     }
@@ -246,7 +246,7 @@ public class LRUMapConcurrentTest
      * @param end
      * @throws Exception
      */
-    public void runConcurrentRangeTests( LRUMap map, int start, int end )
+    public void runConcurrentRangeTests( LRUMap<String, String> map, int start, int
end )
         throws Exception
     {
         for ( int i = start; i < end; i++ )
@@ -256,7 +256,7 @@ public class LRUMapConcurrentTest
 
         for ( int i = end - 1; i >= start; i-- )
         {
-            String res = (String) map.get( i + ":key" );
+            String res = map.get( i + ":key" );
             assertNotNull( "[" + i + ":key] should not be null", res );
         }
 

Modified: commons/proper/jcs/trunk/src/test/org/apache/jcs/utils/struct/LRUMapConcurrentUnitTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/test/org/apache/jcs/utils/struct/LRUMapConcurrentUnitTest.java?rev=1344374&r1=1344373&r2=1344374&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/test/org/apache/jcs/utils/struct/LRUMapConcurrentUnitTest.java
(original)
+++ commons/proper/jcs/trunk/src/test/org/apache/jcs/utils/struct/LRUMapConcurrentUnitTest.java
Wed May 30 18:14:43 2012
@@ -57,7 +57,7 @@ public class LRUMapConcurrentUnitTest
         TestSuite suite = new TestSuite( LRUMapConcurrentUnitTest.class );
 
         // run concurrent tests
-        final LRUMap map = new LRUMap( 2000 );
+        final LRUMap<String, String> map = new LRUMap<String, String>( 2000 );
         suite.addTest( new LRUMapConcurrentUnitTest( "conc1" )
         {
             @Override
@@ -88,7 +88,7 @@ public class LRUMapConcurrentUnitTest
 
         // run more concurrent tests
         final int max2 = 20000;
-        final LRUMap map2 = new LRUMap( max2 );
+        final LRUMap<String, String> map2 = new LRUMap<String, String>( max2
);
         suite.addTest( new LRUMapConcurrentUnitTest( "concB1" )
         {
             @Override
@@ -120,7 +120,7 @@ public class LRUMapConcurrentUnitTest
     public void testSimpleLoad()
         throws Exception
     {
-        LRUMap map = new LRUMap( items );
+        LRUMap<String, String> map = new LRUMap<String, String>( items );
 
         for ( int i = 0; i < items; i++ )
         {
@@ -129,7 +129,7 @@ public class LRUMapConcurrentUnitTest
 
         for ( int i = items - 1; i >= 0; i-- )
         {
-            String res = (String) map.get( i + ":key" );
+            String res = map.get( i + ":key" );
             assertNotNull( "[" + i + ":key] should not be null", res );
         }
 
@@ -140,7 +140,7 @@ public class LRUMapConcurrentUnitTest
     }
 
     /**
-     * Just make sure that the LRU functions int he most simple case.
+     * Just make sure that the LRU functions in he most simple case.
      *
      * @exception Exception
      *                Description of the Exception
@@ -149,7 +149,7 @@ public class LRUMapConcurrentUnitTest
         throws Exception
     {
         int total = 10;
-        LRUMap map = new LRUMap( total );
+        LRUMap<String, String> map = new LRUMap<String, String>( total );
         map.setChunkSize( 1 );
 
         // put the max in
@@ -158,7 +158,7 @@ public class LRUMapConcurrentUnitTest
             map.put( i + ":key", "data" + i );
         }
 
-        Iterator it = map.entrySet().iterator();
+        Iterator<?> it = map.entrySet().iterator();
         while ( it.hasNext() )
         {
             System.out.println( it.next() );
@@ -168,7 +168,7 @@ public class LRUMapConcurrentUnitTest
         // get the max out backwards
         for ( int i = total - 1; i >= 0; i-- )
         {
-            String res = (String) map.get( i + ":key" );
+            String res = map.get( i + ":key" );
             assertNotNull( "[" + i + ":key] should not be null", res );
         }
 
@@ -188,7 +188,7 @@ public class LRUMapConcurrentUnitTest
         throws Exception
     {
         int total = 10000;
-        LRUMap map = new LRUMap( total );
+        LRUMap<String, String> map = new LRUMap<String, String>( total );
         map.setChunkSize( 1 );
 
         // put the max in
@@ -197,17 +197,17 @@ public class LRUMapConcurrentUnitTest
             map.put( i + ":key", "data" + i );
         }
 
-        // get the total number, these shoukld be null
+        // get the total number, these should be null
         for ( int i = total - 1; i >= 0; i-- )
         {
             assertNull( map.get( i + ":key" ) );
 
         }
 
-        // get the total to total *2 items out, these should be foufn.
+        // get the total to total *2 items out, these should be found.
         for ( int i = ( total * 2 ) - 1; i >= total; i-- )
         {
-            String res = (String) map.get( i + ":key" );
+            String res = map.get( i + ":key" );
             assertNotNull( "[" + i + ":key] should not be null", res );
         }
 
@@ -222,7 +222,7 @@ public class LRUMapConcurrentUnitTest
      * @param items
      * @throws Exception
      */
-    public void runConcurrentPutGetTests( LRUMap map, int items )
+    public void runConcurrentPutGetTests( LRUMap<String, String> map, int items )
         throws Exception
     {
         for ( int i = 0; i < items; i++ )
@@ -232,7 +232,7 @@ public class LRUMapConcurrentUnitTest
 
         for ( int i = items - 1; i >= 0; i-- )
         {
-            String res = (String) map.get( i + ":key" );
+            String res = map.get( i + ":key" );
             assertNotNull( "[" + i + ":key] should not be null", res );
         }
     }
@@ -246,7 +246,7 @@ public class LRUMapConcurrentUnitTest
      * @param end
      * @throws Exception
      */
-    public void runConcurrentRangeTests( LRUMap map, int start, int end )
+    public void runConcurrentRangeTests( LRUMap<String, String> map, int start, int
end )
         throws Exception
     {
         for ( int i = start; i < end; i++ )
@@ -256,7 +256,7 @@ public class LRUMapConcurrentUnitTest
 
         for ( int i = end - 1; i >= start; i-- )
         {
-            String res = (String) map.get( i + ":key" );
+            String res = map.get( i + ":key" );
             assertNotNull( "[" + i + ":key] should not be null", res );
         }
 

Modified: commons/proper/jcs/trunk/src/test/org/apache/jcs/utils/struct/LRUMapPerformanceTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/test/org/apache/jcs/utils/struct/LRUMapPerformanceTest.java?rev=1344374&r1=1344373&r2=1344374&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/test/org/apache/jcs/utils/struct/LRUMapPerformanceTest.java
(original)
+++ commons/proper/jcs/trunk/src/test/org/apache/jcs/utils/struct/LRUMapPerformanceTest.java
Wed May 30 18:14:43 2012
@@ -26,7 +26,6 @@ import junit.framework.TestCase;
 import junit.framework.TestSuite;
 
 import org.apache.jcs.JCSvsHashtablePerformanceTest;
-import org.apache.jcs.utils.struct.LRUMap;
 
 /**
  * This ensures that the jcs version of the LRU map is as fast as the commons
@@ -108,7 +107,7 @@ public class LRUMapPerformanceTest
 
         try
         {
-            Map cache = new LRUMap( tries );
+            Map<String, String> cache = new LRUMap<String, String>( tries );
 
             for ( int j = 0; j < loops; j++ )
             {
@@ -138,7 +137,7 @@ public class LRUMapPerformanceTest
                 ///////////////////////////////////////////////////////////////
                 cache2Name = "LRUMapJCS (commons)";
                 //or LRUMapJCS
-                Map cache2 = new org.apache.commons.collections.map.LRUMap( tries );
+                Map<String, String> cache2 = new org.apache.commons.collections.map.LRUMap(
tries );
                 //cache2Name = "Hashtable";
                 //Hashtable cache2 = new Hashtable();
                 start = System.currentTimeMillis();

Modified: commons/proper/jcs/trunk/src/test/org/apache/jcs/utils/struct/LRUMapUnitTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/test/org/apache/jcs/utils/struct/LRUMapUnitTest.java?rev=1344374&r1=1344373&r2=1344374&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/test/org/apache/jcs/utils/struct/LRUMapUnitTest.java (original)
+++ commons/proper/jcs/trunk/src/test/org/apache/jcs/utils/struct/LRUMapUnitTest.java Wed
May 30 18:14:43 2012
@@ -20,10 +20,8 @@ package org.apache.jcs.utils.struct;
  */
 
 import java.util.Map;
-import java.util.Set;
 import java.util.Map.Entry;
-
-import org.apache.jcs.utils.struct.LRUMap;
+import java.util.Set;
 
 import junit.framework.TestCase;
 
@@ -44,7 +42,7 @@ public class LRUMapUnitTest
     public void testPutWithSizeLimit()
     {
         int size = 10;
-        Map cache = new LRUMap( size );
+        Map<String, String> cache = new LRUMap<String, String>( size );
 
         for ( int i = 0; i < size; i++ )
         {
@@ -53,7 +51,7 @@ public class LRUMapUnitTest
 
         for ( int i = 0; i < size; i++ )
         {
-            String data = (String)cache.get( "key:" + i );
+            String data = cache.get( "key:" + i );
             assertEquals( "Data is wrong.", "data:" + i, data );
         }
     }
@@ -65,7 +63,7 @@ public class LRUMapUnitTest
     public void testPutWithNoSizeLimit()
     {
         int size = 10;
-        Map cache = new LRUMap( );
+        Map<String, String> cache = new LRUMap<String, String>( );
 
         for ( int i = 0; i < size; i++ )
         {
@@ -74,7 +72,7 @@ public class LRUMapUnitTest
 
         for ( int i = 0; i < size; i++ )
         {
-            String data = (String)cache.get( "key:" + i );
+            String data = cache.get( "key:" + i );
             assertEquals( "Data is wrong.", "data:" + i, data );
         }
     }
@@ -86,10 +84,10 @@ public class LRUMapUnitTest
     public void testPutAndRemove()
     {
         int size = 10;
-        Map cache = new LRUMap( size );
+        Map<String, String> cache = new LRUMap<String, String>( size );
 
         cache.put( "key:" + 1, "data:" + 1 );
-        String data = (String)cache.remove( "key:" + 1 );
+        String data = cache.remove( "key:" + 1 );
         assertEquals( "Data is wrong.", "data:" + 1, data );
     }
 
@@ -100,7 +98,7 @@ public class LRUMapUnitTest
     public void testRemoveEmpty()
     {
         int size = 10;
-        Map cache = new LRUMap( size );
+        Map<String, String> cache = new LRUMap<String, String>( size );
 
         Object returned = cache.remove( "key:" + 1 );
         assertNull( "Shouldn't hvae anything.", returned );
@@ -114,21 +112,19 @@ public class LRUMapUnitTest
     public void testGetEntrySet()
     {
         int size = 10;
-        Map cache = new LRUMap( size );
+        Map<String, String> cache = new LRUMap<String, String>( size );
 
         for ( int i = 0; i < size; i++ )
         {
             cache.put( "key:" + i, "data:" + i );
         }
 
-        Set entries = cache.entrySet();
+        Set<Entry<String, String>> entries = cache.entrySet();
         assertEquals( "Set contains the wrong number of items.", size, entries.size() );
 
         // check minimal correctness
-        Object[] entryArray = entries.toArray();
-        for ( int i = 0; i < size; i++ )
+        for (Entry<String, String> data : entries)
         {
-            Entry data = (Entry)entryArray[i];
             assertTrue( "Data is wrong.", data.getValue().toString().indexOf( "data:") !=
-1  );
         }
     }



Mime
View raw message