lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ccurr...@apache.org
Subject [Lucene.Net] svn commit: r1294875 [32/45] - in /incubator/lucene.net/trunk: ./ build/ build/vs2010/contrib/ build/vs2010/test/ doc/ src/ src/contrib/Analyzers/ src/contrib/Analyzers/AR/ src/contrib/Analyzers/BR/ src/contrib/Analyzers/CJK/ src/contrib/Analyzers/Cn/ ...
Date Tue, 28 Feb 2012 22:43:28 GMT
Modified: incubator/lucene.net/trunk/test/contrib/Analyzers/NGram/TestEdgeNGramTokenizer.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/contrib/Analyzers/NGram/TestEdgeNGramTokenizer.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/contrib/Analyzers/NGram/TestEdgeNGramTokenizer.cs (original)
+++ incubator/lucene.net/trunk/test/contrib/Analyzers/NGram/TestEdgeNGramTokenizer.cs Tue Feb 28 22:43:08 2012
@@ -1,60 +1,39 @@
-/**
- * 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 System;
+using System;
+using System.Collections.Generic;
 using System.IO;
-using System.Collections;
-
+using System.Linq;
+using System.Text;
 using Lucene.Net.Analysis;
-using Lucene.Net.Analysis.Tokenattributes;
-using Lucene.Net.Util;
+using Lucene.Net.Analysis.NGram;
 using NUnit.Framework;
 
-namespace Lucene.Net.Analysis.NGram
+namespace Lucene.Net.Analyzers.Miscellaneous
 {
-
-    /**
-     * Tests {@link EdgeNGramTokenizer} for correctness.
+    /**
+     * Tests {@link EdgeNGramTokenizer} for correctness.
      */
     [TestFixture]
-    public class TestEdgeNGramTokenizer : BaseTokenStreamTestCase
+    public class EdgeNGramTokenizerTest : BaseTokenStreamTestCase
     {
         private StringReader input;
 
-        [SetUp]
-        public void SetUp()
+        public override void SetUp()
         {
-            base.SetUp();
             input = new StringReader("abcde");
         }
-
         [Test]
         public void TestInvalidInput()
         {
             bool gotException = false;
             try
             {
-                new EdgeNGramTokenizer(input, EdgeNGramTokenizer.Side.FRONT, 0, 0);
+                new EdgeNGramTokenizer(input, Side.FRONT, 0, 0);
             }
-            catch (System.ArgumentException e)
+            catch (ArgumentException e)
             {
                 gotException = true;
             }
-            Assert.IsTrue(gotException);
+            Assert.True(gotException);
         }
 
         [Test]
@@ -63,13 +42,13 @@ namespace Lucene.Net.Analysis.NGram
             bool gotException = false;
             try
             {
-                new EdgeNGramTokenizer(input, EdgeNGramTokenizer.Side.FRONT, 2, 1);
+                new EdgeNGramTokenizer(input, Side.FRONT, 2, 1);
             }
-            catch (System.ArgumentException e)
+            catch (ArgumentException e)
             {
                 gotException = true;
             }
-            Assert.IsTrue(gotException);
+            Assert.True(gotException);
         }
 
         [Test]
@@ -78,54 +57,54 @@ namespace Lucene.Net.Analysis.NGram
             bool gotException = false;
             try
             {
-                new EdgeNGramTokenizer(input, EdgeNGramTokenizer.Side.FRONT, -1, 2);
+                new EdgeNGramTokenizer(input, Side.FRONT, -1, 2);
             }
-            catch (System.ArgumentException e)
+            catch (ArgumentException e)
             {
                 gotException = true;
             }
-            Assert.IsTrue(gotException);
+            Assert.True(gotException);
         }
 
         [Test]
         public void TestFrontUnigram()
         {
-            EdgeNGramTokenizer tokenizer = new EdgeNGramTokenizer(input, EdgeNGramTokenizer.Side.FRONT, 1, 1);
+            EdgeNGramTokenizer tokenizer = new EdgeNGramTokenizer(input, Side.FRONT, 1, 1);
             AssertTokenStreamContents(tokenizer, new String[] { "a" }, new int[] { 0 }, new int[] { 1 }, 5 /* abcde */);
         }
 
         [Test]
         public void TestBackUnigram()
         {
-            EdgeNGramTokenizer tokenizer = new EdgeNGramTokenizer(input, EdgeNGramTokenizer.Side.BACK, 1, 1);
+            EdgeNGramTokenizer tokenizer = new EdgeNGramTokenizer(input, Side.BACK, 1, 1);
             AssertTokenStreamContents(tokenizer, new String[] { "e" }, new int[] { 4 }, new int[] { 5 }, 5 /* abcde */);
         }
 
         [Test]
         public void TestOversizedNgrams()
         {
-            EdgeNGramTokenizer tokenizer = new EdgeNGramTokenizer(input, EdgeNGramTokenizer.Side.FRONT, 6, 6);
+            EdgeNGramTokenizer tokenizer = new EdgeNGramTokenizer(input, Side.FRONT, 6, 6);
             AssertTokenStreamContents(tokenizer, new String[0], new int[0], new int[0], 5 /* abcde */);
         }
 
         [Test]
         public void TestFrontRangeOfNgrams()
         {
-            EdgeNGramTokenizer tokenizer = new EdgeNGramTokenizer(input, EdgeNGramTokenizer.Side.FRONT, 1, 3);
+            EdgeNGramTokenizer tokenizer = new EdgeNGramTokenizer(input, Side.FRONT, 1, 3);
             AssertTokenStreamContents(tokenizer, new String[] { "a", "ab", "abc" }, new int[] { 0, 0, 0 }, new int[] { 1, 2, 3 }, 5 /* abcde */);
         }
 
         [Test]
         public void TestBackRangeOfNgrams()
         {
-            EdgeNGramTokenizer tokenizer = new EdgeNGramTokenizer(input, EdgeNGramTokenizer.Side.BACK, 1, 3);
+            EdgeNGramTokenizer tokenizer = new EdgeNGramTokenizer(input, Side.BACK, 1, 3);
             AssertTokenStreamContents(tokenizer, new String[] { "e", "de", "cde" }, new int[] { 4, 3, 2 }, new int[] { 5, 5, 5 }, 5 /* abcde */);
         }
 
         [Test]
         public void TestReset()
         {
-            EdgeNGramTokenizer tokenizer = new EdgeNGramTokenizer(input, EdgeNGramTokenizer.Side.FRONT, 1, 3);
+            EdgeNGramTokenizer tokenizer = new EdgeNGramTokenizer(input, Side.FRONT, 1, 3);
             AssertTokenStreamContents(tokenizer, new String[] { "a", "ab", "abc" }, new int[] { 0, 0, 0 }, new int[] { 1, 2, 3 }, 5 /* abcde */);
             tokenizer.Reset(new StringReader("abcde"));
             AssertTokenStreamContents(tokenizer, new String[] { "a", "ab", "abc" }, new int[] { 0, 0, 0 }, new int[] { 1, 2, 3 }, 5 /* abcde */);

Modified: incubator/lucene.net/trunk/test/contrib/Analyzers/Properties/AssemblyInfo.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/contrib/Analyzers/Properties/AssemblyInfo.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/contrib/Analyzers/Properties/AssemblyInfo.cs (original)
+++ incubator/lucene.net/trunk/test/contrib/Analyzers/Properties/AssemblyInfo.cs Tue Feb 28 22:43:08 2012
@@ -53,5 +53,5 @@ using System.Runtime.InteropServices;
 // You can specify all the values or you can default the Build and Revision Numbers 
 // by using the '*' as shown below:
 // [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("2.9.2.1")]
-[assembly: AssemblyFileVersion("2.9.2.1")]
+[assembly: AssemblyVersion("3.0.3")]
+[assembly: AssemblyFileVersion("3.0.3")]

Modified: incubator/lucene.net/trunk/test/contrib/Analyzers/Shingle/ShingleAnalyzerWrapperTest.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/contrib/Analyzers/Shingle/ShingleAnalyzerWrapperTest.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/contrib/Analyzers/Shingle/ShingleAnalyzerWrapperTest.cs (original)
+++ incubator/lucene.net/trunk/test/contrib/Analyzers/Shingle/ShingleAnalyzerWrapperTest.cs Tue Feb 28 22:43:08 2012
@@ -44,7 +44,7 @@ namespace Lucene.Net.Analyzers.Shingle
         public IndexSearcher SetUpSearcher(Analyzer analyzer)
         {
             Directory dir = new RAMDirectory();
-            var writer = new IndexWriter(dir, analyzer, true);
+            var writer = new IndexWriter(dir, analyzer, true, IndexWriter.MaxFieldLength.UNLIMITED);
 
             var doc = new Document();
             doc.Add(new Field("content", "please divide this sentence into shingles",
@@ -63,26 +63,26 @@ namespace Lucene.Net.Analyzers.Shingle
 
             writer.Close();
 
-            return new IndexSearcher(dir);
+            return new IndexSearcher(dir, true);
         }
 
-        protected Hits QueryParsingTest(Analyzer analyzer, String qs)
+        protected ScoreDoc[] QueryParsingTest(Analyzer analyzer, String qs)
         {
             Searcher = SetUpSearcher(analyzer);
 
-            var qp = new QueryParser("content", analyzer);
+            var qp = new QueryParser(Util.Version.LUCENE_CURRENT, "content", analyzer);
 
             var q = qp.Parse(qs);
 
-            return Searcher.Search(q);
+            return Searcher.Search(q, null, 1000).ScoreDocs;
         }
 
-        protected void CompareRanks(Hits hits, int[] ranks)
+        protected void CompareRanks(ScoreDoc[] hits, int[] ranks)
         {
-            Assert.AreEqual(ranks.Length, hits.Length());
+            Assert.AreEqual(ranks.Length, hits.Length);
             for (int i = 0; i < ranks.Length; i++)
             {
-                Assert.AreEqual(ranks[i], hits.Id(i));
+                Assert.AreEqual(ranks[i], hits[i].doc);
             }
         }
 
@@ -148,8 +148,8 @@ namespace Lucene.Net.Analyzers.Shingle
             var ts = analyzer.TokenStream("content", new StringReader("this sentence"));
             var j = -1;
 
-            var posIncrAtt = (PositionIncrementAttribute) ts.AddAttribute(typeof (PositionIncrementAttribute));
-            var termAtt = (TermAttribute) ts.AddAttribute(typeof (TermAttribute));
+            var posIncrAtt = ts.AddAttribute<PositionIncrementAttribute>();
+            var termAtt = ts.AddAttribute<TermAttribute>();
 
             while (ts.IncrementToken())
             {
@@ -158,7 +158,7 @@ namespace Lucene.Net.Analyzers.Shingle
                 q.Add(new Term("content", termText), j);
             }
 
-            var hits = Searcher.Search(q);
+            var hits = Searcher.Search(q, null, 1000).ScoreDocs;
             var ranks = new[] {0};
             CompareRanks(hits, ranks);
         }
@@ -178,7 +178,7 @@ namespace Lucene.Net.Analyzers.Shingle
 
             var ts = analyzer.TokenStream("content", new StringReader("test sentence"));
 
-            var termAtt = (TermAttribute) ts.AddAttribute(typeof (TermAttribute));
+            var termAtt = ts.AddAttribute<TermAttribute>();
 
             while (ts.IncrementToken())
             {
@@ -187,7 +187,7 @@ namespace Lucene.Net.Analyzers.Shingle
                       BooleanClause.Occur.SHOULD);
             }
 
-            var hits = Searcher.Search(q);
+            var hits = Searcher.Search(q, null, 1000).ScoreDocs;
             var ranks = new[] {1, 2, 0};
             CompareRanks(hits, ranks);
         }
