1 package org.apache.lucene.analysis; 2 3 import junit.framework.TestCase; 4 import java.io.StringReader ; 5 6 21 22 public class TestPerFieldAnalzyerWrapper extends TestCase { 23 public void testPerField() throws Exception { 24 String text = "Qwerty"; 25 PerFieldAnalyzerWrapper analyzer = 26 new PerFieldAnalyzerWrapper(new WhitespaceAnalyzer()); 27 analyzer.addAnalyzer("special", new SimpleAnalyzer()); 28 29 TokenStream tokenStream = analyzer.tokenStream("field", 30 new StringReader (text)); 31 Token token = tokenStream.next(); 32 assertEquals("WhitespaceAnalyzer does not lowercase", 33 "Qwerty", 34 token.termText()); 35 36 tokenStream = analyzer.tokenStream("special", 37 new StringReader (text)); 38 token = tokenStream.next(); 39 assertEquals("SimpleAnalyzer lowercases", 40 "qwerty", 41 token.termText()); 42 } 43 } 44 | Popular Tags |