You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by ee...@apache.org on 2009/10/15 01:02:56 UTC
svn commit: r825332 - in /incubator/cassandra/branches/cassandra-0.4:
src/java/org/apache/cassandra/utils/FBUtilities.java
test/unit/org/apache/cassandra/utils/FBUtilitiesTest.java
Author: eevans
Date: Wed Oct 14 23:02:55 2009
New Revision: 825332
URL: http://svn.apache.org/viewvc?rev=825332&view=rev
Log:
FBUtilities.bytesToHex and hexToBytes are not inverses
Patch by Sandeep Tata; reviewed by eevans for CASSANDRA-490
Added:
incubator/cassandra/branches/cassandra-0.4/test/unit/org/apache/cassandra/utils/FBUtilitiesTest.java (with props)
Modified:
incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/utils/FBUtilities.java
Modified: incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/utils/FBUtilities.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/utils/FBUtilities.java?rev=825332&r1=825331&r2=825332&view=diff
==============================================================================
--- incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/utils/FBUtilities.java (original)
+++ incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/utils/FBUtilities.java Wed Oct 14 23:02:55 2009
@@ -393,7 +393,7 @@
byte[] bytes = new byte[str.length()/2];
for (int i = 0; i < bytes.length; i++)
{
- bytes[i] = (byte)Integer.parseInt(str.substring(i, i+2), 16);
+ bytes[i] = (byte)Integer.parseInt(str.substring(i*2, i*2+2), 16);
}
return bytes;
}
Added: incubator/cassandra/branches/cassandra-0.4/test/unit/org/apache/cassandra/utils/FBUtilitiesTest.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/branches/cassandra-0.4/test/unit/org/apache/cassandra/utils/FBUtilitiesTest.java?rev=825332&view=auto
==============================================================================
--- incubator/cassandra/branches/cassandra-0.4/test/unit/org/apache/cassandra/utils/FBUtilitiesTest.java (added)
+++ incubator/cassandra/branches/cassandra-0.4/test/unit/org/apache/cassandra/utils/FBUtilitiesTest.java Wed Oct 14 23:02:55 2009
@@ -0,0 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.cassandra.utils;
+
+import static org.junit.Assert.assertArrayEquals;
+
+import org.junit.Test;
+
+
+public class FBUtilitiesTest
+{
+ @Test
+ public void testHexBytesConversion()
+ {
+ byte[] b = "1000".getBytes();
+ String s = FBUtilities.bytesToHex(b);
+ byte[] c = FBUtilities.hexToBytes(s);
+ assertArrayEquals(b, c);
+ }
+}
Propchange: incubator/cassandra/branches/cassandra-0.4/test/unit/org/apache/cassandra/utils/FBUtilitiesTest.java
------------------------------------------------------------------------------
svn:eol-style = native