@@ -220,45 +220,9 @@ namespace Lucene.Net.Analyzers.Shingle
         {
             Analyzer a = new ShingleWrapperSubclassAnalyzer();
             AssertAnalyzesToReuse(a, "this is a test",
-                                  new[] {"this", "is", "a", "test"},
-                                  new[] {0, 5, 8, 10},
-                                  new[] {4, 7, 9, 14});
-        }
-
-        /// <summary>
-        /// analyzer that does not support reuse it is LetterTokenizer on odd invocations, WhitespaceTokenizer on even.
-        /// </summary>
-        [Test]
-        public void TestWrappedAnalyzerDoesNotReuse()
-        {
-            Analyzer a = new ShingleAnalyzerWrapper(new NonreusableAnalyzer());
-            AssertAnalyzesToReuse(a, "please divide into shingles.",
-                                  new[]
-                                      {
-                                          "please", "please divide", "divide", "divide into", "into", "into shingles",
-                                          "shingles"
-                                      },
-                                  new[] {0, 0, 7, 7, 14, 14, 19},
-                                  new[] {6, 13, 13, 18, 18, 27, 27},
-                                  new[] {1, 0, 1, 0, 1, 0, 1});
-            AssertAnalyzesToReuse(a, "please divide into shingles.",
-                                  new[]
-                                      {
-                                          "please", "please divide", "divide", "divide into", "into", "into shingles.",
-                                          "shingles."
-                                      },
-                                  new[] {0, 0, 7, 7, 14, 14, 19},
-                                  new[] {6, 13, 13, 18, 18, 28, 28},
-                                  new[] {1, 0, 1, 0, 1, 0, 1});
-            AssertAnalyzesToReuse(a, "please divide into shingles.",
-                                  new[]
-                                      {
-                                          "please", "please divide", "divide", "divide into", "into", "into shingles",
-                                          "shingles"
-                                      },
-                                  new[] {0, 0, 7, 7, 14, 14, 19},
-                                  new[] {6, 13, 13, 18, 18, 27, 27},
-                                  new[] {1, 0, 1, 0, 1, 0, 1});
+                                  new[] { "this", "is", "a", "test" },
+                                  new[] { 0, 5, 8, 10 },
+                                  new[] { 4, 7, 9, 14 });
         }
 
         #region Nested type: NonreusableAnalyzer
@@ -282,6 +246,12 @@ namespace Lucene.Net.Analyzers.Shingle
 
         private class ShingleWrapperSubclassAnalyzer : ShingleAnalyzerWrapper
         {
+            public ShingleWrapperSubclassAnalyzer()
+                : base(Util.Version.LUCENE_CURRENT)
+            {
+                
+            }
+
             public override TokenStream TokenStream(String fieldName, TextReader reader)
             {
                 return new WhitespaceTokenizer(reader);
@@ -289,5 +259,41 @@ namespace Lucene.Net.Analyzers.Shingle
         } ;
 
         #endregion
+
+        /// <summary>
+        /// analyzer that does not support reuse it is LetterTokenizer on odd invocations, WhitespaceTokenizer on even.
+        /// </summary>
+        [Test]
+        public void TestWrappedAnalyzerDoesNotReuse()
+        {
+            Analyzer a = new ShingleAnalyzerWrapper(new NonreusableAnalyzer());
+            AssertAnalyzesToReuse(a, "please divide into shingles.",
+                                  new[]
+                                      {
+                                          "please", "please divide", "divide", "divide into", "into", "into shingles",
+                                          "shingles"
+                                      },
+                                  new[] { 0, 0, 7, 7, 14, 14, 19 },
+                                  new[] { 6, 13, 13, 18, 18, 27, 27 },
+                                  new[] { 1, 0, 1, 0, 1, 0, 1 });
+            AssertAnalyzesToReuse(a, "please divide into shingles.",
+                                  new[]
+                                      {
+                                          "please", "please divide", "divide", "divide into", "into", "into shingles.",
+                                          "shingles."
+                                      },
+                                  new[] { 0, 0, 7, 7, 14, 14, 19 },
+                                  new[] { 6, 13, 13, 18, 18, 28, 28 },
+                                  new[] { 1, 0, 1, 0, 1, 0, 1 });
+            AssertAnalyzesToReuse(a, "please divide into shingles.",
+                                  new[]
+                                      {
+                                          "please", "please divide", "divide", "divide into", "into", "into shingles",
+                                          "shingles"
+                                      },
+                                  new[] { 0, 0, 7, 7, 14, 14, 19 },
+                                  new[] { 6, 13, 13, 18, 18, 27, 27 },
+                                  new[] { 1, 0, 1, 0, 1, 0, 1 });
+        }
     }
 }
\ No newline at end of file

Modified: incubator/lucene.net/trunk/test/contrib/Analyzers/Shingle/ShingleFilterTest.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/contrib/Analyzers/Shingle/ShingleFilterTest.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/contrib/Analyzers/Shingle/ShingleFilterTest.cs (original)
+++ incubator/lucene.net/trunk/test/contrib/Analyzers/Shingle/ShingleFilterTest.cs Tue Feb 28 22:43:08 2012
@@ -456,10 +456,10 @@ namespace Lucene.Net.Analyzers.Shingle
             var filter = new ShingleFilter(new TestTokenStream(tokensToShingle), maxSize);
             filter.SetOutputUnigrams(outputUnigrams);
 
-            var termAtt = (TermAttribute) filter.AddAttribute(typeof (TermAttribute));
-            var offsetAtt = (OffsetAttribute) filter.AddAttribute(typeof (OffsetAttribute));
-            var posIncrAtt = (PositionIncrementAttribute) filter.AddAttribute(typeof (PositionIncrementAttribute));
-            var typeAtt = (TypeAttribute) filter.AddAttribute(typeof (TypeAttribute));
+            var termAtt = filter.AddAttribute<TermAttribute>();
+            var offsetAtt = filter.AddAttribute<OffsetAttribute>();
+            var posIncrAtt = filter.AddAttribute<PositionIncrementAttribute>();
+            var typeAtt = filter.AddAttribute<TypeAttribute>();
 
             int i = 0;
             while (filter.IncrementToken())
@@ -501,10 +501,10 @@ namespace Lucene.Net.Analyzers.Shingle
             {
                 _testToken = testToken;
 
-                _termAtt = (TermAttribute) AddAttribute(typeof (TermAttribute));
-                _offsetAtt = (OffsetAttribute) AddAttribute(typeof (OffsetAttribute));
-                _posIncrAtt = (PositionIncrementAttribute) AddAttribute(typeof (PositionIncrementAttribute));
-                _typeAtt = (TypeAttribute) AddAttribute(typeof (TypeAttribute));
+                _termAtt = AddAttribute<TermAttribute>();
+                _offsetAtt = AddAttribute<OffsetAttribute>();
+                _posIncrAtt = AddAttribute<PositionIncrementAttribute>();
+                _typeAtt = AddAttribute<TypeAttribute>();
             }
 
             public override bool IncrementToken()
@@ -523,6 +523,11 @@ namespace Lucene.Net.Analyzers.Shingle
 
                 return true;
             }
+
+            protected override void Dispose(bool disposing)
+            {
+                // do nothing
+            }
         }
 
         #endregion

Modified: incubator/lucene.net/trunk/test/contrib/Analyzers/Shingle/TestShingleMatrixFilter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/contrib/Analyzers/Shingle/TestShingleMatrixFilter.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/contrib/Analyzers/Shingle/TestShingleMatrixFilter.cs (original)
+++ incubator/lucene.net/trunk/test/contrib/Analyzers/Shingle/TestShingleMatrixFilter.cs Tue Feb 28 22:43:08 2012
@@ -20,11 +20,11 @@ using System.Collections;
 using System.Collections.Generic;
 using System.IO;
 using Lucene.Net.Analysis;
+using Lucene.Net.Analysis.Shingle.Codec;
+using Lucene.Net.Analysis.Shingle.Matrix;
 using Lucene.Net.Analysis.Tokenattributes;
 using Lucene.Net.Analyzers.Miscellaneous;
 using Lucene.Net.Analyzers.Payloads;
-using Lucene.Net.Analyzers.Shingle.Codec;
-using Lucene.Net.Analyzers.Shingle.Matrix;
 using NUnit.Framework;
 using FlagsAttribute = Lucene.Net.Analysis.Tokenattributes.FlagsAttribute;
 
@@ -38,22 +38,7 @@ namespace Lucene.Net.Analyzers.Shingle
 
         // use this ctor, because SingleTokenTokenStream only uses next(Token), so exclude it
         public TestShingleMatrixFilter(String name) :
-            base(
-            name,
-            new Hashtable(
-                new Dictionary<string, string[]>
-                    {
-                        {
-                            "TestShingleMatrixFilter",
-                            new[]
-                                {
-                                    "testBehavingAsShingleFilter",
-                                    "testMatrix",
-                                    "testIterator"
-                                }
-                            }
-                    }
-                ))
+            base(name)
         {
         }
 
@@ -373,7 +358,7 @@ namespace Lucene.Net.Analyzers.Shingle
             // set it here in case tests are run out of the usual order.
             ShingleMatrixFilter.DefaultSettingsCodec = new SimpleThreeDimensionalTokenSettingsCodec();
 
-            var matrix = new Matrix.Matrix();
+            var matrix = new Matrix();
 
             new Column(TokenFactory("no", 1), matrix);
             new Column(TokenFactory("surprise", 1), matrix);
@@ -447,44 +432,45 @@ namespace Lucene.Net.Analyzers.Shingle
             Assert.IsFalse(ts.IncrementToken());
         }
 
-        private static Token TokenFactory(String text, int posIncr, int startOffset, int endOffset)
+        private Token TokenFactory(String text, int startOffset, int endOffset)
         {
-            var token = new Token(startOffset, endOffset);
+            return TokenFactory(text, 1, 1f, startOffset, endOffset);
+        }
 
