1
package org.apache.lucene.analysis;
3
import java.io.StringReader;
5
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
8
* Licensed to the Apache Software Foundation (ASF) under one or more
9
* contributor license agreements. See the NOTICE file distributed with
10
* this work for additional information regarding copyright ownership.
11
* The ASF licenses this file to You under the Apache License, Version 2.0
12
* (the "License"); you may not use this file except in compliance with
13
* the License. You may obtain a copy of the License at
15
* http://www.apache.org/licenses/LICENSE-2.0
17
* Unless required by applicable law or agreed to in writing, software
18
* distributed under the License is distributed on an "AS IS" BASIS,
19
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
* See the License for the specific language governing permissions and
21
* limitations under the License.
24
public class TestPerFieldAnalzyerWrapper extends BaseTokenStreamTestCase {
25
public void testPerField() throws Exception {
26
String text = "Qwerty";
27
PerFieldAnalyzerWrapper analyzer =
28
new PerFieldAnalyzerWrapper(new WhitespaceAnalyzer(TEST_VERSION_CURRENT));
29
analyzer.addAnalyzer("special", new SimpleAnalyzer(TEST_VERSION_CURRENT));
31
TokenStream tokenStream = analyzer.tokenStream("field",
32
new StringReader(text));
33
CharTermAttribute termAtt = tokenStream.getAttribute(CharTermAttribute.class);
35
assertTrue(tokenStream.incrementToken());
36
assertEquals("WhitespaceAnalyzer does not lowercase",
40
tokenStream = analyzer.tokenStream("special",
41
new StringReader(text));
42
termAtt = tokenStream.getAttribute(CharTermAttribute.class);
43
assertTrue(tokenStream.incrementToken());
44
assertEquals("SimpleAnalyzer lowercases",