You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by co...@apache.org on 2002/05/20 05:36:09 UTC

cvs commit: jakarta-avalon-excalibur/cache/src/test/org/apache/excalibur/cache/impl/test AbstractCacheTestCase.java TimeMapLRUCacheTestCase.java LRUCacheTestCase.java

colus       02/05/19 20:36:09

  Modified:    cache/src/java/org/apache/excalibur/cache/impl
                        TimeMapLRUCache.java LRUCache.java
               cache/src/test/org/apache/excalibur/cache/impl/test
                        AbstractCacheTestCase.java
                        TimeMapLRUCacheTestCase.java LRUCacheTestCase.java
  Added:       cache/src/java/org/apache/excalibur/cache/impl
                        AbstractCache.java
  Removed:     cache/src/java/org/apache/excalibur/cache LRUCache.java
                        AbstractCache.java TimeMapLRUCache.java
                        DefaultCache.java
  Log:
  Seperate interfaces and implementations.
  
  Revision  Changes    Path
  1.3       +1 -2      jakarta-avalon-excalibur/cache/src/java/org/apache/excalibur/cache/impl/TimeMapLRUCache.java
  
  Index: TimeMapLRUCache.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/cache/src/java/org/apache/excalibur/cache/impl/TimeMapLRUCache.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TimeMapLRUCache.java	1 May 2002 04:01:32 -0000	1.2
  +++ TimeMapLRUCache.java	20 May 2002 03:36:09 -0000	1.3
  @@ -8,7 +8,6 @@
   package org.apache.excalibur.cache.impl;
   
   import org.apache.excalibur.cache.CacheStore;
  -import org.apache.excalibur.cache.DefaultCache;
   import org.apache.excalibur.cache.policy.TimeMapLRUPolicy;
   import org.apache.excalibur.cache.store.MemoryStore;
   
  @@ -16,7 +15,7 @@
    * TimeMapLRUCache.
    *
    * @author <a href="alag@users.sourceforge.net">Alexis Agahi</a>
  - * @version $Revision: 1.2 $ $Date: 2002/05/01 04:01:32 $
  + * @version $Revision: 1.3 $ $Date: 2002/05/20 03:36:09 $
    */
   public class TimeMapLRUCache
       extends DefaultCache
  
  
  
  1.3       +1 -2      jakarta-avalon-excalibur/cache/src/java/org/apache/excalibur/cache/impl/LRUCache.java
  
  Index: LRUCache.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/cache/src/java/org/apache/excalibur/cache/impl/LRUCache.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LRUCache.java	1 May 2002 04:01:32 -0000	1.2
  +++ LRUCache.java	20 May 2002 03:36:09 -0000	1.3
  @@ -8,7 +8,6 @@
   package org.apache.excalibur.cache.impl;
   
   import org.apache.excalibur.cache.CacheStore;
  -import org.apache.excalibur.cache.DefaultCache;
   import org.apache.excalibur.cache.policy.LRUPolicy;
   import org.apache.excalibur.cache.store.MemoryStore;
   
  @@ -16,7 +15,7 @@
    * LRUCache.
    *
    * @author <a href="mailto:colus@apache.org">Eung-ju Park</a>
  - * @version $Revision: 1.2 $ $Date: 2002/05/01 04:01:32 $
  + * @version $Revision: 1.3 $ $Date: 2002/05/20 03:36:09 $
    */
   public class LRUCache
       extends DefaultCache
  
  
  
  1.1                  jakarta-avalon-excalibur/cache/src/java/org/apache/excalibur/cache/impl/AbstractCache.java
  
  Index: AbstractCache.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included  with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.excalibur.cache.impl;
  
  import java.util.ArrayList;
  
  import org.apache.excalibur.cache.Cache;
  import org.apache.excalibur.cache.CacheEvent;
  import org.apache.excalibur.cache.CacheListener;
  
  /**
   * An abstract superclass for cache implementations.
   *
   * @author <a href="mailto:colus@apache.org">Eung-ju Park</a>
   * @author <a href="mailto:anryoshi@users.sf.net">Antti Koivunen</a>
   */
  public abstract class AbstractCache
      implements Cache
  {
      private ArrayList m_listeners;
  
      public AbstractCache()
      {
          m_listeners = new ArrayList();
      }
  
      public void addListener( final CacheListener listener )
      {
          m_listeners.add( listener );
      }
  
      public void removeListener( final CacheListener listener )
      {
          m_listeners.remove( listener );
      }
  
      protected void notifyAdded( final Object key, final Object value )
      {
          CacheEvent event = null;
  
          final int s = m_listeners.size();
          if( 0 < s )
          {
              event = new CacheEvent( this, key, value );
          }
          for( int i = 0; i < s; i++ )
          {
              ( (CacheListener)m_listeners.get( i ) ).added( event );
          }
      }
  
      protected void notifyRemoved( final Object key, final Object value )
      {
          CacheEvent event = null;
  
          final int s = m_listeners.size();
          if( 0 < s )
          {
              event = new CacheEvent( this, key, value );
          }
          for( int i = 0; i < s; i++ )
          {
              ( (CacheListener)m_listeners.get( i ) ).removed( event );
          }
      }
  }
  
  
  
  1.3       +49 -7     jakarta-avalon-excalibur/cache/src/test/org/apache/excalibur/cache/impl/test/AbstractCacheTestCase.java
  
  Index: AbstractCacheTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/cache/src/test/org/apache/excalibur/cache/impl/test/AbstractCacheTestCase.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AbstractCacheTestCase.java	1 May 2002 04:01:33 -0000	1.2
  +++ AbstractCacheTestCase.java	20 May 2002 03:36:09 -0000	1.3
  @@ -43,15 +43,57 @@
           }
       }
   
  -    public void testPutNull()
  +    public void testPutWithNullKeyValue()
       {
  -        m_cache.put( null, "VALUE" );
  -        assertEquals( 0, m_cache.size() );
  +        try
  +        {
  +            m_cache.put( null, "VALUE" );
  +            fail( "Null key accepted" );
  +        }
  +        catch ( final NullPointerException npe )
  +        {
  +        }
   
  -        m_cache.put( "KEY", null );
  -        assertEquals( 0, m_cache.size() );
  +        try
  +        {
  +            m_cache.put( "KEY", null );
  +            fail( "Null value accepted" );
  +        }
  +        catch ( final NullPointerException npe )
  +        {
  +        }
   
  -        m_cache.put( null, null );
  -        assertEquals( 0, m_cache.size() );
  +        try
  +        {
  +            m_cache.put( null, null );
  +            fail( "Null key and value accepted" );
  +        }
  +        catch ( final NullPointerException npe )
  +        {
  +        }
  +    }
  +    
  +    public void testGetWithNullKey()
  +    {
  +        try
  +        {
  +            m_cache.get( null );
  +            fail( "Invalid key accepted" );
  +        }
  +        catch ( final NullPointerException npe )
  +        {
  +        }
  +    }
  +
  +    public void testRemoveWithNullKey()
  +    {
  +        try
  +        {
  +            m_cache.remove( null );
  +            fail( "Invalid key accepted" );
  +        }
  +        catch ( final NullPointerException npe )
  +        {
  +        }
       }
   }
  
  
  
  1.3       +1 -1      jakarta-avalon-excalibur/cache/src/test/org/apache/excalibur/cache/impl/test/TimeMapLRUCacheTestCase.java
  
  Index: TimeMapLRUCacheTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/cache/src/test/org/apache/excalibur/cache/impl/test/TimeMapLRUCacheTestCase.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TimeMapLRUCacheTestCase.java	1 May 2002 04:01:33 -0000	1.2
  +++ TimeMapLRUCacheTestCase.java	20 May 2002 03:36:09 -0000	1.3
  @@ -8,7 +8,7 @@
   package org.apache.excalibur.cache.impl.test;
   
   import org.apache.excalibur.cache.Cache;
  -import org.apache.excalibur.cache.TimeMapLRUCache;
  +import org.apache.excalibur.cache.impl.TimeMapLRUCache;
   
   /**
    * TestCase for TimeMapLRUCache
  
  
  
  1.3       +1 -1      jakarta-avalon-excalibur/cache/src/test/org/apache/excalibur/cache/impl/test/LRUCacheTestCase.java
  
  Index: LRUCacheTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/cache/src/test/org/apache/excalibur/cache/impl/test/LRUCacheTestCase.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LRUCacheTestCase.java	1 May 2002 04:01:33 -0000	1.2
  +++ LRUCacheTestCase.java	20 May 2002 03:36:09 -0000	1.3
  @@ -7,7 +7,7 @@
    */
   package org.apache.excalibur.cache.impl.test;
   
  -import org.apache.excalibur.cache.LRUCache;
  +import org.apache.excalibur.cache.impl.LRUCache;
   
   /**
    * TestCase for LRUCache.
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>