+        private Token TokenFactory(String text, int posIncr, int startOffset, int endOffset)
+        {
+            Token token = new Token(startOffset, endOffset);
             token.SetTermBuffer(text);
             token.SetPositionIncrement(posIncr);
-
             return token;
         }
-        
-        private static Token TokenFactory(String text, int posIncr)
+
+        private Token TokenFactory(String text, int posIncr)
         {
             return TokenFactory(text, posIncr, 1f, 0, 0);
         }
 
-        private static Token TokenFactory(String text, int posIncr, float weight, int startOffset, int endOffset)
+        private Token TokenFactory(String text, int posIncr, float weight)
         {
-            var token = new Token(startOffset, endOffset);
+            return TokenFactory(text, posIncr, weight, 0, 0);
+        }
 
+        private Token TokenFactory(String text, int posIncr, float weight, int startOffset, int endOffset)
+        {
+            Token token = new Token(startOffset, endOffset);
             token.SetTermBuffer(text);
             token.SetPositionIncrement(posIncr);
-
             ShingleMatrixFilter.DefaultSettingsCodec.SetWeight(token, weight);
-
             return token;
         }
 
-        private static Token TokenFactory(String text, int posIncr, float weight, int startOffset, int endOffset,
-                                          TokenPositioner positioner)
+        private Token TokenFactory(String text, int posIncr, float weight, int startOffset, int endOffset, TokenPositioner positioner)
         {
-            var token = new Token(startOffset, endOffset);
-
+            Token token = new Token(startOffset, endOffset);
             token.SetTermBuffer(text);
             token.SetPositionIncrement(posIncr);
-
             ShingleMatrixFilter.DefaultSettingsCodec.SetWeight(token, weight);
             ShingleMatrixFilter.DefaultSettingsCodec.SetTokenPositioner(token, positioner);
-
             return token;
         }
 
@@ -492,7 +478,7 @@ namespace Lucene.Net.Analyzers.Shingle
 
         private static void AssertNext(TokenStream ts, String text)
         {
-            var termAtt = (TermAttribute) ts.AddAttribute(typeof (TermAttribute));
+            var termAtt = ts.AddAttribute<TermAttribute>();
 
             Assert.IsTrue(ts.IncrementToken());
             Assert.AreEqual(text, termAtt.Term());
@@ -501,10 +487,10 @@ namespace Lucene.Net.Analyzers.Shingle
         private static void AssertNext(TokenStream ts, String text, int positionIncrement, float boost, int startOffset,
                                        int endOffset)
         {
-            var termAtt = (TermAttribute) ts.AddAttribute(typeof (TermAttribute));
-            var posIncrAtt = (PositionIncrementAttribute) ts.AddAttribute(typeof (PositionIncrementAttribute));
-            var payloadAtt = (PayloadAttribute) ts.AddAttribute(typeof (PayloadAttribute));
-            var offsetAtt = (OffsetAttribute) ts.AddAttribute(typeof (OffsetAttribute));
+            var termAtt = ts.AddAttribute<TermAttribute>();
+            var posIncrAtt = ts.AddAttribute<PositionIncrementAttribute>();
+            var payloadAtt = ts.AddAttribute<PayloadAttribute>();
+            var offsetAtt = ts.AddAttribute<OffsetAttribute>();
 
             Assert.IsTrue(ts.IncrementToken());
             Assert.AreEqual(text, termAtt.Term());
@@ -519,8 +505,8 @@ namespace Lucene.Net.Analyzers.Shingle
 
         private static void AssertNext(TokenStream ts, String text, int startOffset, int endOffset)
         {
-            var termAtt = (TermAttribute) ts.AddAttribute(typeof (TermAttribute));
-            var offsetAtt = (OffsetAttribute) ts.AddAttribute(typeof (OffsetAttribute));
+            var termAtt = ts.AddAttribute<TermAttribute>();
+            var offsetAtt = ts.AddAttribute<OffsetAttribute>();
 
             Assert.IsTrue(ts.IncrementToken());
             Assert.AreEqual(text, termAtt.Term());
@@ -552,12 +538,12 @@ namespace Lucene.Net.Analyzers.Shingle
             public TokenListStream(ICollection<Token> tokens)
             {
                 _tokens = tokens;
-                _termAtt = (TermAttribute) AddAttribute(typeof (TermAttribute));
-                _posIncrAtt = (PositionIncrementAttribute) AddAttribute(typeof (PositionIncrementAttribute));
-                _payloadAtt = (PayloadAttribute) AddAttribute(typeof (PayloadAttribute));
-                _offsetAtt = (OffsetAttribute) AddAttribute(typeof (OffsetAttribute));
-                _typeAtt = (TypeAttribute) AddAttribute(typeof (TypeAttribute));
-                _flagsAtt = (FlagsAttribute) AddAttribute(typeof (FlagsAttribute));
+                _termAtt = AddAttribute<TermAttribute>();
+                _posIncrAtt = AddAttribute<PositionIncrementAttribute>();
+                _payloadAtt = AddAttribute<PayloadAttribute>();
+                _offsetAtt = AddAttribute<OffsetAttribute>();
+                _typeAtt = AddAttribute<TypeAttribute>();
+                _flagsAtt = AddAttribute<FlagsAttribute>();
             }
 
             public override bool IncrementToken()
@@ -587,6 +573,11 @@ namespace Lucene.Net.Analyzers.Shingle
             {
                 _iterator = null;
             }
+
+            protected override void Dispose(bool disposing)
+            {
+                // do nothing
+            }
         }
 
         #endregion

Modified: incubator/lucene.net/trunk/test/contrib/Core/Analysis/Ext/Analysis.Ext.Test.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/contrib/Core/Analysis/Ext/Analysis.Ext.Test.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
Files incubator/lucene.net/trunk/test/contrib/Core/Analysis/Ext/Analysis.Ext.Test.cs (original) and incubator/lucene.net/trunk/test/contrib/Core/Analysis/Ext/Analysis.Ext.Test.cs Tue Feb 28 22:43:08 2012 differ

Modified: incubator/lucene.net/trunk/test/contrib/FastVectorHighlighter/AbstractTestCase.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/contrib/FastVectorHighlighter/AbstractTestCase.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/contrib/FastVectorHighlighter/AbstractTestCase.cs (original)
+++ incubator/lucene.net/trunk/test/contrib/FastVectorHighlighter/AbstractTestCase.cs Tue Feb 28 22:43:08 2012
@@ -77,8 +77,8 @@ namespace Lucene.Net.Search.Vectorhighli
             analyzerW = new WhitespaceAnalyzer();
             analyzerB = new BigramAnalyzer();
             analyzerK = new KeywordAnalyzer();
-            paW = new QueryParser(F, analyzerW);
-            paB = new QueryParser(F, analyzerB);
+            paW = new QueryParser(Util.Version.LUCENE_CURRENT, F, analyzerW);
+            paB = new QueryParser(Util.Version.LUCENE_CURRENT, F, analyzerB);
             dir = new RAMDirectory();
         }
 
@@ -238,8 +238,8 @@ namespace Lucene.Net.Search.Vectorhighli
 
             void Init()
             {
-                termAtt = (TermAttribute)AddAttribute(typeof(TermAttribute));
-                offsetAtt = (OffsetAttribute)AddAttribute(typeof(OffsetAttribute));
+                termAtt = AddAttribute<TermAttribute>();
+                offsetAtt = AddAttribute<OffsetAttribute>();
             }
 
             TermAttribute termAtt = null;

Modified: incubator/lucene.net/trunk/test/contrib/FastVectorHighlighter/IndexTimeSynonymTest.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/contrib/FastVectorHighlighter/IndexTimeSynonymTest.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/contrib/FastVectorHighlighter/IndexTimeSynonymTest.cs (original)
+++ incubator/lucene.net/trunk/test/contrib/FastVectorHighlighter/IndexTimeSynonymTest.cs Tue Feb 28 22:43:08 2012
@@ -345,33 +345,35 @@ namespace Lucene.Net.Search.Vectorhighli
 
             public override TokenStream TokenStream(String fieldName, System.IO.TextReader reader)
             {
-                Token reusableToken = new Token();
-
-                Lucene.Net.Analysis.TokenStream.SetOnlyUseNewAPI(true);
-                TokenStream ts = new AnonymousTokenStream(this, reusableToken);
-
-                ts.AddAttributeImpl(reusableToken);
+                TokenStream ts = new AnonymousTokenStream(this);
                 return ts;
             }
 
             class AnonymousTokenStream : TokenStream
             {
+                private AttributeImpl reusableToken;
                 TokenArrayAnalyzer parent = null;
-                Token reusableToken = null;
 
-                public AnonymousTokenStream(TokenArrayAnalyzer parent,Token reusableToken)
+                public AnonymousTokenStream(TokenArrayAnalyzer parent)
+                    : base(Token.TOKEN_ATTRIBUTE_FACTORY)
                 {
                     this.parent = parent;
-                    this.reusableToken = reusableToken;
+                    this.reusableToken = (AttributeImpl)AddAttribute<TermAttribute>();
                 }
 
                 int p = 0;
                 public override bool IncrementToken()
                 {
                     if (p >= parent.tokens.Length) return false;
-                    parent.tokens[p++].CopyTo(reusableToken);
+                    ClearAttributes();
+                    parent.tokens[p++].CopyTo(this.reusableToken);
                     return true;
                 }
+
+                protected override void Dispose(bool disposing)
+                {
+                    // do nothing
+                }
             }
         }
     }

Modified: incubator/lucene.net/trunk/test/contrib/Highlighter/HighlighterTest.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/contrib/Highlighter/HighlighterTest.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/contrib/Highlighter/HighlighterTest.cs (original)
+++ incubator/lucene.net/trunk/test/contrib/Highlighter/HighlighterTest.cs Tue Feb 28 22:43:08 2012
@@ -33,12 +33,10 @@ using Term = Lucene.Net.Index.Term;
 using ParseException = Lucene.Net.QueryParsers.ParseException;
 using QueryParser = Lucene.Net.QueryParsers.QueryParser;
 using FilteredQuery = Lucene.Net.Search.FilteredQuery;
-using Hits = Lucene.Net.Search.Hits;
 using IndexSearcher = Lucene.Net.Search.IndexSearcher;
 using MultiSearcher = Lucene.Net.Search.MultiSearcher;
 using PhraseQuery = Lucene.Net.Search.PhraseQuery;
 using Query = Lucene.Net.Search.Query;
-using RangeFilter = Lucene.Net.Search.RangeFilter;
 using Searcher = Lucene.Net.Search.Searcher;
 using TermQuery = Lucene.Net.Search.TermQuery;
 using SpanNearQuery = Lucene.Net.Search.Spans.SpanNearQuery;
