LUCENE-3455: Fixed TestLongPostings

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1175685 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Christopher John Male 2011-09-26 06:12:53 +00:00
parent 0bed3142bb
commit a6157373d8
1 changed files with 11 additions and 3 deletions

View File

@ -50,18 +50,26 @@ public class TestLongPostings extends LuceneTestCase {
final TokenStream ts = a.reusableTokenStream("foo", new StringReader(s));
final TermToBytesRefAttribute termAtt = ts.getAttribute(TermToBytesRefAttribute.class);
final BytesRef termBytes = termAtt.getBytesRef();
int count = 0;
ts.reset();
int count = 0;
boolean changed = false;
while(ts.incrementToken()) {
termAtt.fillBytesRef();
if (count == 0 && !termBytes.utf8ToString().equals(s)) {
break;
// The value was changed during analysis. Keep iterating so the
// tokenStream is exhausted.
changed = true;
}
count++;
}
ts.end();
ts.close();
if (count == 1) {
// Did we iterate just once and the value was unchanged?
if (!changed && count == 1) {
return s;
}
}