Package org.apache.lucene.analysis.util

Examples of org.apache.lucene.analysis.util.ClasspathResourceLoader


      } else {
        throw e;
      }
    }
    if (factory instanceof ResourceLoaderAware) {
      ((ResourceLoaderAware) factory).inform(new ClasspathResourceLoader(getClass()));
    }
    return factory;
  }
View Full Code Here


import org.apache.lucene.analysis.util.ResourceLoader;

public class TestStopFilterFactory extends BaseTokenStreamFactoryTestCase {

  public void testInform() throws Exception {
    ResourceLoader loader = new ClasspathResourceLoader(getClass());
    assertTrue("loader is null and it shouldn't be", loader != null);
    StopFilterFactory factory = (StopFilterFactory) tokenFilterFactory("Stop",
        "words", "stop-1.txt",
        "ignoreCase", "true");
    CharArraySet words = factory.getStopWords();
View Full Code Here

   * @deprecated Remove this test in Lucene 5.0 */
  @Deprecated
  public void testSynonymsOld() throws Exception {
    Reader reader = new StringReader("GB");
    TokenStream stream = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
    stream = tokenFilterFactory("Synonym", Version.LUCENE_33, new ClasspathResourceLoader(getClass()),
        "synonyms", "synonyms.txt").create(stream);
    assertTrue(stream instanceof SlowSynonymFilter);
    assertTokenStreamContents(stream,
        new String[] { "GB", "gib", "gigabyte", "gigabytes" },
        new int[] { 1, 0, 0, 0 });
View Full Code Here

   * @deprecated Remove this test in Lucene 5.0 */
  @Deprecated
  public void testSynonymsOld() throws Exception {
    Reader reader = new StringReader("GB");
    TokenStream stream = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
    stream = tokenFilterFactory("Synonym", Version.LUCENE_33, new ClasspathResourceLoader(getClass()),
        "synonyms", "synonyms.txt").create(stream);
    assertTrue(stream instanceof SlowSynonymFilter);
    assertTokenStreamContents(stream,
        new String[] { "GB", "gib", "gigabyte", "gigabytes" },
        new int[] { 1, 0, 0, 0 });
View Full Code Here

   */
  public void testFactoryDefaults() throws IOException {
    Map<String,String> args = new HashMap<>();
    args.put(PhoneticFilterFactory.ENCODER, "Metaphone");
    PhoneticFilterFactory factory = new PhoneticFilterFactory(args);
    factory.inform(new ClasspathResourceLoader(factory.getClass()));
    assertTrue(factory.getEncoder() instanceof Metaphone);
    assertTrue(factory.inject); // default
  }
View Full Code Here

  public void testInjectFalse() throws IOException {
    Map<String,String> args = new HashMap<>();
    args.put(PhoneticFilterFactory.ENCODER, "Metaphone");
    args.put(PhoneticFilterFactory.INJECT, "false");
    PhoneticFilterFactory factory = new PhoneticFilterFactory(args);
    factory.inform(new ClasspathResourceLoader(factory.getClass()));
    assertFalse(factory.inject);
  }
View Full Code Here

  public void testMaxCodeLength() throws IOException {
    Map<String,String> args = new HashMap<>();
    args.put(PhoneticFilterFactory.ENCODER, "Metaphone");
    args.put(PhoneticFilterFactory.MAX_CODE_LENGTH, "2");
    PhoneticFilterFactory factory = new PhoneticFilterFactory(args);
    factory.inform(new ClasspathResourceLoader(factory.getClass()));
    assertEquals(2, ((Metaphone) factory.getEncoder()).getMaxCodeLen());
  }
View Full Code Here

  public void testUnknownEncoder() throws IOException {
    try {
      Map<String,String> args = new HashMap<>();
      args.put("encoder", "XXX");
      PhoneticFilterFactory factory = new PhoneticFilterFactory(args);
      factory.inform(new ClasspathResourceLoader(factory.getClass()));
      fail();
    } catch (IllegalArgumentException expected) {
      assertTrue(expected.getMessage().contains("Error loading encoder"));
    }
  }
View Full Code Here

  public void testUnknownEncoderReflection() throws IOException {
    try {
      Map<String,String> args = new HashMap<>();
      args.put("encoder", "org.apache.commons.codec.language.NonExistence");
      PhoneticFilterFactory factory = new PhoneticFilterFactory(args);
      factory.inform(new ClasspathResourceLoader(factory.getClass()));
      fail();
    } catch (IllegalArgumentException expected) {
      assertTrue(expected.getMessage().contains("Error loading encoder"));
    }
  }
View Full Code Here

   */
  public void testFactoryReflection() throws IOException {
    Map<String,String> args = new HashMap<>();
    args.put(PhoneticFilterFactory.ENCODER, "org.apache.commons.codec.language.Metaphone");
    PhoneticFilterFactory factory = new PhoneticFilterFactory(args);
    factory.inform(new ClasspathResourceLoader(factory.getClass()));
    assertTrue(factory.getEncoder() instanceof Metaphone);
    assertTrue(factory.inject); // default
  }
View Full Code Here

TOP

Related Classes of org.apache.lucene.analysis.util.ClasspathResourceLoader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.