Apache Lucene open-source search software
LUCENE-3849: fix some more test only TokenStreams
Michael McCandlessc1df1e15af3e
diff --git a/lucene/core/src/test/org/apache/lucene/index/Test2BPositions.java b/lucene/core/src/test/org/apache/lucene/index/Test2BPositions.javaindex 1d39c935b39..1426c8290be 100644--- a/lucene/core/src/test/org/apache/lucene/index/Test2BPositions.java+++ b/lucene/core/src/test/org/apache/lucene/index/Test2BPositions.java@@ -88,14 +88,12 @@ public class Test2BPositions extends LuceneTestCase {private final PositionIncrementAttribute posIncAtt = addAttribute(PositionIncrementAttribute.class);int index;- public MyTokenStream() {- termAtt.setLength(1);- termAtt.buffer()[0] = 'a';- }-@Overridepublic boolean incrementToken() {if (index < 52) {+ clearAttributes();+ termAtt.setLength(1);+ termAtt.buffer()[0] = 'a';posIncAtt.setPositionIncrement(1+index);index++;return true;diff --git a/lucene/core/src/test/org/apache/lucene/index/Test2BPostings.java b/lucene/core/src/test/org/apache/lucene/index/Test2BPostings.javaindex ba9c1f38fbe..5825eb89c6d 100644--- a/lucene/core/src/test/org/apache/lucene/index/Test2BPostings.java+++ b/lucene/core/src/test/org/apache/lucene/index/Test2BPostings.java@@ -85,18 +85,14 @@ public class Test2BPostings extends LuceneTestCase {public static final class MyTokenStream extends TokenStream {private final CharTermAttribute termAtt = addAttribute(CharTermAttribute.class);- private final char buffer[];int index;- public MyTokenStream() {- termAtt.setLength(1);- buffer = termAtt.buffer();- }-@Overridepublic boolean incrementToken() {if (index <= 'z') {- buffer[0] = (char) index++;+ clearAttributes();+ termAtt.setLength(1);+ termAtt.buffer()[0] = (char) index++;return true;}return false;diff --git a/lucene/core/src/test/org/apache/lucene/index/Test2BPostingsBytes.java b/lucene/core/src/test/org/apache/lucene/index/Test2BPostingsBytes.javaindex 9c67839ffa8..3332bb67828 100644--- a/lucene/core/src/test/org/apache/lucene/index/Test2BPostingsBytes.java+++ b/lucene/core/src/test/org/apache/lucene/index/Test2BPostingsBytes.java@@ -129,14 +129,12 @@ public class Test2BPostingsBytes extends LuceneTestCase {int index;int n;- public MyTokenStream() {- termAtt.setLength(1);- termAtt.buffer()[0] = 'a';- }-@Overridepublic boolean incrementToken() {if (index < n) {+ clearAttributes();+ termAtt.buffer()[0] = 'a';+ termAtt.setLength(1);index++;return true;}