~slub.team/goobi-indexserver/3.x

« back to all changes in this revision

Viewing changes to lucene/backwards/src/test/org/apache/lucene/analysis/TestPerFieldAnalzyerWrapper.java

  • Committer: Sebastian Meyer
  • Date: 2012-08-03 09:12:40 UTC
  • Revision ID: sebastian.meyer@slub-dresden.de-20120803091240-x6861b0vabq1xror
Remove Lucene and Solr source code and add patches instead
Fix Bug #985487: Auto-suggestion for the search interface

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
package org.apache.lucene.analysis;
2
 
 
3
 
import java.io.StringReader;
4
 
 
5
 
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
6
 
 
7
 
/**
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
14
 
 *
15
 
 *     http://www.apache.org/licenses/LICENSE-2.0
16
 
 *
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.
22
 
 */
23
 
 
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));
30
 
 
31
 
    TokenStream tokenStream = analyzer.tokenStream("field",
32
 
                                            new StringReader(text));
33
 
    CharTermAttribute termAtt = tokenStream.getAttribute(CharTermAttribute.class);
34
 
 
35
 
    assertTrue(tokenStream.incrementToken());
36
 
    assertEquals("WhitespaceAnalyzer does not lowercase",
37
 
                 "Qwerty",
38
 
                 termAtt.toString());
39
 
 
40
 
    tokenStream = analyzer.tokenStream("special",
41
 
                                            new StringReader(text));
42
 
    termAtt = tokenStream.getAttribute(CharTermAttribute.class);
43
 
    assertTrue(tokenStream.incrementToken());
44
 
    assertEquals("SimpleAnalyzer lowercases",
45
 
                 "qwerty",
46
 
                 termAtt.toString());
47
 
  }
48
 
}