You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2010/06/17 12:48:20 UTC

svn commit: r955545 - /lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestPayloads.java

Author: mikemccand
Date: Thu Jun 17 10:48:20 2010
New Revision: 955545

URL: http://svn.apache.org/viewvc?rev=955545&view=rev
Log:
fix false failure: test was converting invalid UTF8 to UTF16 through 2 different APIs (java & Lucene) and then asserting result is equal

Modified:
    lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestPayloads.java

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestPayloads.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestPayloads.java?rev=955545&r1=955544&r2=955545&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestPayloads.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestPayloads.java Thu Jun 17 10:48:20 2010
@@ -529,7 +529,8 @@ public class TestPayloads extends Lucene
             int freq = tp.freq();
             for (int i = 0; i < freq; i++) {
               tp.nextPosition();
-              assertEquals(tp.getPayload().utf8ToString(), termText);
+              final BytesRef payload = tp.getPayload();
+              assertEquals(termText, pool.bytesToString(payload.bytes, payload.offset, payload.length));
             }
           }
         }
@@ -551,7 +552,7 @@ public class TestPayloads extends Lucene
             this.pool = pool;
             payload = pool.get();
             generateRandomData(payload);
-            term = pool.bytesToString(payload);
+            term = pool.bytesToString(payload, 0, payload.length);
             first = true;
             payloadAtt = addAttribute(PayloadAttribute.class);
             termAtt = addAttribute(CharTermAttribute.class);
@@ -584,10 +585,9 @@ public class TestPayloads extends Lucene
             }
         }
         
-        private BytesRef utf8Result = new BytesRef(10);
-
-        synchronized String bytesToString(byte[] bytes) {
-            String s = new String(bytes);
+        static String bytesToString(byte[] bytes, int start, int length) {
+            String s = new String(bytes, start, length);
+            BytesRef utf8Result = new BytesRef(10);
             UnicodeUtil.UTF16toUTF8(s, 0, s.length(), utf8Result);
             try {
                 return new String(utf8Result.bytes, 0, utf8Result.length, "UTF-8");