Package org.apache.lucene.analysis.util

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


   */
  public void testFactoryDefaults() throws IOException {
    Map<String,String> args = new HashMap<String,String>();
    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<String,String>();
    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<String,String>();
    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<String,String>();
      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<String,String>();
      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<String, String>();
    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

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

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

    Tokenizer tokenizer = new MockTokenizer(new StringReader(input), MockTokenizer.WHITESPACE, false);
    Map<String,String> args = new HashMap<String,String>();
    args.put("encoder", algName);
    args.put("inject", inject);
    PhoneticFilterFactory factory = new PhoneticFilterFactory(args);
    factory.inform(new ClasspathResourceLoader(factory.getClass()));
    TokenStream stream = factory.create(tokenizer);
    assertTokenStreamContents(stream, expected);
  }
View Full Code Here

      } else {
        throw e;
      }
    }
    if (factory instanceof ResourceLoaderAware) {
      ((ResourceLoaderAware) factory).inform(new ClasspathResourceLoader(getClass()));
    }
    return factory;
  }
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.