lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From uschind...@apache.org
Subject svn commit: r1366392 - /lucene/dev/trunk/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestAllAnalyzersHaveFactories.java
Date Fri, 27 Jul 2012 14:24:56 GMT
Author: uschindler
Date: Fri Jul 27 14:24:55 2012
New Revision: 1366392

URL: http://svn.apache.org/viewvc?rev=1366392&view=rev
Log:
Improve test

Modified:
    lucene/dev/trunk/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestAllAnalyzersHaveFactories.java

Modified: lucene/dev/trunk/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestAllAnalyzersHaveFactories.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestAllAnalyzersHaveFactories.java?rev=1366392&r1=1366391&r2=1366392&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestAllAnalyzersHaveFactories.java
(original)
+++ lucene/dev/trunk/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestAllAnalyzersHaveFactories.java
Fri Jul 27 14:24:55 2012
@@ -47,7 +47,9 @@ import org.apache.lucene.analysis.path.R
 import org.apache.lucene.analysis.sinks.TeeSinkTokenFilter;
 import org.apache.lucene.analysis.snowball.SnowballFilter;
 import org.apache.lucene.analysis.util.CharFilterFactory;
+import org.apache.lucene.analysis.util.ResourceLoader;
 import org.apache.lucene.analysis.util.ResourceLoaderAware;
+import org.apache.lucene.analysis.util.StringMockResourceLoader;
 import org.apache.lucene.analysis.util.TokenFilterFactory;
 import org.apache.lucene.analysis.util.TokenizerFactory;
 import org.apache.lucene.util.LuceneTestCase;
@@ -95,6 +97,8 @@ public class TestAllAnalyzersHaveFactori
     );
   }
   
+  private static final ResourceLoader loader = new StringMockResourceLoader("");
+  
   public void test() throws Exception {
     List<Class<?>> analysisClasses = new ArrayList<Class<?>>();
     TestRandomChains.getClassesForPackage("org.apache.lucene.analysis", analysisClasses);
@@ -122,12 +126,12 @@ public class TestAllAnalyzersHaveFactori
         try {
           instance.setLuceneMatchVersion(TEST_VERSION_CURRENT);
           instance.init(Collections.<String,String>emptyMap());
-          // TODO: provide fake ResourceLoader
-          if (!(instance instanceof ResourceLoaderAware)) {
-            assertSame(c, instance.create(new StringReader("")).getClass());
+          if (instance instanceof ResourceLoaderAware) {
+            ((ResourceLoaderAware) instance).inform(loader);
           }
+          assertSame(c, instance.create(new StringReader("")).getClass());
         } catch (IllegalArgumentException e) {
-          // TODO: For now pass because some factories have not yet a default config that
always works, some require ResourceLoader
+          // TODO: For now pass because some factories have not yet a default config that
always works
         }
       } else if (TokenFilter.class.isAssignableFrom(c)) {
         String clazzName = c.getSimpleName();
@@ -138,16 +142,16 @@ public class TestAllAnalyzersHaveFactori
         try {
           instance.setLuceneMatchVersion(TEST_VERSION_CURRENT);
           instance.init(Collections.<String,String>emptyMap());
-          // TODO: provide fake ResourceLoader
-          if (!(instance instanceof ResourceLoaderAware)) {
-            Class<? extends TokenStream> createdClazz = instance.create(new KeywordTokenizer(new
StringReader(""))).getClass();
-            // only check instance if factory have wrapped at all!
-            if (KeywordTokenizer.class != createdClazz) {
-              assertSame(c, createdClazz);
-            }
+          if (instance instanceof ResourceLoaderAware) {
+            ((ResourceLoaderAware) instance).inform(loader);
+          }
+          Class<? extends TokenStream> createdClazz = instance.create(new KeywordTokenizer(new
StringReader(""))).getClass();
+          // only check instance if factory have wrapped at all!
+          if (KeywordTokenizer.class != createdClazz) {
+            assertSame(c, createdClazz);
           }
         } catch (IllegalArgumentException e) {
-          // TODO: For now pass because some factories have not yet a default config that
always works, some require ResourceLoader
+          // TODO: For now pass because some factories have not yet a default config that
always works
         }
       } else if (CharFilter.class.isAssignableFrom(c)) {
         String clazzName = c.getSimpleName();
@@ -158,16 +162,16 @@ public class TestAllAnalyzersHaveFactori
         try {
           instance.setLuceneMatchVersion(TEST_VERSION_CURRENT);
           instance.init(Collections.<String,String>emptyMap());
-          // TODO: provide fake ResourceLoader
-          if (!(instance instanceof ResourceLoaderAware)) {
-            Class<? extends Reader> createdClazz = instance.create(new StringReader("")).getClass();
-            // only check instance if factory have wrapped at all!
-            if (StringReader.class != createdClazz) {
-              assertSame(c, createdClazz);
-            }
+          if (instance instanceof ResourceLoaderAware) {
+            ((ResourceLoaderAware) instance).inform(loader);
+          }
+          Class<? extends Reader> createdClazz = instance.create(new StringReader("")).getClass();
+          // only check instance if factory have wrapped at all!
+          if (StringReader.class != createdClazz) {
+            assertSame(c, createdClazz);
           }
         } catch (IllegalArgumentException e) {
-          // TODO: For now pass because some factories have not yet a default config that
always works, some require ResourceLoader
+          // TODO: For now pass because some factories have not yet a default config that
always works
         }
       }
     }



Mime
View raw message