commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t.@apache.org
Subject svn commit: r1232163 [10/10] - in /commons/proper/jcs/branches/generics-interface/src: java/org/apache/jcs/ java/org/apache/jcs/access/ java/org/apache/jcs/access/behavior/ java/org/apache/jcs/admin/ java/org/apache/jcs/auxiliary/ java/org/apache/jcs/a...
Date Mon, 16 Jan 2012 21:05:50 GMT
Modified: commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/engine/memory/MockMemoryCache.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/engine/memory/MockMemoryCache.java?rev=1232163&r1=1232162&r2=1232163&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/engine/memory/MockMemoryCache.java
(original)
+++ commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/engine/memory/MockMemoryCache.java
Mon Jan 16 21:05:44 2012
@@ -37,14 +37,14 @@ import org.apache.jcs.engine.stats.behav
  * <p>
  * @author Aaron Smuts
  */
-public class MockMemoryCache
-    implements MemoryCache
+public class MockMemoryCache<K extends Serializable, V extends Serializable>
+    implements MemoryCache<K, V>
 {
     /** Config */
     private ICompositeCacheAttributes cacheAttr;
 
     /** Internal map */
-    private final HashMap<Serializable, ICacheElement> map = new HashMap<Serializable,
ICacheElement>();
+    private final HashMap<K, ICacheElement<K, V>> map = new HashMap<K, ICacheElement<K,
V>>();
 
     /** The number of times waterfall was called. */
     public int waterfallCallCount = 0;
@@ -56,7 +56,7 @@ public class MockMemoryCache
      * Does nothing
      * @param cache
      */
-    public void initialize( CompositeCache cache )
+    public void initialize( CompositeCache<K, V> cache )
     {
         // nothing
     }
@@ -85,16 +85,16 @@ public class MockMemoryCache
     }
 
     /** @return null */
-    public Iterator<Map.Entry<Serializable, MemoryElementDescriptor>> getIterator()
+    public Iterator<Map.Entry<K, MemoryElementDescriptor<K, V>>> getIterator()
     {
         return null;
     }
 
     /**
      * @return map.keySet().toArray( */
-    public Object[] getKeyArray()
+    public K[] getKeyArray()
     {
-        return map.keySet().toArray();
+        return (K[]) map.keySet().toArray();
     }
 
     /**
@@ -102,7 +102,7 @@ public class MockMemoryCache
      * @return map.remove( key ) != null
      * @throws IOException
      */
