colus       02/03/29 23:24:20

  Modified:    cache/src/test/org/apache/avalon/excalibur/cache/store/test
                        AbstractCacheStoreTestCase.java
               cache/src/test/org/apache/avalon/excalibur/cache/test
                        AbstractCacheTestCase.java LRUCacheTestCase.java
                        TimeMapLRUCacheTestCase.java
               cache/src/test/org/apache/avalon/excalibur/cache/validator/test
                        TimeoutValidatorTestCase.java
               cache/src/java/org/apache/avalon/excalibur/cache Cache.java
                        CacheStore.java DefaultCache.java
                        SynchronizedCache.java ValidatingCache.java
  Log:
  Removed Cache's containsKey method.
  Check key and value parameter.
  
  Revision  Changes    Path
  1.3       +0 -7      
jakarta-avalon-excalibur/cache/src/test/org/apache/avalon/excalibur/cache/store/test/AbstractCacheStoreTestCase.java
  
  Index: AbstractCacheStoreTestCase.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon-excalibur/cache/src/test/org/apache/avalon/excalibur/cache/store/test/AbstractCacheStoreTestCase.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AbstractCacheStoreTestCase.java   16 Mar 2002 00:05:44 -0000      1.2
  +++ AbstractCacheStoreTestCase.java   30 Mar 2002 07:24:19 -0000      1.3
  @@ -24,11 +24,4 @@
       {
           super( name );
       }
  -
  -    public void testNullValue()
  -    {
  -        m_store.put( "KEY", null );
  -        assertTrue( m_store.containsKey( "KEY" ) );
  -        assertEquals( 1, m_store.size() );
  -    }
   }
  
  
  
  1.3       +0 -7      
jakarta-avalon-excalibur/cache/src/test/org/apache/avalon/excalibur/cache/test/AbstractCacheTestCase.java
  
  Index: AbstractCacheTestCase.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon-excalibur/cache/src/test/org/apache/avalon/excalibur/cache/test/AbstractCacheTestCase.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AbstractCacheTestCase.java        16 Mar 2002 00:05:44 -0000      1.2
  +++ AbstractCacheTestCase.java        30 Mar 2002 07:24:19 -0000      1.3
  @@ -24,11 +24,4 @@
       {
           super( name );
       }
  -
  -    public void testNullValue()
  -    {
  -        m_cache.put( "KEY", null );
  -        assertTrue( m_cache.containsKey( "KEY" ) );
  -        assertEquals( 1, m_cache.size() );
  -    }
   }
  
  
  
  1.6       +0 -80     
