Search in sources :

Example 1 with NGramFilterFactory

use of org.apache.lucene.analysis.ngram.NGramFilterFactory in project lucene-solr by apache.

the class ResourceLoaderTest method testAwareCompatibility.

public void testAwareCompatibility() throws Exception {
    Class<?> clazz = ResourceLoaderAware.class;
    // Check ResourceLoaderAware valid objects
    assertAwareCompatibility(clazz, new NGramFilterFactory(new HashMap<>()));
    assertAwareCompatibility(clazz, new KeywordTokenizerFactory(new HashMap<>()));
    // Make sure it throws an error for invalid objects
    Object[] invalid = new Object[] { // new NGramTokenFilter( null ),
    "hello", new Float(12.3f), new LukeRequestHandler(), new JSONResponseWriter() };
    for (Object obj : invalid) {
        try {
            assertAwareCompatibility(clazz, obj);
            Assert.fail("Should be invalid class: " + obj + " FOR " + clazz);
        }// OK
         catch (SolrException ex) {
        }
    }
    clazz = SolrCoreAware.class;
    // Check ResourceLoaderAware valid objects
    assertAwareCompatibility(clazz, new LukeRequestHandler());
    assertAwareCompatibility(clazz, new FacetComponent());
    assertAwareCompatibility(clazz, new JSONResponseWriter());
    // Make sure it throws an error for invalid objects
    invalid = new Object[] { new NGramFilterFactory(new HashMap<>()), "hello", new Float(12.3f), new KeywordTokenizerFactory(new HashMap<>()) };
    for (Object obj : invalid) {
        try {
            assertAwareCompatibility(clazz, obj);
            Assert.fail("Should be invalid class: " + obj + " FOR " + clazz);
        }// OK
         catch (SolrException ex) {
        }
    }
}
Also used : JSONResponseWriter(org.apache.solr.response.JSONResponseWriter) HashMap(java.util.HashMap) FacetComponent(org.apache.solr.handler.component.FacetComponent) LukeRequestHandler(org.apache.solr.handler.admin.LukeRequestHandler) ResourceLoaderAware(org.apache.lucene.analysis.util.ResourceLoaderAware) NGramFilterFactory(org.apache.lucene.analysis.ngram.NGramFilterFactory) SolrException(org.apache.solr.common.SolrException) KeywordTokenizerFactory(org.apache.lucene.analysis.core.KeywordTokenizerFactory)

Aggregations

HashMap (java.util.HashMap)1 KeywordTokenizerFactory (org.apache.lucene.analysis.core.KeywordTokenizerFactory)1 NGramFilterFactory (org.apache.lucene.analysis.ngram.NGramFilterFactory)1 ResourceLoaderAware (org.apache.lucene.analysis.util.ResourceLoaderAware)1 SolrException (org.apache.solr.common.SolrException)1 LukeRequestHandler (org.apache.solr.handler.admin.LukeRequestHandler)1 FacetComponent (org.apache.solr.handler.component.FacetComponent)1 JSONResponseWriter (org.apache.solr.response.JSONResponseWriter)1