lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject [09/27] lucenenet git commit: adding converted analysis common tests
Date Thu, 10 Dec 2015 18:38:58 GMT
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c64856a7/src/Lucene.Net.Tests.Analysis.Common/Analysis/No/TestNorwegianMinimalStemFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/No/TestNorwegianMinimalStemFilter.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/No/TestNorwegianMinimalStemFilter.cs
new file mode 100644
index 0000000..50d744a
--- /dev/null
+++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/No/TestNorwegianMinimalStemFilter.cs
@@ -0,0 +1,156 @@
+using System;
+
+namespace org.apache.lucene.analysis.no
+{
+
+	/*
+	 * 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.
+	 * The ASF licenses this file to You under the Apache License, Version 2.0
+	 * (the "License"); you may not use this file except in compliance with
+	 * the License.  You may obtain a copy of the License at
+	 *
+	 *     http://www.apache.org/licenses/LICENSE-2.0
+	 *
+	 * Unless required by applicable law or agreed to in writing, software
+	 * distributed under the License is distributed on an "AS IS" BASIS,
+	 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+	 * See the License for the specific language governing permissions and
+	 * limitations under the License.
+	 */
+
+
+	using KeywordTokenizer = org.apache.lucene.analysis.core.KeywordTokenizer;
+	using SetKeywordMarkerFilter = org.apache.lucene.analysis.miscellaneous.SetKeywordMarkerFilter;
+	using CharArraySet = org.apache.lucene.analysis.util.CharArraySet;
+
+//JAVA TO C# CONVERTER TODO TASK: This Java 'import static' statement cannot be converted to C#:
+//	import static org.apache.lucene.analysis.VocabularyAssert.*;
+//JAVA TO C# CONVERTER TODO TASK: This Java 'import static' statement cannot be converted to C#:
+//	import static org.apache.lucene.analysis.no.NorwegianLightStemmer.BOKMAAL;
+//JAVA TO C# CONVERTER TODO TASK: This Java 'import static' statement cannot be converted to C#:
+//	import static org.apache.lucene.analysis.no.NorwegianLightStemmer.NYNORSK;
+
+	/// <summary>
+	/// Simple tests for <seealso cref="NorwegianMinimalStemFilter"/>
+	/// </summary>
+	public class TestNorwegianMinimalStemFilter : BaseTokenStreamTestCase
+	{
+	  private Analyzer analyzer = new AnalyzerAnonymousInnerClassHelper();
+
+	  private class AnalyzerAnonymousInnerClassHelper : Analyzer
+	  {
+		  public AnalyzerAnonymousInnerClassHelper()
+		  {
+		  }
+
+		  protected internal override TokenStreamComponents createComponents(string fieldName, Reader reader)
+		  {
+			Tokenizer source = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
+			return new TokenStreamComponents(source, new NorwegianMinimalStemFilter(source, BOKMAAL));
+		  }
+	  }
+
+	  /// <summary>
+	  /// Test against a Bokmål vocabulary file </summary>
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testVocabulary() throws java.io.IOException
+	  public virtual void testVocabulary()
+	  {
+		assertVocabulary(analyzer, new System.IO.FileStream(getDataFile("nb_minimal.txt"), System.IO.FileMode.Open, System.IO.FileAccess.Read));
+	  }
+
+	  /// <summary>
+	  /// Test against a Nynorsk vocabulary file </summary>
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testNynorskVocabulary() throws java.io.IOException
+	  public virtual void testNynorskVocabulary()
+	  {
+		Analyzer analyzer = new AnalyzerAnonymousInnerClassHelper2(this);
+		assertVocabulary(analyzer, new System.IO.FileStream(getDataFile("nn_minimal.txt"), System.IO.FileMode.Open, System.IO.FileAccess.Read));
+	  }
+
+	  private class AnalyzerAnonymousInnerClassHelper2 : Analyzer
+	  {
+		  private readonly TestNorwegianMinimalStemFilter outerInstance;
+
+		  public AnalyzerAnonymousInnerClassHelper2(TestNorwegianMinimalStemFilter outerInstance)
+		  {
+			  this.outerInstance = outerInstance;
+		  }
+
+		  protected internal override TokenStreamComponents createComponents(string fieldName, Reader reader)
+		  {
+			Tokenizer source = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
+			return new TokenStreamComponents(source, new NorwegianMinimalStemFilter(source, NYNORSK));
+		  }
+	  }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testKeyword() throws java.io.IOException
+	  public virtual void testKeyword()
+	  {
+//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
+//ORIGINAL LINE: final org.apache.lucene.analysis.util.CharArraySet exclusionSet = new org.apache.lucene.analysis.util.CharArraySet(TEST_VERSION_CURRENT, asSet("sekretæren"), false);
+		CharArraySet exclusionSet = new CharArraySet(TEST_VERSION_CURRENT, asSet("sekretæren"), false);
+		Analyzer a = new AnalyzerAnonymousInnerClassHelper3(this, exclusionSet);
+		checkOneTerm(a, "sekretæren", "sekretæren");
+	  }
+
+	  private class AnalyzerAnonymousInnerClassHelper3 : Analyzer
+	  {
+		  private readonly TestNorwegianMinimalStemFilter outerInstance;
+
+		  private CharArraySet exclusionSet;
+
+		  public AnalyzerAnonymousInnerClassHelper3(TestNorwegianMinimalStemFilter outerInstance, CharArraySet exclusionSet)
+		  {
+			  this.outerInstance = outerInstance;
+			  this.exclusionSet = exclusionSet;
+		  }
+
+		  protected internal override TokenStreamComponents createComponents(string fieldName, Reader reader)
+		  {
+			Tokenizer source = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
+			TokenStream sink = new SetKeywordMarkerFilter(source, exclusionSet);
+			return new TokenStreamComponents(source, new NorwegianMinimalStemFilter(sink));
+		  }
+	  }
+
+	  /// <summary>
+	  /// blast some random strings through the analyzer </summary>
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testRandomStrings() throws Exception
+	  public virtual void testRandomStrings()
+	  {
+		Random random = random();
+		checkRandomData(random, analyzer, 1000 * RANDOM_MULTIPLIER);
+	  }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testEmptyTerm() throws java.io.IOException
+	  public virtual void testEmptyTerm()
+	  {
+		Analyzer a = new AnalyzerAnonymousInnerClassHelper4(this);
+		checkOneTerm(a, "", "");
+	  }
+
+	  private class AnalyzerAnonymousInnerClassHelper4 : Analyzer
+	  {
+		  private readonly TestNorwegianMinimalStemFilter outerInstance;
+
+		  public AnalyzerAnonymousInnerClassHelper4(TestNorwegianMinimalStemFilter outerInstance)
+		  {
+			  this.outerInstance = outerInstance;
+		  }
+
+		  protected internal override TokenStreamComponents createComponents(string fieldName, Reader reader)
+		  {
+			Tokenizer tokenizer = new KeywordTokenizer(reader);
+			return new TokenStreamComponents(tokenizer, new NorwegianMinimalStemFilter(tokenizer));
+		  }
+	  }
+	}
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c64856a7/src/Lucene.Net.Tests.Analysis.Common/Analysis/No/TestNorwegianMinimalStemFilterFactory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/No/TestNorwegianMinimalStemFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/No/TestNorwegianMinimalStemFilterFactory.cs
new file mode 100644
index 0000000..2deaf8d
--- /dev/null
+++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/No/TestNorwegianMinimalStemFilterFactory.cs
@@ -0,0 +1,81 @@
+namespace org.apache.lucene.analysis.no
+{
+
+	/*
+	 * 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.
+	 * The ASF licenses this file to You under the Apache License, Version 2.0
+	 * (the "License"); you may not use this file except in compliance with
+	 * the License.  You may obtain a copy of the License at
+	 *
+	 *     http://www.apache.org/licenses/LICENSE-2.0
+	 *
+	 * Unless required by applicable law or agreed to in writing, software
+	 * distributed under the License is distributed on an "AS IS" BASIS,
+	 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+	 * See the License for the specific language governing permissions and
+	 * limitations under the License.
+	 */
+
+
+	using BaseTokenStreamFactoryTestCase = org.apache.lucene.analysis.util.BaseTokenStreamFactoryTestCase;
+
+	/// <summary>
+	/// Simple tests to ensure the Norwegian Minimal stem factory is working.
+	/// </summary>
+	public class TestNorwegianMinimalStemFilterFactory : BaseTokenStreamFactoryTestCase
+	{
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testStemming() throws Exception
+	  public virtual void testStemming()
+	  {
+		Reader reader = new StringReader("eple eplet epler eplene eplets eplenes");
+		TokenStream stream = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
+		stream = tokenFilterFactory("NorwegianMinimalStem").create(stream);
+		assertTokenStreamContents(stream, new string[] {"epl", "epl", "epl", "epl", "epl", "epl"});
+	  }
+
+	  /// <summary>
+	  /// Test stemming with variant set explicitly to Bokmål </summary>
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testBokmaalStemming() throws Exception
+	  public virtual void testBokmaalStemming()
+	  {
+		Reader reader = new StringReader("eple eplet epler eplene eplets eplenes");
+		TokenStream stream = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
+		stream = tokenFilterFactory("NorwegianMinimalStem", "variant", "nb").create(stream);
+		assertTokenStreamContents(stream, new string[] {"epl", "epl", "epl", "epl", "epl", "epl"});
+	  }
+
+	  /// <summary>
+	  /// Test stemming with variant set explicitly to Nynorsk </summary>
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testNynorskStemming() throws Exception
+	  public virtual void testNynorskStemming()
+	  {
+		Reader reader = new StringReader("gut guten gutar gutane gutens gutanes");
+		TokenStream stream = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
+		stream = tokenFilterFactory("NorwegianMinimalStem", "variant", "nn").create(stream);
+		assertTokenStreamContents(stream, new string[] {"gut", "gut", "gut", "gut", "gut", "gut"});
+	  }
+
+	  /// <summary>
+	  /// Test that bogus arguments result in exception </summary>
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testBogusArguments() throws Exception
+	  public virtual void testBogusArguments()
+	  {
+		try
+		{
+		  tokenFilterFactory("NorwegianMinimalStem", "bogusArg", "bogusValue");
+		  fail();
+		}
+		catch (System.ArgumentException expected)
+		{
+		  assertTrue(expected.Message.contains("Unknown parameters"));
+		}
+	  }
+	}
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c64856a7/src/Lucene.Net.Tests.Analysis.Common/Analysis/Path/TestPathHierarchyTokenizer.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Path/TestPathHierarchyTokenizer.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Path/TestPathHierarchyTokenizer.cs
new file mode 100644
index 0000000..491d008
--- /dev/null
+++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Path/TestPathHierarchyTokenizer.cs
@@ -0,0 +1,223 @@
+using System;
+
+namespace org.apache.lucene.analysis.path
+{
+
+	/*
+	 * 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.
+	 * The ASF licenses this file to You under the Apache License, Version 2.0
+	 * (the "License"); you may not use this file except in compliance with
+	 * the License.  You may obtain a copy of the License at
+	 *
+	 *     http://www.apache.org/licenses/LICENSE-2.0
+	 *
+	 * Unless required by applicable law or agreed to in writing, software
+	 * distributed under the License is distributed on an "AS IS" BASIS,
+	 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+	 * See the License for the specific language governing permissions and
+	 * limitations under the License.
+	 */
+
+
+	using MappingCharFilter = org.apache.lucene.analysis.charfilter.MappingCharFilter;
+	using NormalizeCharMap = org.apache.lucene.analysis.charfilter.NormalizeCharMap;
+
+	public class TestPathHierarchyTokenizer : BaseTokenStreamTestCase
+	{
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testBasic() throws Exception
+	  public virtual void testBasic()
+	  {
+		string path = "/a/b/c";
+		PathHierarchyTokenizer t = new PathHierarchyTokenizer(new StringReader(path));
+		assertTokenStreamContents(t, new string[]{"/a", "/a/b", "/a/b/c"}, new int[]{0, 0, 0}, new int[]{2, 4, 6}, new int[]{1, 0, 0}, path.Length);
+	  }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testEndOfDelimiter() throws Exception
+	  public virtual void testEndOfDelimiter()
+	  {
+		string path = "/a/b/c/";
+		PathHierarchyTokenizer t = new PathHierarchyTokenizer(new StringReader(path));
+		assertTokenStreamContents(t, new string[]{"/a", "/a/b", "/a/b/c", "/a/b/c/"}, new int[]{0, 0, 0, 0}, new int[]{2, 4, 6, 7}, new int[]{1, 0, 0, 0}, path.Length);
+	  }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testStartOfChar() throws Exception
+	  public virtual void testStartOfChar()
+	  {
+		string path = "a/b/c";
+		PathHierarchyTokenizer t = new PathHierarchyTokenizer(new StringReader(path));
+		assertTokenStreamContents(t, new string[]{"a", "a/b", "a/b/c"}, new int[]{0, 0, 0}, new int[]{1, 3, 5}, new int[]{1, 0, 0}, path.Length);
+	  }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testStartOfCharEndOfDelimiter() throws Exception
+	  public virtual void testStartOfCharEndOfDelimiter()
+	  {
+		string path = "a/b/c/";
+		PathHierarchyTokenizer t = new PathHierarchyTokenizer(new StringReader(path));
+		assertTokenStreamContents(t, new string[]{"a", "a/b", "a/b/c", "a/b/c/"}, new int[]{0, 0, 0, 0}, new int[]{1, 3, 5, 6}, new int[]{1, 0, 0, 0}, path.Length);
+	  }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testOnlyDelimiter() throws Exception
+	  public virtual void testOnlyDelimiter()
+	  {
+		string path = "/";
+		PathHierarchyTokenizer t = new PathHierarchyTokenizer(new StringReader(path));
+		assertTokenStreamContents(t, new string[]{"/"}, new int[]{0}, new int[]{1}, new int[]{1}, path.Length);
+	  }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testOnlyDelimiters() throws Exception
+	  public virtual void testOnlyDelimiters()
+	  {
+		string path = "//";
+		PathHierarchyTokenizer t = new PathHierarchyTokenizer(new StringReader(path));
+		assertTokenStreamContents(t, new string[]{"/", "//"}, new int[]{0, 0}, new int[]{1, 2}, new int[]{1, 0}, path.Length);
+	  }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testReplace() throws Exception
+	  public virtual void testReplace()
+	  {
+		string path = "/a/b/c";
+		PathHierarchyTokenizer t = new PathHierarchyTokenizer(new StringReader(path), '/', '\\');
+		assertTokenStreamContents(t, new string[]{"\\a", "\\a\\b", "\\a\\b\\c"}, new int[]{0, 0, 0}, new int[]{2, 4, 6}, new int[]{1, 0, 0}, path.Length);
+	  }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testWindowsPath() throws Exception
+	  public virtual void testWindowsPath()
+	  {
+		string path = "c:\\a\\b\\c";
+		PathHierarchyTokenizer t = new PathHierarchyTokenizer(new StringReader(path), '\\', '\\');
+		assertTokenStreamContents(t, new string[]{"c:", "c:\\a", "c:\\a\\b", "c:\\a\\b\\c"}, new int[]{0, 0, 0, 0}, new int[]{2, 4, 6, 8}, new int[]{1, 0, 0, 0}, path.Length);
+	  }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testNormalizeWinDelimToLinuxDelim() throws Exception
+	  public virtual void testNormalizeWinDelimToLinuxDelim()
+	  {
+		NormalizeCharMap.Builder builder = new NormalizeCharMap.Builder();
+		builder.add("\\", "/");
+		NormalizeCharMap normMap = builder.build();
+		string path = "c:\\a\\b\\c";
+		Reader cs = new MappingCharFilter(normMap, new StringReader(path));
+		PathHierarchyTokenizer t = new PathHierarchyTokenizer(cs);
+		assertTokenStreamContents(t, new string[]{"c:", "c:/a", "c:/a/b", "c:/a/b/c"}, new int[]{0, 0, 0, 0}, new int[]{2, 4, 6, 8}, new int[]{1, 0, 0, 0}, path.Length);
+	  }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testBasicSkip() throws Exception
+	  public virtual void testBasicSkip()
+	  {
+		string path = "/a/b/c";
+		PathHierarchyTokenizer t = new PathHierarchyTokenizer(new StringReader(path), 1);
+		assertTokenStreamContents(t, new string[]{"/b", "/b/c"}, new int[]{2, 2}, new int[]{4, 6}, new int[]{1, 0}, path.Length);
+	  }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testEndOfDelimiterSkip() throws Exception
+	  public virtual void testEndOfDelimiterSkip()
+	  {
+		string path = "/a/b/c/";
+		PathHierarchyTokenizer t = new PathHierarchyTokenizer(new StringReader(path), 1);
+		assertTokenStreamContents(t, new string[]{"/b", "/b/c", "/b/c/"}, new int[]{2, 2, 2}, new int[]{4, 6, 7}, new int[]{1, 0, 0}, path.Length);
+	  }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testStartOfCharSkip() throws Exception
+	  public virtual void testStartOfCharSkip()
+	  {
+		string path = "a/b/c";
+		PathHierarchyTokenizer t = new PathHierarchyTokenizer(new StringReader(path), 1);
+		assertTokenStreamContents(t, new string[]{"/b", "/b/c"}, new int[]{1, 1}, new int[]{3, 5}, new int[]{1, 0}, path.Length);
+	  }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testStartOfCharEndOfDelimiterSkip() throws Exception
+	  public virtual void testStartOfCharEndOfDelimiterSkip()
+	  {
+		string path = "a/b/c/";
+		PathHierarchyTokenizer t = new PathHierarchyTokenizer(new StringReader(path), 1);
+		assertTokenStreamContents(t, new string[]{"/b", "/b/c", "/b/c/"}, new int[]{1, 1, 1}, new int[]{3, 5, 6}, new int[]{1, 0, 0}, path.Length);
+	  }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testOnlyDelimiterSkip() throws Exception
+	  public virtual void testOnlyDelimiterSkip()
+	  {
+		string path = "/";
+		PathHierarchyTokenizer t = new PathHierarchyTokenizer(new StringReader(path), 1);
+		assertTokenStreamContents(t, new string[]{}, new int[]{}, new int[]{}, new int[]{}, path.Length);
+	  }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testOnlyDelimitersSkip() throws Exception
+	  public virtual void testOnlyDelimitersSkip()
+	  {
+		string path = "//";
+		PathHierarchyTokenizer t = new PathHierarchyTokenizer(new StringReader(path), 1);
+		assertTokenStreamContents(t, new string[]{"/"}, new int[]{1}, new int[]{2}, new int[]{1}, path.Length);
+	  }
+
+	  /// <summary>
+	  /// blast some random strings through the analyzer </summary>
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testRandomStrings() throws Exception
+	  public virtual void testRandomStrings()
+	  {
+		Analyzer a = new AnalyzerAnonymousInnerClassHelper(this);
+		checkRandomData(random(), a, 1000 * RANDOM_MULTIPLIER);
+	  }
+
+	  private class AnalyzerAnonymousInnerClassHelper : Analyzer
+	  {
+		  private readonly TestPathHierarchyTokenizer outerInstance;
+
+		  public AnalyzerAnonymousInnerClassHelper(TestPathHierarchyTokenizer outerInstance)
+		  {
+			  this.outerInstance = outerInstance;
+		  }
+
+		  protected internal override TokenStreamComponents createComponents(string fieldName, Reader reader)
+		  {
+			Tokenizer tokenizer = new PathHierarchyTokenizer(reader);
+			return new TokenStreamComponents(tokenizer, tokenizer);
+		  }
+	  }
+
+	  /// <summary>
+	  /// blast some random large strings through the analyzer </summary>
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testRandomHugeStrings() throws Exception
+	  public virtual void testRandomHugeStrings()
+	  {
+		Random random = random();
+		Analyzer a = new AnalyzerAnonymousInnerClassHelper2(this);
+		checkRandomData(random, a, 100 * RANDOM_MULTIPLIER, 1027);
+	  }
+
+	  private class AnalyzerAnonymousInnerClassHelper2 : Analyzer
+	  {
+		  private readonly TestPathHierarchyTokenizer outerInstance;
+
+		  public AnalyzerAnonymousInnerClassHelper2(TestPathHierarchyTokenizer outerInstance)
+		  {
+			  this.outerInstance = outerInstance;
+		  }
+
+		  protected internal override TokenStreamComponents createComponents(string fieldName, Reader reader)
+		  {
+			Tokenizer tokenizer = new PathHierarchyTokenizer(reader);
+			return new TokenStreamComponents(tokenizer, tokenizer);
+		  }
+	  }
+	}
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c64856a7/src/Lucene.Net.Tests.Analysis.Common/Analysis/Path/TestReversePathHierarchyTokenizer.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Path/TestReversePathHierarchyTokenizer.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Path/TestReversePathHierarchyTokenizer.cs
new file mode 100644
index 0000000..a33bf5e
--- /dev/null
+++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Path/TestReversePathHierarchyTokenizer.cs
@@ -0,0 +1,191 @@
+using System;
+
+namespace org.apache.lucene.analysis.path
+{
+
+	/*
+	 * 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.
+	 * The ASF licenses this file to You under the Apache License, Version 2.0
+	 * (the "License"); you may not use this file except in compliance with
+	 * the License.  You may obtain a copy of the License at
+	 *
+	 *     http://www.apache.org/licenses/LICENSE-2.0
+	 *
+	 * Unless required by applicable law or agreed to in writing, software
+	 * distributed under the License is distributed on an "AS IS" BASIS,
+	 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+	 * See the License for the specific language governing permissions and
+	 * limitations under the License.
+	 */
+
+
+	using TokenStreamComponents = org.apache.lucene.analysis.Analyzer.TokenStreamComponents;
+
+	public class TestReversePathHierarchyTokenizer : BaseTokenStreamTestCase
+	{
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testBasicReverse() throws Exception
+	  public virtual void testBasicReverse()
+	  {
+		string path = "/a/b/c";
+		ReversePathHierarchyTokenizer t = new ReversePathHierarchyTokenizer(new StringReader(path));
+		assertTokenStreamContents(t, new string[]{"/a/b/c", "a/b/c", "b/c", "c"}, new int[]{0, 1, 3, 5}, new int[]{6, 6, 6, 6}, new int[]{1, 0, 0, 0}, path.Length);
+	  }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testEndOfDelimiterReverse() throws Exception
+	  public virtual void testEndOfDelimiterReverse()
+	  {
+		string path = "/a/b/c/";
+		ReversePathHierarchyTokenizer t = new ReversePathHierarchyTokenizer(new StringReader(path));
+		assertTokenStreamContents(t, new string[]{"/a/b/c/", "a/b/c/", "b/c/", "c/"}, new int[]{0, 1, 3, 5}, new int[]{7, 7, 7, 7}, new int[]{1, 0, 0, 0}, path.Length);
+	  }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testStartOfCharReverse() throws Exception
+	  public virtual void testStartOfCharReverse()
+	  {
+		string path = "a/b/c";
+		ReversePathHierarchyTokenizer t = new ReversePathHierarchyTokenizer(new StringReader(path));
+		assertTokenStreamContents(t, new string[]{"a/b/c", "b/c", "c"}, new int[]{0, 2, 4}, new int[]{5, 5, 5}, new int[]{1, 0, 0}, path.Length);
+	  }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testStartOfCharEndOfDelimiterReverse() throws Exception
+	  public virtual void testStartOfCharEndOfDelimiterReverse()
+	  {
+		string path = "a/b/c/";
+		ReversePathHierarchyTokenizer t = new ReversePathHierarchyTokenizer(new StringReader(path));
+		assertTokenStreamContents(t, new string[]{"a/b/c/", "b/c/", "c/"}, new int[]{0, 2, 4}, new int[]{6, 6, 6}, new int[]{1, 0, 0}, path.Length);
+	  }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testOnlyDelimiterReverse() throws Exception
+	  public virtual void testOnlyDelimiterReverse()
+	  {
+		string path = "/";
+		ReversePathHierarchyTokenizer t = new ReversePathHierarchyTokenizer(new StringReader(path));
+		assertTokenStreamContents(t, new string[]{"/"}, new int[]{0}, new int[]{1}, new int[]{1}, path.Length);
+	  }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testOnlyDelimitersReverse() throws Exception
+	  public virtual void testOnlyDelimitersReverse()
+	  {
+		string path = "//";
+		ReversePathHierarchyTokenizer t = new ReversePathHierarchyTokenizer(new StringReader(path));
+		assertTokenStreamContents(t, new string[]{"//", "/"}, new int[]{0, 1}, new int[]{2, 2}, new int[]{1, 0}, path.Length);
+	  }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testEndOfDelimiterReverseSkip() throws Exception
+	  public virtual void testEndOfDelimiterReverseSkip()
+	  {
+		string path = "/a/b/c/";
+		ReversePathHierarchyTokenizer t = new ReversePathHierarchyTokenizer(new StringReader(path), 1);
+		assertTokenStreamContents(t, new string[]{"/a/b/", "a/b/", "b/"}, new int[]{0, 1, 3}, new int[]{5, 5, 5}, new int[]{1, 0, 0}, path.Length);
+	  }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testStartOfCharReverseSkip() throws Exception
+	  public virtual void testStartOfCharReverseSkip()
+	  {
+		string path = "a/b/c";
+		ReversePathHierarchyTokenizer t = new ReversePathHierarchyTokenizer(new StringReader(path), 1);
+		assertTokenStreamContents(t, new string[]{"a/b/", "b/"}, new int[]{0, 2}, new int[]{4, 4}, new int[]{1, 0}, path.Length);
+	  }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testStartOfCharEndOfDelimiterReverseSkip() throws Exception
+	  public virtual void testStartOfCharEndOfDelimiterReverseSkip()
+	  {
+		string path = "a/b/c/";
+		ReversePathHierarchyTokenizer t = new ReversePathHierarchyTokenizer(new StringReader(path), 1);
+		assertTokenStreamContents(t, new string[]{"a/b/", "b/"}, new int[]{0, 2}, new int[]{4, 4}, new int[]{1, 0}, path.Length);
+	  }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testOnlyDelimiterReverseSkip() throws Exception
+	  public virtual void testOnlyDelimiterReverseSkip()
+	  {
+		string path = "/";
+		ReversePathHierarchyTokenizer t = new ReversePathHierarchyTokenizer(new StringReader(path), 1);
+		assertTokenStreamContents(t, new string[]{}, new int[]{}, new int[]{}, new int[]{}, path.Length);
+	  }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testOnlyDelimitersReverseSkip() throws Exception
+	  public virtual void testOnlyDelimitersReverseSkip()
+	  {
+		string path = "//";
+		ReversePathHierarchyTokenizer t = new ReversePathHierarchyTokenizer(new StringReader(path), 1);
+		assertTokenStreamContents(t, new string[]{"/"}, new int[]{0}, new int[]{1}, new int[]{1}, path.Length);
+	  }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testReverseSkip2() throws Exception
+	  public virtual void testReverseSkip2()
+	  {
+		string path = "/a/b/c/";
+		ReversePathHierarchyTokenizer t = new ReversePathHierarchyTokenizer(new StringReader(path), 2);
+		assertTokenStreamContents(t, new string[]{"/a/", "a/"}, new int[]{0, 1}, new int[]{3, 3}, new int[]{1, 0}, path.Length);
+	  }
+
+	  /// <summary>
+	  /// blast some random strings through the analyzer </summary>
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testRandomStrings() throws Exception
+	  public virtual void testRandomStrings()
+	  {
+		Analyzer a = new AnalyzerAnonymousInnerClassHelper(this);
+		checkRandomData(random(), a, 1000 * RANDOM_MULTIPLIER);
+	  }
+
+	  private class AnalyzerAnonymousInnerClassHelper : Analyzer
+	  {
+		  private readonly TestReversePathHierarchyTokenizer outerInstance;
+
+		  public AnalyzerAnonymousInnerClassHelper(TestReversePathHierarchyTokenizer outerInstance)
+		  {
+			  this.outerInstance = outerInstance;
+		  }
+
+		  protected internal override Analyzer.TokenStreamComponents createComponents(string fieldName, Reader reader)
+		  {
+			Tokenizer tokenizer = new ReversePathHierarchyTokenizer(reader);
+			return new Analyzer.TokenStreamComponents(tokenizer, tokenizer);
+		  }
+	  }
+
+	  /// <summary>
+	  /// blast some random large strings through the analyzer </summary>
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testRandomHugeStrings() throws Exception
+	  public virtual void testRandomHugeStrings()
+	  {
+		Random random = random();
+		Analyzer a = new AnalyzerAnonymousInnerClassHelper2(this);
+		checkRandomData(random, a, 100 * RANDOM_MULTIPLIER, 1027);
+	  }
+
+	  private class AnalyzerAnonymousInnerClassHelper2 : Analyzer
+	  {
+		  private readonly TestReversePathHierarchyTokenizer outerInstance;
+
+		  public AnalyzerAnonymousInnerClassHelper2(TestReversePathHierarchyTokenizer outerInstance)
+		  {
+			  this.outerInstance = outerInstance;
+		  }
+
+		  protected internal override Analyzer.TokenStreamComponents createComponents(string fieldName, Reader reader)
+		  {
+			Tokenizer tokenizer = new ReversePathHierarchyTokenizer(reader);
+			return new Analyzer.TokenStreamComponents(tokenizer, tokenizer);
+		  }
+	  }
+	}
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c64856a7/src/Lucene.Net.Tests.Analysis.Common/Analysis/Pattern/TestPatternCaptureGroupTokenFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Pattern/TestPatternCaptureGroupTokenFilter.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Pattern/TestPatternCaptureGroupTokenFilter.cs
new file mode 100644
index 0000000..69ebbcc
--- /dev/null
+++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Pattern/TestPatternCaptureGroupTokenFilter.cs
@@ -0,0 +1,231 @@
+namespace org.apache.lucene.analysis.pattern
+{
+
+	/*
+	 * 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.
+	 * The ASF licenses this file to You under the Apache License, Version 2.0
+	 * (the "License"); you may not use this file except in compliance with
+	 * the License.  You may obtain a copy of the License at
+	 *
+	 *     http://www.apache.org/licenses/LICENSE-2.0
+	 *
+	 * Unless required by applicable law or agreed to in writing, software
+	 * distributed under the License is distributed on an "AS IS" BASIS,
+	 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+	 * See the License for the specific language governing permissions and
+	 * limitations under the License.
+	 */
+
+
+	public class TestPatternCaptureGroupTokenFilter : BaseTokenStreamTestCase
+	{
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testNoPattern() throws Exception
+	  public virtual void testNoPattern()
+	  {
+		testPatterns("foobarbaz", new string[] {}, new string[] {"foobarbaz"}, new int[] {0}, new int[] {9}, new int[] {1}, false);
+		testPatterns("foobarbaz", new string[] {}, new string[] {"foobarbaz"}, new int[] {0}, new int[] {9}, new int[] {1}, true);
+
+		testPatterns("foo bar baz", new string[] {}, new string[] {"foo","bar","baz"}, new int[] {0,4,8}, new int[] {3,7,11}, new int[] {1,1,1}, false);
+
+		testPatterns("foo bar baz", new string[] {}, new string[] {"foo","bar","baz"}, new int[] {0,4,8}, new int[] {3,7,11}, new int[] {1,1,1}, true);
+	  }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testNoMatch() throws Exception
+	  public virtual void testNoMatch()
+	  {
+		testPatterns("foobarbaz", new string[] {"xx"}, new string[] {"foobarbaz"}, new int[] {0}, new int[] {9}, new int[] {1}, false);
+		testPatterns("foobarbaz", new string[] {"xx"}, new string[] {"foobarbaz"}, new int[] {0}, new int[] {9}, new int[] {1}, true);
+
+		testPatterns("foo bar baz", new string[] {"xx"}, new string[] {"foo","bar","baz"}, new int[] {0,4,8}, new int[] {3,7,11}, new int[] {1,1,1}, false);
+
+		testPatterns("foo bar baz", new string[] {"xx"}, new string[] {"foo","bar","baz"}, new int[] {0,4,8}, new int[] {3,7,11}, new int[] {1,1,1}, true);
+	  }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testNoCapture() throws Exception
+	  public virtual void testNoCapture()
+	  {
+		testPatterns("foobarbaz", new string[] {".."}, new string[] {"foobarbaz"}, new int[] {0}, new int[] {9}, new int[] {1}, false);
+		testPatterns("foobarbaz", new string[] {".."}, new string[] {"foobarbaz"}, new int[] {0}, new int[] {9}, new int[] {1}, true);
+
+		testPatterns("foo bar baz", new string[] {".."}, new string[] {"foo","bar","baz"}, new int[] {0,4,8}, new int[] {3,7,11}, new int[] {1,1,1}, false);
+
+		testPatterns("foo bar baz", new string[] {".."}, new string[] {"foo","bar","baz"}, new int[] {0,4,8}, new int[] {3,7,11}, new int[] {1,1,1}, true);
+	  }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testEmptyCapture() throws Exception
+	  public virtual void testEmptyCapture()
+	  {
+		testPatterns("foobarbaz", new string[] {".(y*)"}, new string[] {"foobarbaz"}, new int[] {0}, new int[] {9}, new int[] {1}, false);
+		testPatterns("foobarbaz", new string[] {".(y*)"}, new string[] {"foobarbaz"}, new int[] {0}, new int[] {9}, new int[] {1}, true);
+
+		testPatterns("foo bar baz", new string[] {".(y*)"}, new string[] {"foo","bar","baz"}, new int[] {0,4,8}, new int[] {3,7,11}, new int[] {1,1,1}, false);
+
+		testPatterns("foo bar baz", new string[] {".(y*)"}, new string[] {"foo","bar","baz"}, new int[] {0,4,8}, new int[] {3,7,11}, new int[] {1,1,1}, true);
+	  }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testCaptureAll() throws Exception
+	  public virtual void testCaptureAll()
+	  {
+		testPatterns("foobarbaz", new string[] {"(.+)"}, new string[] {"foobarbaz"}, new int[] {0}, new int[] {9}, new int[] {1}, false);
+		testPatterns("foobarbaz", new string[] {"(.+)"}, new string[] {"foobarbaz"}, new int[] {0}, new int[] {9}, new int[] {1}, true);
+
+		testPatterns("foo bar baz", new string[] {"(.+)"}, new string[] {"foo","bar","baz"}, new int[] {0,4,8}, new int[] {3,7,11}, new int[] {1,1,1}, false);
+
+		testPatterns("foo bar baz", new string[] {"(.+)"}, new string[] {"foo","bar","baz"}, new int[] {0,4,8}, new int[] {3,7,11}, new int[] {1,1,1}, true);
+	  }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testCaptureStart() throws Exception
+	  public virtual void testCaptureStart()
+	  {
+		testPatterns("foobarbaz", new string[] {"^(.)"}, new string[] {"f"}, new int[] {0}, new int[] {9}, new int[] {1}, false);
+		testPatterns("foobarbaz", new string[] {"^(.)"}, new string[] {"foobarbaz","f"}, new int[] {0,0}, new int[] {9,9}, new int[] {1,0}, true);
+
+		testPatterns("foo bar baz", new string[] {"^(.)"}, new string[] {"f","b","b"}, new int[] {0,4,8}, new int[] {3,7,11}, new int[] {1,1,1}, false);
+
+		testPatterns("foo bar baz", new string[] {"^(.)"}, new string[] {"foo","f","bar","b","baz","b"}, new int[] {0,0,4,4,8,8}, new int[] {3,3,7,7,11,11}, new int[] {1,0,1,0,1,0}, true);
+	  }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testCaptureMiddle() throws Exception
+	  public virtual void testCaptureMiddle()
+	  {
+		testPatterns("foobarbaz", new string[] {"^.(.)."}, new string[] {"o"}, new int[] {0}, new int[] {9}, new int[] {1}, false);
+		testPatterns("foobarbaz", new string[] {"^.(.)."}, new string[] {"foobarbaz","o"}, new int[] {0,0}, new int[] {9,9}, new int[] {1,0}, true);
+
+		testPatterns("foo bar baz", new string[] {"^.(.)."}, new string[] {"o","a","a"}, new int[] {0,4,8}, new int[] {3,7,11}, new int[] {1,1,1}, false);
+
+		testPatterns("foo bar baz", new string[] {"^.(.)."}, new string[] {"foo","o","bar","a","baz","a"}, new int[] {0,0,4,4,8,8}, new int[] {3,3,7,7,11,11}, new int[] {1,0,1,0,1,0}, true);
+	  }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testCaptureEnd() throws Exception
+	  public virtual void testCaptureEnd()
+	  {
+		testPatterns("foobarbaz", new string[] {"(.)$"}, new string[] {"z"}, new int[] {0}, new int[] {9}, new int[] {1}, false);
+		testPatterns("foobarbaz", new string[] {"(.)$"}, new string[] {"foobarbaz","z"}, new int[] {0,0}, new int[] {9,9}, new int[] {1,0}, true);
+
+		testPatterns("foo bar baz", new string[] {"(.)$"}, new string[] {"o","r","z"}, new int[] {0,4,8}, new int[] {3,7,11}, new int[] {1,1,1}, false);
+
+		testPatterns("foo bar baz", new string[] {"(.)$"}, new string[] {"foo","o","bar","r","baz","z"}, new int[] {0,0,4,4,8,8}, new int[] {3,3,7,7,11,11}, new int[] {1,0,1,0,1,0}, true);
+	  }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testCaptureStartMiddle() throws Exception
+	  public virtual void testCaptureStartMiddle()
+	  {
+		testPatterns("foobarbaz", new string[] {"^(.)(.)"}, new string[] {"f","o"}, new int[] {0,0}, new int[] {9,9}, new int[] {1,0}, false);
+		testPatterns("foobarbaz", new string[] {"^(.)(.)"}, new string[] {"foobarbaz","f","o"}, new int[] {0,0,0}, new int[] {9,9,9}, new int[] {1,0,0}, true);
+
+		testPatterns("foo bar baz", new string[] {"^(.)(.)"}, new string[] {"f","o","b","a","b","a"}, new int[] {0,0,4,4,8,8}, new int[] {3,3,7,7,11,11}, new int[] {1,0,1,0,1,0}, false);
+
+		testPatterns("foo bar baz", new string[] {"^(.)(.)"}, new string[] {"foo","f","o","bar","b","a","baz","b","a"}, new int[] {0,0,0,4,4,4,8,8,8}, new int[] {3,3,3,7,7,7,11,11,11}, new int[] {1,0,0,1,0,0,1,0,0}, true);
+	  }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testCaptureStartEnd() throws Exception
+	  public virtual void testCaptureStartEnd()
+	  {
+		testPatterns("foobarbaz", new string[] {"^(.).+(.)$"}, new string[] {"f","z"}, new int[] {0,0}, new int[] {9,9}, new int[] {1,0}, false);
+		testPatterns("foobarbaz", new string[] {"^(.).+(.)$"}, new string[] {"foobarbaz","f","z"}, new int[] {0,0,0}, new int[] {9,9,9}, new int[] {1,0,0}, true);
+
+		testPatterns("foo bar baz", new string[] {"^(.).+(.)$"}, new string[] {"f","o","b","r","b","z"}, new int[] {0,0,4,4,8,8}, new int[] {3,3,7,7,11,11}, new int[] {1,0,1,0,1,0}, false);
+
+		testPatterns("foo bar baz", new string[] {"^(.).+(.)$"}, new string[] {"foo","f","o","bar","b","r","baz","b","z"}, new int[] {0,0,0,4,4,4,8,8,8}, new int[] {3,3,3,7,7,7,11,11,11}, new int[] {1,0,0,1,0,0,1,0,0}, true);
+	  }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testCaptureMiddleEnd() throws Exception
+	  public virtual void testCaptureMiddleEnd()
+	  {
+		testPatterns("foobarbaz", new string[] {"(.)(.)$"}, new string[] {"a","z"}, new int[] {0,0}, new int[] {9,9}, new int[] {1,0}, false);
+		testPatterns("foobarbaz", new string[] {"(.)(.)$"}, new string[] {"foobarbaz","a","z"}, new int[] {0,0,0}, new int[] {9,9,9}, new int[] {1,0,0}, true);
+
+		testPatterns("foo bar baz", new string[] {"(.)(.)$"}, new string[] {"o","o","a","r","a","z"}, new int[] {0,0,4,4,8,8}, new int[] {3,3,7,7,11,11}, new int[] {1,0,1,0,1,0}, false);
+
+		testPatterns("foo bar baz", new string[] {"(.)(.)$"}, new string[] {"foo","o","o","bar","a","r","baz","a","z"}, new int[] {0,0,0,4,4,4,8,8,8}, new int[] {3,3,3,7,7,7,11,11,11}, new int[] {1,0,0,1,0,0,1,0,0}, true);
+	  }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testMultiCaptureOverlap() throws Exception
+	  public virtual void testMultiCaptureOverlap()
+	  {
+		testPatterns("foobarbaz", new string[] {"(.(.(.)))"}, new string[] {"foo","oo","o","bar","ar","r","baz","az","z"}, new int[] {0,0,0,0,0,0,0,0,0}, new int[] {9,9,9,9,9,9,9,9,9}, new int[] {1,0,0,0,0,0,0,0,0}, false);
+		testPatterns("foobarbaz", new string[] {"(.(.(.)))"}, new string[] {"foobarbaz","foo","oo","o","bar","ar","r","baz","az","z"}, new int[] {0,0,0,0,0,0,0,0,0,0}, new int[] {9,9,9,9,9,9,9,9,9,9}, new int[] {1,0,0,0,0,0,0,0,0,0}, true);
+
+		testPatterns("foo bar baz", new string[] {"(.(.(.)))"}, new string[] {"foo","oo","o","bar","ar","r","baz","az","z"}, new int[] {0,0,0,4,4,4,8,8,8}, new int[] {3,3,3,7,7,7,11,11,11}, new int[] {1,0,0,1,0,0,1,0,0}, false);
+
+		testPatterns("foo bar baz", new string[] {"(.(.(.)))"}, new string[] {"foo","oo","o","bar","ar","r","baz","az","z"}, new int[] {0,0,0,4,4,4,8,8,8}, new int[] {3,3,3,7,7,7,11,11,11}, new int[] {1,0,0,1,0,0,1,0,0}, true);
+	  }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testMultiPattern() throws Exception
+	  public virtual void testMultiPattern()
+	  {
+		testPatterns("aaabbbaaa", new string[] {"(aaa)","(bbb)","(ccc)"}, new string[] {"aaa","bbb","aaa"}, new int[] {0,0,0}, new int[] {9,9,9}, new int[] {1,0,0}, false);
+		testPatterns("aaabbbaaa", new string[] {"(aaa)","(bbb)","(ccc)"}, new string[] {"aaabbbaaa","aaa","bbb","aaa"}, new int[] {0,0,0,0}, new int[] {9,9,9,9}, new int[] {1,0,0,0}, true);
+
+		testPatterns("aaa bbb aaa", new string[] {"(aaa)","(bbb)","(ccc)"}, new string[] {"aaa","bbb","aaa"}, new int[] {0,4,8}, new int[] {3,7,11}, new int[] {1,1,1}, false);
+
+		testPatterns("aaa bbb aaa", new string[] {"(aaa)","(bbb)","(ccc)"}, new string[] {"aaa","bbb","aaa"}, new int[] {0,4,8}, new int[] {3,7,11}, new int[] {1,1,1}, true);
+	  }
+
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testCamelCase() throws Exception
+	  public virtual void testCamelCase()
+	  {
+		testPatterns("letsPartyLIKEits1999_dude", new string[] {"([A-Z]{2,})", "(?<![A-Z])([A-Z][a-z]+)", "(?:^|\\b|(?<=[0-9_])|(?<=[A-Z]{2}))([a-z]+)", "([0-9]+)"}, new string[] {"lets","Party","LIKE","its","1999","dude"}, new int[] {0,0,0,0,0,0}, new int[] {25,25,25,25,25,25}, new int[] {1,0,0,0,0,0,0}, false);
+		testPatterns("letsPartyLIKEits1999_dude", new string[] {"([A-Z]{2,})", "(?<![A-Z])([A-Z][a-z]+)", "(?:^|\\b|(?<=[0-9_])|(?<=[A-Z]{2}))([a-z]+)", "([0-9]+)"}, new string[] {"letsPartyLIKEits1999_dude","lets","Party","LIKE","its","1999","dude"}, new int[] {0,0,0,0,0,0,0}, new int[] {25,25,25,25,25,25,25}, new int[] {1,0,0,0,0,0,0,0}, true);
+	  }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testRandomString() throws Exception
+	  public virtual void testRandomString()
+	  {
+		Analyzer a = new AnalyzerAnonymousInnerClassHelper(this);
+
+		checkRandomData(random(), a, 1000 * RANDOM_MULTIPLIER);
+	  }
+
+	  private class AnalyzerAnonymousInnerClassHelper : Analyzer
+	  {
+		  private readonly TestPatternCaptureGroupTokenFilter outerInstance;
+
+		  public AnalyzerAnonymousInnerClassHelper(TestPatternCaptureGroupTokenFilter outerInstance)
+		  {
+			  this.outerInstance = outerInstance;
+		  }
+
+
+		  protected internal override TokenStreamComponents createComponents(string fieldName, Reader reader)
+		  {
+			Tokenizer tokenizer = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
+			return new TokenStreamComponents(tokenizer, new PatternCaptureGroupTokenFilter(tokenizer, false, Pattern.compile("((..)(..))")));
+		  }
+	  }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: private void testPatterns(String input, String[] regexes, String[] tokens, int[] startOffsets, int[] endOffsets, int[] positions, boolean preserveOriginal) throws Exception
+	  private void testPatterns(string input, string[] regexes, string[] tokens, int[] startOffsets, int[] endOffsets, int[] positions, bool preserveOriginal)
+	  {
+		Pattern[] patterns = new Pattern[regexes.Length];
+		for (int i = 0; i < regexes.Length; i++)
+		{
+		  patterns[i] = Pattern.compile(regexes[i]);
+		}
+		TokenStream ts = new PatternCaptureGroupTokenFilter(new MockTokenizer(new StringReader(input), MockTokenizer.WHITESPACE, false), preserveOriginal, patterns);
+		assertTokenStreamContents(ts, tokens, startOffsets, endOffsets, positions);
+	  }
+
+	}
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c64856a7/src/Lucene.Net.Tests.Analysis.Common/Analysis/Pattern/TestPatternReplaceCharFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Pattern/TestPatternReplaceCharFilter.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Pattern/TestPatternReplaceCharFilter.cs
new file mode 100644
index 0000000..2423cfd
--- /dev/null
+++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Pattern/TestPatternReplaceCharFilter.cs
@@ -0,0 +1,313 @@
+using System;
+using System.Text;
+
+/*
+ * 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.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace org.apache.lucene.analysis.pattern
+{
+
+
+	using TestUtil = org.apache.lucene.util.TestUtil;
+	using Ignore = org.junit.Ignore;
+
+	/// <summary>
+	/// Tests <seealso cref="PatternReplaceCharFilter"/>
+	/// </summary>
+	public class TestPatternReplaceCharFilter : BaseTokenStreamTestCase
+	{
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testFailingDot() throws java.io.IOException
+	  public virtual void testFailingDot()
+	  {
+		checkOutput("A. .B.", "\\.[\\s]*", ".", "A..B.", "A..B.");
+	  }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testLongerReplacement() throws java.io.IOException
+	  public virtual void testLongerReplacement()
+	  {
+		checkOutput("XXabcZZabcYY", "abc", "abcde", "XXabcdeZZabcdeYY", "XXabcccZZabcccYY");
+		checkOutput("XXabcabcYY", "abc", "abcde", "XXabcdeabcdeYY", "XXabcccabcccYY");
+		checkOutput("abcabcYY", "abc", "abcde", "abcdeabcdeYY", "abcccabcccYY");
+		checkOutput("YY", "^", "abcde", "abcdeYY", "YYYYYYY");
+			// Should be: "-----YY" but we're enforcing non-negative offsets.
+		checkOutput("YY", "$", "abcde", "YYabcde", "YYYYYYY");
+		checkOutput("XYZ", ".", "abc", "abcabcabc", "XXXYYYZZZ");
+		checkOutput("XYZ", ".", "$0abc", "XabcYabcZabc", "XXXXYYYYZZZZ");
+	  }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testShorterReplacement() throws java.io.IOException
+	  public virtual void testShorterReplacement()
+	  {
+		checkOutput("XXabcZZabcYY", "abc", "xy", "XXxyZZxyYY", "XXabZZabYY");
+		checkOutput("XXabcabcYY", "abc", "xy", "XXxyxyYY", "XXababYY");
+		checkOutput("abcabcYY", "abc", "xy", "xyxyYY", "ababYY");
+		checkOutput("abcabcYY", "abc", "", "YY", "YY");
+		checkOutput("YYabcabc", "abc", "", "YY", "YY");
+	  }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: private void checkOutput(String input, String pattern, String replacement, String expectedOutput, String expectedIndexMatchedOutput) throws java.io.IOException
+	  private void checkOutput(string input, string pattern, string replacement, string expectedOutput, string expectedIndexMatchedOutput)
+	  {
+		  CharFilter cs = new PatternReplaceCharFilter(pattern(pattern), replacement, new StringReader(input));
+
+		StringBuilder output = new StringBuilder();
+		for (int chr = cs.read(); chr > 0; chr = cs.read())
+		{
+		  output.Append((char) chr);
+		}
+
+		StringBuilder indexMatched = new StringBuilder();
+		for (int i = 0; i < output.Length; i++)
+		{
+		  indexMatched.Append((cs.correctOffset(i) < 0 ? "-" : input[cs.correctOffset(i)]));
+		}
+
+		bool outputGood = expectedOutput.Equals(output.ToString());
+		bool indexMatchedGood = expectedIndexMatchedOutput.Equals(indexMatched.ToString());
+
+		if (!outputGood || !indexMatchedGood || false)
+		{
+		  Console.WriteLine("Pattern : " + pattern);
+		  Console.WriteLine("Replac. : " + replacement);
+		  Console.WriteLine("Input   : " + input);
+		  Console.WriteLine("Output  : " + output);
+		  Console.WriteLine("Expected: " + expectedOutput);
+		  Console.WriteLine("Output/i: " + indexMatched);
+		  Console.WriteLine("Expected: " + expectedIndexMatchedOutput);
+		  Console.WriteLine();
+		}
+
+		assertTrue("Output doesn't match.", outputGood);
+		assertTrue("Index-matched output doesn't match.", indexMatchedGood);
+	  }
+
+	  //           1111
+	  // 01234567890123
+	  // this is test.
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testNothingChange() throws java.io.IOException
+	  public virtual void testNothingChange()
+	  {
+		const string BLOCK = "this is test.";
+		CharFilter cs = new PatternReplaceCharFilter(pattern("(aa)\\s+(bb)\\s+(cc)"), "$1$2$3", new StringReader(BLOCK));
+		TokenStream ts = new MockTokenizer(cs, MockTokenizer.WHITESPACE, false);
+		assertTokenStreamContents(ts, new string[] {"this", "is", "test."}, new int[] {0, 5, 8}, new int[] {4, 7, 13}, BLOCK.Length);
+	  }
+
+	  // 012345678
+	  // aa bb cc
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testReplaceByEmpty() throws java.io.IOException
+	  public virtual void testReplaceByEmpty()
+	  {
+		const string BLOCK = "aa bb cc";
+		CharFilter cs = new PatternReplaceCharFilter(pattern("(aa)\\s+(bb)\\s+(cc)"), "", new StringReader(BLOCK));
+		TokenStream ts = new MockTokenizer(cs, MockTokenizer.WHITESPACE, false);
+		assertTokenStreamContents(ts, new string[] {});
+	  }
+
+	  // 012345678
+	  // aa bb cc
+	  // aa#bb#cc
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void test1block1matchSameLength() throws java.io.IOException
+	  public virtual void test1block1matchSameLength()
+	  {
+		const string BLOCK = "aa bb cc";
+		CharFilter cs = new PatternReplaceCharFilter(pattern("(aa)\\s+(bb)\\s+(cc)"), "$1#$2#$3", new StringReader(BLOCK));
+		TokenStream ts = new MockTokenizer(cs, MockTokenizer.WHITESPACE, false);
+		assertTokenStreamContents(ts, new string[] {"aa#bb#cc"}, new int[] {0}, new int[] {8}, BLOCK.Length);
+	  }
+
+	  //           11111
+	  // 012345678901234
+	  // aa bb cc dd
+	  // aa##bb###cc dd
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void test1block1matchLonger() throws java.io.IOException
+	  public virtual void test1block1matchLonger()
+	  {
+		const string BLOCK = "aa bb cc dd";
+		CharFilter cs = new PatternReplaceCharFilter(pattern("(aa)\\s+(bb)\\s+(cc)"), "$1##$2###$3", new StringReader(BLOCK));
+		TokenStream ts = new MockTokenizer(cs, MockTokenizer.WHITESPACE, false);
+		assertTokenStreamContents(ts, new string[] {"aa##bb###cc", "dd"}, new int[] {0, 9}, new int[] {8, 11}, BLOCK.Length);
+	  }
+
+	  // 01234567
+	  //  a  a
+	  //  aa  aa
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void test1block2matchLonger() throws java.io.IOException
+	  public virtual void test1block2matchLonger()
+	  {
+		const string BLOCK = " a  a";
+		CharFilter cs = new PatternReplaceCharFilter(pattern("a"), "aa", new StringReader(BLOCK));
+		TokenStream ts = new MockTokenizer(cs, MockTokenizer.WHITESPACE, false);
+		assertTokenStreamContents(ts, new string[] {"aa", "aa"}, new int[] {1, 4}, new int[] {2, 5}, BLOCK.Length);
+	  }
+
+	  //           11111
+	  // 012345678901234
+	  // aa  bb   cc dd
+	  // aa#bb dd
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void test1block1matchShorter() throws java.io.IOException
+	  public virtual void test1block1matchShorter()
+	  {
+		const string BLOCK = "aa  bb   cc dd";
+		CharFilter cs = new PatternReplaceCharFilter(pattern("(aa)\\s+(bb)\\s+(cc)"), "$1#$2", new StringReader(BLOCK));
+		TokenStream ts = new MockTokenizer(cs, MockTokenizer.WHITESPACE, false);
+		assertTokenStreamContents(ts, new string[] {"aa#bb", "dd"}, new int[] {0, 12}, new int[] {11, 14}, BLOCK.Length);
+	  }
+
+	  //           111111111122222222223333
+	  // 0123456789012345678901234567890123
+	  //   aa bb cc --- aa bb aa   bb   cc
+	  //   aa  bb  cc --- aa bb aa  bb  cc
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void test1blockMultiMatches() throws java.io.IOException
+	  public virtual void test1blockMultiMatches()
+	  {
+		const string BLOCK = "  aa bb cc --- aa bb aa   bb   cc";
+		CharFilter cs = new PatternReplaceCharFilter(pattern("(aa)\\s+(bb)\\s+(cc)"), "$1  $2  $3", new StringReader(BLOCK));
+		TokenStream ts = new MockTokenizer(cs, MockTokenizer.WHITESPACE, false);
+		assertTokenStreamContents(ts, new string[] {"aa", "bb", "cc", "---", "aa", "bb", "aa", "bb", "cc"}, new int[] {2, 6, 9, 11, 15, 18, 21, 25, 29}, new int[] {4, 8, 10, 14, 17, 20, 23, 27, 33}, BLOCK.Length);
+	  }
+
+	  //           11111111112222222222333333333
+	  // 012345678901234567890123456789012345678
+	  //   aa bb cc --- aa bb aa. bb aa   bb cc
+	  //   aa##bb cc --- aa##bb aa. bb aa##bb cc
+
+	  //   aa bb cc --- aa bbbaa. bb aa   b cc
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void test2blocksMultiMatches() throws java.io.IOException
+	  public virtual void test2blocksMultiMatches()
+	  {
+		const string BLOCK = "  aa bb cc --- aa bb aa. bb aa   bb cc";
+
+		CharFilter cs = new PatternReplaceCharFilter(pattern("(aa)\\s+(bb)"), "$1##$2", new StringReader(BLOCK));
+		TokenStream ts = new MockTokenizer(cs, MockTokenizer.WHITESPACE, false);
+		assertTokenStreamContents(ts, new string[] {"aa##bb", "cc", "---", "aa##bb", "aa.", "bb", "aa##bb", "cc"}, new int[] {2, 8, 11, 15, 21, 25, 28, 36}, new int[] {7, 10, 14, 20, 24, 27, 35, 38}, BLOCK.Length);
+	  }
+
+	  //           11111111112222222222333333333
+	  // 012345678901234567890123456789012345678
+	  //  a bb - ccc . --- bb a . ccc ccc bb
+	  //  aa b - c . --- b aa . c c b
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testChain() throws java.io.IOException
+	  public virtual void testChain()
+	  {
+		const string BLOCK = " a bb - ccc . --- bb a . ccc ccc bb";
+		CharFilter cs = new PatternReplaceCharFilter(pattern("a"), "aa", new StringReader(BLOCK));
+		cs = new PatternReplaceCharFilter(pattern("bb"), "b", cs);
+		cs = new PatternReplaceCharFilter(pattern("ccc"), "c", cs);
+		TokenStream ts = new MockTokenizer(cs, MockTokenizer.WHITESPACE, false);
+		assertTokenStreamContents(ts, new string[] {"aa", "b", "-", "c", ".", "---", "b", "aa", ".", "c", "c", "b"}, new int[] {1, 3, 6, 8, 12, 14, 18, 21, 23, 25, 29, 33}, new int[] {2, 5, 7, 11, 13, 17, 20, 22, 24, 28, 32, 35}, BLOCK.Length);
+	  }
+
+	  private Pattern pattern(string p)
+	  {
+		return Pattern.compile(p);
+	  }
+
+	  /// <summary>
+	  /// A demonstration of how backtracking regular expressions can lead to relatively 
+	  /// easy DoS attacks.
+	  /// </summary>
+	  /// <seealso cref= "http://swtch.com/~rsc/regexp/regexp1.html" </seealso>
+//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
+//ORIGINAL LINE: @Ignore public void testNastyPattern() throws Exception
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+	  public virtual void testNastyPattern()
+	  {
+		Pattern p = Pattern.compile("(c.+)*xy");
+		string input = "[;<!--aecbbaa--><    febcfdc fbb = \"fbeeebff\" fc = dd   >\\';<eefceceaa e= babae\" eacbaff =\"fcfaccacd\" = bcced>>><  bccaafe edb = ecfccdff\"   <?</script><    edbd ebbcd=\"faacfcc\" aeca= bedbc ceeaac =adeafde aadccdaf = \"afcc ffda=aafbe &#x16921ed5\"1843785582']";
+		for (int i = 0; i < input.Length; i++)
+		{
+		  Matcher matcher = p.matcher(input.Substring(0, i));
+		  long t = DateTimeHelperClass.CurrentUnixTimeMillis();
+		  if (matcher.find())
+		  {
+			Console.WriteLine(matcher.group());
+		  }
+		  Console.WriteLine(i + " > " + (DateTimeHelperClass.CurrentUnixTimeMillis() - t) / 1000.0);
+		}
+	  }
+
+	  /// <summary>
+	  /// blast some random strings through the analyzer </summary>
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testRandomStrings() throws Exception
+	  public virtual void testRandomStrings()
+	  {
+		int numPatterns = 10 + random().Next(20);
+		Random random = new Random(random().nextLong());
+		for (int i = 0; i < numPatterns; i++)
+		{
+//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
+//ORIGINAL LINE: final java.util.regex.Pattern p = org.apache.lucene.util.TestUtil.randomPattern(random());
+		  Pattern p = TestUtil.randomPattern(random());
+
+//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
+//ORIGINAL LINE: final String replacement = org.apache.lucene.util.TestUtil.randomSimpleString(random);
+		  string replacement = TestUtil.randomSimpleString(random);
+		  Analyzer a = new AnalyzerAnonymousInnerClassHelper(this, p, replacement);
+
+		  /* max input length. don't make it longer -- exponential processing
+		   * time for certain patterns. */ 
+		  const int maxInputLength = 30;
+		  /* ASCII only input?: */
+		  const bool asciiOnly = true;
+		  checkRandomData(random, a, 250 * RANDOM_MULTIPLIER, maxInputLength, asciiOnly);
+		}
+	  }
+
+	  private class AnalyzerAnonymousInnerClassHelper : Analyzer
+	  {
+		  private readonly TestPatternReplaceCharFilter outerInstance;
+
+		  private Pattern p;
+		  private string replacement;
+
+		  public AnalyzerAnonymousInnerClassHelper(TestPatternReplaceCharFilter outerInstance, Pattern p, string replacement)
+		  {
+			  this.outerInstance = outerInstance;
+			  this.p = p;
+			  this.replacement = replacement;
+		  }
+
+		  protected internal override TokenStreamComponents createComponents(string fieldName, Reader reader)
+		  {
+			Tokenizer tokenizer = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
+			return new TokenStreamComponents(tokenizer, tokenizer);
+		  }
+
+		  protected internal override Reader initReader(string fieldName, Reader reader)
+		  {
+			return new PatternReplaceCharFilter(p, replacement, reader);
+		  }
+	  }
+	}
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c64856a7/src/Lucene.Net.Tests.Analysis.Common/Analysis/Pattern/TestPatternReplaceCharFilterFactory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Pattern/TestPatternReplaceCharFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Pattern/TestPatternReplaceCharFilterFactory.cs
new file mode 100644
index 0000000..a41564b
--- /dev/null
+++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Pattern/TestPatternReplaceCharFilterFactory.cs
@@ -0,0 +1,86 @@
+namespace org.apache.lucene.analysis.pattern
+{
+
+	/*
+	 * 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.
+	 * The ASF licenses this file to You under the Apache License, Version 2.0
+	 * (the "License"); you may not use this file except in compliance with
+	 * the License.  You may obtain a copy of the License at
+	 *
+	 *     http://www.apache.org/licenses/LICENSE-2.0
+	 *
+	 * Unless required by applicable law or agreed to in writing, software
+	 * distributed under the License is distributed on an "AS IS" BASIS,
+	 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+	 * See the License for the specific language governing permissions and
+	 * limitations under the License.
+	 */
+
+
+	using BaseTokenStreamFactoryTestCase = org.apache.lucene.analysis.util.BaseTokenStreamFactoryTestCase;
+
+	/// <summary>
+	/// Simple tests to ensure this factory is working
+	/// </summary>
+	public class TestPatternReplaceCharFilterFactory : BaseTokenStreamFactoryTestCase
+	{
+
+	  //           1111
+	  // 01234567890123
+	  // this is test.
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testNothingChange() throws Exception
+	  public virtual void testNothingChange()
+	  {
+		Reader reader = new StringReader("this is test.");
+		reader = charFilterFactory("PatternReplace", "pattern", "(aa)\\s+(bb)\\s+(cc)", "replacement", "$1$2$3").create(reader);
+		TokenStream ts = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
+		assertTokenStreamContents(ts, new string[] {"this", "is", "test."}, new int[] {0, 5, 8}, new int[] {4, 7, 13});
+	  }
+
+	  // 012345678
+	  // aa bb cc
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testReplaceByEmpty() throws Exception
+	  public virtual void testReplaceByEmpty()
+	  {
+		Reader reader = new StringReader("aa bb cc");
+		reader = charFilterFactory("PatternReplace", "pattern", "(aa)\\s+(bb)\\s+(cc)").create(reader);
+		TokenStream ts = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
+		assertTokenStreamContents(ts, new string[] {});
+	  }
+
+	  // 012345678
+	  // aa bb cc
+	  // aa#bb#cc
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void test1block1matchSameLength() throws Exception
+	  public virtual void test1block1matchSameLength()
+	  {
+		Reader reader = new StringReader("aa bb cc");
+		reader = charFilterFactory("PatternReplace", "pattern", "(aa)\\s+(bb)\\s+(cc)", "replacement", "$1#$2#$3").create(reader);
+		TokenStream ts = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
+		assertTokenStreamContents(ts, new string[] {"aa#bb#cc"}, new int[] {0}, new int[] {8});
+	  }
+
+	  /// <summary>
+	  /// Test that bogus arguments result in exception </summary>
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testBogusArguments() throws Exception
+	  public virtual void testBogusArguments()
+	  {
+		try
+		{
+		  charFilterFactory("PatternReplace", "pattern", "something", "bogusArg", "bogusValue");
+		  fail();
+		}
+		catch (System.ArgumentException expected)
+		{
+		  assertTrue(expected.Message.contains("Unknown parameters"));
+		}
+	  }
+	}
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c64856a7/src/Lucene.Net.Tests.Analysis.Common/Analysis/Pattern/TestPatternReplaceFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Pattern/TestPatternReplaceFilter.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Pattern/TestPatternReplaceFilter.cs
new file mode 100644
index 0000000..1c077a3
--- /dev/null
+++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Pattern/TestPatternReplaceFilter.cs
@@ -0,0 +1,145 @@
+/*
+ * 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.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace org.apache.lucene.analysis.pattern
+{
+
+	using KeywordTokenizer = org.apache.lucene.analysis.core.KeywordTokenizer;
+
+
+	public class TestPatternReplaceFilter : BaseTokenStreamTestCase
+	{
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testReplaceAll() throws Exception
+	  public virtual void testReplaceAll()
+	  {
+		string input = "aabfooaabfooabfoob ab caaaaaaaaab";
+		TokenStream ts = new PatternReplaceFilter(new MockTokenizer(new StringReader(input), MockTokenizer.WHITESPACE, false), Pattern.compile("a*b"), "-", true);
+		assertTokenStreamContents(ts, new string[] {"-foo-foo-foo-", "-", "c-"});
+	  }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testReplaceFirst() throws Exception
+	  public virtual void testReplaceFirst()
+	  {
+		string input = "aabfooaabfooabfoob ab caaaaaaaaab";
+		TokenStream ts = new PatternReplaceFilter(new MockTokenizer(new StringReader(input), MockTokenizer.WHITESPACE, false), Pattern.compile("a*b"), "-", false);
+		assertTokenStreamContents(ts, new string[] {"-fooaabfooabfoob", "-", "c-"});
+	  }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testStripFirst() throws Exception
+	  public virtual void testStripFirst()
+	  {
+		string input = "aabfooaabfooabfoob ab caaaaaaaaab";
+		TokenStream ts = new PatternReplaceFilter(new MockTokenizer(new StringReader(input), MockTokenizer.WHITESPACE, false), Pattern.compile("a*b"), null, false);
+		assertTokenStreamContents(ts, new string[] {"fooaabfooabfoob", "", "c"});
+	  }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testStripAll() throws Exception
+	  public virtual void testStripAll()
+	  {
+		string input = "aabfooaabfooabfoob ab caaaaaaaaab";
+		TokenStream ts = new PatternReplaceFilter(new MockTokenizer(new StringReader(input), MockTokenizer.WHITESPACE, false), Pattern.compile("a*b"), null, true);
+		assertTokenStreamContents(ts, new string[] {"foofoofoo", "", "c"});
+	  }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testReplaceAllWithBackRef() throws Exception
+	  public virtual void testReplaceAllWithBackRef()
+	  {
+		string input = "aabfooaabfooabfoob ab caaaaaaaaab";
+		TokenStream ts = new PatternReplaceFilter(new MockTokenizer(new StringReader(input), MockTokenizer.WHITESPACE, false), Pattern.compile("(a*)b"), "$1\\$", true);
+		assertTokenStreamContents(ts, new string[] {"aa$fooaa$fooa$foo$", "a$", "caaaaaaaaa$"});
+	  }
+
+	  /// <summary>
+	  /// blast some random strings through the analyzer </summary>
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testRandomStrings() throws Exception
+	  public virtual void testRandomStrings()
+	  {
+		Analyzer a = new AnalyzerAnonymousInnerClassHelper(this);
+		checkRandomData(random(), a, 1000 * RANDOM_MULTIPLIER);
+
+		Analyzer b = new AnalyzerAnonymousInnerClassHelper2(this);
+		checkRandomData(random(), b, 1000 * RANDOM_MULTIPLIER);
+	  }
+
+	  private class AnalyzerAnonymousInnerClassHelper : Analyzer
+	  {
+		  private readonly TestPatternReplaceFilter outerInstance;
+
+		  public AnalyzerAnonymousInnerClassHelper(TestPatternReplaceFilter outerInstance)
+		  {
+			  this.outerInstance = outerInstance;
+		  }
+
+		  protected internal override TokenStreamComponents createComponents(string fieldName, Reader reader)
+		  {
+			Tokenizer tokenizer = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
+			TokenStream filter = new PatternReplaceFilter(tokenizer, Pattern.compile("a"), "b", false);
+			return new TokenStreamComponents(tokenizer, filter);
+		  }
+	  }
+
+	  private class AnalyzerAnonymousInnerClassHelper2 : Analyzer
+	  {
+		  private readonly TestPatternReplaceFilter outerInstance;
+
+		  public AnalyzerAnonymousInnerClassHelper2(TestPatternReplaceFilter outerInstance)
+		  {
+			  this.outerInstance = outerInstance;
+		  }
+
+		  protected internal override TokenStreamComponents createComponents(string fieldName, Reader reader)
+		  {
+			Tokenizer tokenizer = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
+			TokenStream filter = new PatternReplaceFilter(tokenizer, Pattern.compile("a"), "b", true);
+			return new TokenStreamComponents(tokenizer, filter);
+		  }
+	  }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testEmptyTerm() throws java.io.IOException
+	  public virtual void testEmptyTerm()
+	  {
+		Analyzer a = new AnalyzerAnonymousInnerClassHelper3(this);
+		checkOneTerm(a, "", "");
+	  }
+
+	  private class AnalyzerAnonymousInnerClassHelper3 : Analyzer
+	  {
+		  private readonly TestPatternReplaceFilter outerInstance;
+
+		  public AnalyzerAnonymousInnerClassHelper3(TestPatternReplaceFilter outerInstance)
+		  {
+			  this.outerInstance = outerInstance;
+		  }
+
+		  protected internal override TokenStreamComponents createComponents(string fieldName, Reader reader)
+		  {
+			Tokenizer tokenizer = new KeywordTokenizer(reader);
+			return new TokenStreamComponents(tokenizer, new PatternReplaceFilter(tokenizer, Pattern.compile("a"), "b", true));
+		  }
+	  }
+
+	}
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c64856a7/src/Lucene.Net.Tests.Analysis.Common/Analysis/Pattern/TestPatternReplaceFilterFactory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Pattern/TestPatternReplaceFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Pattern/TestPatternReplaceFilterFactory.cs
new file mode 100644
index 0000000..306d38c
--- /dev/null
+++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Pattern/TestPatternReplaceFilterFactory.cs
@@ -0,0 +1,59 @@
+namespace org.apache.lucene.analysis.pattern
+{
+
+	/*
+	 * 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.
+	 * The ASF licenses this file to You under the Apache License, Version 2.0
+	 * (the "License"); you may not use this file except in compliance with
+	 * the License.  You may obtain a copy of the License at
+	 *
+	 *     http://www.apache.org/licenses/LICENSE-2.0
+	 *
+	 * Unless required by applicable law or agreed to in writing, software
+	 * distributed under the License is distributed on an "AS IS" BASIS,
+	 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+	 * See the License for the specific language governing permissions and
+	 * limitations under the License.
+	 */
+
+	using BaseTokenStreamFactoryTestCase = org.apache.lucene.analysis.util.BaseTokenStreamFactoryTestCase;
+
+
+	/// <summary>
+	/// Simple tests to ensure this factory is working
+	/// </summary>
+	public class TestPatternReplaceFilterFactory : BaseTokenStreamFactoryTestCase
+	{
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testReplaceAll() throws Exception
+	  public virtual void testReplaceAll()
+	  {
+		Reader reader = new StringReader("aabfooaabfooabfoob ab caaaaaaaaab");
+		TokenStream stream = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
+		stream = tokenFilterFactory("PatternReplace", "pattern", "a*b", "replacement", "-").create(stream);
+
+		assertTokenStreamContents(stream, new string[] {"-foo-foo-foo-", "-", "c-"});
+	  }
+
+	  /// <summary>
+	  /// Test that bogus arguments result in exception </summary>
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testBogusArguments() throws Exception
+	  public virtual void testBogusArguments()
+	  {
+		try
+		{
+		  tokenFilterFactory("PatternReplace", "pattern", "something", "bogusArg", "bogusValue");
+		  fail();
+		}
+		catch (System.ArgumentException expected)
+		{
+		  assertTrue(expected.Message.contains("Unknown parameters"));
+		}
+	  }
+	}
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c64856a7/src/Lucene.Net.Tests.Analysis.Common/Analysis/Pattern/TestPatternTokenizer.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Pattern/TestPatternTokenizer.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Pattern/TestPatternTokenizer.cs
new file mode 100644
index 0000000..28d8b03
--- /dev/null
+++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Pattern/TestPatternTokenizer.cs
@@ -0,0 +1,170 @@
+using System.Collections.Generic;
+using System.Text;
+
+/*
+ * 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.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace org.apache.lucene.analysis.pattern
+{
+
+
+	using TokenStreamComponents = org.apache.lucene.analysis.Analyzer.TokenStreamComponents;
+	using MappingCharFilter = org.apache.lucene.analysis.charfilter.MappingCharFilter;
+	using NormalizeCharMap = org.apache.lucene.analysis.charfilter.NormalizeCharMap;
+	using PathHierarchyTokenizer = org.apache.lucene.analysis.path.PathHierarchyTokenizer;
+	using CharTermAttribute = org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
+
+	public class TestPatternTokenizer : BaseTokenStreamTestCase
+	{
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testSplitting() throws Exception
+	  public virtual void testSplitting()
+	  {
+		string qpattern = "\\'([^\\']+)\\'"; // get stuff between "'"
+		string[][] tests = new string[][]
+		{
+			new string[] {"-1", "--", "aaa--bbb--ccc", "aaa bbb ccc"},
+			new string[] {"-1", ":", "aaa:bbb:ccc", "aaa bbb ccc"},
+			new string[] {"-1", "\\p{Space}", "aaa   bbb \t\tccc  ", "aaa bbb ccc"},
+			new string[] {"-1", ":", "boo:and:foo", "boo and foo"},
+			new string[] {"-1", "o", "boo:and:foo", "b :and:f"},
+			new string[] {"0", ":", "boo:and:foo", ": :"},
+			new string[] {"0", qpattern, "aaa 'bbb' 'ccc'", "'bbb' 'ccc'"},
+			new string[] {"1", qpattern, "aaa 'bbb' 'ccc'", "bbb ccc"}
+		};
+
+		foreach (string[] test in tests)
+		{
+		  TokenStream stream = new PatternTokenizer(new StringReader(test[2]), Pattern.compile(test[1]), int.Parse(test[0]));
+		  string @out = tsToString(stream);
+		  // System.out.println( test[2] + " ==> " + out );
+
+		  assertEquals("pattern: " + test[1] + " with input: " + test[2], test[3], @out);
+
+		  // Make sure it is the same as if we called 'split'
+		  // test disabled, as we remove empty tokens
+		  /*if( "-1".equals( test[0] ) ) {
+		    String[] split = test[2].split( test[1] );
+		    stream = tokenizer.create( new StringReader( test[2] ) );
+		    int i=0;
+		    for( Token t = stream.next(); null != t; t = stream.next() ) 
+		    {
+		      assertEquals( "split: "+test[1] + " "+i, split[i++], new String(t.termBuffer(), 0, t.termLength()) );
+		    }
+		  }*/
+		}
+	  }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testOffsetCorrection() throws Exception
+	  public virtual void testOffsetCorrection()
+	  {
+		const string INPUT = "G&uuml;nther G&uuml;nther is here";
+
+		// create MappingCharFilter
+		IList<string> mappingRules = new List<string>();
+		mappingRules.Add("\"&uuml;\" => \"ü\"");
+		NormalizeCharMap.Builder builder = new NormalizeCharMap.Builder();
+		builder.add("&uuml;", "ü");
+		NormalizeCharMap normMap = builder.build();
+		CharFilter charStream = new MappingCharFilter(normMap, new StringReader(INPUT));
+
+		// create PatternTokenizer
+		TokenStream stream = new PatternTokenizer(charStream, Pattern.compile("[,;/\\s]+"), -1);
+		assertTokenStreamContents(stream, new string[] {"Günther", "Günther", "is", "here"}, new int[] {0, 13, 26, 29}, new int[] {12, 25, 28, 33}, INPUT.Length);
+
+		charStream = new MappingCharFilter(normMap, new StringReader(INPUT));
+		stream = new PatternTokenizer(charStream, Pattern.compile("Günther"), 0);
+		assertTokenStreamContents(stream, new string[] {"Günther", "Günther"}, new int[] {0, 13}, new int[] {12, 25}, INPUT.Length);
+	  }
+
+	  /// <summary>
+	  /// TODO: rewrite tests not to use string comparison.
+	  /// </summary>
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: private static String tsToString(org.apache.lucene.analysis.TokenStream in) throws java.io.IOException
+	  private static string tsToString(TokenStream @in)
+	  {
+		StringBuilder @out = new StringBuilder();
+		CharTermAttribute termAtt = @in.addAttribute(typeof(CharTermAttribute));
+		// extra safety to enforce, that the state is not preserved and also
+		// assign bogus values
+		@in.clearAttributes();
+		termAtt.setEmpty().append("bogusTerm");
+		@in.reset();
+		while (@in.incrementToken())
+		{
+		  if (@out.Length > 0)
+		  {
+			@out.Append(' ');
+		  }
+		  @out.Append(termAtt.ToString());
+		  @in.clearAttributes();
+		  termAtt.setEmpty().append("bogusTerm");
+		}
+
+		@in.close();
+		return @out.ToString();
+	  }
+
+	  /// <summary>
+	  /// blast some random strings through the analyzer </summary>
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testRandomStrings() throws Exception
+	  public virtual void testRandomStrings()
+	  {
+		Analyzer a = new AnalyzerAnonymousInnerClassHelper(this);
+		checkRandomData(random(), a, 1000 * RANDOM_MULTIPLIER);
+
+		Analyzer b = new AnalyzerAnonymousInnerClassHelper2(this);
+		checkRandomData(random(), b, 1000 * RANDOM_MULTIPLIER);
+	  }
+
+	  private class AnalyzerAnonymousInnerClassHelper : Analyzer
+	  {
+		  private readonly TestPatternTokenizer outerInstance;
+
+		  public AnalyzerAnonymousInnerClassHelper(TestPatternTokenizer outerInstance)
+		  {
+			  this.outerInstance = outerInstance;
+		  }
+
+		  protected internal override Analyzer.TokenStreamComponents createComponents(string fieldName, Reader reader)
+		  {
+			Tokenizer tokenizer = new PatternTokenizer(reader, Pattern.compile("a"), -1);
+			return new Analyzer.TokenStreamComponents(tokenizer);
+		  }
+	  }
+
+	  private class AnalyzerAnonymousInnerClassHelper2 : Analyzer
+	  {
+		  private readonly TestPatternTokenizer outerInstance;
+
+		  public AnalyzerAnonymousInnerClassHelper2(TestPatternTokenizer outerInstance)
+		  {
+			  this.outerInstance = outerInstance;
+		  }
+
+		  protected internal override Analyzer.TokenStreamComponents createComponents(string fieldName, Reader reader)
+		  {
+			Tokenizer tokenizer = new PatternTokenizer(reader, Pattern.compile("a"), 0);
+			return new Analyzer.TokenStreamComponents(tokenizer);
+		  }
+	  }
+	}
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c64856a7/src/Lucene.Net.Tests.Analysis.Common/Analysis/Pattern/TestPatternTokenizerFactory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Pattern/TestPatternTokenizerFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Pattern/TestPatternTokenizerFactory.cs
new file mode 100644
index 0000000..1435951
--- /dev/null
+++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Pattern/TestPatternTokenizerFactory.cs
@@ -0,0 +1,58 @@
+namespace org.apache.lucene.analysis.pattern
+{
+
+	/*
+	 * 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.
+	 * The ASF licenses this file to You under the Apache License, Version 2.0
+	 * (the "License"); you may not use this file except in compliance with
+	 * the License.  You may obtain a copy of the License at
+	 *
+	 *     http://www.apache.org/licenses/LICENSE-2.0
+	 *
+	 * Unless required by applicable law or agreed to in writing, software
+	 * distributed under the License is distributed on an "AS IS" BASIS,
+	 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+	 * See the License for the specific language governing permissions and
+	 * limitations under the License.
+	 */
+
+
+	using BaseTokenStreamFactoryTestCase = org.apache.lucene.analysis.util.BaseTokenStreamFactoryTestCase;
+
+	/// <summary>
+	/// Simple Tests to ensure this factory is working </summary>
+	public class TestPatternTokenizerFactory : BaseTokenStreamFactoryTestCase
+	{
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testFactory() throws Exception
+	  public virtual void testFactory()
+	  {
+//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
+//ORIGINAL LINE: final java.io.Reader reader = new java.io.StringReader("Günther Günther is here");
+		Reader reader = new StringReader("Günther Günther is here");
+		// create PatternTokenizer
+		TokenStream stream = tokenizerFactory("Pattern", "pattern", "[,;/\\s]+").create(reader);
+		assertTokenStreamContents(stream, new string[] {"Günther", "Günther", "is", "here"});
+	  }
+
+	  /// <summary>
+	  /// Test that bogus arguments result in exception </summary>
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testBogusArguments() throws Exception
+	  public virtual void testBogusArguments()
+	  {
+		try
+		{
+		  tokenizerFactory("Pattern", "pattern", "something", "bogusArg", "bogusValue");
+		  fail();
+		}
+		catch (System.ArgumentException expected)
+		{
+		  assertTrue(expected.Message.contains("Unknown parameters"));
+		}
+	  }
+	}
+
+}
\ No newline at end of file


Mime
View raw message