jakarta-avalon-excalibur/cache/src/test/org/apache/avalon/excalibur/cache/test/LRUCacheTestCase.java
  
  Index: LRUCacheTestCase.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon-excalibur/cache/src/test/org/apache/avalon/excalibur/cache/test/LRUCacheTestCase.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- LRUCacheTestCase.java     27 Jan 2002 04:59:28 -0000      1.5
  +++ LRUCacheTestCase.java     30 Mar 2002 07:24:19 -0000      1.6
  @@ -27,84 +27,4 @@
       {
           m_cache = new LRUCache( 10 );
       }
  -
  -    private static final String KEY1 = "key 1";
  -    private static final String VALUE1 = "value 1";
  -    private static final String VALUE1_1 = "value 1-1";
  -    private static final String KEY2 = "key 2";
  -    private static final String VALUE2 = "value 2";
  -    private static final String KEY3 = "key 3";
  -    private static final String VALUE3 = "value 3";
  -
  -    public void testPutGet()
  -    {
  -        final Cache cache = new LRUCache( 3 );
  -
  -        assertTrue( !cache.containsKey( KEY1 ) );
  -        assertNull( cache.put( KEY1, VALUE1 ) );
  -        assertTrue( cache.containsKey( KEY1 ) );
  -        assertEquals( VALUE1, cache.get( KEY1 ) );
  -
  -        assertTrue( !cache.containsKey( KEY2 ) );
  -        assertNull( cache.put( KEY2, VALUE2 ) );
  -        assertTrue( cache.containsKey( KEY2 ) );
  -        assertEquals( VALUE2, cache.get( KEY2 ) );
  -
  -        assertTrue( !cache.containsKey( KEY3 ) );
  -        assertNull( cache.put( KEY3, VALUE3 ) );
  -        assertTrue( cache.containsKey( KEY3 ) );
  -        assertEquals( VALUE3, cache.get( KEY3 ) );
  -
  -        assertTrue( cache.containsKey( KEY1 ) );
  -        assertEquals( VALUE1, cache.put( KEY1, VALUE1_1 ) );
  -        assertTrue( cache.containsKey( KEY1 ) );
  -        assertEquals( VALUE1_1, cache.get( KEY1 ) );
  -
  -        cache.clear();
  -        assertEquals( 0, cache.size() );
  -        assertTrue( !cache.containsKey( KEY1 ) );
  -        assertTrue( !cache.containsKey( KEY2 ) );
  -        assertTrue( !cache.containsKey( KEY3 ) );
  -    }
  -
  -    public void testRemove()
  -    {
  -        final Cache cache = new LRUCache( 3 );
  -
  -        assertTrue( !cache.containsKey( KEY1 ) );
  -        assertNull( cache.put( KEY1, VALUE1 ) );
  -        assertTrue( cache.containsKey( KEY1 ) );
  -        assertEquals( VALUE1, cache.get( KEY1 ) );
  -
  -        assertTrue( !cache.containsKey( KEY2 ) );
  -        assertNull( cache.put( KEY2, VALUE2 ) );
  -        assertTrue( cache.containsKey( KEY2 ) );
  -        assertEquals( VALUE2, cache.get( KEY2 ) );
  -
  -        assertTrue( !cache.containsKey( KEY3 ) );
  -        assertNull( cache.put( KEY3, VALUE3 ) );
  -        assertTrue( cache.containsKey( KEY3 ) );
  -        assertEquals( VALUE3, cache.get( KEY3 ) );
  -
  -        assertEquals( VALUE1, cache.remove( KEY1 ) );
  -        assertTrue( !cache.containsKey( KEY1 ) );
  -        assertTrue( cache.containsKey( KEY2 ) );
  -        assertTrue( cache.containsKey( KEY3 ) );
  -
  -        assertEquals( VALUE2, cache.remove( KEY2 ) );
  -        assertTrue( !cache.containsKey( KEY1 ) );
  -        assertTrue( !cache.containsKey( KEY2 ) );
  -        assertTrue( cache.containsKey( KEY3 ) );
  -
  -        assertEquals( VALUE3, cache.remove( KEY3 ) );
  -        assertTrue( !cache.containsKey( KEY1 ) );
  -        assertTrue( !cache.containsKey( KEY2 ) );
  -        assertTrue( !cache.containsKey( KEY3 ) );
  -
  -        cache.clear();
  -        assertEquals( 0, cache.size() );
  -        assertTrue( !cache.containsKey( KEY1 ) );
  -        assertTrue( !cache.containsKey( KEY2 ) );
  -        assertTrue( !cache.containsKey( KEY3 ) );
  -    }
   }
  
  
  
  1.2       +0 -105    
