Add extra check to TokenStream tests, only get attribute not create it

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@763793 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Uwe Schindler 2009-04-09 20:32:35 +00:00
parent b5c4f8e67d
commit ca6451958b
2 changed files with 8 additions and 4 deletions

View File

@ -29,8 +29,10 @@ public class TestIntTrieTokenStream extends LuceneTestCase {
public void testStreamNewAPI() throws Exception {
final IntTrieTokenStream stream=new IntTrieTokenStream(value, precisionStep);
stream.setUseNewAPI(true);
final ShiftAttribute shiftAtt = (ShiftAttribute) stream.addAttribute(ShiftAttribute.class);
final TermAttribute termAtt = (TermAttribute) stream.addAttribute(TermAttribute.class);
final ShiftAttribute shiftAtt = (ShiftAttribute) stream.getAttribute(ShiftAttribute.class);
assertNotNull("Has shift attribute", shiftAtt);
final TermAttribute termAtt = (TermAttribute) stream.getAttribute(TermAttribute.class);
assertNotNull("Has term attribute", termAtt);
for (int shift=0; shift<32; shift+=precisionStep) {
assertTrue("New token is available", stream.incrementToken());
assertEquals("Shift value", shift, shiftAtt.getShift());

View File

@ -29,8 +29,10 @@ public class TestLongTrieTokenStream extends LuceneTestCase {
public void testStreamNewAPI() throws Exception {
final LongTrieTokenStream stream=new LongTrieTokenStream(value, precisionStep);
stream.setUseNewAPI(true);
final ShiftAttribute shiftAtt = (ShiftAttribute) stream.addAttribute(ShiftAttribute.class);
final TermAttribute termAtt = (TermAttribute) stream.addAttribute(TermAttribute.class);
final ShiftAttribute shiftAtt = (ShiftAttribute) stream.getAttribute(ShiftAttribute.class);
assertNotNull("Has shift attribute", shiftAtt);
final TermAttribute termAtt = (TermAttribute) stream.getAttribute(TermAttribute.class);
assertNotNull("Has term attribute", termAtt);
for (int shift=0; shift<64; shift+=precisionStep) {
assertTrue("New token is available", stream.incrementToken());
assertEquals("Shift value", shift, shiftAtt.getShift());