1 package org.apache.lucene.analysis.sinks;
4 * Copyright 2004 The Apache Software Foundation
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 import java.io.IOException;
20 import java.io.StringReader;
22 import org.apache.lucene.analysis.BaseTokenStreamTestCase;
23 import org.apache.lucene.analysis.TeeSinkTokenFilter;
24 import org.apache.lucene.analysis.TeeSinkTokenFilter.SinkTokenStream;
25 import org.apache.lucene.analysis.MockTokenizer;
27 public class TokenRangeSinkTokenizerTest extends BaseTokenStreamTestCase {
29 public void test() throws IOException {
30 TokenRangeSinkFilter sinkFilter = new TokenRangeSinkFilter(2, 4);
31 String test = "The quick red fox jumped over the lazy brown dogs";
32 TeeSinkTokenFilter tee = new TeeSinkTokenFilter(new MockTokenizer(new StringReader(test), MockTokenizer.WHITESPACE, false));
33 SinkTokenStream rangeToks = tee.newSinkTokenStream(sinkFilter);
37 while(tee.incrementToken()) {
43 while (rangeToks.incrementToken()) {
47 assertTrue(count + " does not equal: " + 10, count == 10);
48 assertTrue("rangeToks Size: " + sinkCount + " is not: " + 2, sinkCount == 2);