jakarta-avalon-excalibur/cache/src/test/org/apache/avalon/excalibur/cache/test/TimeMapLRUCacheTestCase.java
  
  Index: TimeMapLRUCacheTestCase.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon-excalibur/cache/src/test/org/apache/avalon/excalibur/cache/test/TimeMapLRUCacheTestCase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TimeMapLRUCacheTestCase.java      28 Jan 2002 06:07:28 -0000      1.1
  +++ TimeMapLRUCacheTestCase.java      30 Mar 2002 07:24:19 -0000      1.2
  @@ -27,109 +27,4 @@
       {
           m_cache = new TimeMapLRUCache( 10 );
       }
  -
  -    private static final String KEY1 = "key 1";
  -    private static final String VALUE1 = "value 1";
  -    private static final String VALUE1_1 = "value 1-1";
  -    private static final String KEY2 = "key 2";
  -    private static final String VALUE2 = "value 2";
  -    private static final String KEY3 = "key 3";
  -    private static final String VALUE3 = "value 3";
  -    private static final String KEY4 = "key 4";
  -    private static final String VALUE4 = "value 4";
  -
  -    public void testPutGet()
  -    {
  -
  -        final Cache cache = new TimeMapLRUCache( 3 );
  -
  -        assertTrue( !cache.containsKey( KEY1 ) );
  -        assertNull( cache.put( KEY1, VALUE1 ) );
  -        assertTrue( cache.containsKey( KEY1 ) );
  -        assertEquals( VALUE1, cache.get( KEY1 ) );
  -
  -        assertTrue( !cache.containsKey( KEY2 ) );
  -        assertNull( cache.put( KEY2, VALUE2 ) );
  -        assertTrue( cache.containsKey( KEY2 ) );
  -        assertEquals( VALUE2, cache.get( KEY2 ) );
  -
  -        assertTrue( !cache.containsKey( KEY3 ) );
  -        assertNull( cache.put( KEY3, VALUE3 ) );
  -        assertTrue( cache.containsKey( KEY3 ) );
  -        assertEquals( VALUE3, cache.get( KEY3 ) );
  -
  -        assertTrue( cache.containsKey( KEY1 ) );
  -        assertEquals( VALUE1, cache.put( KEY1, VALUE1_1 ) );
  -        assertTrue( cache.containsKey( KEY1 ) );
  -        assertEquals( VALUE1_1, cache.get( KEY1 ) );
  -
  -        cache.clear();
  -        assertEquals( 0, cache.size() );
  -        assertTrue( !cache.containsKey( KEY1 ) );
  -        assertTrue( !cache.containsKey( KEY2 ) );
  -        assertTrue( !cache.containsKey( KEY3 ) );
  -
  -        assertNull( cache.put( KEY1, VALUE1 ) );
  -        assertNull( cache.put( KEY2, VALUE2 ) );
  -        assertNull( cache.put( KEY3, VALUE3 ) );
  -        assertNull( cache.put( KEY4, VALUE4 ) );
  -        assertTrue( !cache.containsKey( KEY1 ) );
  -        assertNull( cache.put( KEY1, VALUE1 ) );
  -        assertTrue( !cache.containsKey( KEY2 ) );
  -        assertNull( cache.put( KEY2, VALUE2 ) );
  -        assertTrue( !cache.containsKey( KEY3 ) );
  -
  -        cache.clear();
  -        assertNull( cache.put( KEY1, VALUE1 ) );
  -        assertNull( cache.put( KEY2, VALUE2 ) );
  -        assertNull( cache.put( KEY3, VALUE3 ) );
  -        cache.get( KEY1 );
  -        assertNull( cache.put( KEY4, VALUE4 ) );
  -        assertTrue( cache.containsKey( KEY1 ) );
  -        assertTrue( !cache.containsKey( KEY2 ) );
  -        cache.clear();
  -
  -    }
  -
  -    public void testRemove()
  -    {
  -
  -        final Cache cache = new TimeMapLRUCache( 3 );
  -
  -        assertTrue( !cache.containsKey( KEY1 ) );
  -        assertNull( cache.put( KEY1, VALUE1 ) );
  -        assertTrue( cache.containsKey( KEY1 ) );
  -        assertEquals( VALUE1, cache.get( KEY1 ) );
  -
  -        assertTrue( !cache.containsKey( KEY2 ) );
  -        assertNull( cache.put( KEY2, VALUE2 ) );
  -        assertTrue( cache.containsKey( KEY2 ) );
  -        assertEquals( VALUE2, cache.get( KEY2 ) );
  -
  -        assertTrue( !cache.containsKey( KEY3 ) );
  -        assertNull( cache.put( KEY3, VALUE3 ) );
  -        assertTrue( cache.containsKey( KEY3 ) );
  -        assertEquals( VALUE3, cache.get( KEY3 ) );
  -
  -        assertEquals( VALUE1, cache.remove( KEY1 ) );
  -        assertTrue( !cache.containsKey( KEY1 ) );
  -        assertTrue( cache.containsKey( KEY2 ) );
  -        assertTrue( cache.containsKey( KEY3 ) );
  -
  -        assertEquals( VALUE2, cache.remove( KEY2 ) );
  -        assertTrue( !cache.containsKey( KEY1 ) );
  -        assertTrue( !cache.containsKey( KEY2 ) );
  -        assertTrue( cache.containsKey( KEY3 ) );
  -
  -        assertEquals( VALUE3, cache.remove( KEY3 ) );
  -        assertTrue( !cache.containsKey( KEY1 ) );
  -        assertTrue( !cache.containsKey( KEY2 ) );
  -        assertTrue( !cache.containsKey( KEY3 ) );
  -
  -        cache.clear();
  -        assertEquals( 0, cache.size() );
  -        assertTrue( !cache.containsKey( KEY1 ) );
  -        assertTrue( !cache.containsKey( KEY2 ) );
  -        assertTrue( !cache.containsKey( KEY3 ) );
  -    }
   }
  
  
  
  1.5       +2 -2      
