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;
21 import java.text.SimpleDateFormat;
22 import java.util.Locale;
24 import org.apache.lucene.analysis.BaseTokenStreamTestCase;
25 import org.apache.lucene.analysis.TeeSinkTokenFilter;
26 import org.apache.lucene.analysis.TeeSinkTokenFilter.SinkTokenStream;
27 import org.apache.lucene.analysis.MockTokenizer;
29 public class DateRecognizerSinkTokenizerTest extends BaseTokenStreamTestCase {
31 public void test() throws IOException {
32 DateRecognizerSinkFilter sinkFilter = new DateRecognizerSinkFilter(new SimpleDateFormat("MM/dd/yyyy", Locale.US));
33 String test = "The quick red fox jumped over the lazy brown dogs on 7/11/2006 The dogs finally reacted on 7/12/2006";
34 TeeSinkTokenFilter tee = new TeeSinkTokenFilter(new MockTokenizer(new StringReader(test), MockTokenizer.WHITESPACE, false));
35 SinkTokenStream sink = tee.newSinkTokenStream(sinkFilter);
39 while (tee.incrementToken()) {
42 assertTrue(count + " does not equal: " + 18, count == 18);
46 while (sink.incrementToken()) {
49 assertTrue("sink Size: " + sinkCount + " is not: " + 2, sinkCount == 2);