From ca6451958bf08b4fccc4ba321ac18c86ce65e273 Mon Sep 17 00:00:00 2001 From: Uwe Schindler Date: Thu, 9 Apr 2009 20:32:35 +0000 Subject: [PATCH] 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 --- .../apache/lucene/search/trie/TestIntTrieTokenStream.java | 6 ++++-- .../apache/lucene/search/trie/TestLongTrieTokenStream.java | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/contrib/queries/src/test/org/apache/lucene/search/trie/TestIntTrieTokenStream.java b/contrib/queries/src/test/org/apache/lucene/search/trie/TestIntTrieTokenStream.java index cdd4f17daad..e53b6e22d1e 100644 --- a/contrib/queries/src/test/org/apache/lucene/search/trie/TestIntTrieTokenStream.java +++ b/contrib/queries/src/test/org/apache/lucene/search/trie/TestIntTrieTokenStream.java @@ -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()); diff --git a/contrib/queries/src/test/org/apache/lucene/search/trie/TestLongTrieTokenStream.java b/contrib/queries/src/test/org/apache/lucene/search/trie/TestLongTrieTokenStream.java index f2341220f99..e116f9eca66 100644 --- a/contrib/queries/src/test/org/apache/lucene/search/trie/TestLongTrieTokenStream.java +++ b/contrib/queries/src/test/org/apache/lucene/search/trie/TestLongTrieTokenStream.java @@ -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());