@@ -495,7 +493,7 @@ namespace Lucene.Net.Search.Highlight
 		{
 			DoSearching("meat");
 			Highlighter highlighter = new Highlighter(this, new QueryScorer(query));
-			highlighter.SetMaxDocBytesToAnalyze(30);
+			highlighter.SetMaxDocCharsToAnalyze(30);
 			TokenStream tokenStream = analyzer.TokenStream(FIELD_NAME, new System.IO.StringReader(texts[0]));
 			highlighter.GetBestFragment(tokenStream, texts[0]);
 			Assert.IsTrue(numHighlights == 0, "Setting MaxDocBytesToAnalyze should have prevented " + "us from finding matches for this record: " + numHighlights + " found");
@@ -521,16 +519,16 @@ namespace Lucene.Net.Search.Highlight
 				sb.Append(stopWords[0]);
 			}
 			
-			hg.SetMaxDocBytesToAnalyze(100);
+			hg.SetMaxDocCharsToAnalyze(100);
 			match = hg.GetBestFragment(new StandardAnalyzer(stopWords), "data", sb.ToString());
-			Assert.IsTrue(match.Length < hg.GetMaxDocBytesToAnalyze(), "Matched text should be no more than 100 chars in length ");
+			Assert.IsTrue(match.Length < hg.GetMaxDocCharsToAnalyze(), "Matched text should be no more than 100 chars in length ");
 			
 			//add another tokenized word to the overrall length - but set way beyond 
 			//the length of text under consideration (after a large slug of stop words + whitespace)
 			sb.Append(" ");
 			sb.Append(goodWord);
 			match = hg.GetBestFragment(new StandardAnalyzer(stopWords), "data", sb.ToString());
-			Assert.IsTrue(match.Length < hg.GetMaxDocBytesToAnalyze(), "Matched text should be no more than 100 chars in length ");
+			Assert.IsTrue(match.Length < hg.GetMaxDocCharsToAnalyze(), "Matched text should be no more than 100 chars in length ");
 		}
 		
 		