jakarta-avalon-excalibur/cache/src/test/org/apache/avalon/excalibur/cache/validator/test/TimeoutValidatorTestCase.java
  
  Index: TimeoutValidatorTestCase.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon-excalibur/cache/src/test/org/apache/avalon/excalibur/cache/validator/test/TimeoutValidatorTestCase.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TimeoutValidatorTestCase.java     16 Mar 2002 00:05:44 -0000      1.4
  +++ TimeoutValidatorTestCase.java     30 Mar 2002 07:24:19 -0000      1.5
  @@ -39,7 +39,7 @@
   
           Thread.sleep( 100 );
   
  -        assertTrue( cache.containsKey( "K1" ) );
  +        assertNull( cache.get( "K1" ) );
       }
   
       public void testExpired()
  @@ -55,6 +55,6 @@
   
           Thread.sleep( 2000 );
   
  -        assertTrue( !cache.containsKey( "K1" ) );
  +        assertNull( cache.get( "K1" ) );
       }
   }
  
  
  
  1.11      +1 -10     
jakarta-avalon-excalibur/cache/src/java/org/apache/avalon/excalibur/cache/Cache.java
  
  Index: Cache.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon-excalibur/cache/src/java/org/apache/avalon/excalibur/cache/Cache.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- Cache.java        27 Mar 2002 14:35:10 -0000      1.10
  +++ Cache.java        30 Mar 2002 07:24:19 -0000      1.11
  @@ -11,7 +11,7 @@
   
   /**
    * This is a cache that caches objects for reuse.
  - * Key and value are must not <code>null</code>.
  + * Key and value are must not be <code>null</code>.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Eung-ju Park</a>
    */
  @@ -70,15 +70,6 @@
        * @return the value removed. null if old value not exists
        */
       Object remove( Object key );
  -
  -    /**
  -     * Returns true if this cache contains a specified key.
  -     *
  -     * @param key key whose presence in this map is to be tested
  -     * @return true if matching item in the cache
  -     * @deprecated unnecessary
  -     */
  -    boolean containsKey( Object key );
   
       /**
        * Clear cache.
  
  
  
  1.8       +3 -2      
jakarta-avalon-excalibur/cache/src/java/org/apache/avalon/excalibur/cache/CacheStore.java
  
  Index: CacheStore.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon-excalibur/cache/src/java/org/apache/avalon/excalibur/cache/CacheStore.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- CacheStore.java   27 Mar 2002 14:35:10 -0000      1.7
  +++ CacheStore.java   30 Mar 2002 07:24:19 -0000      1.8
  @@ -9,6 +9,7 @@
   
   /**
    * Store cached objects.
  + * Key and value are must not be <code>null</code>.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Eung-ju Park</a>
    */
  @@ -35,8 +36,8 @@
       boolean isFull();
   
       /**
  -     * @param key must not null
  -     * @param value must not null
  +     * @param key
  +     * @param value
        */
       Object put( Object key, Object value );
   
  
  
  
  1.10      +15 -6     
