svn commit: r722136 - in /jakarta/jcs/trunk: src/java/org/apache/jcs/access/behavior/ src/java/org/apache/jcs/auxiliary/ src/test/org/apache/jcs/auxiliary/remote/ src/test/org/apache/jcs/auxiliary/remote/server/ xdocs/

[email protected] Mon, 01 Dec 2008 17:07:21 -0000
Newsgroups gmane.comp.jakarta.turbine.jcs.devel
Message-ID <[email protected]>
Author: asmuts
Date: Mon Dec  1 09:07:21 2008
New Revision: 722136

URL: http://svn.apache.org/viewvc?rev=722136&view=rev
Log:
Fixed getMatching processing bug.

Modified:
    jakarta/jcs/trunk/src/java/org/apache/jcs/access/behavior/ICacheAccess.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/AbstractAuxiliaryCacheEventLogging.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/RemoteCacheUnitTest.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerUnitTest.java
    jakarta/jcs/trunk/xdocs/changes.xml

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/access/behavior/ICacheAccess.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/access/behavior/ICacheAccess.java?rev=722136&r1=722135&r2=722136&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/access/behavior/ICacheAccess.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/access/behavior/ICacheAccess.java Mon Dec  1 09:07:21 2008
@@ -19,6 +19,7 @@
  * under the License.
  */
 
+import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
 
@@ -41,6 +42,14 @@
     Object get( Object name );
 
     /**
+     * Retrieve matching objects from the cache region this instance provides access to.
+     * <p>
+     * @param pattern - a key pattern for the objects stored
+     * @return A map of key to values.  These are stripped from the wrapper.
+     */
+    HashMap getMatching( String pattern );
+    
+    /**
      * Puts in cache if an item does not exist with the name in that region.
      * <p>
      * @param name

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/AbstractAuxiliaryCacheEventLogging.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/AbstractAuxiliaryCacheEventLogging.java?rev=722136&r1=722135&r2=722136&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/AbstractAuxiliaryCacheEventLogging.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/AbstractAuxiliaryCacheEventLogging.java Mon Dec  1 09:07:21 2008
@@ -2,7 +2,6 @@
 
 import java.io.IOException;
 import java.io.Serializable;
-import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
 
@@ -172,8 +171,7 @@
     public Map getMatching( String pattern )
         throws IOException
     {
-        // do nothing
-        return new HashMap();
+        return getMatchingWithEventLogging( pattern );
     }
 
     /**
@@ -187,8 +185,7 @@
     protected final Map getMatchingWithEventLogging( String pattern )
         throws IOException
     {
-        ICacheEvent cacheEvent = createICacheEvent( getCacheName(), pattern,
-                                                    ICacheEventLogger.GETMATCHING_EVENT );
+        ICacheEvent cacheEvent = createICacheEvent( getCacheName(), pattern, ICacheEventLogger.GETMATCHING_EVENT );
         try
         {
             return processGetMatching( pattern );
@@ -209,7 +206,7 @@
      */
     protected abstract Map processGetMatching( String pattern )
         throws IOException;
-    
+
     /**
      * Removes the item from the cache. Wraps the remove in event logs.
      * <p>

Modified: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/RemoteCacheUnitTest.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/RemoteCacheUnitTest.java?rev=722136&r1=722135&r2=722136&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/RemoteCacheUnitTest.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/RemoteCacheUnitTest.java Mon Dec  1 09:07:21 2008
@@ -20,6 +20,7 @@
  */
 
 import java.util.HashSet;
+import java.util.Map;
 
 import junit.framework.TestCase;
 
@@ -235,4 +236,32 @@
         assertEquals( "Start should have been called.", 1, cacheEventLogger.startICacheEventCalls );
         assertEquals( "End should have been called.", 1, cacheEventLogger.endICacheEventCalls );
     }
+    
+    /**
+     * Verify event log calls.
+     * <p>
+     * @throws Exception
+     */
+    public void testGetMatching_simple()
+        throws Exception
+    {
+        // SETUP
+        String pattern = "adsfasdfasd.?";
+        IRemoteCacheAttributes cattr = new RemoteCacheAttributes();
+        MockRemoteCacheService service = new MockRemoteCacheService();
+        MockRemoteCacheListener listener = new MockRemoteCacheListener();
+
+        RemoteCache remoteCache = new RemoteCache( cattr, service, listener );
+
+        MockCacheEventLogger cacheEventLogger = new MockCacheEventLogger();
+        remoteCache.setCacheEventLogger( cacheEventLogger );
+
+        // DO WORK
+        Map result = remoteCache.getMatching( pattern );
+
+        // VERIFY
+        assertNotNull( "Should have a map", result );
+        assertEquals( "Start should have been called.", 1, cacheEventLogger.startICacheEventCalls );
+        assertEquals( "End should have been called.", 1, cacheEventLogger.endICacheEventCalls );
+    }
 }

Modified: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerUnitTest.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerUnitTest.java?rev=722136&r1=722135&r2=722136&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerUnitTest.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerUnitTest.java Mon Dec  1 09:07:21 2008
@@ -409,6 +409,30 @@
      * <p>
      * @throws Exception
      */
+    public void testGetMatching_simple()
+        throws Exception
+    {
+        // SETUP
+        IRemoteCacheServerAttributes rcsa = new RemoteCacheServerAttributes();
+        rcsa.setConfigFileName( "/TestRemoteCacheServer.ccf" );
+        RemoteCacheServer server = new RemoteCacheServer( rcsa );
+
+        MockCacheEventLogger cacheEventLogger = new MockCacheEventLogger();
+        server.setCacheEventLogger( cacheEventLogger );
+
+        // DO WORK
+        server.getMatching( "region", "pattern", 0 );
+
+        // VERIFY
+        assertEquals( "Start should have been called.", 1, cacheEventLogger.startICacheEventCalls );
+        assertEquals( "End should have been called.", 1, cacheEventLogger.endICacheEventCalls );
+    }
+    
+    /**
+     * Verify event log calls.
+     * <p>
+     * @throws Exception
+     */
     public void testGetMultiple_simple()
         throws Exception
     {

Modified: jakarta/jcs/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/xdocs/changes.xml?rev=722136&r1=722135&r2=722136&view=diff
==============================================================================
--- jakarta/jcs/trunk/xdocs/changes.xml (original)
+++ jakarta/jcs/trunk/xdocs/changes.xml Mon Dec  1 09:07:21 2008
@@ -21,6 +21,12 @@
 	<body>
 		<release version="1.4-dev" date="in SVN">
 		</release>
+		<release version="1.3.2.6" date="2008-12-01" description="tempbuild">
+			<action dev="asmuts" type="fix">Fixed balking bug in getMatching( String pattern ) API.
+			</action>
+			<action dev="asmuts" type="fix">Fixed event naming bug in getMatching( String pattern ) API.
+			</action>
+		</release>
 		<release version="1.3.2.5" date="2008-11-20" description="tempbuild">
 			<action dev="asmuts" type="update">Added a getMatching( String pattern ) API.
 			</action>