01: package org.apache.lucene.analysis;
02:
03: import org.apache.lucene.util.LuceneTestCase;
04: import java.io.StringReader;
05:
06: /**
07: * Licensed to the Apache Software Foundation (ASF) under one or more
08: * contributor license agreements. See the NOTICE file distributed with
09: * this work for additional information regarding copyright ownership.
10: * The ASF licenses this file to You under the Apache License, Version 2.0
11: * (the "License"); you may not use this file except in compliance with
12: * the License. You may obtain a copy of the License at
13: *
14: * http://www.apache.org/licenses/LICENSE-2.0
15: *
16: * Unless required by applicable law or agreed to in writing, software
17: * distributed under the License is distributed on an "AS IS" BASIS,
18: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19: * See the License for the specific language governing permissions and
20: * limitations under the License.
21: */
22:
23: public class TestPerFieldAnalzyerWrapper extends LuceneTestCase {
24: public void testPerField() throws Exception {
25: String text = "Qwerty";
26: PerFieldAnalyzerWrapper analyzer = new PerFieldAnalyzerWrapper(
27: new WhitespaceAnalyzer());
28: analyzer.addAnalyzer("special", new SimpleAnalyzer());
29:
30: TokenStream tokenStream = analyzer.tokenStream("field",
31: new StringReader(text));
32: Token token = tokenStream.next();
33: assertEquals("WhitespaceAnalyzer does not lowercase", "Qwerty",
34: token.termText());
35:
36: tokenStream = analyzer.tokenStream("special", new StringReader(
37: text));
38: token = tokenStream.next();
39: assertEquals("SimpleAnalyzer lowercases", "qwerty", token
40: .termText());
41: }
42: }
|