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

« back to all changes in this revision

Viewing changes to solr/core/src/test/org/apache/solr/analysis/LengthFilterTest.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.solr.analysis;
2
 
 
3
 
/**
4
 
 * Copyright 2004 The Apache Software Foundation
5
 
 *
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
9
 
 *
10
 
 *     http://www.apache.org/licenses/LICENSE-2.0
11
 
 *
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.
17
 
 */
18
 
 
19
 
import java.io.IOException;
20
 
import java.io.StringReader;
21
 
import java.util.HashMap;
22
 
import java.util.Map;
23
 
 
24
 
import org.apache.lucene.analysis.MockTokenizer;
25
 
import org.apache.lucene.analysis.TokenStream;
26
 
 
27
 
public class LengthFilterTest extends BaseTokenTestCase {
28
 
 
29
 
  public void test() throws IOException {
30
 
    LengthFilterFactory factory = new LengthFilterFactory();
31
 
    Map<String, String> args = new HashMap<String, String>();
32
 
    args.put(LengthFilterFactory.MIN_KEY, String.valueOf(4));
33
 
    args.put(LengthFilterFactory.MAX_KEY, String.valueOf(10));
34
 
    // default: args.put("enablePositionIncrements", "false");
35
 
    factory.init(args);
36
 
    String test = "foo foobar super-duper-trooper";
37
 
    TokenStream stream = factory.create(new MockTokenizer(new StringReader(test), MockTokenizer.WHITESPACE, false));
38
 
    assertTokenStreamContents(stream, new String[] { "foobar" }, new int[] { 1 });
39
 
 
40
 
    factory = new LengthFilterFactory();
41
 
    args = new HashMap<String, String>();
42
 
    args.put(LengthFilterFactory.MIN_KEY, String.valueOf(4));
43
 
    args.put(LengthFilterFactory.MAX_KEY, String.valueOf(10));
44
 
    args.put("enablePositionIncrements", "true");
45
 
    factory.init(args);
46
 
    stream = factory.create(new MockTokenizer(new StringReader(test), MockTokenizer.WHITESPACE, false));
47
 
    assertTokenStreamContents(stream, new String[] { "foobar" }, new int[] { 2 });
48
 
  }
49
 
}
 
 
b'\\ No newline at end of file'