accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From medi...@apache.org
Subject svn commit: r1408525 - /accumulo/trunk/core/src/test/java/org/apache/accumulo/core/data/MutationTest.java
Date Tue, 13 Nov 2012 01:00:26 GMT
Author: medined
Date: Tue Nov 13 01:00:25 2012
New Revision: 1408525

URL: http://svn.apache.org/viewvc?rev=1408525&view=rev
Log:
ACCUMULO-850: Replace System.out Message In MutationTest With Asserts

Modified:
    accumulo/trunk/core/src/test/java/org/apache/accumulo/core/data/MutationTest.java

Modified: accumulo/trunk/core/src/test/java/org/apache/accumulo/core/data/MutationTest.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/test/java/org/apache/accumulo/core/data/MutationTest.java?rev=1408525&r1=1408524&r2=1408525&view=diff
==============================================================================
--- accumulo/trunk/core/src/test/java/org/apache/accumulo/core/data/MutationTest.java (original)
+++ accumulo/trunk/core/src/test/java/org/apache/accumulo/core/data/MutationTest.java Tue
Nov 13 01:00:25 2012
@@ -30,6 +30,7 @@ import org.apache.accumulo.core.security
 import org.apache.hadoop.io.Text;
 
 public class MutationTest extends TestCase {
+  
   public void test1() {
     Mutation m = new Mutation(new Text("r1"));
     m.put(new Text("cf1"), new Text("cq1"), new Value("v1".getBytes()));
@@ -402,15 +403,19 @@ public class MutationTest extends TestCa
     dos.close();
     long newSize = dos.size();
     assertTrue(newSize < oldSize);
-    System.out.println(String.format("%d %d %.2f%%", newSize - exampleLen, oldSize - exampleLen,
(newSize-exampleLen) * 100. / (oldSize - exampleLen)));
+    assertEquals(10, newSize - exampleLen);
+    assertEquals(68, oldSize - exampleLen);
+    // I am converting to integer to avoid comparing floats which are inaccurate
+    assertEquals(14705, (int)(((newSize-exampleLen) * 100. / (oldSize - exampleLen)) * 1000));
+    StringBuilder sb = new StringBuilder();
     byte[] ba = bos.toByteArray();
     for (int i = 0; i < bos.size(); i += 4) {
       for (int j = i; j < bos.size() && j < i + 4; j++) {
-        System.out.append(String.format("%02x", ba[j]));
+        sb.append(String.format("%02x", ba[j]));
       }
-      System.out.append(" ");
+      sb.append(" ");
     }
-    System.out.println();
+    assertEquals("80322031 32333435 36373839 20313233 34353637 38392031 32333435 36373839
20313233 34353637 38392031 32333435 36373839 06000000 00000001 ", sb.toString());
     
   }
   



Mime
View raw message