lucene-multilingual

Multilingual enhancements for the Lucene text search library
git clone https://code.djc.id.au/git/lucene-multilingual/

src/test/java/au/com/miskinhill/search/analysis/PerLanguageAnalyzerWrapperUnitTest.java (1207B) - raw

      1 package au.com.miskinhill.search.analysis;
      2 
      3 import static org.easymock.EasyMock.*;
      4 import static org.hamcrest.CoreMatchers.*;
      5 import static org.junit.Assert.*;
      6 
      7 import java.util.Arrays;
      8 
      9 import org.junit.Before;
     10 import org.junit.Test;
     11 
     12 public class PerLanguageAnalyzerWrapperUnitTest {
     13 	
     14 	private Analyzer defaultAnalyzer = createMock(Analyzer.class);
     15 	private Analyzer enAnalyzer = createMock(Analyzer.class);
     16 	private Analyzer ruAnalyzer = createMock(Analyzer.class);
     17 	private PerLanguageAnalyzerMap plam;
     18 	
     19 	@Before
     20 	public void setUp() {
     21 	   plam = new PerLanguageAnalyzerMap(defaultAnalyzer);
     22        plam.addAnalyzer("en", enAnalyzer);
     23        plam.addAnalyzer("ru", ruAnalyzer);
     24 	}
     25 
     26 	@Test
     27 	public void testGetAnalyzers() {
     28 		assertThat(plam.getAnalyzers(), 
     29 				equalTo(Arrays.asList(defaultAnalyzer, enAnalyzer, ruAnalyzer)));
     30 	}
     31 	
     32 	@Test
     33 	public void testTokenStreamEmptyLanguage() {
     34 	    assertThat(plam.getAnalyzer(""), equalTo(defaultAnalyzer));
     35 	}
     36 	
     37 	@Test
     38 	public void testTokenStreamNullLanguage() {
     39 	    assertThat(plam.getAnalyzer(null), equalTo(defaultAnalyzer));
     40 	}
     41 	
     42 	@Test
     43 	public void testTokenStreamSomeLanguage() {
     44 	    assertThat(plam.getAnalyzer("en"), equalTo(enAnalyzer));
     45 	}
     46 	
     47 }