You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jcs-dev@jakarta.apache.org by hc...@apache.org on 2005/01/27 12:08:54 UTC

cvs commit: jakarta-turbine-jcs/sandbox/yajcache/test/org/apache/jcs/yajcache/file CacheFileDAOTest.java

hchar       2005/01/27 03:08:54

  Modified:    sandbox/yajcache/test/org/apache/jcs/yajcache/file
                        CacheFileDAOTest.java
  Log:
  return type of method readCacheItem changed
  
  Revision  Changes    Path
  1.3       +20 -11    jakarta-turbine-jcs/sandbox/yajcache/test/org/apache/jcs/yajcache/file/CacheFileDAOTest.java
  
  Index: CacheFileDAOTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-jcs/sandbox/yajcache/test/org/apache/jcs/yajcache/file/CacheFileDAOTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- CacheFileDAOTest.java	24 Jan 2005 10:42:14 -0000	1.2
  +++ CacheFileDAOTest.java	27 Jan 2005 11:08:54 -0000	1.3
  @@ -23,7 +23,7 @@
   import junit.framework.*;
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  -import org.apache.jcs.yajcache.annotate.*;
  +import org.apache.jcs.yajcache.lang.annotation.*;
   
   /**
    *
  @@ -51,9 +51,9 @@
                   CacheFileContentType.XML_ENCODER, "key2", ba2);
           
           log.debug("test readCacheItem");
  -        byte[] ba1r = CacheFileDAO.inst.readCacheItem("testCache", "key1");
  +        byte[] ba1r = CacheFileDAO.inst.readCacheItem("testCache", "key1").getContent();
           assertTrue(Arrays.equals(ba1, ba1r));
  -        byte[] ba2r = CacheFileDAO.inst.readCacheItem("testCache", "key2");
  +        byte[] ba2r = (byte[]) CacheFileDAO.inst.readCacheItem("testCache", "key2").getContent();
           assertTrue(Arrays.equals(ba2, ba2r));
           
           log.debug("test removeCacheItem");
  @@ -66,19 +66,21 @@
           CacheFileUtils.inst.mkCacheDirs("testCacheCorrupt");
           
           log.debug("test readCacheItem missing content");
  -        byte[] ba = CacheFileDAO.inst.readCacheItem("testCacheCorrupt", "keyx");
  +        CacheFileContent cfc = CacheFileDAO.inst.readCacheItem("testCacheCorrupt", "keyx");
  +        byte[] ba = cfc == null ? null : cfc.getContent();
           assertTrue(ba == null);
   
           log.debug("test readCacheItem with corrupted hash code");
           File file = CacheFileUtils.inst.getCacheFile("testCacheCorrupt", "keyy");
           RandomAccessFile raf = new RandomAccessFile(file, "rw");
           byte[] ba2 = {1, 2, 3, 4};
  -        CacheFileContent cfc = CacheFileContent.getInstance(CacheFileContentType.JAVA_SERIALIZATION, ba2);
  +        cfc = CacheFileContent.getInstance(CacheFileContentType.JAVA_SERIALIZATION, ba2);
           cfc.setContentHashCode(0);
           cfc.write(raf);
           raf.close();
   
  -        byte[] ba2i = CacheFileDAO.inst.readCacheItem("testCacheCorrupt", "keyy");
  +        cfc = CacheFileDAO.inst.readCacheItem("testCacheCorrupt", "keyy");
  +        byte[] ba2i = cfc == null ? null : cfc.getContent();
           assertTrue(ba2i == null);
   
           log.debug("test readCacheItem with corrupted length");
  @@ -88,8 +90,9 @@
           cfc.setContentLength(100);
           cfc.write(raf);
           raf.close();
  -
  -        ba2i = CacheFileDAO.inst.readCacheItem("testCacheCorrupt", "keyy");
  +        
  +        cfc = CacheFileDAO.inst.readCacheItem("testCacheCorrupt", "keyy");
  +        ba2i = cfc == null ? null : cfc.getContent();
           assertTrue(ba2i == null);
   
           log.debug("test readCacheItem with corrupted content");
  @@ -99,7 +102,9 @@
           cfc.setContent(new byte[] {'a', 'b', 'c', 'd', 'e'});
           cfc.write(raf);
           raf.close();
  -        ba2i = CacheFileDAO.inst.readCacheItem("testCacheCorrupt", "keyy");
  +
  +        cfc = CacheFileDAO.inst.readCacheItem("testCacheCorrupt", "keyy");
  +        ba2i = cfc == null ? null : cfc.getContent();
           assertTrue(ba2i == null);
           
           log.debug("test readCacheItem with appended content");
  @@ -109,7 +114,9 @@
           cfc.setContent(new byte[] {1, 2, 3, 4, 5});
           cfc.write(raf);
           raf.close();
  -        ba2i = CacheFileDAO.inst.readCacheItem("testCacheCorrupt", "keyy");
  +        
  +        cfc = CacheFileDAO.inst.readCacheItem("testCacheCorrupt", "keyy");
  +        ba2i = cfc == null ? null : cfc.getContent();
           assertTrue(ba2i == null);
           
           log.debug("test readCacheItem with content less than min length");
  @@ -119,7 +126,9 @@
           cfc.setContent(null);
           cfc.write(raf);
           raf.close();
  -        ba2i = CacheFileDAO.inst.readCacheItem("testCacheCorrupt", "keyy");
  +
  +        cfc = CacheFileDAO.inst.readCacheItem("testCacheCorrupt", "keyy");
  +        ba2i = cfc == null ? null : cfc.getContent();
           assertTrue(ba2i == null);
           
           log.debug(CacheFileDAO.inst.toString());
  
  
  

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