Modified: incubator/lucene.net/trunk/test/contrib/Queries/BooleanFilterTest.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/contrib/Queries/BooleanFilterTest.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/contrib/Queries/BooleanFilterTest.cs (original)
+++ incubator/lucene.net/trunk/test/contrib/Queries/BooleanFilterTest.cs Tue Feb 28 22:43:08 2012
@@ -1,7 +1,7 @@
 /**
  * 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.
+ * 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
@@ -30,23 +30,17 @@ using NUnit.Framework;
 
 namespace Lucene.Net.Search
 {
-    /// <summary>
-    /// Summary description for UnitTest1
-    /// </summary>
     [TestFixture]
-    public class BooleanFilterTest
+    public class BooleanFilterTest : TestCase
     {
-        public BooleanFilterTest() { }
-
+        private RAMDirectory directory;
         private IndexReader reader;
 
-        #region setup/teardown methods
-
         [SetUp]
-        public void MyTestInitialize()
+        protected void SetUp()
         {
-            RAMDirectory directory = new RAMDirectory();
-            IndexWriter writer = new IndexWriter(directory, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+            directory = new RAMDirectory();
+            IndexWriter writer = new IndexWriter(directory, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.UNLIMITED);
 
             //Add series of docs with filterable fields : acces rights, prices, dates and "in-stock" flags
             AddDoc(writer, "admin guest", "010", "20040101", "Y");
@@ -58,264 +52,127 @@ namespace Lucene.Net.Search
             writer.Close();
             reader = IndexReader.Open(directory, true);
         }
-        
 
-         [TearDown]
-         public void MyTestCleanup() 
-         {
-             if (this.reader != null)
-             {
-                 this.reader.Close();
-                 this.reader = null;
-             }
-         }
-        
-        #endregion
-
-        [Test]
-        public void Should_Test()
+        private void AddDoc(IndexWriter writer, String accessRights, String price, String date, String inStock)
         {
-            for (int i = 0; i < 2; i++)
-            {
-                bool old = (i == 0);
-
-                BooleanFilter booleanFilter = new BooleanFilter();
-                booleanFilter.Add(new BooleanFilterClause(GetTermsFilter("price", "030", old), BooleanClause.Occur.SHOULD));
-                TstFilterCard("Should retrieves only 1 doc", 1, booleanFilter);
-            }
+            Document doc = new Document();
+            doc.Add(new Field("accessRights", accessRights, Field.Store.YES, Field.Index.ANALYZED));
+            doc.Add(new Field("price", price, Field.Store.YES, Field.Index.ANALYZED));
+            doc.Add(new Field("date", date, Field.Store.YES, Field.Index.ANALYZED));
+            doc.Add(new Field("inStock", inStock, Field.Store.YES, Field.Index.ANALYZED));
+            writer.AddDocument(doc);
         }
 
-        [Test]
-        public void Shoulds_Test()
+        private Filter GetRangeFilter(String field, String lowerPrice, String upperPrice)
         {
-            for (int i = 0; i < 2; i++)
-            {
-                bool old = (i == 0);
-
-                BooleanFilter booleanFilter = new BooleanFilter();
-                booleanFilter.Add(new BooleanFilterClause(GetRangeFilter("price", "010", "020", old), BooleanClause.Occur.SHOULD));
-                booleanFilter.Add(new BooleanFilterClause(GetRangeFilter("price", "020", "030", old), BooleanClause.Occur.SHOULD));
-                TstFilterCard("Shoulds are Ored together", 5, booleanFilter);
-            }
+            Filter f = new TermRangeFilter(field, lowerPrice, upperPrice, true, true);
+            return f;
         }
 
-        [Test]
-        public void ShouldsAndMustNot_Test()
+        private Filter GetTermsFilter(String field, String text)
         {
-            for (int i = 0; i < 2; i++)
-            {
-                bool old = (i == 0);
-
-                BooleanFilter booleanFilter = new BooleanFilter();
-                booleanFilter.Add(new BooleanFilterClause(GetRangeFilter("price", "010", "020", old), BooleanClause.Occur.SHOULD));
-                booleanFilter.Add(new BooleanFilterClause(GetRangeFilter("price", "020", "030", old), BooleanClause.Occur.SHOULD));
-                booleanFilter.Add(new BooleanFilterClause(GetTermsFilter("inStock", "N", old), BooleanClause.Occur.MUST_NOT));
-                TstFilterCard("Shoulds Ored but AndNot", 4, booleanFilter);
-
-                booleanFilter.Add(new BooleanFilterClause(GetTermsFilter("inStock", "Maybe", old), BooleanClause.Occur.MUST_NOT));
-                TstFilterCard("Shoulds Ored but AndNots", 3, booleanFilter);
-            }
+            TermsFilter tf = new TermsFilter();
+            tf.AddTerm(new Term(field, text));
 
+            return tf;
         }
 
-        [Test]
-        public void ShouldsAndMust_Test()
+        private void TstFilterCard(String mes, int expected, Filter filt)
         {
-            for (int i = 0; i < 2; i++)
+            DocIdSetIterator disi = filt.GetDocIdSet(reader).Iterator();
+            int actual = 0;
+            while (disi.NextDoc() != DocIdSetIterator.NO_MORE_DOCS)
             {
-                bool old = (i == 0);
-
-                BooleanFilter booleanFilter = new BooleanFilter();
-                booleanFilter.Add(new BooleanFilterClause(GetRangeFilter("price", "010", "020", old), BooleanClause.Occur.SHOULD));
-                booleanFilter.Add(new BooleanFilterClause(GetRangeFilter("price", "020", "030", old), BooleanClause.Occur.SHOULD));
-                booleanFilter.Add(new BooleanFilterClause(GetTermsFilter("accessRights", "admin", old), BooleanClause.Occur.MUST));
-                TstFilterCard("Shoulds Ored but MUST", 3, booleanFilter);
+                actual++;
             }
+            Assert.AreEqual(expected, actual, mes);
         }
 
         [Test]
-        public void ShouldsAndMusts_Test()
+        public void TestShould()
         {
-            for (int i = 0; i < 2; i++)
-            {
-                bool old = (i == 0);
-
-                BooleanFilter booleanFilter = new BooleanFilter();
-                booleanFilter.Add(new BooleanFilterClause(GetRangeFilter("price", "010", "020", old), BooleanClause.Occur.SHOULD));
-                booleanFilter.Add(new BooleanFilterClause(GetRangeFilter("price", "020", "030", old), BooleanClause.Occur.SHOULD));
-                booleanFilter.Add(new BooleanFilterClause(GetTermsFilter("accessRights", "admin", old), BooleanClause.Occur.MUST));
-                booleanFilter.Add(new BooleanFilterClause(GetRangeFilter("date", "20040101", "20041231", old), BooleanClause.Occur.MUST));
-                TstFilterCard("Shoulds Ored but MUSTs ANDED", 1, booleanFilter);
-            }
+            BooleanFilter booleanFilter = new BooleanFilter();
+            booleanFilter.Add(new FilterClause(GetTermsFilter("price", "030"), BooleanClause.Occur.SHOULD));
+            TstFilterCard("Should retrieves only 1 doc", 1, booleanFilter);
         }
 
         [Test]
-        public void ShouldsAndMustsAndMustNot_Test()
+        public void TestShoulds()
         {
-            for (int i = 0; i < 2; i++)
-            {
-                bool old = (i == 0);
-
-                BooleanFilter booleanFilter = new BooleanFilter();
-                booleanFilter.Add(new BooleanFilterClause(GetRangeFilter("price", "030", "040", old), BooleanClause.Occur.SHOULD));
-                booleanFilter.Add(new BooleanFilterClause(GetTermsFilter("accessRights", "admin", old), BooleanClause.Occur.MUST));
-                booleanFilter.Add(new BooleanFilterClause(GetRangeFilter("date", "20050101", "20051231", old), BooleanClause.Occur.MUST));
-                booleanFilter.Add(new BooleanFilterClause(GetTermsFilter("inStock", "N", old), BooleanClause.Occur.MUST_NOT));
-                TstFilterCard("Shoulds Ored but MUSTs ANDED and MustNot", 0, booleanFilter);
-            }
+            BooleanFilter booleanFilter = new BooleanFilter();
+            booleanFilter.Add(new FilterClause(GetRangeFilter("price", "010", "020"), BooleanClause.Occur.SHOULD));
+            booleanFilter.Add(new FilterClause(GetRangeFilter("price", "020", "030"), BooleanClause.Occur.SHOULD));
+            TstFilterCard("Shoulds are Ored together", 5, booleanFilter);
         }
 
         [Test]
-        public void JustMust_Test()
+        public void TestShouldsAndMustNot()
         {
-            for (int i = 0; i < 2; i++)
-            {
-                bool old = (i == 0);
+            BooleanFilter booleanFilter = new BooleanFilter();
+            booleanFilter.Add(new FilterClause(GetRangeFilter("price", "010", "020"), BooleanClause.Occur.SHOULD));
+            booleanFilter.Add(new FilterClause(GetRangeFilter("price", "020", "030"), BooleanClause.Occur.SHOULD));
+            booleanFilter.Add(new FilterClause(GetTermsFilter("inStock", "N"), BooleanClause.Occur.MUST_NOT));
+            TstFilterCard("Shoulds Ored but AndNot", 4, booleanFilter);
 
-                BooleanFilter booleanFilter = new BooleanFilter();
-                booleanFilter.Add(new BooleanFilterClause(GetTermsFilter("accessRights", "admin", old), BooleanClause.Occur.MUST));
-                TstFilterCard("MUST", 3, booleanFilter);
-            }
+            booleanFilter.Add(new FilterClause(GetTermsFilter("inStock", "Maybe"), BooleanClause.Occur.MUST_NOT));
+            TstFilterCard("Shoulds Ored but AndNots", 3, booleanFilter);
         }
 
         [Test]
-        public void JustMustNot_Test()
+        public void TestShouldsAndMust()
         {
-            for (int i = 0; i < 2; i++)
-            {
-                bool old = (i == 0);
-
-                BooleanFilter booleanFilter = new BooleanFilter();
-                booleanFilter.Add(new BooleanFilterClause(GetTermsFilter("inStock", "N", old), BooleanClause.Occur.MUST_NOT));
-                TstFilterCard("MUST_NOT", 4, booleanFilter);
-            }
+            BooleanFilter booleanFilter = new BooleanFilter();
+            booleanFilter.Add(new FilterClause(GetRangeFilter("price", "010", "020"), BooleanClause.Occur.SHOULD));
+            booleanFilter.Add(new FilterClause(GetRangeFilter("price", "020", "030"), BooleanClause.Occur.SHOULD));
+            booleanFilter.Add(new FilterClause(GetTermsFilter("accessRights", "admin"), BooleanClause.Occur.MUST));
+            TstFilterCard("Shoulds Ored but MUST", 3, booleanFilter);
         }
 
         [Test]
-        public void MustAndMustNot_Test()
+        public void TestShouldsAndMusts()
         {
-            for (int i = 0; i < 2; i++)
-            {
-                bool old = (i == 0);
-
-                BooleanFilter booleanFilter = new BooleanFilter();
-                booleanFilter.Add(new BooleanFilterClause(GetTermsFilter("inStock", "N", old), BooleanClause.Occur.MUST));
-                booleanFilter.Add(new BooleanFilterClause(GetTermsFilter("price", "030", old), BooleanClause.Occur.MUST_NOT));
-                TstFilterCard("MUST_NOT wins over MUST for same docs", 0, booleanFilter);
-            }
+            BooleanFilter booleanFilter = new BooleanFilter();
+            booleanFilter.Add(new FilterClause(GetRangeFilter("price", "010", "020"), BooleanClause.Occur.SHOULD));
+            booleanFilter.Add(new FilterClause(GetRangeFilter("price", "020", "030"), BooleanClause.Occur.SHOULD));
+            booleanFilter.Add(new FilterClause(GetTermsFilter("accessRights", "admin"), BooleanClause.Occur.MUST));
+            booleanFilter.Add(new FilterClause(GetRangeFilter("date", "20040101", "20041231"), BooleanClause.Occur.MUST));
+            TstFilterCard("Shoulds Ored but MUSTs ANDED", 1, booleanFilter);
         }
 
         [Test]
-        public void HashEquality()
+        public void TestShouldsAndMustsAndMustNot()
         {
-            BooleanFilter a = new BooleanFilter();
-            a.Add(new BooleanFilterClause(GetTermsFilter("inStock", "N", false), BooleanClause.Occur.MUST));
-            a.Add(new BooleanFilterClause(GetTermsFilter("price", "030", false), BooleanClause.Occur.MUST_NOT));
-
-            BooleanFilter b = new BooleanFilter();
-            b.Add(new BooleanFilterClause(GetTermsFilter("inStock", "N", false), BooleanClause.Occur.MUST));
-            b.Add(new BooleanFilterClause(GetTermsFilter("price", "030", false), BooleanClause.Occur.MUST_NOT));
-
-            Assert.AreEqual(a.GetHashCode(), b.GetHashCode(), "Hashes do not match");
+            BooleanFilter booleanFilter = new BooleanFilter();
+            booleanFilter.Add(new FilterClause(GetRangeFilter("price", "030", "040"), BooleanClause.Occur.SHOULD));
+            booleanFilter.Add(new FilterClause(GetTermsFilter("accessRights", "admin"), BooleanClause.Occur.MUST));
+            booleanFilter.Add(new FilterClause(GetRangeFilter("date", "20050101", "20051231"), BooleanClause.Occur.MUST));
+            booleanFilter.Add(new FilterClause(GetTermsFilter("inStock", "N"), BooleanClause.Occur.MUST_NOT));
+            TstFilterCard("Shoulds Ored but MUSTs ANDED and MustNot", 0, booleanFilter);
         }
 
         [Test]
-        public void ToString_Test()
+        public void TestJustMust()
         {
-            BooleanFilter b = new BooleanFilter();
-            b.Add(new BooleanFilterClause(GetTermsFilter("inStock", "N", false), BooleanClause.Occur.MUST));
-            b.Add(new BooleanFilterClause(GetTermsFilter("price", "030", false), BooleanClause.Occur.MUST_NOT));
-            b.Add(new BooleanFilterClause(GetRangeFilter("price", "030", "040", false), BooleanClause.Occur.SHOULD));
-
-            Assert.AreEqual("BooleanFilter( price:[030 TO 040] +( inStock:N ) -( price:030 ))", b.ToString());
+            BooleanFilter booleanFilter = new BooleanFilter();
+            booleanFilter.Add(new FilterClause(GetTermsFilter("accessRights", "admin"), BooleanClause.Occur.MUST));
+            TstFilterCard("MUST", 3, booleanFilter);
         }
 
         [Test]
-        [ExpectedException(typeof(NotSupportedException))]
-        public void ExOnBits_Test()
+        public void TestJustMustNot()
         {
-            BooleanFilter b = new BooleanFilter();
-            b.Add(new BooleanFilterClause(GetTermsFilter("inStock", "N", false), BooleanClause.Occur.MUST));
-            b.Add(new BooleanFilterClause(GetTermsFilter("price", "030", false), BooleanClause.Occur.MUST_NOT));
-            b.Add(new BooleanFilterClause(GetRangeFilter("price", "030", "040", false), BooleanClause.Occur.SHOULD));
-
-            BitArray bits = b.Bits(this.reader);
-        }
-
-        #region helpers
-
-        private void AddDoc(IndexWriter writer, String accessRights, String price, String date, String inStock)
-        {
-            Document doc = new Document();
-            doc.Add(new Field("accessRights", accessRights, Field.Store.YES, Field.Index.ANALYZED));
-            doc.Add(new Field("price", price, Field.Store.YES, Field.Index.ANALYZED));
-            doc.Add(new Field("date", date, Field.Store.YES, Field.Index.ANALYZED));
-            doc.Add(new Field("inStock", inStock, Field.Store.YES, Field.Index.ANALYZED));
-            writer.AddDocument(doc);
+            BooleanFilter booleanFilter = new BooleanFilter();
+            booleanFilter.Add(new FilterClause(GetTermsFilter("inStock", "N"), BooleanClause.Occur.MUST_NOT));
+            TstFilterCard("MUST_NOT", 4, booleanFilter);
         }
 
-        private Filter GetOldBitSetFilter(Filter filter)
-        {
-            return new MockBooleanFilter(filter);
-        }
-
-        private Filter GetRangeFilter(String field, String lowerPrice, String upperPrice, bool old)
-        {
-            Filter f = new TermRangeFilter(field, lowerPrice, upperPrice, true, true);
-            if (old)
-            {
-                return GetOldBitSetFilter(f);
-            }
-
-            return f;
-        }
-
-        private Filter GetTermsFilter(String field, String text, bool old)
-        {
-            TermsFilter tf = new TermsFilter();
-            tf.AddTerm(new Term(field, text));
-            if (old)
-            {
-                return GetOldBitSetFilter(tf);
-            }
-
-            return tf;
-        }
-
-        private void TstFilterCard(String mes, int expected, Filter filt)
-        {
-            DocIdSetIterator disi = filt.GetDocIdSet(reader).Iterator();
-            int actual = 0;
-            while (disi.NextDoc() != DocIdSetIterator.NO_MORE_DOCS)
-            {
-                actual++;
-            }
-            Assert.AreEqual(expected, actual, mes);
-        }
-
-        #endregion
-    }
-
-    public class MockBooleanFilter : Filter
-    {
-        private Filter filter;
-
-        public MockBooleanFilter(Filter f)
-        {
-            this.filter = f;
-        }
-
-        [Obsolete]
-        public override BitArray Bits(IndexReader reader)
+        [Test]
+        public void TestMustAndMustNot()
         {
-            BitArray bits = new BitArray(reader.MaxDoc());
-            DocIdSetIterator it = filter.GetDocIdSet(reader).Iterator();
-            int doc = DocIdSetIterator.NO_MORE_DOCS;
-            while ((doc = it.NextDoc()) != DocIdSetIterator.NO_MORE_DOCS)
-            {
-                bits.Set(doc, true);
-            }
-            return bits;
+            BooleanFilter booleanFilter = new BooleanFilter();
+            booleanFilter.Add(new FilterClause(GetTermsFilter("inStock", "N"), BooleanClause.Occur.MUST));
+            booleanFilter.Add(new FilterClause(GetTermsFilter("price", "030"), BooleanClause.Occur.MUST_NOT));
+            TstFilterCard("MUST_NOT wins over MUST for same docs", 0, booleanFilter);
         }
     }
 }

Modified: incubator/lucene.net/trunk/test/contrib/Queries/DuplicateFilterTest.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/contrib/Queries/DuplicateFilterTest.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/contrib/Queries/DuplicateFilterTest.cs (original)
+++ incubator/lucene.net/trunk/test/contrib/Queries/DuplicateFilterTest.cs Tue Feb 28 22:43:08 2012
@@ -44,7 +44,7 @@ namespace Lucene.Net.Search
         public void SetUp()
         {
             directory = new RAMDirectory();
-            IndexWriter writer = new IndexWriter(directory, new StandardAnalyzer(), true);
+            IndexWriter writer = new IndexWriter(directory, new StandardAnalyzer(Util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.UNLIMITED);
 
             //Add series of docs with filterable fields : url, text and dates  flags
             AddDoc(writer, "http://lucene.apache.org", "lucene 1.4.3 available", "20040101");
@@ -84,10 +84,10 @@ namespace Lucene.Net.Search
         {
             DuplicateFilter df = new DuplicateFilter(KEY_FIELD);
             Hashtable results = new Hashtable();
-            Hits h = searcher.Search(tq, df);
-            for (int i = 0; i < h.Length(); i++)
+            var h = searcher.Search(tq, df, 1000).ScoreDocs;
+            for (int i = 0; i < h.Length; i++)
             {
-                Document d = h.Doc(i);
+                Document d = searcher.Doc(h[i].doc);
                 String url = d.Get(KEY_FIELD);
                 Assert.IsFalse(results.Contains(url), "No duplicate urls should be returned");
                 results.Add(url,url);
@@ -98,12 +98,12 @@ namespace Lucene.Net.Search
         public void TestNoFilter()
         {
             Hashtable results = new Hashtable();
-            Hits h = searcher.Search(tq);
-            Assert.IsTrue(h.Length() > 0, "Default searching should have found some matches");
+            ScoreDoc[] h = searcher.Search(tq, null, 1000).ScoreDocs;
+            Assert.IsTrue(h.Length > 0, "Default searching should have found some matches");
             bool dupsFound = false;
-            for (int i = 0; i < h.Length(); i++)
+            for (int i = 0; i < h.Length; i++)
             {
-                Document d = h.Doc(i);
+                Document d = searcher.Doc(h[i].doc);
                 String url = d.Get(KEY_FIELD);
                 if (!dupsFound)
                     dupsFound = results.Contains(url);
@@ -118,11 +118,11 @@ namespace Lucene.Net.Search
             DuplicateFilter df = new DuplicateFilter(KEY_FIELD);
             df.SetProcessingMode(DuplicateFilter.PM_FAST_INVALIDATION);
             Hashtable results = new Hashtable();
-            Hits h = searcher.Search(tq, df);
-            Assert.IsTrue(h.Length() > 0, "Filtered searching should have found some matches");
-            for (int i = 0; i < h.Length(); i++)
+            ScoreDoc[] h = searcher.Search(tq, df, 1000).ScoreDocs;
+            Assert.IsTrue(h.Length > 0, "Filtered searching should have found some matches");
+            for (int i = 0; i < h.Length; i++)
             {
-                Document d = h.Doc(i);
+                Document d = searcher.Doc(h[i].doc);
                 String url = d.Get(KEY_FIELD);
                 Assert.IsFalse(results.Contains(url), "No duplicate urls should be returned");
                 results.Add(url,url);
@@ -135,11 +135,11 @@ namespace Lucene.Net.Search
         {
             DuplicateFilter df = new DuplicateFilter(KEY_FIELD);
             df.SetKeepMode(DuplicateFilter.KM_USE_LAST_OCCURRENCE);
-            Hits h = searcher.Search(tq, df);
-            Assert.IsTrue(h.Length() > 0, "Filtered searching should have found some matches");
-            for (int i = 0; i < h.Length(); i++)
+            ScoreDoc[] h = searcher.Search(tq, df, 1000).ScoreDocs;
+            Assert.IsTrue(h.Length > 0, "Filtered searching should have found some matches");
+            for (int i = 0; i < h.Length; i++)
             {
-                Document d = h.Doc(i);
+                Document d = searcher.Doc(h[i].doc);
                 String url = d.Get(KEY_FIELD);
                 TermDocs td = reader.TermDocs(new Term(KEY_FIELD, url));
                 int lastDoc = 0;
@@ -147,7 +147,7 @@ namespace Lucene.Net.Search
                 {
                     lastDoc = td.Doc();
                 }
-                Assert.AreEqual(lastDoc, h.Id((i)), "Duplicate urls should return last doc");
+                Assert.AreEqual(lastDoc, h[i].doc, "Duplicate urls should return last doc");
             }
         }
 
@@ -156,17 +156,17 @@ namespace Lucene.Net.Search
         {
             DuplicateFilter df = new DuplicateFilter(KEY_FIELD);
             df.SetKeepMode(DuplicateFilter.KM_USE_FIRST_OCCURRENCE);
-            Hits h = searcher.Search(tq, df);
-            Assert.IsTrue(h.Length() > 0, "Filtered searching should have found some matches");
-            for (int i = 0; i < h.Length(); i++)
+            ScoreDoc[] h = searcher.Search(tq, df, 1000).ScoreDocs;
+            Assert.IsTrue(h.Length > 0, "Filtered searching should have found some matches");
+            for (int i = 0; i < h.Length; i++)
             {
-                Document d = h.Doc(i);
+                Document d = searcher.Doc(h[i].doc);
                 String url = d.Get(KEY_FIELD);
                 TermDocs td = reader.TermDocs(new Term(KEY_FIELD, url));
                 int lastDoc = 0;
                 td.Next();
                 lastDoc = td.Doc();
-                Assert.AreEqual(lastDoc, h.Id((i)), "Duplicate urls should return first doc");
+                Assert.AreEqual(lastDoc, h[i].doc, "Duplicate urls should return first doc");
             }
         }
     }

Modified: incubator/lucene.net/trunk/test/contrib/Queries/FuzzyLikeThisQueryTest.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/contrib/Queries/FuzzyLikeThisQueryTest.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/contrib/Queries/FuzzyLikeThisQueryTest.cs (original)
+++ incubator/lucene.net/trunk/test/contrib/Queries/FuzzyLikeThisQueryTest.cs Tue Feb 28 22:43:08 2012
@@ -72,13 +72,13 @@ namespace Lucene.Net.Search
             FuzzyLikeThisQuery flt = new FuzzyLikeThisQuery(10, analyzer);
             flt.AddTerms("smith", "name", 0.3f, 1);
             Query q = flt.Rewrite(searcher.GetIndexReader());
-            Hashtable queryTerms = new Hashtable();
+            ISet<Term> queryTerms = new HashSet<Term>();
             q.ExtractTerms(queryTerms);
             Assert.IsTrue(queryTerms.Contains(new Term("name", "smythe")),"Should have variant smythe");
             Assert.IsTrue(queryTerms.Contains(new Term("name", "smith")), "Should have variant smith");
             Assert.IsTrue(queryTerms.Contains(new Term("name", "smyth")), "Should have variant smyth");
             TopDocs topDocs = searcher.Search(flt, 1);
-            ScoreDoc[] sd = topDocs.scoreDocs;
+            ScoreDoc[] sd = topDocs.ScoreDocs;
             Assert.IsTrue((sd != null) && (sd.Length > 0), "score docs must match 1 doc");
             Document doc = searcher.Doc(sd[0].doc);
             Assert.AreEqual("2", doc.Get("id"), "Should match most similar not most rare variant");
@@ -91,12 +91,12 @@ namespace Lucene.Net.Search
             FuzzyLikeThisQuery flt = new FuzzyLikeThisQuery(10, analyzer);
             flt.AddTerms("jonathin smoth", "name", 0.3f, 1);
             Query q = flt.Rewrite(searcher.GetIndexReader());
-            Hashtable queryTerms = new Hashtable();
+            ISet<Term> queryTerms = new HashSet<Term>();
             q.ExtractTerms(queryTerms);
             Assert.IsTrue(queryTerms.Contains(new Term("name", "jonathan")),"Should have variant jonathan");
             Assert.IsTrue(queryTerms.Contains(new Term("name", "smith")), "Should have variant smith");
             TopDocs topDocs = searcher.Search(flt, 1);
-            ScoreDoc[] sd = topDocs.scoreDocs;
+            ScoreDoc[] sd = topDocs.ScoreDocs;
             Assert.IsTrue((sd != null) && (sd.Length > 0), "score docs must match 1 doc");
             Document doc = searcher.Doc(sd[0].doc);
             Assert.AreEqual("2", doc.Get("id"), "Should match most similar when using 2 words");
@@ -109,11 +109,11 @@ namespace Lucene.Net.Search
             FuzzyLikeThisQuery flt = new FuzzyLikeThisQuery(10, analyzer);
             flt.AddTerms("fernando smith", "name", 0.3f, 1);
             Query q = flt.Rewrite(searcher.GetIndexReader());
-            Hashtable queryTerms = new Hashtable();
+            ISet<Term> queryTerms = new HashSet<Term>();
             q.ExtractTerms(queryTerms);
             Assert.IsTrue(queryTerms.Contains(new Term("name", "smith")), "Should have variant smith");
             TopDocs topDocs = searcher.Search(flt, 1);
-            ScoreDoc[] sd = topDocs.scoreDocs;
+            ScoreDoc[] sd = topDocs.ScoreDocs;
             Assert.IsTrue((sd != null) && (sd.Length > 0), "score docs must match 1 doc");
             Document doc = searcher.Doc(sd[0].doc);
             Assert.AreEqual("2", doc.Get("id"), "Should match most similar when using 2 words");

Modified: incubator/lucene.net/trunk/test/contrib/Queries/Similar/TestMoreLikeThis.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/contrib/Queries/Similar/TestMoreLikeThis.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/contrib/Queries/Similar/TestMoreLikeThis.cs (original)
+++ incubator/lucene.net/trunk/test/contrib/Queries/Similar/TestMoreLikeThis.cs Tue Feb 28 22:43:08 2012
@@ -46,7 +46,8 @@ namespace Lucene.Net.Search.Similar
         {
             base.SetUp();
             directory = new RAMDirectory();
-            IndexWriter writer = new IndexWriter(directory, new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_29),true, IndexWriter.MaxFieldLength.UNLIMITED);
+            IndexWriter writer = new IndexWriter(directory, new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_CURRENT),
+                                                 true, IndexWriter.MaxFieldLength.UNLIMITED);
 
             // Add series of docs with specific information for MoreLikeThis
             AddDoc(writer, "lucene");

Modified: incubator/lucene.net/trunk/test/contrib/Queries/TermsFilterTest.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/contrib/Queries/TermsFilterTest.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/contrib/Queries/TermsFilterTest.cs (original)
+++ incubator/lucene.net/trunk/test/contrib/Queries/TermsFilterTest.cs Tue Feb 28 22:43:08 2012
@@ -98,15 +98,5 @@ namespace Lucene.Net.Search
             bits = (OpenBitSet)tf.GetDocIdSet(reader);
             Assert.AreEqual(2, bits.Cardinality(), "Must match 2");
         }
-
-        [Test]
-        [ExpectedException(typeof(NotSupportedException))]
-        public void ExOnBits()
-        {
-            TermsFilter a = new TermsFilter();
-            a.AddTerm(new Term("field1", "a"));
-            a.AddTerm(new Term("field1", "b"));
-            BitArray b = a.Bits(null);
-        }
     }
 }

Modified: incubator/lucene.net/trunk/test/contrib/Regex/Contrib.Regex.Test.csproj
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/contrib/Regex/Contrib.Regex.Test.csproj?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/contrib/Regex/Contrib.Regex.Test.csproj (original)
+++ incubator/lucene.net/trunk/test/contrib/Regex/Contrib.Regex.Test.csproj Tue Feb 28 22:43:08 2012
@@ -19,7 +19,6 @@
  under the License.
 
 -->
-
 <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <PropertyGroup>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -62,7 +61,8 @@
   </ItemGroup>
   <ItemGroup>
     <Compile Include="Properties\AssemblyInfo.cs" />
-    <Compile Include="TestRegexpQuery.cs" />
+    <Compile Include="TestRegexQuery.cs" />
+    <Compile Include="TestSpanRegexQuery.cs" />
   </ItemGroup>
   <ItemGroup>
     <ProjectReference Include="..\..\..\src\contrib\Regex\Contrib.Regex.csproj">

Modified: incubator/lucene.net/trunk/test/contrib/SimpleFacetedSearch/TestSimpleFacetedSearch.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/contrib/SimpleFacetedSearch/TestSimpleFacetedSearch.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/contrib/SimpleFacetedSearch/TestSimpleFacetedSearch.cs (original)
+++ incubator/lucene.net/trunk/test/contrib/SimpleFacetedSearch/TestSimpleFacetedSearch.cs Tue Feb 28 22:43:08 2012
@@ -31,6 +31,7 @@ using Lucene.Net.Store;
 using Lucene.Net.Util;
 
 using NUnit.Framework;
+using Version = Lucene.Net.Util.Version;
 
 namespace Lucene.Net.Search
 {
@@ -44,7 +45,7 @@ namespace Lucene.Net.Search
         public void SetUp()
         {
 
-            IndexWriter writer = new IndexWriter(_Dir, new StandardAnalyzer(), true);
+            IndexWriter writer = new IndexWriter(_Dir, new StandardAnalyzer(Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.UNLIMITED);
 
             AddDoc(writer, "us", "CCN", "politics", "The White House doubles down on social media");
             AddDoc(writer, "us", "CCN", "politics", "Senate Dems fail to block filibuster over judicial nominee");

Modified: incubator/lucene.net/trunk/test/contrib/Snowball/Analysis/Snowball/TestSnowball.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/contrib/Snowball/Analysis/Snowball/TestSnowball.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/contrib/Snowball/Analysis/Snowball/TestSnowball.cs (original)
+++ incubator/lucene.net/trunk/test/contrib/Snowball/Analysis/Snowball/TestSnowball.cs Tue Feb 28 22:43:08 2012
@@ -19,129 +19,141 @@
  *
 */
 