jakarta-avalon-excalibur/cache/src/java/org/apache/avalon/excalibur/cache/DefaultCache.java
  
  Index: DefaultCache.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon-excalibur/cache/src/java/org/apache/avalon/excalibur/cache/DefaultCache.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- DefaultCache.java 16 Mar 2002 00:05:44 -0000      1.9
  +++ DefaultCache.java 30 Mar 2002 07:24:19 -0000      1.10
  @@ -37,6 +37,11 @@
   
       public Object put( final Object key, final Object value )
       {
  +        if ( null == key || null == value )
  +        {
  +            return null;
  +        }
  +
           final Object oldValue = remove( key );
   
           if( m_store.isFull() )
  @@ -53,6 +58,11 @@
   
       public Object get( final Object key )
       {
  +        if ( null == key )
  +        {
  +            return null;
  +        }
  +
           final Object value = m_store.get( key );
           m_policy.hit( key );
   
  @@ -61,8 +71,12 @@
   
       public Object remove( final Object key )
       {
  -        Object value = null;
  +        if ( null == key )
  +        {
  +            return null;
  +        }
   
  +        Object value = null;
           if( m_store.containsKey( key ) )
           {
               value = m_store.remove( key );
  @@ -71,11 +85,6 @@
           }
   
           return value;
  -    }
  -
  -    public boolean containsKey( final Object key )
  -    {
  -        return m_store.containsKey( key );
       }
   
       public void clear()
  
  
  
  1.3       +1 -9      
jakarta-avalon-excalibur/cache/src/java/org/apache/avalon/excalibur/cache/SynchronizedCache.java
  
  Index: SynchronizedCache.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon-excalibur/cache/src/java/org/apache/avalon/excalibur/cache/SynchronizedCache.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SynchronizedCache.java    16 Mar 2002 00:05:44 -0000      1.2
  +++ SynchronizedCache.java    30 Mar 2002 07:24:19 -0000      1.3
  @@ -68,19 +68,11 @@
           }
       }
   
  -    public Object remove( Object key )
  +    public Object remove( final Object key )
       {
           synchronized( m_cache )
           {
               return m_cache.remove( key );
  -        }
  -    }
  -
  -    public boolean containsKey( final Object key )
  -    {
  -        synchronized( m_cache )
  -        {
  -            return m_cache.containsKey( key );
           }
       }
   
  
  
  
  1.5       +1 -21     
jakarta-avalon-excalibur/cache/src/java/org/apache/avalon/excalibur/cache/ValidatingCache.java
  
  Index: ValidatingCache.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon-excalibur/cache/src/java/org/apache/avalon/excalibur/cache/ValidatingCache.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ValidatingCache.java      16 Mar 2002 00:05:44 -0000      1.4
  +++ ValidatingCache.java      30 Mar 2002 07:24:19 -0000      1.5
  @@ -79,29 +79,9 @@
           return value;
       }
   
  -    public Object remove( Object key )
  +    public Object remove( final Object key )
       {
           return m_cache.remove( key );
  -    }
  -
  -    public boolean containsKey( final Object key )
  -    {
  -        boolean contains = false;
  -
  -        if( m_cache.containsKey( key ) )
  -        {
  -            final Object value = m_cache.get( key );
  -            if( validate( key, value ) )
  -            {
  -                contains = true;
  -            }
  -            else
  -            {
  -                remove( key );
  -            }
  -        }
  -
  -        return contains;
       }
   
       public void clear()
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to