Author: asmuts
Date: Wed Nov  9 17:55:39 2005
New Revision: 332196

URL: http://svn.apache.org/viewcvs?rev=332196&view=rev
Log:
added an additional test for tcp lateral

Modified:
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/hsql/HSQLCache.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/engine/CacheElement.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/utils/access/JCSWorker.java
    
jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/TestTCPLateral.java

Modified: 
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/hsql/HSQLCache.java
URL: 
http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/hsql/HSQLCache.java?rev=332196&r1=332195&r2=332196&view=diff
==============================================================================
--- 
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/hsql/HSQLCache.java 
(original)
+++ 
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/hsql/HSQLCache.java 
Wed Nov  9 17:55:39 2005
@@ -74,7 +74,7 @@
 
         this.cattr = cattr;
 
-        String rafroot = cattr.getDiskPath();
+        String rafroot = this.cattr.getDiskPath();
 
         numInstances++;
 

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/engine/CacheElement.java
URL: 
http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/java/org/apache/jcs/engine/CacheElement.java?rev=332196&r1=332195&r2=332196&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/engine/CacheElement.java 
(original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/engine/CacheElement.java Wed Nov  
9 17:55:39 2005
@@ -129,13 +129,21 @@
         return this.attr;
     }
 
-    /** Description of the Method */
+    /**
+     * @return a hash of the key only
+     * 
+     */
     public int hashCode()
     {
         return key.hashCode();
     }
 
-    /** Description of the Method */
+    /**
+     * For debuggin only.
+     * 
+     * @return String representation
+     *  
+     */
     public String toString()
     {
         return "[cacheName=" + cacheName + ", key=" + key + ", val=" + val + 
", attr = " + attr + "]";

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/utils/access/JCSWorker.java
URL: 
http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/java/org/apache/jcs/utils/access/JCSWorker.java?rev=332196&r1=332195&r2=332196&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/utils/access/JCSWorker.java 
(original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/utils/access/JCSWorker.java Wed 
Nov  9 17:55:39 2005
@@ -101,12 +101,8 @@
     /**
      * Constructor which takes a region for the JCS cache.
      * 
-     * @param aName
+     * @param aRegion
      *            The Region to use for the JCS cache.
-     * @param aKey
-     *            The key to store the result under.
-     * @param aGroup
-     *            The group to store the result under.
      */
     public JCSWorker( final String aRegion )
     {
@@ -191,6 +187,9 @@
      * work and subsequent calls to a CachedWorker with identical
      * region/key/group will wait on the results of this call. It will call the
      * JCSWorkerHelper.doWork() if the cache misses, and will put the result.
+     * @param aKey
+     * @param aGroup
+     * @param aHelper
      * 
      * @return Either the result of doing the work, or the cached result.
      * @throws Exception
@@ -201,8 +200,8 @@
         throws Exception
     {
         Object result = null;
-        long start = 0;
-        long dbTime = 0;
+        //long start = 0;
+        //long dbTime = 0;
         JCSWorkerHelper helper = null;
 
         synchronized ( map )

Modified: 
jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/TestTCPLateral.java
URL: 
http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/TestTCPLateral.java?rev=332196&r1=332195&r2=332196&view=diff
==============================================================================
--- 
jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/TestTCPLateral.java
 (original)
+++ 
jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/TestTCPLateral.java
 Wed Nov  9 17:55:39 2005
@@ -155,4 +155,45 @@
         assertEquals( "Didn't get the correct object", element2.getVal(), 
cacheElement.getVal() );
     }
 
+    
+    /**
+     * Send objects with the same key but different values.
+     * @throws Exception
+     */
+    public void testSameKeyObjectDifferentValueObject()
+        throws Exception
+    {
+        TCPLateralCacheAttributes lattr = new TCPLateralCacheAttributes();
+        lattr.setTcpListenerPort( 1101 );
+        lattr.setTransmissionTypeName( "TCP" );
+        CompositeCacheManagerMockImpl cacheMgr = new 
CompositeCacheManagerMockImpl();
+        System.out.println( "mock cache = " + cacheMgr.getCache( "test" ) );
+
+        // get the listener started
+        // give it our mock cache manager
+        LateralTCPListener listener = (LateralTCPListener) 
LateralTCPListener.getInstance( lattr, cacheMgr );
+
+        TCPLateralCacheAttributes lattr2 = new TCPLateralCacheAttributes();
+        lattr2.setTcpListenerPort( 1102 );
+        lattr2.setTransmissionTypeName( "TCP" );
+        lattr2.setTcpServer( "localhost:1101" );
+
+        LateralTCPService service = new LateralTCPService( lattr2 );
+        service.setListenerId( 123456 );
+
+        String key = "key";
+        ICacheElement element = new CacheElement( "test", key, "value1" );
+        service.update( element );
+
+        Thread.sleep( 300 );
+
+        ICacheElement element2 = new CacheElement( "test", key, "value2" );
+        service.update( element2 );
+
+        Thread.sleep( 1000 );
+
+        ICacheElement cacheElement = cacheMgr.getCache().get( "key" );
+        System.out.println( "cacheElement = " + cacheElement );
+        assertEquals( "Didn't get the correct object", element2.getVal(), 
cacheElement.getVal() );
+    }
 }



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

Reply via email to