Commits

Anonymous committed 32abd2f

CACHE-288 Error in the HashDiskPersistenceListener byteArrayToHexString

Comments (0)

Files changed (3)

     <info organisation="opensymphony" module="oscache"
           revision="2.4-dev"
           status="integration"
-          publication="20060806120000">
+          publication="20070314120000">
         <license name="Apache" url="http://www.apache.org/licenses/LICENSE-2.0.txt"/>
         <ivyauthor name="opensymphony" url="http://www.opensymphony.com/"/>
 

src/java/com/opensymphony/oscache/plugins/diskpersistence/HashDiskPersistenceListener.java

 /*
- * Copyright (c) 2002-2003 by OpenSymphony
+ * Copyright (c) 2002-2007 by OpenSymphony
  * All rights reserved.
  */
 package com.opensymphony.oscache.plugins.diskpersistence;
             out.append(PSEUDO[(int) ch]); // convert the nibble to a String Character
             ch = (byte) (in[i] & 0x0F); // Strip off low nibble 
             out.append(PSEUDO[(int) ch]); // convert the nibble to a String Character
-            i++;
         }
 
         return out.toString();

src/test/java/com/opensymphony/oscache/plugins/diskpersistence/TestHashDiskPersistenceListener.java

 /*
- * Copyright (c) 2002-2003 by OpenSymphony
+ * Copyright (c) 2002-2007 by OpenSymphony
  * All rights reserved.
  */
-/*
- * Created on Aug 30, 2004
- *
- * TODO To change the template for this generated file go to
- * Window - Preferences - Java - Code Style - Code Templates
- */
 package com.opensymphony.oscache.plugins.diskpersistence;
 
-
-/*
- * Copyright (c) 2002-2003 by OpenSymphony
- * All rights reserved.
- */
 import com.opensymphony.oscache.base.CacheEntry;
 import com.opensymphony.oscache.base.Config;
 import com.opensymphony.oscache.base.persistence.CachePersistenceException;
             fail("Exception raised!");
         }
     }
+    
+    private static final byte[] BYTES_1 = {0x00};
+    private static final byte[] BYTES_2 = {0x00, 0x00};
+    private static final byte[] BYTES_3 = {0x00, 0x00, 0x00};
+    private static final byte[] BYTES_4 = {0x01};
+    
+    /**
+     * Test against bug issue CACHE-288.
+     */
+    public void testByteArrayToHexString() {
+        assertFalse("ByteArrayToHexStrings 1 and 2 shouldn't be equal", 
+                HashDiskPersistenceListener.byteArrayToHexString(BYTES_1).
+                equals(HashDiskPersistenceListener.byteArrayToHexString(BYTES_2)));
+        assertFalse("ByteArrayToHexStrings 1 and 3 shouldn't be equal", 
+                HashDiskPersistenceListener.byteArrayToHexString(BYTES_1).
+                equals(HashDiskPersistenceListener.byteArrayToHexString(BYTES_3)));
+        assertFalse("ByteArrayToHexStrings 1 and 4 shouldn't be equal", 
+                HashDiskPersistenceListener.byteArrayToHexString(BYTES_1).
+                equals(HashDiskPersistenceListener.byteArrayToHexString(BYTES_4)));
+        assertFalse("ByteArrayToHexStrings 1 and 4 shouldn't be equal", 
+                HashDiskPersistenceListener.byteArrayToHexString(BYTES_1).
+                equals(HashDiskPersistenceListener.byteArrayToHexString(BYTES_4)));
+    }
 
     protected void tearDown() throws Exception {
         listener.clear();
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.