jakarta-jcs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asm...@apache.org
Subject svn commit: r685702 [5/5] - in /jakarta/jcs/trunk: ./ src/java/org/apache/jcs/auxiliary/ src/java/org/apache/jcs/auxiliary/disk/ src/java/org/apache/jcs/auxiliary/disk/block/ src/java/org/apache/jcs/auxiliary/disk/indexed/ src/java/org/apache/jcs/auxil...
Date Wed, 13 Aug 2008 22:14:48 GMT
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=685702&r1=685701&r2=685702&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
Wed Aug 13 15:14:46 2008
@@ -19,12 +19,14 @@
  * under the License.
  */
 
+import java.util.HashSet;
 import java.util.LinkedList;
 import java.util.List;
 
 import junit.framework.TestCase;
 
-import org.apache.jcs.auxiliary.remote.RemoteCacheListenerMockImpl;
+import org.apache.jcs.auxiliary.MockCacheEventLogger;
+import org.apache.jcs.auxiliary.remote.MockRemoteCacheListener;
 import org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheAttributes;
 import org.apache.jcs.auxiliary.remote.server.behavior.IRemoteCacheServerAttributes;
 import org.apache.jcs.engine.CacheElement;
@@ -39,9 +41,8 @@
 public class RemoteCacheServerUnitTest
     extends TestCase
 {
-
     /**
-     * Add a listner. Pass the id of 0, verify that the server sets a new listener id. Do
another
+     * Add a listener. Pass the id of 0, verify that the server sets a new listener id. Do
another
      * and verify that the second gets an id of 2.
      * <p>
      * @throws Exception
@@ -50,12 +51,17 @@
         throws Exception
     {
         // SETUP
+        String expectedIp1 = "adfasdf";
+        String expectedIp2 = "adsfadsafaf";
+
         IRemoteCacheServerAttributes rcsa = new RemoteCacheServerAttributes();
         rcsa.setConfigFileName( "/TestRemoteCacheServer.ccf" );
         RemoteCacheServer server = new RemoteCacheServer( rcsa );
 
-        RemoteCacheListenerMockImpl mockListener1 = new RemoteCacheListenerMockImpl();
-        RemoteCacheListenerMockImpl mockListener2 = new RemoteCacheListenerMockImpl();
+        MockRemoteCacheListener mockListener1 = new MockRemoteCacheListener();
+        mockListener1.localAddress = expectedIp1;
+        MockRemoteCacheListener mockListener2 = new MockRemoteCacheListener();
+        mockListener2.localAddress = expectedIp2;
 
         String cacheName = "testAddListener";
 
@@ -66,6 +72,8 @@
         // VERIFY
         assertEquals( "Wrong listener id.", 1, mockListener1.getListenerId() );
         assertEquals( "Wrong listener id.", 2, mockListener2.getListenerId() );
+        assertEquals( "Wrong ip.", expectedIp1, server.getIPAddressForRequesterId( 1 ) );
+        assertEquals( "Wrong ip.", expectedIp2, server.getIPAddressForRequesterId( 2 ) );
     }
 
     /**
@@ -82,8 +90,8 @@
         rcsa.setConfigFileName( "/TestRemoteCacheServer.ccf" );
         RemoteCacheServer server = new RemoteCacheServer( rcsa );
 
-        RemoteCacheListenerMockImpl mockListener1 = new RemoteCacheListenerMockImpl();
-        RemoteCacheListenerMockImpl mockListener2 = new RemoteCacheListenerMockImpl();
+        MockRemoteCacheListener mockListener1 = new MockRemoteCacheListener();
+        MockRemoteCacheListener mockListener2 = new MockRemoteCacheListener();
 
         // DO WORK
         // don't specify the cache name
@@ -96,7 +104,7 @@
     }
 
     /**
-     * Add a listner. Pass the id of 0, verify that the server sets a new listener id. Do
another
+     * Add a listener. Pass the id of 0, verify that the server sets a new listener id. Do
another
      * and verify that the second gets an id of 2. Call remove Listener and verify that it
is
      * removed.
      * <p>
@@ -110,8 +118,8 @@
         rcsa.setConfigFileName( "/TestRemoteCacheServer.ccf" );
         RemoteCacheServer server = new RemoteCacheServer( rcsa );
 
-        RemoteCacheListenerMockImpl mockListener1 = new RemoteCacheListenerMockImpl();
-        RemoteCacheListenerMockImpl mockListener2 = new RemoteCacheListenerMockImpl();
+        MockRemoteCacheListener mockListener1 = new MockRemoteCacheListener();
+        MockRemoteCacheListener mockListener2 = new MockRemoteCacheListener();
 
         String cacheName = "testAddListenerToAllThenRemove";
 
@@ -144,9 +152,9 @@
         rcsa.setConfigFileName( "/TestRemoteCacheServer.ccf" );
         RemoteCacheServer server = new RemoteCacheServer( rcsa );
 
-        RemoteCacheListenerMockImpl mockListener1 = new RemoteCacheListenerMockImpl();
+        MockRemoteCacheListener mockListener1 = new MockRemoteCacheListener();
         mockListener1.remoteType = IRemoteCacheServerAttributes.CLUSTER;
-        RemoteCacheListenerMockImpl mockListener2 = new RemoteCacheListenerMockImpl();
+        MockRemoteCacheListener mockListener2 = new MockRemoteCacheListener();
         mockListener2.remoteType = IRemoteCacheServerAttributes.CLUSTER;
 
         String cacheName = "testAddListenerToAllThenRemove";
@@ -164,6 +172,7 @@
         // DO WORK
         server.removeCacheListener( cacheName, mockListener1.getListenerId() );
         assertEquals( "Wrong number of listeners.", 1, server.getClusterListeners( cacheName
).eventQMap.size() );
+        assertNull( "Should be no entry in the ip map.", server.getIPAddressForRequesterId(
1 ) );
     }
 
     /**
@@ -178,7 +187,7 @@
         IRemoteCacheServerAttributes rcsa = new RemoteCacheServerAttributes();
         rcsa.setConfigFileName( "/TestRemoteCacheServer.ccf" );
 
-        RemoteCacheListenerMockImpl mockListener = new RemoteCacheListenerMockImpl();
+        MockRemoteCacheListener mockListener = new MockRemoteCacheListener();
         RemoteCacheServer server = new RemoteCacheServer( rcsa );
 
         String cacheName = "testSimpleRegisterListenerAndPut";
@@ -224,11 +233,11 @@
         RemoteCacheServer server = new RemoteCacheServer( rcsa );
 
         // this is to get the listenr id for inserts.
-        RemoteCacheListenerMockImpl clusterListener = new RemoteCacheListenerMockImpl();
+        MockRemoteCacheListener clusterListener = new MockRemoteCacheListener();
         clusterListener.remoteType = IRemoteCacheAttributes.CLUSTER;
 
         // this should get the updates
-        RemoteCacheListenerMockImpl localListener = new RemoteCacheListenerMockImpl();
+        MockRemoteCacheListener localListener = new MockRemoteCacheListener();
         localListener.remoteType = IRemoteCacheAttributes.LOCAL;
 
         String cacheName = "testSimpleRegisterListenerAndPut_FromClusterWithLCC";
@@ -271,7 +280,7 @@
         IRemoteCacheServerAttributes rcsa = new RemoteCacheServerAttributes();
         rcsa.setConfigFileName( "/TestRemoteCacheServer.ccf" );
 
-        RemoteCacheListenerMockImpl mockListener = new RemoteCacheListenerMockImpl();
+        MockRemoteCacheListener mockListener = new MockRemoteCacheListener();
         RemoteCacheServer server = new RemoteCacheServer( rcsa );
 
         String cacheName = "testSimpleRegisterListenerAndPut";
@@ -298,4 +307,125 @@
         }
     }
 
+    /**
+     * Verify event log calls.
+     * <p>
+     * @throws Exception
+     */
+    public void testUpdate_simple()
+        throws Exception
+    {
+        // SETUP
+        IRemoteCacheServerAttributes rcsa = new RemoteCacheServerAttributes();
+        rcsa.setConfigFileName( "/TestRemoteCacheServer.ccf" );
+        RemoteCacheServer server = new RemoteCacheServer( rcsa );
+
+        MockCacheEventLogger cacheEventLogger = new MockCacheEventLogger();
+        server.setCacheEventLogger( cacheEventLogger );
+
+        ICacheElement item = new CacheElement( "region", "key", "value" );
+
+        // DO WORK
+        server.update( item );
+
+        // 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 testGet_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.get( "region", "key" );
+
+        // 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
+    {
+        // SETUP
+        IRemoteCacheServerAttributes rcsa = new RemoteCacheServerAttributes();
+        rcsa.setConfigFileName( "/TestRemoteCacheServer.ccf" );
+        RemoteCacheServer server = new RemoteCacheServer( rcsa );
+
+        MockCacheEventLogger cacheEventLogger = new MockCacheEventLogger();
+        server.setCacheEventLogger( cacheEventLogger );
+
+        // DO WORK
+        server.getMultiple( "region", new HashSet() );
+
+        // 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 testRemove_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.remove( "region", "key" );
+
+        // 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 testRemoveAll_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.remove( "region", "key" );
+
+        // VERIFY
+        assertEquals( "Start should have been called.", 1, cacheEventLogger.startICacheEventCalls
);
+        assertEquals( "End should have been called.", 1, cacheEventLogger.endICacheEventCalls
);
+    }    
 }

Added: jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/CompositeCacheConfiguratorUnitTest.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/CompositeCacheConfiguratorUnitTest.java?rev=685702&view=auto
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/CompositeCacheConfiguratorUnitTest.java
(added)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/CompositeCacheConfiguratorUnitTest.java
Wed Aug 13 15:14:46 2008
@@ -0,0 +1,116 @@
+package org.apache.jcs.engine.control;
+
+import java.util.Properties;
+
+import junit.framework.TestCase;
+
+/** Unit tests for the configurator. */
+public class CompositeCacheConfiguratorUnitTest
+    extends TestCase
+{
+    /**
+     * Verify that we don't get an error.
+     */
+    public void testParseCacheEventLogger_Null()
+    {
+        // SETUP
+        Properties props = new Properties();
+
+        CompositeCacheConfigurator configurator = new CompositeCacheConfigurator( CompositeCacheManager
+            .getUnconfiguredInstance() );
+
+        // DO WORK
+        MockCacheEventLogger result = (MockCacheEventLogger) configurator.parseCacheEventLogger(
props, "junk" );
+
+        // VERIFY
+        assertNull( "Should not have a logger.", result );
+    }
+
+    /**
+     * Verify that we don't get an error.
+     */
+    public void testParseCacheEventLogger_NullName()
+    {
+        // SETUP
+        Properties props = new Properties();
+
+        CompositeCacheConfigurator configurator = new CompositeCacheConfigurator( CompositeCacheManager
+            .getUnconfiguredInstance() );
+
+        // DO WORK
+        MockCacheEventLogger result = (MockCacheEventLogger) configurator.parseCacheEventLogger(
props, null );
+
+        // VERIFY
+        assertNull( "Should not have a logger.", result );
+    }
+
+    /**
+     * Verify that we can parse the event logger.
+     */
+    public void testParseCacheEventLogger_Normal()
+    {
+        // SETUP
+        String auxName = "MYAux";
+        String testPropertyValue = "This is the value";
+        String className = MockCacheEventLogger.class.getCanonicalName();
+
+        Properties props = new Properties();
+        props.put( "jcs.auxiliary." + auxName + CompositeCacheConfigurator.CACHE_EVENT_LOGGER_PREFIX,
className );
+        props.put( "jcs.auxiliary." + auxName + CompositeCacheConfigurator.CACHE_EVENT_LOGGER_PREFIX
+            + CompositeCacheConfigurator.ATTRIBUTE_PREFIX + ".testProperty", testPropertyValue
);
+
+        CompositeCacheConfigurator configurator = new CompositeCacheConfigurator( CompositeCacheManager
+            .getUnconfiguredInstance() );
+
+        // DO WORK
+        MockCacheEventLogger result = (MockCacheEventLogger) configurator.parseCacheEventLogger(
props, auxName );
+
+        // VERIFY
+        assertNotNull( "Should have a logger.", result );
+        assertEquals( "Property should be set.", testPropertyValue, result.getTestProperty()
);
+    }
+
+    /**
+     * Verify that we can parse the ElementSerializer.
+     */
+    public void testParseElementSerializer_Normal()
+    {
+        // SETUP
+        String auxName = "MYAux";
+        String testPropertyValue = "This is the value";
+        String className = MockElementSerializer.class.getCanonicalName();
+
+        Properties props = new Properties();
+        props.put( "jcs.auxiliary." + auxName + CompositeCacheConfigurator.SERIALIZER_PREFIX,
className );
+        props.put( "jcs.auxiliary." + auxName + CompositeCacheConfigurator.SERIALIZER_PREFIX
+            + CompositeCacheConfigurator.ATTRIBUTE_PREFIX + ".testProperty", testPropertyValue
);
+
+        CompositeCacheConfigurator configurator = new CompositeCacheConfigurator( CompositeCacheManager
+            .getUnconfiguredInstance() );
+
+        // DO WORK
+        MockElementSerializer result = (MockElementSerializer) configurator.parseElementSerializer(
props, auxName );
+
+        // VERIFY
+        assertNotNull( "Should have a logger.", result );
+        assertEquals( "Property should be set.", testPropertyValue, result.getTestProperty()
);
+    }
+
+    /**
+     * Verify that we can parse the ElementSerializer.
+     */
+    public void testParseElementSerializer_Null()
+    {
+        // SETUP
+        Properties props = new Properties();
+
+        CompositeCacheConfigurator configurator = new CompositeCacheConfigurator( CompositeCacheManager
+            .getUnconfiguredInstance() );
+
+        // DO WORK
+        MockElementSerializer result = (MockElementSerializer) configurator.parseElementSerializer(
props, "junk" );
+
+        // VERIFY
+        assertNull( "Should not have a logger.", result );
+    }
+}

Modified: jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/CompositeCacheDiskUsageUnitTest.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/CompositeCacheDiskUsageUnitTest.java?rev=685702&r1=685701&r2=685702&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/CompositeCacheDiskUsageUnitTest.java
(original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/CompositeCacheDiskUsageUnitTest.java
Wed Aug 13 15:14:46 2008
@@ -35,8 +35,10 @@
 import org.apache.jcs.engine.CompositeCacheAttributes;
 import org.apache.jcs.engine.ElementAttributes;
 import org.apache.jcs.engine.behavior.ICacheElement;
+import org.apache.jcs.engine.behavior.ICacheEventLogger;
 import org.apache.jcs.engine.behavior.ICompositeCacheAttributes;
 import org.apache.jcs.engine.behavior.IElementAttributes;
+import org.apache.jcs.engine.behavior.IElementSerializer;
 import org.apache.jcs.engine.stats.behavior.IStats;
 
 /**
@@ -460,6 +462,18 @@
         {
             return null;
         }
+
+        public void setCacheEventLogger( ICacheEventLogger cacheEventLogger )
+        {
+            // TODO Auto-generated method stub
+            
+        }
+
+        public void setElementSerializer( IElementSerializer elementSerializer )
+        {
+            // TODO Auto-generated method stub
+            
+        }
     }
 
 }

Modified: jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/CompositeCacheUnitTest.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/CompositeCacheUnitTest.java?rev=685702&r1=685701&r2=685702&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/CompositeCacheUnitTest.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/CompositeCacheUnitTest.java Wed
Aug 13 15:14:46 2008
@@ -24,7 +24,7 @@
 import junit.framework.TestCase;
 
 import org.apache.jcs.auxiliary.AuxiliaryCache;
-import org.apache.jcs.auxiliary.AuxiliaryCacheMockImpl;
+import org.apache.jcs.auxiliary.MockAuxiliaryCache;
 import org.apache.jcs.engine.CacheElement;
 import org.apache.jcs.engine.CompositeCacheAttributes;
 import org.apache.jcs.engine.ElementAttributes;
@@ -32,7 +32,7 @@
 import org.apache.jcs.engine.behavior.ICacheElement;
 import org.apache.jcs.engine.behavior.ICompositeCacheAttributes;
 import org.apache.jcs.engine.behavior.IElementAttributes;
-import org.apache.jcs.engine.memory.MemoryCacheMockImpl;
+import org.apache.jcs.engine.memory.MockMemoryCache;
 
 /**
  * Tests that directly engage the composite cache.
@@ -53,7 +53,7 @@
     {
         // SETUP
         String cacheName = "testCacheName";
-        String mockMemoryCacheClassName = "org.apache.jcs.engine.memory.MemoryCacheMockImpl";
+        String mockMemoryCacheClassName = "org.apache.jcs.engine.memory.MockMemoryCache";
         ICompositeCacheAttributes cattr = new CompositeCacheAttributes();
         cattr.setMemoryCacheName( mockMemoryCacheClassName );
 
@@ -61,7 +61,7 @@
 
         CompositeCache cache = new CompositeCache( cacheName, cattr, attr );
 
-        AuxiliaryCacheMockImpl diskMock = new AuxiliaryCacheMockImpl();
+        MockAuxiliaryCache diskMock = new MockAuxiliaryCache();
         diskMock.cacheType = ICache.DISK_CACHE;
         AuxiliaryCache[] aux = new AuxiliaryCache[] { diskMock };
         cache.setAuxCaches( aux );
@@ -77,7 +77,7 @@
         cache.dispose();
 
         // VERIFY
-        MemoryCacheMockImpl memoryCache = (MemoryCacheMockImpl) cache.getMemoryCache();
+        MockMemoryCache memoryCache = (MockMemoryCache) cache.getMemoryCache();
         assertEquals( "Wrong number freed.", numToInsert, memoryCache.lastNumberOfFreedElements
);
     }
 
@@ -92,7 +92,7 @@
     {
         // SETUP
         String cacheName = "testCacheName";
-        String mockMemoryCacheClassName = "org.apache.jcs.engine.memory.MemoryCacheMockImpl";
+        String mockMemoryCacheClassName = "org.apache.jcs.engine.memory.MockMemoryCache";
         ICompositeCacheAttributes cattr = new CompositeCacheAttributes();
         cattr.setMemoryCacheName( mockMemoryCacheClassName );
 
@@ -100,7 +100,7 @@
 
         CompositeCache cache = new CompositeCache( cacheName, cattr, attr );
 
-        AuxiliaryCacheMockImpl diskMock = new AuxiliaryCacheMockImpl();
+        MockAuxiliaryCache diskMock = new MockAuxiliaryCache();
         diskMock.cacheType = ICache.REMOTE_CACHE;
         AuxiliaryCache[] aux = new AuxiliaryCache[] { diskMock };
         cache.setAuxCaches( aux );
@@ -116,7 +116,7 @@
         cache.dispose();
 
         // VERIFY
-        MemoryCacheMockImpl memoryCache = (MemoryCacheMockImpl) cache.getMemoryCache();
+        MockMemoryCache memoryCache = (MockMemoryCache) cache.getMemoryCache();
         assertEquals( "Wrong number freed.", 0, memoryCache.lastNumberOfFreedElements );
     }
 }

Added: jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/MockCacheEventLogger.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/MockCacheEventLogger.java?rev=685702&view=auto
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/MockCacheEventLogger.java (added)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/MockCacheEventLogger.java Wed
Aug 13 15:14:46 2008
@@ -0,0 +1,139 @@
+package org.apache.jcs.engine.control;
+
+import java.io.Serializable;
+
+import org.apache.jcs.engine.behavior.ICacheElement;
+import org.apache.jcs.engine.behavior.ICacheEventLogger;
+
+/**
+ * For testing the configurator.
+ */
+public class MockCacheEventLogger
+    implements ICacheEventLogger
+{
+    /** test property */
+    private String testProperty;
+
+    /**
+     * @param source
+     * @param eventName
+     * @param optionalDetails
+     */
+    public void logApplicationEvent( String source, String eventName, String optionalDetails
)
+    {
+        // TODO Auto-generated method stub            
+    }
+
+    /**
+     * @param source
+     * @param region
+     * @param eventName
+     * @param optionalDetails
+     * @param key
+     */
+    public void logEndICacheEvent( String source, String region, String eventName, String
optionalDetails,
+                                   Serializable key )
+    {
+        // TODO Auto-generated method stub            
+    }
+
+    /**
+     * @param source
+     * @param region
+     * @param eventName
+     * @param optionalDetails
+     * @param item
+     */
+    public void logEndICacheEvent( String source, String region, String eventName, String
optionalDetails,
+                                   ICacheElement item )
+    {
+        // TODO Auto-generated method stub            
+    }
+
+    /**
+     * @param source
+     * @param eventName
+     * @param errorMessage
+     */
+    public void logError( String source, String eventName, String errorMessage )
+    {
+        // TODO Auto-generated method stub            
+    }
+
+    /**
+     * @param source
+     * @param region
+     * @param eventName
+     * @param errorMessage
+     */
+    public void logError( String source, String region, String eventName, String errorMessage
)
+    {
+        // TODO Auto-generated method stub            
+    }
+
+    /**
+     * @param source
+     * @param region
+     * @param eventName
+     * @param errorMessage
+     * @param item
+     */
+    public void logError( String source, String region, String eventName, String errorMessage,
ICacheElement item )
+    {
+        // TODO Auto-generated method stub            
+    }
+
+    /**
+     * @param source
+     * @param region
+     * @param eventName
+     * @param errorMessage
+     * @param key
+     */
+    public void logError( String source, String region, String eventName, String errorMessage,
Serializable key )
+    {
+        // TODO Auto-generated method stub            
+    }
+
+    /**
+     * @param source
+     * @param region
+     * @param eventName
+     * @param optionalDetails
+     * @param key
+     */
+    public void logStartICacheEvent( String source, String region, String eventName, String
optionalDetails,
+                                     Serializable key )
+    {
+        // TODO Auto-generated method stub            
+    }
+
+    /**
+     * @param source
+     * @param region
+     * @param eventName
+     * @param optionalDetails
+     * @param item
+     */
+    public void logStartICacheEvent( String source, String region, String eventName, String
optionalDetails,
+                                     ICacheElement item )
+    {
+        // TODO Auto-generated method stub
+    }
+
+    /**
+     * @param testProperty
+     */
+    public void setTestProperty( String testProperty )
+    {
+        this.testProperty = testProperty;
+    }
+
+    /**
+     * @return testProperty
+     */
+    public String getTestProperty()
+    {
+        return testProperty;
+    }
+}
\ No newline at end of file

Copied: jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/MockCompositeCacheManager.java
(from r682483, jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/CompositeCacheManagerMockImpl.java)
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/MockCompositeCacheManager.java?p2=jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/MockCompositeCacheManager.java&p1=jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/CompositeCacheManagerMockImpl.java&r1=682483&r2=685702&rev=685702&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/CompositeCacheManagerMockImpl.java
(original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/MockCompositeCacheManager.java
Wed Aug 13 15:14:46 2008
@@ -25,7 +25,7 @@
 
 /**
  */
-public class CompositeCacheManagerMockImpl
+public class MockCompositeCacheManager
     implements ICompositeCacheManager
 {
 

Propchange: jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/MockCompositeCacheManager.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Added: jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/MockElementSerializer.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/MockElementSerializer.java?rev=685702&view=auto
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/MockElementSerializer.java (added)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/MockElementSerializer.java Wed
Aug 13 15:14:46 2008
@@ -0,0 +1,58 @@
+package org.apache.jcs.engine.control;
+
+import java.io.IOException;
+import java.io.Serializable;
+
+import org.apache.jcs.engine.behavior.IElementSerializer;
+import org.apache.jcs.utils.serialization.StandardSerializer;
+
+/** For mocking. */
+public class MockElementSerializer
+    implements IElementSerializer
+{
+    /** test property */
+    private String testProperty;
+    
+    private StandardSerializer serializer = new StandardSerializer();    
+    
+    /**
+     * @param bytes 
+     * @return Object
+     * @throws IOException 
+     * @throws ClassNotFoundException 
+     * 
+     */
+    public Object deSerialize( byte[] bytes )
+        throws IOException, ClassNotFoundException
+    {
+        return serializer.deSerialize( bytes );
+    }
+
+    /**
+     * @param obj 
+     * @return byte[]
+     * @throws IOException 
+     * 
+     */
+    public byte[] serialize( Serializable obj )
+        throws IOException
+    {
+        return serializer.serialize( obj );
+    }
+    
+    /**
+     * @param testProperty
+     */
+    public void setTestProperty( String testProperty )
+    {
+        this.testProperty = testProperty;
+    }
+
+    /**
+     * @return testProperty
+     */
+    public String getTestProperty()
+    {
+        return testProperty;
+    }    
+}

Copied: jakarta/jcs/trunk/src/test/org/apache/jcs/engine/memory/MockMemoryCache.java (from
r682483, jakarta/jcs/trunk/src/test/org/apache/jcs/engine/memory/MemoryCacheMockImpl.java)
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/engine/memory/MockMemoryCache.java?p2=jakarta/jcs/trunk/src/test/org/apache/jcs/engine/memory/MockMemoryCache.java&p1=jakarta/jcs/trunk/src/test/org/apache/jcs/engine/memory/MemoryCacheMockImpl.java&r1=682483&r2=685702&rev=685702&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/engine/memory/MemoryCacheMockImpl.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/engine/memory/MockMemoryCache.java Wed Aug 13
15:14:46 2008
@@ -37,7 +37,7 @@
  * <p>
  * @author Aaron Smuts
  */
-public class MemoryCacheMockImpl
+public class MockMemoryCache
     implements MemoryCache
 {
     private ICompositeCacheAttributes cacheAttr;

Propchange: jakarta/jcs/trunk/src/test/org/apache/jcs/engine/memory/MockMemoryCache.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Modified: jakarta/jcs/trunk/src/test/org/apache/jcs/engine/memory/shrinking/ShrinkerThreadUnitTest.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/engine/memory/shrinking/ShrinkerThreadUnitTest.java?rev=685702&r1=685701&r2=685702&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/engine/memory/shrinking/ShrinkerThreadUnitTest.java
(original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/engine/memory/shrinking/ShrinkerThreadUnitTest.java
Wed Aug 13 15:14:46 2008
@@ -26,7 +26,7 @@
 import org.apache.jcs.engine.ElementAttributes;
 import org.apache.jcs.engine.behavior.ICacheElement;
 import org.apache.jcs.engine.control.event.ElementEventHandlerMockImpl;
-import org.apache.jcs.engine.memory.MemoryCacheMockImpl;
+import org.apache.jcs.engine.memory.MockMemoryCache;
 
 /**
  * This tests the functionality of the shrinker thread.
@@ -48,7 +48,7 @@
     public void testSimpleShrink()
         throws Exception
     {
-        MemoryCacheMockImpl memory = new MemoryCacheMockImpl();
+        MockMemoryCache memory = new MockMemoryCache();
 
         CompositeCacheAttributes cacheAttr = new CompositeCacheAttributes();
         cacheAttr.setMaxMemoryIdleTimeSeconds( 1 );
@@ -92,7 +92,7 @@
     public void testSimpleShrinkMutiple()
         throws Exception
     {
-        MemoryCacheMockImpl memory = new MemoryCacheMockImpl();
+        MockMemoryCache memory = new MockMemoryCache();
 
         CompositeCacheAttributes cacheAttr = new CompositeCacheAttributes();
         cacheAttr.setMaxMemoryIdleTimeSeconds( 1 );
@@ -141,7 +141,7 @@
     public void testSimpleShrinkMutipleWithEventHandler()
     throws Exception
 {
-    MemoryCacheMockImpl memory = new MemoryCacheMockImpl();
+    MockMemoryCache memory = new MockMemoryCache();
 
     CompositeCacheAttributes cacheAttr = new CompositeCacheAttributes();
     cacheAttr.setMaxMemoryIdleTimeSeconds( 1 );

Modified: jakarta/jcs/trunk/src/test/org/apache/jcs/utils/serialization/SerializationConversionUtilUnitTest.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/utils/serialization/SerializationConversionUtilUnitTest.java?rev=685702&r1=685701&r2=685702&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/utils/serialization/SerializationConversionUtilUnitTest.java
(original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/utils/serialization/SerializationConversionUtilUnitTest.java
Wed Aug 13 15:14:46 2008
@@ -32,22 +32,21 @@
 
 /**
  * Tests the serialization conversion util.
- *
+ *<p>
  * @author Aaron Smuts
- *
  */
 public class SerializationConversionUtilUnitTest
     extends TestCase
 {
-
     /**
      * Verify that we can go back and forth with the simplest of objects.
-     *
+     *<p>
      * @throws Exception
      */
     public void testSimpleConversion()
         throws Exception
     {
+        // SETUP
         String cacheName = "testName";
         String key = "key";
         String value = "value fdsadf dsafdsa fdsaf dsafdsaf dsafdsaf dsaf dsaf dsaf dsafa
dsaf dsaf dsafdsaf";
@@ -60,29 +59,34 @@
         ICacheElement before = new CacheElement( cacheName, key, value );
         before.setElementAttributes( attr );
 
+        // DO WORK
         ICacheElementSerialized serialized = SerializationConversionUtil.getSerializedCacheElement(
before,
                                                                                         
           elementSerializer );
+
+        // VERIFY
         assertNotNull( "Should have a serialized object.", serialized );
         System.out.println( "testSimpleConversion, " + serialized );
 
+        // DO WORK
         ICacheElement after = SerializationConversionUtil.getDeSerializedCacheElement( serialized,
elementSerializer );
 
+        // VERIFY
         assertNotNull( "Should have a deserialized object.", after );
         assertEquals( "Values should be the same.", before.getVal(), after.getVal() );
         assertEquals( "Attributes should be the same.", before.getElementAttributes().getMaxLifeSeconds(),
after
             .getElementAttributes().getMaxLifeSeconds() );
         assertEquals( "Keys should be the same.", before.getKey(), after.getKey() );
         assertEquals( "Cache name should be the same.", before.getCacheName(), after.getCacheName()
);
-
     }
 
     /**
      * Verify that we get an IOException for a null serializer.
-     *
+     * <p>
      * @throws Exception
      */
     public void testNullSerializerConversion()
     {
+        // SETUP
         String cacheName = "testName";
         String key = "key";
         String value = "value fdsadf dsafdsa fdsaf dsafdsaf dsafdsaf dsaf dsaf dsaf dsafa
dsaf dsaf dsafdsaf";
@@ -95,16 +99,17 @@
         ICacheElement before = new CacheElement( cacheName, key, value );
         before.setElementAttributes( attr );
 
+        // DO WORK
         try
         {
             SerializationConversionUtil.getSerializedCacheElement( before, elementSerializer
);
+
+            // VERIFY
             fail( "We should have received an IOException." );
         }
         catch ( IOException e )
         {
             // expected
         }
-
     }
-
 }

Modified: jakarta/jcs/trunk/src/test/org/apache/jcs/utils/serialization/StandardSerializerUnitTest.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/utils/serialization/StandardSerializerUnitTest.java?rev=685702&r1=685701&r2=685702&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/utils/serialization/StandardSerializerUnitTest.java
(original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/utils/serialization/StandardSerializerUnitTest.java
Wed Aug 13 15:14:46 2008
@@ -23,54 +23,53 @@
 
 /**
  * Tests the standard serializer.
- *
+ *<p>
  * @author Aaron Smuts
- *
  */
 public class StandardSerializerUnitTest
     extends TestCase
 {
-
     /**
      * Test simple back and forth with a string.
-     *
+     *<p>
      * @throws Exception
-     *
      */
     public void testSimpleBackAndForth()
         throws Exception
     {
+        // SETUP
         StandardSerializer serializer = new StandardSerializer();
 
         String before = "adsfdsafdsafdsafdsafdsafdsafdsagfdsafdsafdsfdsafdsafsa333 31231";
 
+        // DO WORK
         String after = (String) serializer.deSerialize( serializer.serialize( before ) );
 
+        // VERIFY
         assertEquals( "Before and after should be the same.", before, after );
     }
 
     /**
-     * Test serialization with a null object.  Verify that we don't get an error.
-     *
+     * Test serialization with a null object. Verify that we don't get an error.
+     *<p>
      * @throws Exception
-     *
      */
     public void testNullInput()
         throws Exception
     {
+        // SETUP
         StandardSerializer serializer = new StandardSerializer();
 
         String before = null;
 
+        // DO WORK
         byte[] serialized = serializer.serialize( before );
-
-        System.out.println( "testNullInput " + serialized );
+        //System.out.println( "testNullInput " + serialized );
 
         String after = (String) serializer.deSerialize( serialized );
+        //System.out.println( "testNullInput " + after );
 
-        System.out.println( "testNullInput " + after );
-
+        // VERIFY
         assertNull( "Should have nothing.", after );
-
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: jcs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jcs-dev-help@jakarta.apache.org


Mime
View raw message