-/* ====================================================================
-* The Apache Software License, Version 1.1
-*
-* Copyright (c) 2004 The Apache Software Foundation.  All rights
-* reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions
-* are met:
-*
-* 1. Redistributions of source code must retain the above copyright
-*    notice, this list of conditions and the following disclaimer.
-*
-* 2. Redistributions in binary form must reproduce the above copyright
-*    notice, this list of conditions and the following disclaimer in
-*    the documentation and/or other materials provided with the
-*    distribution.
-*
-* 3. The end-user documentation included with the redistribution,
-*    if any, must include the following acknowledgment:
-*       "This product includes software developed by the
-*        Apache Software Foundation (http://www.apache.org/)."
-*    Alternately, this acknowledgment may appear in the software itself,
-*    if and wherever such third-party acknowledgments normally appear.
-*
-* 4. The names "Apache" and "Apache Software Foundation" and
-*    "Apache Lucene" must not be used to endorse or promote products
-*    derived from this software without prior written permission. For
-*    written permission, please contact apache@apache.org.
-*
-* 5. Products derived from this software may not be called "Apache",
-*    "Apache Lucene", nor may "Apache" appear in their name, without
-*    prior written permission of the Apache Software Foundation.
-*
-* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
-* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-* DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
-* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
-* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
-* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-* SUCH DAMAGE.
-* ====================================================================
-*
-* This software consists of voluntary contributions made by many
-* individuals on behalf of the Apache Software Foundation.  For more
-* information on the Apache Software Foundation, please see
-* <http://www.apache.org/>.
-*/
-
 using System;
