gora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From k...@apache.org
Subject svn commit: r1363659 - in /gora/trunk: CHANGES.txt gora-core/src/test/java/org/apache/gora/store/DataStoreTestUtil.java
Date Fri, 20 Jul 2012 05:53:46 GMT
Author: kazk
Date: Fri Jul 20 05:53:46 2012
New Revision: 1363659

URL: http://svn.apache.org/viewvc?rev=1363659&view=rev
Log:
Fixes GORA-152 to get byte array from ByteBuffer only between position and limit

Modified:
    gora/trunk/CHANGES.txt
    gora/trunk/gora-core/src/test/java/org/apache/gora/store/DataStoreTestUtil.java

Modified: gora/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/gora/trunk/CHANGES.txt?rev=1363659&r1=1363658&r2=1363659&view=diff
==============================================================================
--- gora/trunk/CHANGES.txt (original)
+++ gora/trunk/CHANGES.txt Fri Jul 20 05:53:46 2012
@@ -6,6 +6,8 @@ Gora Change Log
 
 0.3 (trunk) Current Development:
 
+* GORA-152 gora-core test incorrectly uses ByteBuffer's array() method to get its byte array
(kazk)
+
 * GORA-151 CassandraStore's schemaExists() method always returns false (kazk)
 
 * GORA-150 Introduce Configuration property preferred.schema.name (ferdy)

Modified: gora/trunk/gora-core/src/test/java/org/apache/gora/store/DataStoreTestUtil.java
URL: http://svn.apache.org/viewvc/gora/trunk/gora-core/src/test/java/org/apache/gora/store/DataStoreTestUtil.java?rev=1363659&r1=1363658&r2=1363659&view=diff
==============================================================================
--- gora/trunk/gora-core/src/test/java/org/apache/gora/store/DataStoreTestUtil.java (original)
+++ gora/trunk/gora-core/src/test/java/org/apache/gora/store/DataStoreTestUtil.java Fri Jul
20 05:53:46 2012
@@ -293,7 +293,7 @@ public class DataStoreTestUtil {
 
     for (int i = 0; i < urls.length; i++) {
       WebPage webPage = dataStore.get(urls[i]);
-      Assert.assertEquals(content + i, ByteUtils.toString(webPage.getContent().array()));
+      Assert.assertEquals(content + i, ByteUtils.toString( toByteArray(webPage.getContent())
));
       Assert.assertEquals(10, webPage.getParsedContent().size());
       int j = 0;
       for (Utf8 pc : webPage.getParsedContent()) {
@@ -336,9 +336,9 @@ public class DataStoreTestUtil {
     Assert.assertNotNull(page);
 
     Assert.assertEquals(URLS[i], page.getUrl().toString());
-    Assert.assertTrue("content error:" + new String(page.getContent().array()) +
+    Assert.assertTrue("content error:" + new String( toByteArray(page.getContent()) ) +
         " actual=" + CONTENTS[i] + " i=" + i
-    , Arrays.equals(page.getContent().array()
+    , Arrays.equals( toByteArray(page.getContent() )
         , CONTENTS[i].getBytes()));
 
     GenericArray<Utf8> parsedContent = page.getParsedContent();
@@ -718,4 +718,15 @@ public class DataStoreTestUtil {
     }
 
   }
+
+  private static byte[] toByteArray(ByteBuffer buffer) {
+    int p = buffer.position();
+    int n = buffer.limit() - p;
+    byte[] bytes = new byte[n];
+    for (int i = 0; i < n; i++) {
+      bytes[i] = buffer.get(p++);
+    }
+    return bytes;
+  }
+
 }



Mime
View raw message