lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject [35/52] [abbrv] lucenenet git commit: Ported Analysis.Util.TestAnalysisSPILoader and fixed a bug in AnalysisSPILoader.
Date Thu, 01 Sep 2016 14:39:56 GMT
Ported Analysis.Util.TestAnalysisSPILoader and fixed a bug in AnalysisSPILoader.


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/0549bf11
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/0549bf11
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/0549bf11

Branch: refs/heads/master
Commit: 0549bf1111831fe8589d554960e763bb197c34ab
Parents: 753dd0b
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Wed Aug 24 19:27:49 2016 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Wed Aug 24 19:27:49 2016 +0700

----------------------------------------------------------------------
 .../Analysis/Util/AnalysisSPILoader.cs          |   2 +-
 .../Analysis/Util/TestAnalysisSPILoader.cs      | 488 ++++++++++---------
 .../Lucene.Net.Tests.Analysis.Common.csproj     |   1 +
 3 files changed, 252 insertions(+), 239 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/0549bf11/src/Lucene.Net.Analysis.Common/Analysis/Util/AnalysisSPILoader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Util/AnalysisSPILoader.cs b/src/Lucene.Net.Analysis.Common/Analysis/Util/AnalysisSPILoader.cs
index 56c7f5a..e92bf3f 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Util/AnalysisSPILoader.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Util/AnalysisSPILoader.cs
@@ -106,7 +106,7 @@ namespace Lucene.Net.Analysis.Util
             Type service = LookupClass(name);
             try
             {
-                return (S)Activator.CreateInstance(clazz,
+                return (S)Activator.CreateInstance(service,
                     BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance,
                     null, new object[] { args }, CultureInfo.InvariantCulture);
             }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/0549bf11/src/Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestAnalysisSPILoader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestAnalysisSPILoader.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestAnalysisSPILoader.cs
index edfad89..736457e 100644
--- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestAnalysisSPILoader.cs
+++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestAnalysisSPILoader.cs
@@ -1,9 +1,14 @@
-´╗┐using System.Collections.Generic;
-
-namespace org.apache.lucene.analysis.util
+´╗┐using Lucene.Net.Analysis.CharFilters;
+using Lucene.Net.Analysis.Core;
+using Lucene.Net.Analysis.Miscellaneous;
+using Lucene.Net.Util;
+using NUnit.Framework;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace Lucene.Net.Analysis.Util
 {
-
-	/*
+    /*
 	 * Licensed to the Apache Software Foundation (ASF) under one or more
 	 * contributor license agreements.  See the NOTICE file distributed with
 	 * this work for additional information regarding copyright ownership.
@@ -20,237 +25,244 @@ namespace org.apache.lucene.analysis.util
 	 * limitations under the License.
 	 */
 
-
-	using HTMLStripCharFilterFactory = org.apache.lucene.analysis.charfilter.HTMLStripCharFilterFactory;
-	using LowerCaseFilterFactory = org.apache.lucene.analysis.core.LowerCaseFilterFactory;
-	using WhitespaceTokenizerFactory = org.apache.lucene.analysis.core.WhitespaceTokenizerFactory;
-	using RemoveDuplicatesTokenFilterFactory = org.apache.lucene.analysis.miscellaneous.RemoveDuplicatesTokenFilterFactory;
-	using LuceneTestCase = org.apache.lucene.util.LuceneTestCase;
-
-	public class TestAnalysisSPILoader : LuceneTestCase
-	{
-
-	  private IDictionary<string, string> versionArgOnly()
-	  {
-		return new HashMapAnonymousInnerClassHelper(this);
-	  }
-
-	  private class HashMapAnonymousInnerClassHelper : Dictionary<string, string>
-	  {
-		  private readonly TestAnalysisSPILoader outerInstance;
-
-		  public HashMapAnonymousInnerClassHelper(TestAnalysisSPILoader outerInstance)
-		  {
-			  this.outerInstance = outerInstance;
-
-			  this.put("luceneMatchVersion", TEST_VERSION_CURRENT.ToString());
-		  }
-
-	  }
-
-	  public virtual void testLookupTokenizer()
-	  {
-		assertSame(typeof(WhitespaceTokenizerFactory), TokenizerFactory.forName("Whitespace", versionArgOnly()).GetType());
-		assertSame(typeof(WhitespaceTokenizerFactory), TokenizerFactory.forName("WHITESPACE", versionArgOnly()).GetType());
-		assertSame(typeof(WhitespaceTokenizerFactory), TokenizerFactory.forName("whitespace", versionArgOnly()).GetType());
-	  }
-
-	  public virtual void testBogusLookupTokenizer()
-	  {
-		try
-		{
-		  TokenizerFactory.forName("sdfsdfsdfdsfsdfsdf", new Dictionary<string, string>());
-		  fail();
-		}
-		catch (System.ArgumentException)
-		{
-		  //
-		}
-
-		try
-		{
-		  TokenizerFactory.forName("!(**#$U*#$*", new Dictionary<string, string>());
-		  fail();
-		}
-		catch (System.ArgumentException)
-		{
-		  //
-		}
-	  }
-
-	  public virtual void testLookupTokenizerClass()
-	  {
-		assertSame(typeof(WhitespaceTokenizerFactory), TokenizerFactory.lookupClass("Whitespace"));
-		assertSame(typeof(WhitespaceTokenizerFactory), TokenizerFactory.lookupClass("WHITESPACE"));
-		assertSame(typeof(WhitespaceTokenizerFactory), TokenizerFactory.lookupClass("whitespace"));
-	  }
-
-	  public virtual void testBogusLookupTokenizerClass()
-	  {
-		try
-		{
-		  TokenizerFactory.lookupClass("sdfsdfsdfdsfsdfsdf");
-		  fail();
-		}
-		catch (System.ArgumentException)
-		{
-		  //
-		}
-
-		try
-		{
-		  TokenizerFactory.lookupClass("!(**#$U*#$*");
-		  fail();
-		}
-		catch (System.ArgumentException)
-		{
-		  //
-		}
-	  }
-
-	  public virtual void testAvailableTokenizers()
-	  {
-		assertTrue(TokenizerFactory.availableTokenizers().contains("whitespace"));
-	  }
-
-	  public virtual void testLookupTokenFilter()
-	  {
-		assertSame(typeof(LowerCaseFilterFactory), TokenFilterFactory.forName("Lowercase", versionArgOnly()).GetType());
-		assertSame(typeof(LowerCaseFilterFactory), TokenFilterFactory.forName("LOWERCASE", versionArgOnly()).GetType());
-		assertSame(typeof(LowerCaseFilterFactory), TokenFilterFactory.forName("lowercase", versionArgOnly()).GetType());
-
-		assertSame(typeof(RemoveDuplicatesTokenFilterFactory), TokenFilterFactory.forName("RemoveDuplicates",
versionArgOnly()).GetType());
-		assertSame(typeof(RemoveDuplicatesTokenFilterFactory), TokenFilterFactory.forName("REMOVEDUPLICATES",
versionArgOnly()).GetType());
-		assertSame(typeof(RemoveDuplicatesTokenFilterFactory), TokenFilterFactory.forName("removeduplicates",
versionArgOnly()).GetType());
-	  }
-
-	  public virtual void testBogusLookupTokenFilter()
-	  {
-		try
-		{
-		  TokenFilterFactory.forName("sdfsdfsdfdsfsdfsdf", new Dictionary<string, string>());
-		  fail();
-		}
-		catch (System.ArgumentException)
-		{
-		  //
-		}
-
-		try
-		{
-		  TokenFilterFactory.forName("!(**#$U*#$*", new Dictionary<string, string>());
-		  fail();
-		}
-		catch (System.ArgumentException)
-		{
-		  //
-		}
-	  }
-
-	  public virtual void testLookupTokenFilterClass()
-	  {
-		assertSame(typeof(LowerCaseFilterFactory), TokenFilterFactory.lookupClass("Lowercase"));
-		assertSame(typeof(LowerCaseFilterFactory), TokenFilterFactory.lookupClass("LOWERCASE"));
-		assertSame(typeof(LowerCaseFilterFactory), TokenFilterFactory.lookupClass("lowercase"));
-
-		assertSame(typeof(RemoveDuplicatesTokenFilterFactory), TokenFilterFactory.lookupClass("RemoveDuplicates"));
-		assertSame(typeof(RemoveDuplicatesTokenFilterFactory), TokenFilterFactory.lookupClass("REMOVEDUPLICATES"));
-		assertSame(typeof(RemoveDuplicatesTokenFilterFactory), TokenFilterFactory.lookupClass("removeduplicates"));
-	  }
-
-	  public virtual void testBogusLookupTokenFilterClass()
-	  {
-		try
-		{
-		  TokenFilterFactory.lookupClass("sdfsdfsdfdsfsdfsdf");
-		  fail();
-		}
-		catch (System.ArgumentException)
-		{
-		  //
-		}
-
-		try
-		{
-		  TokenFilterFactory.lookupClass("!(**#$U*#$*");
-		  fail();
-		}
-		catch (System.ArgumentException)
-		{
-		  //
-		}
-	  }
-
-	  public virtual void testAvailableTokenFilters()
-	  {
-		assertTrue(TokenFilterFactory.availableTokenFilters().contains("lowercase"));
-		assertTrue(TokenFilterFactory.availableTokenFilters().contains("removeduplicates"));
-	  }
-
-	  public virtual void testLookupCharFilter()
-	  {
-		assertSame(typeof(HTMLStripCharFilterFactory), CharFilterFactory.forName("HTMLStrip", versionArgOnly()).GetType());
-		assertSame(typeof(HTMLStripCharFilterFactory), CharFilterFactory.forName("HTMLSTRIP", versionArgOnly()).GetType());
-		assertSame(typeof(HTMLStripCharFilterFactory), CharFilterFactory.forName("htmlstrip", versionArgOnly()).GetType());
-	  }
-
-	  public virtual void testBogusLookupCharFilter()
-	  {
-		try
-		{
-		  CharFilterFactory.forName("sdfsdfsdfdsfsdfsdf", new Dictionary<string, string>());
-		  fail();
-		}
-		catch (System.ArgumentException)
-		{
-		  //
-		}
-
-		try
-		{
-		  CharFilterFactory.forName("!(**#$U*#$*", new Dictionary<string, string>());
-		  fail();
-		}
-		catch (System.ArgumentException)
-		{
-		  //
-		}
-	  }
-
-	  public virtual void testLookupCharFilterClass()
-	  {
-		assertSame(typeof(HTMLStripCharFilterFactory), CharFilterFactory.lookupClass("HTMLStrip"));
-		assertSame(typeof(HTMLStripCharFilterFactory), CharFilterFactory.lookupClass("HTMLSTRIP"));
-		assertSame(typeof(HTMLStripCharFilterFactory), CharFilterFactory.lookupClass("htmlstrip"));
-	  }
-
-	  public virtual void testBogusLookupCharFilterClass()
-	  {
-		try
-		{
-		  CharFilterFactory.lookupClass("sdfsdfsdfdsfsdfsdf");
-		  fail();
-		}
-		catch (System.ArgumentException)
-		{
-		  //
-		}
-
-		try
-		{
-		  CharFilterFactory.lookupClass("!(**#$U*#$*");
-		  fail();
-		}
-		catch (System.ArgumentException)
-		{
-		  //
-		}
-	  }
-
-	  public virtual void testAvailableCharFilters()
-	  {
-		assertTrue(CharFilterFactory.availableCharFilters().contains("htmlstrip"));
-	  }
-	}
-
+    public class TestAnalysisSPILoader : LuceneTestCase
+    {
+
+        private IDictionary<string, string> VersionArgOnly()
+        {
+            return new HashMapAnonymousInnerClassHelper(this);
+        }
+
+        private class HashMapAnonymousInnerClassHelper : Dictionary<string, string>
+        {
+            private readonly TestAnalysisSPILoader outerInstance;
+
+            public HashMapAnonymousInnerClassHelper(TestAnalysisSPILoader outerInstance)
+            {
+                this.outerInstance = outerInstance;
+
+                this["luceneMatchVersion"] = TEST_VERSION_CURRENT.ToString();
+            }
+
+        }
+
+        [Test]
+        public virtual void TestLookupTokenizer()
+        {
+            assertSame(typeof(WhitespaceTokenizerFactory), TokenizerFactory.ForName("Whitespace",
VersionArgOnly()).GetType());
+            assertSame(typeof(WhitespaceTokenizerFactory), TokenizerFactory.ForName("WHITESPACE",
VersionArgOnly()).GetType());
+            assertSame(typeof(WhitespaceTokenizerFactory), TokenizerFactory.ForName("whitespace",
VersionArgOnly()).GetType());
+        }
+
+        [Test]
+        public virtual void TestBogusLookupTokenizer()
+        {
+            try
+            {
+                TokenizerFactory.ForName("sdfsdfsdfdsfsdfsdf", new Dictionary<string,
string>());
+                fail();
+            }
+            catch (System.ArgumentException)
+            {
+                //
+            }
+
+            try
+            {
+                TokenizerFactory.ForName("!(**#$U*#$*", new Dictionary<string, string>());
+                fail();
+            }
+            catch (System.ArgumentException)
+            {
+                //
+            }
+        }
+
+        [Test]
+        public virtual void TestLookupTokenizerClass()
+        {
+            assertSame(typeof(WhitespaceTokenizerFactory), TokenizerFactory.LookupClass("Whitespace"));
+            assertSame(typeof(WhitespaceTokenizerFactory), TokenizerFactory.LookupClass("WHITESPACE"));
+            assertSame(typeof(WhitespaceTokenizerFactory), TokenizerFactory.LookupClass("whitespace"));
+        }
+
+        [Test]
+        public virtual void TestBogusLookupTokenizerClass()
+        {
+            try
+            {
+                TokenizerFactory.LookupClass("sdfsdfsdfdsfsdfsdf");
+                fail();
+            }
+            catch (System.ArgumentException)
+            {
+                //
+            }
+
+            try
+            {
+                TokenizerFactory.LookupClass("!(**#$U*#$*");
+                fail();
+            }
+            catch (System.ArgumentException)
+            {
+                //
+            }
+        }
+
+        [Test]
+        public virtual void TestAvailableTokenizers()
+        {
+            assertTrue(TokenizerFactory.AvailableTokenizers.Contains("whitespace"));
+        }
+
+        [Test]
+        public virtual void TestLookupTokenFilter()
+        {
+            assertSame(typeof(LowerCaseFilterFactory), TokenFilterFactory.ForName("Lowercase",
VersionArgOnly()).GetType());
+            assertSame(typeof(LowerCaseFilterFactory), TokenFilterFactory.ForName("LOWERCASE",
VersionArgOnly()).GetType());
+            assertSame(typeof(LowerCaseFilterFactory), TokenFilterFactory.ForName("lowercase",
VersionArgOnly()).GetType());
+
+            assertSame(typeof(RemoveDuplicatesTokenFilterFactory), TokenFilterFactory.ForName("RemoveDuplicates",
VersionArgOnly()).GetType());
+            assertSame(typeof(RemoveDuplicatesTokenFilterFactory), TokenFilterFactory.ForName("REMOVEDUPLICATES",
VersionArgOnly()).GetType());
+            assertSame(typeof(RemoveDuplicatesTokenFilterFactory), TokenFilterFactory.ForName("removeduplicates",
VersionArgOnly()).GetType());
+        }
+
+        [Test]
+        public virtual void TestBogusLookupTokenFilter()
+        {
+            try
+            {
+                TokenFilterFactory.ForName("sdfsdfsdfdsfsdfsdf", new Dictionary<string,
string>());
+                fail();
+            }
+            catch (System.ArgumentException)
+            {
+                //
+            }
+
+            try
+            {
+                TokenFilterFactory.ForName("!(**#$U*#$*", new Dictionary<string, string>());
+                fail();
+            }
+            catch (System.ArgumentException)
+            {
+                //
+            }
+        }
+
+        [Test]
+        public virtual void TestLookupTokenFilterClass()
+        {
+            assertSame(typeof(LowerCaseFilterFactory), TokenFilterFactory.LookupClass("Lowercase"));
+            assertSame(typeof(LowerCaseFilterFactory), TokenFilterFactory.LookupClass("LOWERCASE"));
+            assertSame(typeof(LowerCaseFilterFactory), TokenFilterFactory.LookupClass("lowercase"));
+
+            assertSame(typeof(RemoveDuplicatesTokenFilterFactory), TokenFilterFactory.LookupClass("RemoveDuplicates"));
+            assertSame(typeof(RemoveDuplicatesTokenFilterFactory), TokenFilterFactory.LookupClass("REMOVEDUPLICATES"));
+            assertSame(typeof(RemoveDuplicatesTokenFilterFactory), TokenFilterFactory.LookupClass("removeduplicates"));
+        }
+
+        [Test]
+        public virtual void TestBogusLookupTokenFilterClass()
+        {
+            try
+            {
+                TokenFilterFactory.LookupClass("sdfsdfsdfdsfsdfsdf");
+                fail();
+            }
+            catch (System.ArgumentException)
+            {
+                //
+            }
+
+            try
+            {
+                TokenFilterFactory.LookupClass("!(**#$U*#$*");
+                fail();
+            }
+            catch (System.ArgumentException)
+            {
+                //
+            }
+        }
+
+        [Test]
+        public virtual void TestAvailableTokenFilters()
+        {
+            assertTrue(TokenFilterFactory.AvailableTokenFilters.Contains("lowercase"));
+            assertTrue(TokenFilterFactory.AvailableTokenFilters.Contains("removeduplicates"));
+        }
+
+        [Test]
+        public virtual void TestLookupCharFilter()
+        {
+            assertSame(typeof(HTMLStripCharFilterFactory), CharFilterFactory.ForName("HTMLStrip",
VersionArgOnly()).GetType());
+            assertSame(typeof(HTMLStripCharFilterFactory), CharFilterFactory.ForName("HTMLSTRIP",
VersionArgOnly()).GetType());
+            assertSame(typeof(HTMLStripCharFilterFactory), CharFilterFactory.ForName("htmlstrip",
VersionArgOnly()).GetType());
+        }
+
+        [Test]
+        public virtual void TestBogusLookupCharFilter()
+        {
+            try
+            {
+                CharFilterFactory.ForName("sdfsdfsdfdsfsdfsdf", new Dictionary<string,
string>());
+                fail();
+            }
+            catch (System.ArgumentException)
+            {
+                //
+            }
+
+            try
+            {
+                CharFilterFactory.ForName("!(**#$U*#$*", new Dictionary<string, string>());
+                fail();
+            }
+            catch (System.ArgumentException)
+            {
+                //
+            }
+        }
+
+        [Test]
+        public virtual void TestLookupCharFilterClass()
+        {
+            assertSame(typeof(HTMLStripCharFilterFactory), CharFilterFactory.LookupClass("HTMLStrip"));
+            assertSame(typeof(HTMLStripCharFilterFactory), CharFilterFactory.LookupClass("HTMLSTRIP"));
+            assertSame(typeof(HTMLStripCharFilterFactory), CharFilterFactory.LookupClass("htmlstrip"));
+        }
+
+        [Test]
+        public virtual void TestBogusLookupCharFilterClass()
+        {
+            try
+            {
+                CharFilterFactory.LookupClass("sdfsdfsdfdsfsdfsdf");
+                fail();
+            }
+            catch (System.ArgumentException)
+            {
+                //
+            }
+
+            try
+            {
+                CharFilterFactory.LookupClass("!(**#$U*#$*");
+                fail();
+            }
+            catch (System.ArgumentException)
+            {
+                //
+            }
+        }
+
+        [Test]
+        public virtual void TestAvailableCharFilters()
+        {
+            assertTrue(CharFilterFactory.AvailableCharFilters.Contains("htmlstrip"));
+        }
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/0549bf11/src/Lucene.Net.Tests.Analysis.Common/Lucene.Net.Tests.Analysis.Common.csproj
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Analysis.Common/Lucene.Net.Tests.Analysis.Common.csproj
b/src/Lucene.Net.Tests.Analysis.Common/Lucene.Net.Tests.Analysis.Common.csproj
index 532ee86..048bac7 100644
--- a/src/Lucene.Net.Tests.Analysis.Common/Lucene.Net.Tests.Analysis.Common.csproj
+++ b/src/Lucene.Net.Tests.Analysis.Common/Lucene.Net.Tests.Analysis.Common.csproj
@@ -303,6 +303,7 @@
     <Compile Include="Analysis\Tr\TestTurkishLowerCaseFilterFactory.cs" />
     <Compile Include="Analysis\Util\BaseTokenStreamFactoryTestCase.cs" />
     <Compile Include="Analysis\Util\StringMockResourceLoader.cs" />
+    <Compile Include="Analysis\Util\TestAnalysisSPILoader.cs" />
     <Compile Include="Analysis\Util\TestCharacterUtils.cs" />
     <Compile Include="Analysis\Util\TestCharArrayIterator.cs" />
     <Compile Include="Analysis\Util\TestCharArrayMap.cs" />


Mime
View raw message