+using System.IO;
+using Lucene.Net.Analysis.Standard;
+using Lucene.Net.Analysis.Tokenattributes;
+using Lucene.Net.Index;
 using NUnit.Framework;
 using Lucene.Net.Analysis;
+using FlagsAttribute = Lucene.Net.Analysis.Tokenattributes.FlagsAttribute;
+using Version = Lucene.Net.Util.Version;
 
 namespace Lucene.Net.Analysis.Snowball
 {
-	[TestFixture]
-	public class TestSnowball
-	{
-		private class AnonymousClassTokenStream : TokenStream
-		{
-			public AnonymousClassTokenStream(Token tok, TestSnowball enclosingInstance)
-			{
-				InitBlock(tok, enclosingInstance);
-			}
-			private void  InitBlock(Token tok, TestSnowball enclosingInstance)
-			{
-				this.tok = tok;
-				this.enclosingInstance = enclosingInstance;
-			}
-			private Token tok;
-			private TestSnowball enclosingInstance;
-			public TestSnowball Enclosing_Instance
-			{
-				get
-				{
-					return enclosingInstance;
-				}
-				
-			}
-            public override Token Next()
-			{
-				return tok;
-			}
-		}
-		
-		public virtual void  AssertAnalyzesTo(Analyzer a, System.String input, System.String[] output)
-		{
-			TokenStream ts = a.TokenStream("dummy", new System.IO.StringReader(input));
-			for (int i = 0; i < output.Length; i++)
-			{
-				Token t = ts.Next();
-				Assert.IsNotNull(t);
-				Assert.AreEqual(output[i], t.TermText());
-			}
-			Assert.IsNull(ts.Next());
-			ts.Close();
-		}
-		[Test]
-		public virtual void  TestEnglish()
-		{
-			Analyzer a = new SnowballAnalyzer("English");
-			AssertAnalyzesTo(a, "he abhorred accents", new System.String[]{"he", "abhor", "accent"});
-		}
-		[Test]
-		public virtual void  TestFilterTokens()
-		{
-			Token tok = new Token("accents", 2, 7, "wrd");
-			tok.SetPositionIncrement(3);
-			
-			SnowballFilter filter = new SnowballFilter(new AnonymousClassTokenStream(tok, this), "English");
-			
-			Token newtok = filter.Next();
-			
-			Assert.AreEqual("accent", newtok.TermText());
-			Assert.AreEqual(2, newtok.StartOffset());
-			Assert.AreEqual(7, newtok.EndOffset());
-			Assert.AreEqual("wrd", newtok.Type());
-			Assert.AreEqual(3, newtok.GetPositionIncrement());
-		}
-	}
-}
+    [TestFixture]
+    public class TestSnowball : BaseTokenStreamTestCase
+    {
+        [Test]
+        public void TestEnglish()
+        {
+            Analyzer a = new SnowballAnalyzer(Version.LUCENE_CURRENT, "English");
+            AssertAnalyzesTo(a, "he abhorred accents",
+                new String[] { "he", "abhor", "accent" });
+        }
+
+        [Test]
+        public void TestStopwords()
+        {
+            Analyzer a = new SnowballAnalyzer(Version.LUCENE_CURRENT, "English",
+                StandardAnalyzer.STOP_WORDS_SET);
+            AssertAnalyzesTo(a, "the quick brown fox jumped",
+                new String[] { "quick", "brown", "fox", "jump" });
+        }
+
+        [Test]
+        public void TestReusableTokenStream()
+        {
+            Analyzer a = new SnowballAnalyzer(Version.LUCENE_CURRENT, "English");
+            AssertAnalyzesToReuse(a, "he abhorred accents",
+                new String[] { "he", "abhor", "accent" });
+            AssertAnalyzesToReuse(a, "she abhorred him",
+                new String[] { "she", "abhor", "him" });
+        }
+
+        /**
+         * subclass that acts just like whitespace analyzer for testing
+         */
+        private class SnowballSubclassAnalyzer : SnowballAnalyzer
+        {
+            public SnowballSubclassAnalyzer(String name)
+                : base(Version.LUCENE_CURRENT, name)
+            {
+
+            }
+
+            public override TokenStream TokenStream(String fieldName, TextReader reader)
+            {
+                return new WhitespaceTokenizer(reader);
+            }
+        }
+
+        [Test]
+        public void TestLucene1678BwComp()
+        {
+            Analyzer a = new SnowballSubclassAnalyzer("English");
+            AssertAnalyzesToReuse(a, "he abhorred accents",
+                new String[] { "he", "abhorred", "accents" });
+        }
+
+        [Test]
+        public void TestFilterTokens()
+        {
+            SnowballFilter filter = new SnowballFilter(new TestTokenStream(), "English");
+            TermAttribute termAtt = filter.GetAttribute<TermAttribute>();
+            OffsetAttribute offsetAtt = filter.GetAttribute<OffsetAttribute>();
+            TypeAttribute typeAtt = filter.GetAttribute<TypeAttribute>();
+            PayloadAttribute payloadAtt = filter.GetAttribute<PayloadAttribute>();
+            PositionIncrementAttribute posIncAtt = filter.GetAttribute<PositionIncrementAttribute>();
+            FlagsAttribute flagsAtt = filter.GetAttribute<FlagsAttribute>();
+
+            filter.IncrementToken();
+
+            Assert.AreEqual("accent", termAtt.Term());
+            Assert.AreEqual(2, offsetAtt.StartOffset());
+            Assert.AreEqual(7, offsetAtt.EndOffset());
+            Assert.AreEqual("wrd", typeAtt.Type());
+            Assert.AreEqual(3, posIncAtt.GetPositionIncrement());
+            Assert.AreEqual(77, flagsAtt.GetFlags());
+            Assert.AreEqual(new Payload(new byte[] { 0, 1, 2, 3 }), payloadAtt.GetPayload());
+        }
+
+        [Test(Description = "LUCENENET-54")]
+        public void TestJiraLuceneNet54()
+        {
+            var analyzer = new SnowballAnalyzer(Lucene.Net.Util.Version.LUCENE_CURRENT, "Finnish");
+            var input = new StringReader("terve");
+            var tokenStream = analyzer.TokenStream("fieldName", input);
+            var termAttr = tokenStream.AddAttribute<TermAttribute>();
+            Assert.That(tokenStream.IncrementToken(), Is.True);
+            Assert.That(termAttr.Term(), Is.EqualTo("terv"));
+        }
+
+        private sealed class TestTokenStream : TokenStream
+        {
+            private TermAttribute termAtt;
+            private OffsetAttribute offsetAtt;
+            private TypeAttribute typeAtt;
+            private PayloadAttribute payloadAtt;
+            private PositionIncrementAttribute posIncAtt;
+            private FlagsAttribute flagsAtt;
+
+            internal TestTokenStream()
+            {
+                termAtt = AddAttribute<TermAttribute>();
+                offsetAtt = AddAttribute<OffsetAttribute>();
+                typeAtt = AddAttribute<TypeAttribute>();
+                payloadAtt = AddAttribute<PayloadAttribute>();
+                posIncAtt = AddAttribute<PositionIncrementAttribute>();
+                flagsAtt = AddAttribute<FlagsAttribute>();
+            }
+
+            public override bool IncrementToken()
+            {
+                ClearAttributes();
+                termAtt.SetTermBuffer("accents");
+                offsetAtt.SetOffset(2, 7);
+                typeAtt.SetType("wrd");
+                posIncAtt.SetPositionIncrement(3);
+                payloadAtt.SetPayload(new Payload(new byte[] { 0, 1, 2, 3 }));
+                flagsAtt.SetFlags(77);
+                return true;
+            }
+
+            protected override void Dispose(bool disposing)
+            {
+                // do nothing
+            }
+        }
+    }
+}
\ No newline at end of file

