commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t.@apache.org
Subject svn commit: r1329570 - in /commons/proper/jcs/branches/generics-interface/src: java/org/apache/jcs/admin/ java/org/apache/jcs/auxiliary/disk/ java/org/apache/jcs/auxiliary/disk/block/ java/org/apache/jcs/auxiliary/disk/indexed/ java/org/apache/jcs/engi...
Date Tue, 24 Apr 2012 07:05:19 GMT
Author: tv
Date: Tue Apr 24 07:05:18 2012
New Revision: 1329570

URL: http://svn.apache.org/viewvc?rev=1329570&view=rev
Log:
Remove unit test failures

Modified:
    commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/admin/JCSAdminBean.java
    commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/AbstractDiskCache.java
    commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/block/BlockDiskCache.java
    commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCache.java
    commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/control/CompositeCache.java
    commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/match/KeyMatcherPatternImpl.java
    commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/match/behavior/IKeyMatcher.java
    commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/AbstractDoulbeLinkedListMemoryCache.java
    commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/AbstractMemoryCache.java
    commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/behavior/IMemoryCache.java
    commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/lru/LHMLRUMemoryCache.java
    commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/shrinking/ShrinkerThread.java
    commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/admin/AdminBeanUnitTest.java
    commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/engine/match/KeyMatcherPatternImpllUnitTest.java
    commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/engine/memory/MockMemoryCache.java
    commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/engine/memory/lru/LHMLRUMemoryCacheUnitTest.java
    commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/engine/memory/mru/MRUMemoryCacheUnitTest.java

Modified: commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/admin/JCSAdminBean.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/admin/JCSAdminBean.java?rev=1329570&r1=1329569&r2=1329570&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/admin/JCSAdminBean.java
(original)
+++ commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/admin/JCSAdminBean.java
Tue Apr 24 07:05:18 2012
@@ -28,6 +28,7 @@ import java.util.Date;
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.Map;
+import java.util.Set;
 
 import org.apache.jcs.access.exception.CacheException;
 import org.apache.jcs.auxiliary.remote.server.RemoteCacheServer;
@@ -74,12 +75,12 @@ public class JCSAdminBean
      * @return List of CacheElementInfo objects
      * @throws Exception
      */
-    public <K extends Serializable, V extends Serializable> LinkedList<CacheElementInfo>
buildElementInfo( String cacheName )
+    public LinkedList<CacheElementInfo> buildElementInfo( String cacheName )
         throws Exception
     {
-        CompositeCache<K, V> cache = cacheHub.getCache( cacheName );
+        CompositeCache<Serializable, Serializable> cache = cacheHub.getCache( cacheName
);
 
-        K[] keys = cache.getMemoryCache().getKeyArray();
+        Serializable[] keys = cache.getMemoryCache().getKeySet().toArray(new Serializable[0]);
 
         // Attempt to sort keys according to their natural ordering. If that
         // fails, get the key array again and continue unsorted.
@@ -89,12 +90,12 @@ public class JCSAdminBean
         }
         catch ( Exception e )
         {
-            keys = cache.getMemoryCache().getKeyArray();
+            keys = cache.getMemoryCache().getKeySet().toArray(new Serializable[0]);
         }
 
         LinkedList<CacheElementInfo> records = new LinkedList<CacheElementInfo>();
 
-        ICacheElement<K, V> element;
+        ICacheElement<Serializable, Serializable> element;
         IElementAttributes attributes;
         CacheElementInfo elementInfo;
 
@@ -102,15 +103,15 @@ public class JCSAdminBean
 
         long now = System.currentTimeMillis();
 
