mirror of https://github.com/apache/lucene.git
SolrResourceLoader.assertAwareCompatibility() could be static
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1663701 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1d56eb2a98
commit
2576931e6a
|
@ -763,7 +763,7 @@ public class SolrResourceLoader implements ResourceLoader,Closeable
|
|||
/**
|
||||
* Utility function to throw an exception if the class is invalid
|
||||
*/
|
||||
void assertAwareCompatibility( Class aware, Object obj )
|
||||
static void assertAwareCompatibility( Class aware, Object obj )
|
||||
{
|
||||
Class[] valid = awareCompatibility.get( aware );
|
||||
if( valid == null ) {
|
||||
|
|
|
@ -23,7 +23,6 @@ import org.apache.lucene.analysis.TokenStream;
|
|||
import org.apache.lucene.analysis.core.KeywordTokenizerFactory;
|
||||
import org.apache.lucene.analysis.ngram.NGramFilterFactory;
|
||||
import org.apache.lucene.util.IOUtils;
|
||||
import org.apache.lucene.util.TestUtil;
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.apache.solr.common.SolrException;
|
||||
import org.apache.solr.handler.admin.LukeRequestHandler;
|
||||
|
@ -46,6 +45,8 @@ import java.util.Map;
|
|||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarOutputStream;
|
||||
|
||||
import static org.apache.solr.core.SolrResourceLoader.assertAwareCompatibility;
|
||||
|
||||
public class ResourceLoaderTest extends SolrTestCaseJ4
|
||||
{
|
||||
public void testInstanceDir() throws Exception {
|
||||
|
@ -87,8 +88,8 @@ public class ResourceLoaderTest extends SolrTestCaseJ4
|
|||
|
||||
Class<?> clazz = ResourceLoaderAware.class;
|
||||
// Check ResourceLoaderAware valid objects
|
||||
loader.assertAwareCompatibility( clazz, new NGramFilterFactory(new HashMap<String,String>()) );
|
||||
loader.assertAwareCompatibility( clazz, new KeywordTokenizerFactory(new HashMap<String,String>()) );
|
||||
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[] {
|
||||
|
@ -99,7 +100,7 @@ public class ResourceLoaderTest extends SolrTestCaseJ4
|
|||
};
|
||||
for( Object obj : invalid ) {
|
||||
try {
|
||||
loader.assertAwareCompatibility( clazz, obj );
|
||||
assertAwareCompatibility(clazz, obj);
|
||||
Assert.fail( "Should be invalid class: "+obj + " FOR " + clazz );
|
||||
}
|
||||
catch( SolrException ex ) { } // OK
|
||||
|
@ -108,19 +109,19 @@ public class ResourceLoaderTest extends SolrTestCaseJ4
|
|||
|
||||
clazz = SolrCoreAware.class;
|
||||
// Check ResourceLoaderAware valid objects
|
||||
loader.assertAwareCompatibility( clazz, new LukeRequestHandler() );
|
||||
loader.assertAwareCompatibility( clazz, new FacetComponent() );
|
||||
loader.assertAwareCompatibility( clazz, new JSONResponseWriter() );
|
||||
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<String,String>()),
|
||||
new NGramFilterFactory(new HashMap<>()),
|
||||
"hello", new Float( 12.3f ),
|
||||
new KeywordTokenizerFactory(new HashMap<String,String>())
|
||||
new KeywordTokenizerFactory(new HashMap<>())
|
||||
};
|
||||
for( Object obj : invalid ) {
|
||||
try {
|
||||
loader.assertAwareCompatibility( clazz, obj );
|
||||
assertAwareCompatibility(clazz, obj);
|
||||
Assert.fail( "Should be invalid class: "+obj + " FOR " + clazz );
|
||||
}
|
||||
catch( SolrException ex ) { } // OK
|
||||
|
|
Loading…
Reference in New Issue