Modified: incubator/lucene.net/trunk/test/contrib/Snowball/Contrib.Snowball.Test.csproj
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/contrib/Snowball/Contrib.Snowball.Test.csproj?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/contrib/Snowball/Contrib.Snowball.Test.csproj (original)
+++ incubator/lucene.net/trunk/test/contrib/Snowball/Contrib.Snowball.Test.csproj Tue Feb 28 22:43:08 2012
@@ -19,7 +19,6 @@
  under the License.
 
 -->
-
 <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
   <PropertyGroup>
     <ProjectType>Local</ProjectType>
@@ -148,6 +147,10 @@
       <Project>{5D4AD9BE-1FFB-41AB-9943-25737971BF57}</Project>
       <Name>Lucene.Net</Name>
     </ProjectReference>
+    <ProjectReference Include="..\..\core\Lucene.Net.Test.csproj">
+      <Project>{AAF68BCF-F781-45FC-98B3-2B9CEE411E01}</Project>
+      <Name>Lucene.Net.Test</Name>
+    </ProjectReference>
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <PropertyGroup>

Modified: incubator/lucene.net/trunk/test/contrib/Spatial/TestCartesian.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/contrib/Spatial/TestCartesian.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/contrib/Spatial/TestCartesian.cs (original)
+++ incubator/lucene.net/trunk/test/contrib/Spatial/TestCartesian.cs Tue Feb 28 22:43:08 2012
@@ -17,14 +17,10 @@
 
 using System;
 using System.Collections.Generic;
-using System.Text;
 using Lucene.Net.Analysis;
 using Lucene.Net.Documents;
 using Lucene.Net.Index;
 using Lucene.Net.Search;
-using Lucene.Net.Search.Function;
-using Lucene.Net.Spatial.GeoHash;
-using Lucene.Net.Spatial.Geometry;
 using Lucene.Net.Spatial.Tier;
 using Lucene.Net.Spatial.Tier.Projectors;
 using Lucene.Net.Store;
@@ -143,8 +139,8 @@ namespace Lucene.Net.Contrib.Spatial.Tes
 			// Perform the search, using the term query, the distance filter, and the
 			// distance sort
 			TopDocs hits = _searcher.Search(tq, dq.Filter, 1000, sort);
-			int results = hits.totalHits;
-			ScoreDoc[] scoreDocs = hits.scoreDocs;
+			int results = hits.TotalHits;
+			ScoreDoc[] scoreDocs = hits.ScoreDocs;
 
 			// Get a list of distances
 			Dictionary<int, Double> distances = dq.DistanceFilter.Distances;

Modified: incubator/lucene.net/trunk/test/contrib/SpellChecker/Test/TestJaroWinklerDistance.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/contrib/SpellChecker/Test/TestJaroWinklerDistance.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/contrib/SpellChecker/Test/TestJaroWinklerDistance.cs (original)
+++ incubator/lucene.net/trunk/test/contrib/SpellChecker/Test/TestJaroWinklerDistance.cs Tue Feb 28 22:43:08 2012
@@ -15,10 +15,6 @@
  * limitations under the License.
  */
 
-using System;
-using System.Collections.Generic;
-using System.Text;
-
 using NUnit.Framework;
 
 using SpellChecker.Net.Search.Spell;
@@ -28,7 +24,7 @@ namespace SpellChecker.Net.Test.Search.S
     [TestFixture]
     public class TestJaroWinklerDistance
     {
-        private StringDistance sd = new JaroWinklerDistance();
+        private readonly StringDistance sd = new JaroWinklerDistance();
 
         [Test]
         public void TestGetDistance()

Modified: incubator/lucene.net/trunk/test/contrib/SpellChecker/Test/TestLevenshteinDistance.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/contrib/SpellChecker/Test/TestLevenshteinDistance.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/contrib/SpellChecker/Test/TestLevenshteinDistance.cs (original)
+++ incubator/lucene.net/trunk/test/contrib/SpellChecker/Test/TestLevenshteinDistance.cs Tue Feb 28 22:43:08 2012
@@ -15,9 +15,6 @@
  * limitations under the License.
  */
 
-using System;
-using System.Collections.Generic;
-using System.Text;
 using SpellChecker.Net.Search.Spell;
 using NUnit.Framework;
 
@@ -26,7 +23,7 @@ namespace SpellChecker.Net.Test.Search.S
     [TestFixture]
     public class TestLevenshteinDistance
     {
-        private StringDistance sd = new LevenshteinDistance();
+        private readonly StringDistance sd = new LevenshteinDistance();
 
         [Test]
         public void TestGetDistance()

Modified: incubator/lucene.net/trunk/test/contrib/SpellChecker/Test/TestLuceneDictionary.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/contrib/SpellChecker/Test/TestLuceneDictionary.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/contrib/SpellChecker/Test/TestLuceneDictionary.cs (original)
+++ incubator/lucene.net/trunk/test/contrib/SpellChecker/Test/TestLuceneDictionary.cs Tue Feb 28 22:43:08 2012
@@ -17,9 +17,6 @@
 
 using System;
 using System.Collections;
-using System.Collections.Generic;
-using System.Text;
-
 using NUnit.Framework;
 
 using Lucene.Net.Store;
@@ -34,9 +31,9 @@ namespace SpellChecker.Net.Test.Search.S
     public class TestLuceneDictionary
     {
 
-        private Directory store = new RAMDirectory();
+        private readonly Directory store = new RAMDirectory();
 
-        private IndexReader indexReader = null;
+        private IndexReader indexReader;
 
         private LuceneDictionary ld;
         private IEnumerator it;
@@ -45,11 +42,9 @@ namespace SpellChecker.Net.Test.Search.S
         public void SetUp()
         {
 
-            IndexWriter writer = new IndexWriter(store, new WhitespaceAnalyzer(), true);
-
-            Document doc;
+            var writer = new IndexWriter(store, new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.UNLIMITED);
 
-            doc = new Document();
+            var doc = new Document();
             doc.Add(new Field("aaa", "foo", Field.Store.YES, Field.Index.ANALYZED));
             writer.AddDocument(doc);
 
@@ -208,7 +203,7 @@ namespace SpellChecker.Net.Test.Search.S
         [Test]
         public void TestSpellchecker()
         {
-            SpellChecker.Net.Search.Spell.SpellChecker sc = new SpellChecker.Net.Search.Spell.SpellChecker(new RAMDirectory());
+            var sc = new Net.Search.Spell.SpellChecker(new RAMDirectory());
             indexReader = IndexReader.Open(store);
             sc.IndexDictionary(new LuceneDictionary(indexReader, "contents"));
             String[] suggestions = sc.SuggestSimilar("Tam", 1);
@@ -221,22 +216,23 @@ namespace SpellChecker.Net.Test.Search.S
         }
         
         #region .NET 
-        void AssertTrue(string s, bool b)
+
+        static void AssertTrue(string s, bool b)
         {
             Assert.IsTrue(b, s);
         }
 
-        void AssertFalse(string s, bool b)
+        static void AssertFalse(string s, bool b)
         {
             Assert.IsFalse(b, s);
         }
 
-        void AssertEquals(int i, int j)
+        static void AssertEquals(int i, int j)
         {
             Assert.AreEqual(i, j);
         }
 
-        void AssertEquals(string i, string j)
+        static void AssertEquals(string i, string j)
         {
             Assert.AreEqual(i, j);
         }
@@ -266,7 +262,6 @@ namespace System.Runtime.CompilerService
     [AttributeUsage(AttributeTargets.Method)]
     public sealed class ExtensionAttribute : Attribute
     {
-        public ExtensionAttribute() { }
     }
 }
 #endregion

Modified: incubator/lucene.net/trunk/test/contrib/SpellChecker/Test/TestNGramDistance.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/contrib/SpellChecker/Test/TestNGramDistance.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/contrib/SpellChecker/Test/TestNGramDistance.cs (original)
+++ incubator/lucene.net/trunk/test/contrib/SpellChecker/Test/TestNGramDistance.cs Tue Feb 28 22:43:08 2012
@@ -15,10 +15,6 @@
  * limitations under the License.
  */
 
-using System;
-using System.Collections.Generic;
-using System.Text;
-
 using NUnit.Framework;
 
 using SpellChecker.Net.Search.Spell;

Modified: incubator/lucene.net/trunk/test/contrib/SpellChecker/Test/TestPlainTextDictionary.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/contrib/SpellChecker/Test/TestPlainTextDictionary.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/contrib/SpellChecker/Test/TestPlainTextDictionary.cs (original)
+++ incubator/lucene.net/trunk/test/contrib/SpellChecker/Test/TestPlainTextDictionary.cs Tue Feb 28 22:43:08 2012
@@ -17,7 +17,6 @@
 
 using System;
 using System.IO;
-using System.Collections.Generic;
 using System.Text;
 
 using NUnit.Framework;
@@ -35,11 +34,11 @@ namespace SpellChecker.Net.Test.Search.S
         public void TestBuild()
         {
 
-            String LF = System.Environment.NewLine;
-            String input = "oneword" + LF + "twoword" + LF + "threeword";
-            PlainTextDictionary ptd = new PlainTextDictionary( new MemoryStream( System.Text.Encoding.UTF8.GetBytes(input)) );
-            RAMDirectory ramDir = new RAMDirectory();
-            SpellChecker.Net.Search.Spell.SpellChecker spellChecker = new SpellChecker.Net.Search.Spell.SpellChecker(ramDir);
+            var LF = Environment.NewLine;
+            var input = "oneword" + LF + "twoword" + LF + "threeword";
+            var ptd = new PlainTextDictionary( new MemoryStream( Encoding.UTF8.GetBytes(input)) );
+            var ramDir = new RAMDirectory();
+            var spellChecker = new Net.Search.Spell.SpellChecker(ramDir);
             spellChecker.IndexDictionary(ptd);
             String[] similar = spellChecker.SuggestSimilar("treeword", 2);
             Assert.AreEqual(2, similar.Length);



Mime
View raw message