-        for ( int i = 0; i < keys.length; i++ )
+        for (Serializable key : keys)
         {
-            element = cache.getMemoryCache().getQuiet( keys[i] );
+            element = cache.getMemoryCache().getQuiet( key );
 
             attributes = element.getElementAttributes();
 
             elementInfo = new CacheElementInfo();
 
-            elementInfo.key = String.valueOf( keys[i] );
+            elementInfo.key = String.valueOf( key );
             elementInfo.eternal = attributes.getIsEternal();
             elementInfo.maxLifeSeconds = attributes.getMaxLifeSeconds();
 
@@ -345,10 +346,9 @@ public class JCSAdminBean
                 // actual key object as stored in the cache (i.e. a Serializable object).
To find the key in this form,
                 // we iterate through all keys stored in the memory cache until we find one
whose toString matches
                 // the string supplied...
-                Object[] allKeysInCache = cache.getMemoryCache().getKeyArray();
-                for (int i = 0; i < allKeysInCache.length; i++)
+                Set<? extends Serializable> allKeysInCache = cache.getMemoryCache().getKeySet();
+                for (Serializable keyInCache : allKeysInCache)
                 {
-                    Object keyInCache = allKeysInCache[i];
                     if (keyInCache.toString().equals(key))
                     {
                         if (keyToRemove == null)

Modified: commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/AbstractDiskCache.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/AbstractDiskCache.java?rev=1329570&r1=1329569&r2=1329570&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/AbstractDiskCache.java
(original)
+++ commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/AbstractDiskCache.java
Tue Apr 24 07:05:18 2012
@@ -24,6 +24,7 @@ import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -323,12 +324,12 @@ public abstract class AbstractDiskCache<
         throws IOException
     {
         // Get the keys from purgatory
-        K[] keyArray = null;
+        Set<K> keyArray = null;
 
         // this avoids locking purgatory, but it uses more memory
         synchronized ( purgatory )
         {
-            keyArray = (K[]) purgatory.keySet().toArray();
+            keyArray = new HashSet<K>(purgatory.keySet());
         }
 
         Set<K> matchingKeys = getKeyMatcher().getMatchingKeysFromArray( pattern, keyArray
);

Modified: commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/block/BlockDiskCache.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/block/BlockDiskCache.java?rev=1329570&r1=1329569&r2=1329570&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/block/BlockDiskCache.java
(original)
+++ commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/block/BlockDiskCache.java
Tue Apr 24 07:05:18 2012
@@ -246,11 +246,11 @@ public class BlockDiskCache<K extends Se
     {
         Map<K, ICacheElement<K, V>> elements = new HashMap<K, ICacheElement<K,
V>>();
 
-        K[] keyArray = null;
+        Set<K> keyArray = null;
         storageLock.readLock().lock();
         try
         {
-            keyArray = (K[]) this.keyStore.keySet().toArray();
+            keyArray = new HashSet<K>(keyStore.keySet());
         }
         finally
         {

Modified: commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCache.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCache.java?rev=1329570&r1=1329569&r2=1329570&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCache.java
(original)
+++ commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCache.java
Tue Apr 24 07:05:18 2012
@@ -663,11 +663,11 @@ public class IndexedDiskCache<K extends 
         Map<K, ICacheElement<K, V>> elements = new HashMap<K, ICacheElement<K,
V>>();
         try
         {
-            K[] keyArray = null;
+            Set<K> keyArray = null;
             storageLock.readLock().lock();
             try
             {
-                keyArray = (K[]) keyHash.keySet().toArray();
+                keyArray = new HashSet<K>(keyHash.keySet());
             }
             finally
             {

Modified: commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/control/CompositeCache.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/control/CompositeCache.java?rev=1329570&r1=1329569&r2=1329570&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/control/CompositeCache.java
(original)
+++ commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/control/CompositeCache.java
Tue Apr 24 07:05:18 2012
@@ -863,7 +863,7 @@ public class CompositeCache<K extends Se
     {
         // find matches in key array
         // this avoids locking the memory cache, but it uses more memory
-        K[] keyArray = memCache.getKeyArray();
+        Set<K> keyArray = memCache.getKeySet();
 
         Set<K> matchingKeys = getKeyMatcher().getMatchingKeysFromArray( pattern, keyArray
);
 
@@ -874,7 +874,7 @@ public class CompositeCache<K extends Se
     /**
      * If local invocation look in aux caches, even if not local look in disk auxiliaries.
      * <p>
-     * Moves in reverse order of definition. This will allow you to override those that are
fromthe
+     * Moves in reverse order of definition. This will allow you to override those that are
from the
      * remote with those on disk.
      * <p>
      * @param pattern
@@ -1317,8 +1317,8 @@ public class CompositeCache<K extends Se
         // Now, shut down the event queue
         if (elementEventQ != null)
         {
-            elementEventQ.destroy();
-            elementEventQ = null;
+        	elementEventQ.destroy();
+        	elementEventQ = null;
         }
 
         // Dispose of each auxiliary cache, Remote auxiliaries will be

Modified: commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/match/KeyMatcherPatternImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/match/KeyMatcherPatternImpl.java?rev=1329570&r1=1329569&r2=1329570&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/match/KeyMatcherPatternImpl.java
(original)
+++ commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/match/KeyMatcherPatternImpl.java
Tue Apr 24 07:05:18 2012
@@ -22,7 +22,7 @@ public class KeyMatcherPatternImpl<K ext
      * @param keyArray
      * @return Set of the matching keys
      */
-    public Set<K> getMatchingKeysFromArray( String pattern, K[] keyArray )
+    public Set<K> getMatchingKeysFromArray( String pattern, Set<K> keyArray )
     {
         Pattern compiledPattern = Pattern.compile( pattern );
 

Modified: commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/match/behavior/IKeyMatcher.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/match/behavior/IKeyMatcher.java?rev=1329570&r1=1329569&r2=1329570&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/match/behavior/IKeyMatcher.java
(original)
+++ commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/match/behavior/IKeyMatcher.java
Tue Apr 24 07:05:18 2012
@@ -13,5 +13,5 @@ public interface IKeyMatcher<K extends S
      * @param keyArray
      * @return Set of the matching keys
      */
-    Set<K> getMatchingKeysFromArray( String pattern, K[] keyArray );
+    Set<K> getMatchingKeysFromArray( String pattern, Set<K> keyArray );
 }

Modified: commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/AbstractDoulbeLinkedListMemoryCache.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/AbstractDoulbeLinkedListMemoryCache.java?rev=1329570&r1=1329569&r2=1329570&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/AbstractDoulbeLinkedListMemoryCache.java
(original)
+++ commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/AbstractDoulbeLinkedListMemoryCache.java
Tue Apr 24 07:05:18 2012
@@ -7,6 +7,7 @@ import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Map.Entry;
+import java.util.Set;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -677,13 +678,13 @@ public abstract class AbstractDoulbeLink
      * @return An Object[]
      */
     @Override
-    public K[] getKeyArray()
+    public Set<K> getKeySet()
     {
         // need a better locking strategy here.
         synchronized ( this )
         {
             // may need to lock to map here?
-            return (K[]) map.keySet().toArray();
+            return map.keySet();
         }
     }
 

Modified: commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/AbstractMemoryCache.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/AbstractMemoryCache.java?rev=1329570&r1=1329569&r2=1329570&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/AbstractMemoryCache.java
(original)
+++ commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/AbstractMemoryCache.java
Tue Apr 24 07:05:18 2012
@@ -210,11 +210,11 @@ public abstract class AbstractMemoryCach
         throws IOException;
 
     /**
-     * Get an Array of the keys for all elements in the memory cache
+     * Get a set of the keys for all elements in the memory cache
      * <p>
-     * @return An Object[]
+     * @return A set of the key type
      */
-    public abstract K[] getKeyArray();
+    public abstract Set<K> getKeySet();
 
     /**
      * Removes all cached items from the cache.

Modified: commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/behavior/IMemoryCache.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/behavior/IMemoryCache.java?rev=1329570&r1=1329569&r2=1329570&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/behavior/IMemoryCache.java
(original)
+++ commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/behavior/IMemoryCache.java
Tue Apr 24 07:05:18 2012
@@ -73,14 +73,14 @@ public interface IMemoryCache<K extends 
     Iterator<Map.Entry<K, MemoryElementDescriptor<K, V>>> getIterator();
 
     /**
-     * Get an Array of the keys for all elements in the memory cache.
+     * Get a set of the keys for all elements in the memory cache.
      * <p>
-     * @return Object[]
+     * @return a set of the key type
      * @TODO This should probably be done in chunks with a range passed in. This
      *       will be a problem if someone puts a 1,000,000 or so items in a
      *       region.
      */
-    K[] getKeyArray();
+    Set<K> getKeySet();
 
     /**
      * Removes an item from the cache

Modified: commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/lru/LHMLRUMemoryCache.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/lru/LHMLRUMemoryCache.java?rev=1329570&r1=1329569&r2=1329570&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/lru/LHMLRUMemoryCache.java
(original)
+++ commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/lru/LHMLRUMemoryCache.java
Tue Apr 24 07:05:18 2012
@@ -25,6 +25,7 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.Map;
+import java.util.Set;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -229,13 +230,13 @@ public class LHMLRUMemoryCache<K extends
      * @return An Object[]
      */
     @Override
-    public K[] getKeyArray()
+    public Set<K> getKeySet()
     {
         // need a better locking strategy here.
         synchronized ( this )
         {
             // may need to lock to map here?
-            return (K[])map.keySet().toArray();
+            return map.keySet();
         }
     }
 

Modified: commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/shrinking/ShrinkerThread.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/shrinking/ShrinkerThread.java?rev=1329570&r1=1329569&r2=1329570&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/shrinking/ShrinkerThread.java
(original)
+++ commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/shrinking/ShrinkerThread.java
Tue Apr 24 07:05:18 2012
@@ -22,6 +22,7 @@ package org.apache.jcs.engine.memory.shr
 import java.io.IOException;
 import java.io.Serializable;
 import java.util.ArrayList;
+import java.util.Set;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -121,22 +122,20 @@ public class ShrinkerThread<K extends Se
 
         try
         {
-            K[] keys = cache.getKeyArray();
-            int size = keys.length;
+            Set<K> keys = cache.getKeySet();
+            int size = keys.size();
             if ( log.isDebugEnabled() )
             {
                 log.debug( "Keys size: " + size );
             }
 
-            K key;
             ICacheElement<K, V> cacheElement;
             IElementAttributes attributes;
 
             int spoolCount = 0;
 
-            for ( int i = 0; i < size; i++ )
+            for (K key : keys)
             {
-                key = keys[i];
                 cacheElement = cache.getQuiet( key );
 
                 if ( cacheElement == null )

Modified: commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/admin/AdminBeanUnitTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/admin/AdminBeanUnitTest.java?rev=1329570&r1=1329569&r2=1329570&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/admin/AdminBeanUnitTest.java
(original)
+++ commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/admin/AdminBeanUnitTest.java
Tue Apr 24 07:05:18 2012
@@ -19,7 +19,6 @@ package org.apache.jcs.admin;
  * under the License.
  */
 
-import java.util.Iterator;
 import java.util.List;
 
 import junit.framework.TestCase;
@@ -52,14 +51,12 @@ public class AdminBeanUnitTest
 
         JCSAdminBean admin = new JCSAdminBean();
 
-        List regions = admin.buildCacheInfo();
+        List<CacheRegionInfo> regions = admin.buildCacheInfo();
 
         boolean foundRegion = false;
 
-        Iterator it = regions.iterator();
-        while ( it.hasNext() )
+        for (CacheRegionInfo info : regions)
         {
-            CacheRegionInfo info = (CacheRegionInfo) it.next();
             System.out.println( info );
 
             if ( info.getCache().getCacheName().equals( regionName ) )
@@ -94,11 +91,11 @@ public class AdminBeanUnitTest
 
         JCSAdminBean admin = new JCSAdminBean();
 
-        List elements = admin.buildElementInfo( regionName );
+        List<CacheElementInfo> elements = admin.buildElementInfo( regionName );
 
         assertEquals( "Wrong number of elements in the region.", 1, elements.size() );
 
-        CacheElementInfo elementInfo = (CacheElementInfo) elements.get( 0 );
+        CacheElementInfo elementInfo = elements.get( 0 );
         System.out.println( elementInfo );
         assertEquals( "Wrong key.", key, elementInfo.getKey() );
     }
@@ -123,17 +120,17 @@ public class AdminBeanUnitTest
         String key = "myKey";
         cache.put( key, "value" );
 
-        List elements = admin.buildElementInfo( regionName );
+        List<CacheElementInfo> elements = admin.buildElementInfo( regionName );
 
         assertEquals( "Wrong number of elements in the region.", 1, elements.size() );
 
-        CacheElementInfo elementInfo = (CacheElementInfo) elements.get( 0 );
+        CacheElementInfo elementInfo = elements.get( 0 );
 
         assertEquals( "Wrong key.", key, elementInfo.getKey() );
 
         admin.removeItem( regionName, key );
 
-        List elements2 = admin.buildElementInfo( regionName );
+        List<CacheElementInfo> elements2 = admin.buildElementInfo( regionName );
         assertEquals( "Wrong number of elements in the region after remove.", 0, elements2.size()
);
     }
 
@@ -155,7 +152,7 @@ public class AdminBeanUnitTest
 
         admin.clearAllRegions();
 
-        List elements2 = admin.buildElementInfo( regionName );
+        List<CacheElementInfo> elements2 = admin.buildElementInfo( regionName );
         assertEquals( "Wrong number of elements in the region after remove.", 0, elements2.size()
);
     }
 }

Modified: commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/engine/match/KeyMatcherPatternImpllUnitTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/engine/match/KeyMatcherPatternImpllUnitTest.java?rev=1329570&r1=1329569&r2=1329570&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/engine/match/KeyMatcherPatternImpllUnitTest.java
(original)
+++ commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/engine/match/KeyMatcherPatternImpllUnitTest.java
Tue Apr 24 07:05:18 2012
@@ -1,5 +1,6 @@
 package org.apache.jcs.engine.match;
 
+import java.util.HashSet;
 import java.util.Set;
 
 import junit.framework.TestCase;
@@ -15,15 +16,14 @@ public class KeyMatcherPatternImpllUnitT
     {
         // SETUP
         int numToInsertPrefix1 = 10;
-        int araySize = numToInsertPrefix1;
-        String[] keyArray = new String[araySize];
+        Set<String> keyArray = new HashSet<String>();
 
         String keyprefix1 = "MyPrefixC";
 
         // insert with prefix1
         for ( int i = 0; i < numToInsertPrefix1; i++ )
         {
-            keyArray[i] = keyprefix1 + String.valueOf( i );
+            keyArray.add(keyprefix1 + String.valueOf( i ));
         }
 
         KeyMatcherPatternImpl<String> keyMatcher = new KeyMatcherPatternImpl<String>();
@@ -42,15 +42,14 @@ public class KeyMatcherPatternImpllUnitT
     {
         // SETUP
         int numToInsertPrefix1 = 10;
-        int araySize = numToInsertPrefix1 + 1;
-        String[] keyArray = new String[araySize];
+        Set<String> keyArray = new HashSet<String>();
 
         String keyprefix1 = "MyPrefixC";
 
         // insert with prefix1
         for ( int i = 1; i < numToInsertPrefix1 + 1; i++ )
         {
-            keyArray[i] = keyprefix1 + String.valueOf( i );
+            keyArray.add(keyprefix1 + String.valueOf( i ));
         }
 
         KeyMatcherPatternImpl<String> keyMatcher = new KeyMatcherPatternImpl<String>();
@@ -65,13 +64,12 @@ public class KeyMatcherPatternImpllUnitT
     /**
      * Verify that the matching method works.
      */
-    public void testGetMathcingKeysFromArray_TwoTypes()
+    public void testGetMatchingKeysFromArray_TwoTypes()
     {
         // SETUP
         int numToInsertPrefix1 = 10;
         int numToInsertPrefix2 = 50;
-        int araySize = numToInsertPrefix1 + numToInsertPrefix2;
-        String[] keyArray = new String[araySize];
+        Set<String> keyArray = new HashSet<String>();
 
         String keyprefix1 = "MyPrefixA";
         String keyprefix2 = "MyPrefixB";
@@ -79,13 +77,13 @@ public class KeyMatcherPatternImpllUnitT
         // insert with prefix1
         for ( int i = 0; i < numToInsertPrefix1; i++ )
         {
-            keyArray[i] = keyprefix1 + String.valueOf( i );
+            keyArray.add(keyprefix1 + String.valueOf( i ));
         }
 
         // insert with prefix2
         for ( int i = numToInsertPrefix1; i < numToInsertPrefix2 + numToInsertPrefix1;
i++ )
         {
-            keyArray[i] = keyprefix2 + String.valueOf( i );
+            keyArray.add(keyprefix2 + String.valueOf( i ));
         }
 
         KeyMatcherPatternImpl<String> keyMatcher = new KeyMatcherPatternImpl<String>();

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=1329570&r1=1329569&r2=1329570&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
Tue Apr 24 07:05:18 2012
@@ -93,9 +93,9 @@ public class MockMemoryCache<K extends S
 
     /**
      * @return map.keySet().toArray( */
-    public K[] getKeyArray()
+    public Set<K> getKeySet()
     {
-        return (K[]) map.keySet().toArray();
+        return map.keySet();
     }
 
     /**

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=1329570&r1=1329569&r2=1329570&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
Tue Apr 24 07:05:18 2012
@@ -264,9 +264,9 @@ public class LHMLRUMemoryCacheUnitTest
             mru.update( ice );
         }
 
-        Object[] keys = mru.getKeyArray();
+        Set<String> keys = mru.getKeySet();
 
-        assertEquals( "Wrong number of keys.", items, keys.length );
+        assertEquals( "Wrong number of keys.", items, keys.size() );
     }
 
     /**

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=1329570&r1=1329569&r2=1329570&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
Tue Apr 24 07:05:18 2012
@@ -265,9 +265,9 @@ public class MRUMemoryCacheUnitTest
             mru.update( ice );
         }
 
-        Object[] keys = mru.getKeyArray();
+        Set<String> keys = mru.getKeySet();
 
-        assertEquals( "Wrong number of keys.", items, keys.length );
+        assertEquals( "Wrong number of keys.", items, keys.size() );
     }
 
     /**



Mime
View raw message