-    public boolean remove( Serializable key )
+    public boolean remove( K key )
         throws IOException
     {
         return map.remove( key ) != null;
@@ -122,7 +122,7 @@ public class MockMemoryCache
      * @return (ICacheElement) map.get( key )
      * @throws IOException
      */
-    public ICacheElement get( Serializable key )
+    public ICacheElement<K, V> get( K key )
         throws IOException
     {
         return map.get( key );
@@ -133,20 +133,20 @@ public class MockMemoryCache
      * @return elements
      * @throws IOException
      */
-    public Map<Serializable, ICacheElement> getMultiple(Set<Serializable> keys)
+    public Map<K, ICacheElement<K, V>> getMultiple(Set<K> keys)
         throws IOException
     {
-        Map<Serializable, ICacheElement> elements = new HashMap<Serializable, ICacheElement>();
+        Map<K, ICacheElement<K, V>> elements = new HashMap<K, ICacheElement<K,
V>>();
 
         if ( keys != null && !keys.isEmpty() )
         {
-            Iterator<Serializable> iterator = keys.iterator();
+            Iterator<K> iterator = keys.iterator();
 
             while ( iterator.hasNext() )
             {
-                Serializable key = iterator.next();
+                K key = iterator.next();
 
-                ICacheElement element = get( key );
+                ICacheElement<K, V> element = get( key );
 
                 if ( element != null )
                 {
@@ -163,7 +163,7 @@ public class MockMemoryCache
      * @return (ICacheElement) map.get( key )
      * @throws IOException
      */
-    public ICacheElement getQuiet( Serializable key )
+    public ICacheElement<K, V> getQuiet( K key )
         throws IOException
     {
         return map.get( key );
@@ -173,7 +173,7 @@ public class MockMemoryCache
      * @param ce
      * @throws IOException
      */
-    public void waterfal( ICacheElement ce )
+    public void waterfal( ICacheElement<K, V> ce )
         throws IOException
     {
         waterfallCallCount++;
@@ -183,7 +183,7 @@ public class MockMemoryCache
      * @param ce
      * @throws IOException
      */
-    public void update( ICacheElement ce )
+    public void update( ICacheElement<K, V> ce )
         throws IOException
     {
         if ( ce != null )
@@ -209,7 +209,7 @@ public class MockMemoryCache
     }
 
     /** @return null */
-    public CompositeCache getCompositeCache()
+    public CompositeCache<K, V> getCompositeCache()
     {
         return null;
     }
@@ -218,7 +218,7 @@ public class MockMemoryCache
      * @param group
      * @return null
      */
-    public Set<Serializable> getGroupKeys( String group )
+    public Set<K> getGroupKeys( String group )
     {
         return null;
     }

Modified: commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/engine/memory/lru/LHMLRUMemoryCacheConcurrentUnitTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/engine/memory/lru/LHMLRUMemoryCacheConcurrentUnitTest.java?rev=1232163&r1=1232162&r2=1232163&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/engine/memory/lru/LHMLRUMemoryCacheConcurrentUnitTest.java
(original)
+++ commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/engine/memory/lru/LHMLRUMemoryCacheConcurrentUnitTest.java
Mon Jan 16 21:05:44 2012
@@ -119,7 +119,7 @@ public class LHMLRUMemoryCacheConcurrent
 
         for ( int i = 0; i < items; i++ )
         {
-            ICacheElement ice = new CacheElement( cache.getCacheName(), i + ":key", region
+ " data " + i );
+            ICacheElement<String, String> ice = new CacheElement( cache.getCacheName(),
i + ":key", region + " data " + i );
             ice.setElementAttributes( cache.getElementAttributes() );
             lru.update( ice );
         }
@@ -151,7 +151,7 @@ public class LHMLRUMemoryCacheConcurrent
         }
         for ( int i = 100; i < items; i++ )
         {
-            ICacheElement element = (ICacheElement) elements.get( i + ":key" );
+            ICacheElement<String, String> element = (ICacheElement) elements.get( i
+ ":key" );
             assertNotNull( "element " + i + ":key is missing", element );
             assertEquals( "value " + i + ":key", region + " data " + i, element.getVal()
);
         }

Modified: commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/engine/memory/lru/LHMLRUMemoryCacheUnitTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/engine/memory/lru/LHMLRUMemoryCacheUnitTest.java?rev=1232163&r1=1232162&r2=1232163&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/engine/memory/lru/LHMLRUMemoryCacheUnitTest.java
(original)
+++ commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/engine/memory/lru/LHMLRUMemoryCacheUnitTest.java
Mon Jan 16 21:05:44 2012
@@ -107,7 +107,7 @@ public class LHMLRUMemoryCacheUnitTest
         }
         for ( int i = max + 2; i < items; i++ )
         {
-            ICacheElement element = (ICacheElement) elements.get( i + ":key" );
+            ICacheElement<String, String> element = (ICacheElement) elements.get( i
+ ":key" );
             assertNotNull( "element " + i + ":key is missing", element );
             assertEquals( "value " + i + ":key", "myregion" + " data " + i, element.getVal()
);
         }
@@ -259,7 +259,7 @@ public class LHMLRUMemoryCacheUnitTest
 
         for ( int i = 0; i < items; i++ )
         {
-            ICacheElement ice = new CacheElement( cache.getCacheName(), i + ":key", cache.getCacheName()
+ " data " + i );
+            ICacheElement<String, String> ice = new CacheElement( cache.getCacheName(),
i + ":key", cache.getCacheName() + " data " + i );
             ice.setElementAttributes( cache.getElementAttributes() );
             mru.update( ice );
         }

Modified: commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/engine/memory/lru/LRUMemoryCacheConcurrentUnitTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/engine/memory/lru/LRUMemoryCacheConcurrentUnitTest.java?rev=1232163&r1=1232162&r2=1232163&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/engine/memory/lru/LRUMemoryCacheConcurrentUnitTest.java
(original)
+++ commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/engine/memory/lru/LRUMemoryCacheConcurrentUnitTest.java
Mon Jan 16 21:05:44 2012
@@ -118,7 +118,7 @@ public class LRUMemoryCacheConcurrentUni
 
         for ( int i = 0; i < items; i++ )
         {
-            ICacheElement ice = new CacheElement( cache.getCacheName(), i + ":key", region
+ " data " + i );
+            ICacheElement<String, String> ice = new CacheElement( cache.getCacheName(),
i + ":key", region + " data " + i );
             ice.setElementAttributes( cache.getElementAttributes() );
             lru.update( ice );
         }
@@ -150,7 +150,7 @@ public class LRUMemoryCacheConcurrentUni
         }
         for ( int i = 100; i < items; i++ )
         {
-            ICacheElement element = (ICacheElement) elements.get( i + ":key" );
+            ICacheElement<String, String> element = (ICacheElement) elements.get( i
+ ":key" );
             assertNotNull( "element " + i + ":key is missing", element );
             assertEquals( "value " + i + ":key", region + " data " + i, element.getVal()
);
         }

Modified: commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/engine/memory/mru/MRUMemoryCacheUnitTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/engine/memory/mru/MRUMemoryCacheUnitTest.java?rev=1232163&r1=1232162&r2=1232163&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/engine/memory/mru/MRUMemoryCacheUnitTest.java
(original)
+++ commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/engine/memory/mru/MRUMemoryCacheUnitTest.java
Mon Jan 16 21:05:44 2012
@@ -108,7 +108,7 @@ public class MRUMemoryCacheUnitTest
         }
         for ( int i = max + 2; i < items; i++ )
         {
-            ICacheElement element = (ICacheElement) elements.get( i + ":key" );
+            ICacheElement<String, String> element = (ICacheElement) elements.get( i
+ ":key" );
             assertNotNull( "element " + i + ":key is missing", element );
             assertEquals( "value " + i + ":key", "myregion" + " data " + i, element.getVal()
);
         }
@@ -260,7 +260,7 @@ public class MRUMemoryCacheUnitTest
 
         for ( int i = 0; i < items; i++ )
         {
-            ICacheElement ice = new CacheElement( cache.getCacheName(), i + ":key", cache.getCacheName()
+ " data " + i );
+            ICacheElement<String, String> ice = new CacheElement( cache.getCacheName(),
i + ":key", cache.getCacheName() + " data " + i );
             ice.setElementAttributes( cache.getElementAttributes() );
             mru.update( ice );
         }

Modified: commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/engine/memory/shrinking/ShrinkerThreadUnitTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/engine/memory/shrinking/ShrinkerThreadUnitTest.java?rev=1232163&r1=1232162&r2=1232163&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/engine/memory/shrinking/ShrinkerThreadUnitTest.java
(original)
+++ commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/engine/memory/shrinking/ShrinkerThreadUnitTest.java
Mon Jan 16 21:05:44 2012
@@ -55,7 +55,7 @@ public class ShrinkerThreadUnitTest
         String key = "key";
         String value = "value";
 
-        ICacheElement element = new CacheElement( "testRegion", key, value );
+        ICacheElement<String, String> element = new CacheElement( "testRegion", key,
value );
         ElementAttributes elementAttr = new ElementAttributes();
         elementAttr.setIsEternal( false );
         element.setElementAttributes( elementAttr );
@@ -89,7 +89,7 @@ public class ShrinkerThreadUnitTest
         String key = "key";
         String value = "value";
 
-        ICacheElement element = new CacheElement( "testRegion", key, value );
+        ICacheElement<String, String> element = new CacheElement( "testRegion", key,
value );
         ElementAttributes elementAttr = new ElementAttributes();
         elementAttr.setIsEternal( false );
         element.setElementAttributes( elementAttr );
@@ -123,7 +123,7 @@ public class ShrinkerThreadUnitTest
         String key = "key";
         String value = "value";
 
-        ICacheElement element = new CacheElement( "testRegion", key, value );
+        ICacheElement<String, String> element = new CacheElement( "testRegion", key,
value );
         ElementAttributes elementAttr = new ElementAttributes();
         elementAttr.setIsEternal( false );
         element.setElementAttributes( elementAttr );
@@ -158,7 +158,7 @@ public class ShrinkerThreadUnitTest
         String key = "key";
         String value = "value";
 
-        ICacheElement element = new CacheElement( "testRegion", key, value );
+        ICacheElement<String, String> element = new CacheElement( "testRegion", key,
value );
         ElementAttributes elementAttr = new ElementAttributes();
         elementAttr.setIsEternal( false );
         element.setElementAttributes( elementAttr );
@@ -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( "testRegion", key,
value );
 
         ElementAttributes elementAttr = new ElementAttributes();
         elementAttr.setIsEternal( false );
@@ -205,7 +205,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.
@@ -219,7 +219,7 @@ public class ShrinkerThreadUnitTest
         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 );
     }
@@ -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( "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.
@@ -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( "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.

Modified: commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/utils/serialization/SerializationConversionUtilUnitTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/utils/serialization/SerializationConversionUtilUnitTest.java?rev=1232163&r1=1232162&r2=1232163&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/utils/serialization/SerializationConversionUtilUnitTest.java
(original)
+++ commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/utils/serialization/SerializationConversionUtilUnitTest.java
Mon Jan 16 21:05:44 2012
@@ -48,7 +48,7 @@ public class SerializationConversionUtil
     {
         // SETUP
         IElementSerializer elementSerializer = new StandardSerializer();
-        ICacheElement before = null;
+        ICacheElement<String, String> before = null;
 
         // DO WORK
         ICacheElementSerialized result = SerializationConversionUtil.getSerializedCacheElement(
before,
@@ -71,7 +71,7 @@ public class SerializationConversionUtil
         ICacheElementSerialized 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,7 +95,7 @@ public class SerializationConversionUtil
         IElementAttributes attr = new ElementAttributes();
         attr.setMaxLifeSeconds( 34 );
 
-        ICacheElement before = new CacheElement( cacheName, key, value );
+        ICacheElement<String, String> before = new CacheElement( cacheName, key, value
);
         before.setElementAttributes( attr );
 
         // DO WORK
@@ -107,7 +107,7 @@ public class SerializationConversionUtil
         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,7 +136,7 @@ public class SerializationConversionUtil
         IElementAttributes attr = new ElementAttributes();
         attr.setMaxLifeSeconds( 34 );
 
-        ICacheElement before = new CacheElement( cacheName, key, value );
+        ICacheElement<String, String> before = new CacheElement( cacheName, key, value
);
         before.setElementAttributes( attr );
 
         // DO WORK
@@ -150,7 +150,7 @@ public class SerializationConversionUtil
         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 +176,7 @@ public class SerializationConversionUtil
         IElementAttributes attr = new ElementAttributes();
         attr.setMaxLifeSeconds( 34 );
 
-        ICacheElement before = new CacheElement( cacheName, key, value );
+        ICacheElement<String, String> before = new CacheElement( cacheName, key, value
);
         before.setElementAttributes( attr );
 
         // DO WORK



Mime
View raw message