You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by ni...@apache.org on 2016/10/11 18:35:10 UTC

[25/47] lucenenet git commit: Added Codecs.Pulsing tests + mocks to the project

Added Codecs.Pulsing tests + mocks to the project


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

Branch: refs/heads/master
Commit: d5d18d005e8aa7138e5537ca65d59a8107cfee54
Parents: 8e1656b
Author: Shad Storhaug <sh...@shadstorhaug.com>
Authored: Tue Oct 11 00:13:34 2016 +0700
Committer: Shad Storhaug <sh...@shadstorhaug.com>
Committed: Tue Oct 11 00:26:23 2016 +0700

----------------------------------------------------------------------
 .../NestedPulsingPostingsFormat.cs              |  97 ++++++
 .../Lucene.Net.TestFramework.csproj             |   1 +
 .../Lucene.Net.Tests.Codecs.csproj              |   3 +
 .../Pulsing/Test10KPulsings.cs                  | 319 +++++++++----------
 .../Pulsing/TestPulsingPostingsFormat.cs        |  44 ++-
 .../Pulsing/TestPulsingReuse.cs                 | 219 ++++++-------
 6 files changed, 379 insertions(+), 304 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d5d18d00/src/Lucene.Net.TestFramework/Codecs/NestedPulsing/NestedPulsingPostingsFormat.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Codecs/NestedPulsing/NestedPulsingPostingsFormat.cs b/src/Lucene.Net.TestFramework/Codecs/NestedPulsing/NestedPulsingPostingsFormat.cs
new file mode 100644
index 0000000..e8c27e6
--- /dev/null
+++ b/src/Lucene.Net.TestFramework/Codecs/NestedPulsing/NestedPulsingPostingsFormat.cs
@@ -0,0 +1,97 @@
+\ufeffusing Lucene.Net.Codecs.Lucene41;
+using Lucene.Net.Codecs.Pulsing;
+using Lucene.Net.Index;
+using Lucene.Net.Util;
+
+namespace Lucene.Net.Codecs.NestedPulsing
+{
+    /*
+     * 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.
+     */
+
+    /// <summary>
+    /// Pulsing(1, Pulsing(2, Lucene41))
+    /// 
+    /// @lucene.experimental
+    /// </summary>
+    // TODO: if we create PulsingPostingsBaseFormat then we
+    // can simplify this? note: I don't like the *BaseFormat
+    // hierarchy, maybe we can clean that up...
+    public class NestedPulsingPostingsFormat : PostingsFormat
+    {
+        public NestedPulsingPostingsFormat()
+            : base("NestedPulsing")
+        {
+        }
+
+        public override FieldsConsumer FieldsConsumer(SegmentWriteState state)
+        {
+            PostingsWriterBase docsWriter = null;
+            PostingsWriterBase pulsingWriterInner = null;
+            PostingsWriterBase pulsingWriter = null;
+
+            // Terms dict
+            bool success = false;
+            try
+            {
+                docsWriter = new Lucene41PostingsWriter(state);
+
+                pulsingWriterInner = new PulsingPostingsWriter(state, 2, docsWriter);
+                pulsingWriter = new PulsingPostingsWriter(state, 1, pulsingWriterInner);
+                FieldsConsumer ret = new BlockTreeTermsWriter(state, pulsingWriter,
+                    BlockTreeTermsWriter.DEFAULT_MIN_BLOCK_SIZE, BlockTreeTermsWriter.DEFAULT_MAX_BLOCK_SIZE);
+                success = true;
+                return ret;
+            }
+            finally
+            {
+                if (!success)
+                {
+                    IOUtils.CloseWhileHandlingException(docsWriter, pulsingWriterInner, pulsingWriter);
+                }
+            }
+        }
+
+        public override FieldsProducer FieldsProducer(SegmentReadState state)
+        {
+            PostingsReaderBase docsReader = null;
+            PostingsReaderBase pulsingReaderInner = null;
+            PostingsReaderBase pulsingReader = null;
+            bool success = false;
+            try
+            {
+                docsReader = new Lucene41PostingsReader(state.Directory, state.FieldInfos, state.SegmentInfo, state.Context, state.SegmentSuffix);
+                pulsingReaderInner = new PulsingPostingsReader(state, docsReader);
+                pulsingReader = new PulsingPostingsReader(state, pulsingReaderInner);
+                FieldsProducer ret = new BlockTreeTermsReader(
+                                                              state.Directory, state.FieldInfos, state.SegmentInfo,
+                                                              pulsingReader,
+                                                              state.Context,
+                                                              state.SegmentSuffix,
+                                                              state.TermsIndexDivisor);
+                success = true;
+                return ret;
+            }
+            finally
+            {
+                if (!success)
+                {
+                    IOUtils.CloseWhileHandlingException(docsReader, pulsingReaderInner, pulsingReader);
+                }
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d5d18d00/src/Lucene.Net.TestFramework/Lucene.Net.TestFramework.csproj
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Lucene.Net.TestFramework.csproj b/src/Lucene.Net.TestFramework/Lucene.Net.TestFramework.csproj
index bbee1e8..dd333d1 100644
--- a/src/Lucene.Net.TestFramework/Lucene.Net.TestFramework.csproj
+++ b/src/Lucene.Net.TestFramework/Lucene.Net.TestFramework.csproj
@@ -257,6 +257,7 @@
     <Compile Include="Codecs\MockSep\MockSingleIntFactory.cs" />
     <Compile Include="Codecs\MockSep\MockSingleIntIndexInput.cs" />
     <Compile Include="Codecs\MockSep\MockSingleIntIndexOutput.cs" />
+    <Compile Include="Codecs\NestedPulsing\NestedPulsingPostingsFormat.cs" />
     <Compile Include="Codecs\ramonly\RAMOnlyPostingsFormat.cs">
       <SubType>Code</SubType>
     </Compile>

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d5d18d00/src/Lucene.Net.Tests.Codecs/Lucene.Net.Tests.Codecs.csproj
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Codecs/Lucene.Net.Tests.Codecs.csproj b/src/Lucene.Net.Tests.Codecs/Lucene.Net.Tests.Codecs.csproj
index db67f15..ec557a4 100644
--- a/src/Lucene.Net.Tests.Codecs/Lucene.Net.Tests.Codecs.csproj
+++ b/src/Lucene.Net.Tests.Codecs/Lucene.Net.Tests.Codecs.csproj
@@ -49,6 +49,9 @@
     <Compile Include="IntBlock\TestIntBlockCodec.cs" />
     <Compile Include="IntBlock\TestVariableIntBlockPostingsFormat.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="Pulsing\Test10KPulsings.cs" />
+    <Compile Include="Pulsing\TestPulsingPostingsFormat.cs" />
+    <Compile Include="Pulsing\TestPulsingReuse.cs" />
     <Compile Include="Sep\TestSepPostingsFormat.cs" />
     <Compile Include="SimpleText\TestSimpleTextDocValuesFormat.cs" />
     <Compile Include="SimpleText\TestSimpleTextPostingsFormat.cs" />

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d5d18d00/src/Lucene.Net.Tests.Codecs/Pulsing/Test10KPulsings.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Codecs/Pulsing/Test10KPulsings.cs b/src/Lucene.Net.Tests.Codecs/Pulsing/Test10KPulsings.cs
index c9fab57..71aea64 100644
--- a/src/Lucene.Net.Tests.Codecs/Pulsing/Test10KPulsings.cs
+++ b/src/Lucene.Net.Tests.Codecs/Pulsing/Test10KPulsings.cs
@@ -1,9 +1,17 @@
-\ufeffusing System.Text;
-
-namespace org.apache.lucene.codecs.pulsing
+\ufeffusing Lucene.Net.Analysis;
+using Lucene.Net.Documents;
+using Lucene.Net.Index;
+using Lucene.Net.Search;
+using Lucene.Net.Store;
+using Lucene.Net.Util;
+using NUnit.Framework;
+using System.Globalization;
+using System.IO;
+using System.Text;
+
+namespace Lucene.Net.Codecs.Pulsing
 {
-
-	/*
+    /*
 	 * Licensed to the Apache Software Foundation (ASF) under one or more
 	 * contributor license agreements.  See the NOTICE file distributed with
 	 * this work for additional information regarding copyright ownership.
@@ -20,164 +28,145 @@ namespace org.apache.lucene.codecs.pulsing
 	 * limitations under the License.
 	 */
 
-
-	using MockAnalyzer = org.apache.lucene.analysis.MockAnalyzer;
-	using Document = org.apache.lucene.document.Document;
-	using Field = org.apache.lucene.document.Field;
-	using FieldType = org.apache.lucene.document.FieldType;
-	using TextField = org.apache.lucene.document.TextField;
-	using DocsEnum = org.apache.lucene.index.DocsEnum;
-	using IndexOptions = org.apache.lucene.index.FieldInfo.IndexOptions;
-	using IndexReader = org.apache.lucene.index.IndexReader;
-	using MultiFields = org.apache.lucene.index.MultiFields;
-	using RandomIndexWriter = org.apache.lucene.index.RandomIndexWriter;
-	using TermsEnum = org.apache.lucene.index.TermsEnum;
-	using DocIdSetIterator = org.apache.lucene.search.DocIdSetIterator;
-	using BaseDirectoryWrapper = org.apache.lucene.store.BaseDirectoryWrapper;
-	using LuceneTestCase = org.apache.lucene.util.LuceneTestCase;
-	using TestUtil = org.apache.lucene.util.TestUtil;
-
-	/// <summary>
-	/// Pulses 10k terms/docs, 
-	/// originally designed to find JRE bugs (https://issues.apache.org/jira/browse/LUCENE-3335)
-	/// 
-	/// @lucene.experimental
-	/// </summary>
-//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
-//ORIGINAL LINE: @LuceneTestCase.Nightly public class Test10KPulsings extends org.apache.lucene.util.LuceneTestCase
-	public class Test10KPulsings : LuceneTestCase
-	{
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: public void test10kPulsed() throws Exception
-	  public virtual void test10kPulsed()
-	  {
-		// we always run this test with pulsing codec.
-		Codec cp = TestUtil.alwaysPostingsFormat(new Pulsing41PostingsFormat(1));
-
-		File f = createTempDir("10kpulsed");
-		BaseDirectoryWrapper dir = newFSDirectory(f);
-		dir.CheckIndexOnClose = false; // we do this ourselves explicitly
-		RandomIndexWriter iw = new RandomIndexWriter(random(), dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).setCodec(cp));
-
-		Document document = new Document();
-		FieldType ft = new FieldType(TextField.TYPE_STORED);
-
-		switch (TestUtil.Next(random(), 0, 2))
-		{
-		  case 0:
-			  ft.IndexOptions = IndexOptions.DOCS_ONLY;
-			  break;
-		  case 1:
-			  ft.IndexOptions = IndexOptions.DOCS_AND_FREQS;
-			  break;
-		  default:
-			  ft.IndexOptions = IndexOptions.DOCS_AND_FREQS_AND_POSITIONS;
-			  break;
-		}
-
-		Field field = newField("field", "", ft);
-		document.add(field);
-
-		NumberFormat df = new DecimalFormat("00000", new DecimalFormatSymbols(Locale.ROOT));
-
-		for (int i = 0; i < 10050; i++)
-		{
-		  field.StringValue = df.format(i);
-		  iw.addDocument(document);
-		}
-
-		IndexReader ir = iw.Reader;
-		iw.close();
-
-		TermsEnum te = MultiFields.getTerms(ir, "field").iterator(null);
-		DocsEnum de = null;
-
-		for (int i = 0; i < 10050; i++)
-		{
-		  string expected = df.format(i);
-		  assertEquals(expected, te.next().utf8ToString());
-		  de = TestUtil.docs(random(), te, null, de, DocsEnum.FLAG_NONE);
-		  assertTrue(de.nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
-		  assertEquals(DocIdSetIterator.NO_MORE_DOCS, de.nextDoc());
-		}
-		ir.close();
-
-		TestUtil.checkIndex(dir);
-		dir.close();
-	  }
-
-	  /// <summary>
-	  /// a variant, that uses pulsing, but uses a high TF to force pass thru to the underlying codec
-	  /// </summary>
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: public void test10kNotPulsed() throws Exception
-	  public virtual void test10kNotPulsed()
-	  {
-		// we always run this test with pulsing codec.
-		int freqCutoff = TestUtil.Next(random(), 1, 10);
-		Codec cp = TestUtil.alwaysPostingsFormat(new Pulsing41PostingsFormat(freqCutoff));
-
-		File f = createTempDir("10knotpulsed");
-		BaseDirectoryWrapper dir = newFSDirectory(f);
-		dir.CheckIndexOnClose = false; // we do this ourselves explicitly
-		RandomIndexWriter iw = new RandomIndexWriter(random(), dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).setCodec(cp));
-
-		Document document = new Document();
-		FieldType ft = new FieldType(TextField.TYPE_STORED);
-
-		switch (TestUtil.Next(random(), 0, 2))
-		{
-		  case 0:
-			  ft.IndexOptions = IndexOptions.DOCS_ONLY;
-			  break;
-		  case 1:
-			  ft.IndexOptions = IndexOptions.DOCS_AND_FREQS;
-			  break;
-		  default:
-			  ft.IndexOptions = IndexOptions.DOCS_AND_FREQS_AND_POSITIONS;
-			  break;
-		}
-
-		Field field = newField("field", "", ft);
-		document.add(field);
-
-		NumberFormat df = new DecimalFormat("00000", new DecimalFormatSymbols(Locale.ROOT));
-
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final int freq = freqCutoff + 1;
-		int freq = freqCutoff + 1;
-
-		for (int i = 0; i < 10050; i++)
-		{
-		  StringBuilder sb = new StringBuilder();
-		  for (int j = 0; j < freq; j++)
-		  {
-			sb.Append(df.format(i));
-			sb.Append(' '); // whitespace
-		  }
-		  field.StringValue = sb.ToString();
-		  iw.addDocument(document);
-		}
-
-		IndexReader ir = iw.Reader;
-		iw.close();
-
-		TermsEnum te = MultiFields.getTerms(ir, "field").iterator(null);
-		DocsEnum de = null;
-
-		for (int i = 0; i < 10050; i++)
-		{
-		  string expected = df.format(i);
-		  assertEquals(expected, te.next().utf8ToString());
-		  de = TestUtil.docs(random(), te, null, de, DocsEnum.FLAG_NONE);
-		  assertTrue(de.nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
-		  assertEquals(DocIdSetIterator.NO_MORE_DOCS, de.nextDoc());
-		}
-		ir.close();
-
-		TestUtil.checkIndex(dir);
-		dir.close();
-	  }
-	}
-
+    /// <summary>
+    /// Pulses 10k terms/docs, 
+    /// originally designed to find JRE bugs (https://issues.apache.org/jira/browse/LUCENE-3335)
+    /// 
+    /// @lucene.experimental
+    /// </summary>
+    // LUCENENET TODO: This was marked with the Nightly attribute in Java Lucene
+    public class Test10KPulsings : LuceneTestCase
+    {
+        [Test]
+        public virtual void Test10kPulsed()
+        {
+            // we always run this test with pulsing codec.
+            Codec cp = TestUtil.AlwaysPostingsFormat(new Pulsing41PostingsFormat(1));
+
+            DirectoryInfo f = CreateTempDir("10kpulsed");
+            BaseDirectoryWrapper dir = NewFSDirectory(f);
+            dir.CheckIndexOnClose = false; // we do this ourselves explicitly
+            RandomIndexWriter iw = new RandomIndexWriter(Random(), dir, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())).SetCodec(cp));
+
+            Document document = new Document();
+            FieldType ft = new FieldType(TextField.TYPE_STORED);
+
+            switch (TestUtil.NextInt(Random(), 0, 2))
+            {
+                case 0:
+                    ft.IndexOptions = FieldInfo.IndexOptions.DOCS_ONLY;
+                    break;
+                case 1:
+                    ft.IndexOptions = FieldInfo.IndexOptions.DOCS_AND_FREQS;
+                    break;
+                default:
+                    ft.IndexOptions = FieldInfo.IndexOptions.DOCS_AND_FREQS_AND_POSITIONS;
+                    break;
+            }
+
+            Field field = NewField("field", "", ft);
+            document.Add(field);
+
+            //NumberFormat df = new DecimalFormat("00000", new DecimalFormatSymbols(Locale.ROOT));
+
+            for (int i = 0; i < 10050; i++)
+            {
+                //field.StringValue = df.format(i);
+                field.StringValue = i.ToString("00000", CultureInfo.InvariantCulture);
+                iw.AddDocument(document);
+            }
+
+            IndexReader ir = iw.Reader;
+            iw.Dispose();
+
+            TermsEnum te = MultiFields.GetTerms(ir, "field").Iterator(null);
+            DocsEnum de = null;
+
+            for (int i = 0; i < 10050; i++)
+            {
+                //string expected = df.format(i);
+                string expected = i.ToString("00000", CultureInfo.InvariantCulture);
+                assertEquals(expected, te.Next().Utf8ToString());
+                de = TestUtil.Docs(Random(), te, null, de, DocsEnum.FLAG_NONE);
+                assertTrue(de.NextDoc() != DocIdSetIterator.NO_MORE_DOCS);
+                assertEquals(DocIdSetIterator.NO_MORE_DOCS, de.NextDoc());
+            }
+            ir.Dispose();
+
+            TestUtil.CheckIndex(dir);
+            dir.Dispose();
+        }
+
+        /// <summary>
+        /// a variant, that uses pulsing, but uses a high TF to force pass thru to the underlying codec
+        /// </summary>
+        [Test]
+        public virtual void Test10kNotPulsed()
+        {
+            // we always run this test with pulsing codec.
+            int freqCutoff = TestUtil.NextInt(Random(), 1, 10);
+            Codec cp = TestUtil.AlwaysPostingsFormat(new Pulsing41PostingsFormat(freqCutoff));
+
+            DirectoryInfo f = CreateTempDir("10knotpulsed");
+            BaseDirectoryWrapper dir = NewFSDirectory(f);
+            dir.CheckIndexOnClose = false; // we do this ourselves explicitly
+            RandomIndexWriter iw = new RandomIndexWriter(Random(), dir, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())).SetCodec(cp));
+
+            Document document = new Document();
+            FieldType ft = new FieldType(TextField.TYPE_STORED);
+
+            switch (TestUtil.NextInt(Random(), 0, 2))
+            {
+                case 0:
+                    ft.IndexOptions = FieldInfo.IndexOptions.DOCS_ONLY;
+                    break;
+                case 1:
+                    ft.IndexOptions = FieldInfo.IndexOptions.DOCS_AND_FREQS;
+                    break;
+                default:
+                    ft.IndexOptions = FieldInfo.IndexOptions.DOCS_AND_FREQS_AND_POSITIONS;
+                    break;
+            }
+
+            Field field = NewField("field", "", ft);
+            document.Add(field);
+
+            //NumberFormat df = new DecimalFormat("00000", new DecimalFormatSymbols(Locale.ROOT));
+
+            int freq = freqCutoff + 1;
+
+            for (int i = 0; i < 10050; i++)
+            {
+                StringBuilder sb = new StringBuilder();
+                for (int j = 0; j < freq; j++)
+                {
+                    //sb.Append(df.format(i));
+                    sb.Append(i.ToString("00000", CultureInfo.InvariantCulture));
+                    sb.Append(' '); // whitespace
+                }
+                field.StringValue = sb.ToString();
+                iw.AddDocument(document);
+            }
+
+            IndexReader ir = iw.Reader;
+            iw.Dispose();
+
+            TermsEnum te = MultiFields.GetTerms(ir, "field").Iterator(null);
+            DocsEnum de = null;
+
+            for (int i = 0; i < 10050; i++)
+            {
+                //string expected = df.format(i);
+                string expected = i.ToString("00000", CultureInfo.InvariantCulture);
+                assertEquals(expected, te.Next().Utf8ToString());
+                de = TestUtil.Docs(Random(), te, null, de, DocsEnum.FLAG_NONE);
+                assertTrue(de.NextDoc() != DocIdSetIterator.NO_MORE_DOCS);
+                assertEquals(DocIdSetIterator.NO_MORE_DOCS, de.NextDoc());
+            }
+            ir.Dispose();
+
+            TestUtil.CheckIndex(dir);
+            dir.Dispose();
+        }
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d5d18d00/src/Lucene.Net.Tests.Codecs/Pulsing/TestPulsingPostingsFormat.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Codecs/Pulsing/TestPulsingPostingsFormat.cs b/src/Lucene.Net.Tests.Codecs/Pulsing/TestPulsingPostingsFormat.cs
index 249e8e1..cd6f9f2 100644
--- a/src/Lucene.Net.Tests.Codecs/Pulsing/TestPulsingPostingsFormat.cs
+++ b/src/Lucene.Net.Tests.Codecs/Pulsing/TestPulsingPostingsFormat.cs
@@ -1,7 +1,10 @@
-\ufeffnamespace org.apache.lucene.codecs.pulsing
-{
+\ufeffusing Lucene.Net.Index;
+using Lucene.Net.Util;
+using NUnit.Framework;
 
-	/*
+namespace Lucene.Net.Codecs.Pulsing
+{
+    /*
 	 * 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.
@@ -18,25 +21,20 @@
 	 * limitations under the License.
 	 */
 
-	using BasePostingsFormatTestCase = org.apache.lucene.index.BasePostingsFormatTestCase;
-	using TestUtil = org.apache.lucene.util.TestUtil;
-	using TestUtil = org.apache.lucene.util.TestUtil;
-
-	/// <summary>
-	/// Tests PulsingPostingsFormat
-	/// </summary>
-	public class TestPulsingPostingsFormat : BasePostingsFormatTestCase
-	{
-	  // TODO: randomize cutoff
-	  private readonly Codec codec = TestUtil.alwaysPostingsFormat(new Pulsing41PostingsFormat());
-
-	  protected internal override Codec Codec
-	  {
-		  get
-		  {
-			return codec;
-		  }
-	  }
-	}
+    /// <summary>
+    /// Tests PulsingPostingsFormat
+    /// </summary>
+    public class TestPulsingPostingsFormat : BasePostingsFormatTestCase
+    {
+        // TODO: randomize cutoff
+        private readonly Codec codec = TestUtil.AlwaysPostingsFormat(new Pulsing41PostingsFormat());
 
+        protected override Codec Codec
+        {
+            get
+            {
+                return codec;
+            }
+        }
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d5d18d00/src/Lucene.Net.Tests.Codecs/Pulsing/TestPulsingReuse.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Codecs/Pulsing/TestPulsingReuse.cs b/src/Lucene.Net.Tests.Codecs/Pulsing/TestPulsingReuse.cs
index f35c108..b6cc5ba 100644
--- a/src/Lucene.Net.Tests.Codecs/Pulsing/TestPulsingReuse.cs
+++ b/src/Lucene.Net.Tests.Codecs/Pulsing/TestPulsingReuse.cs
@@ -1,9 +1,16 @@
-\ufeffusing System.Collections.Generic;
-
-namespace org.apache.lucene.codecs.pulsing
+\ufeffusing Lucene.Net.Analysis;
+using Lucene.Net.Codecs.NestedPulsing;
+using Lucene.Net.Documents;
+using Lucene.Net.Index;
+using Lucene.Net.Store;
+using Lucene.Net.Support;
+using Lucene.Net.Util;
+using NUnit.Framework;
+using System.Collections.Generic;
+
+namespace Lucene.Net.Codecs.Pulsing
 {
-
-	/*
+    /*
 	 * Licensed to the Apache Software Foundation (ASF) under one or more
 	 * contributor license agreements.  See the NOTICE file distributed with
 	 * this work for additional information regarding copyright ownership.
@@ -20,115 +27,95 @@ namespace org.apache.lucene.codecs.pulsing
 	 * limitations under the License.
 	 */
 
-
-	using MockAnalyzer = org.apache.lucene.analysis.MockAnalyzer;
-	using NestedPulsingPostingsFormat = org.apache.lucene.codecs.nestedpulsing.NestedPulsingPostingsFormat;
-	using Document = org.apache.lucene.document.Document;
-	using Field = org.apache.lucene.document.Field;
-	using TextField = org.apache.lucene.document.TextField;
-	using AtomicReader = org.apache.lucene.index.AtomicReader;
-	using DirectoryReader = org.apache.lucene.index.DirectoryReader;
-	using DocsAndPositionsEnum = org.apache.lucene.index.DocsAndPositionsEnum;
-	using DocsEnum = org.apache.lucene.index.DocsEnum;
-	using RandomIndexWriter = org.apache.lucene.index.RandomIndexWriter;
-	using TermsEnum = org.apache.lucene.index.TermsEnum;
-	using BaseDirectoryWrapper = org.apache.lucene.store.BaseDirectoryWrapper;
-	using Directory = org.apache.lucene.store.Directory;
-	using LuceneTestCase = org.apache.lucene.util.LuceneTestCase;
-	using TestUtil = org.apache.lucene.util.TestUtil;
-
-	/// <summary>
-	/// Tests that pulsing codec reuses its enums and wrapped enums
-	/// </summary>
-	public class TestPulsingReuse : LuceneTestCase
-	{
-	  // TODO: this is a basic test. this thing is complicated, add more
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: public void testSophisticatedReuse() throws Exception
-	  public virtual void testSophisticatedReuse()
-	  {
-		// we always run this test with pulsing codec.
-		Codec cp = TestUtil.alwaysPostingsFormat(new Pulsing41PostingsFormat(1));
-		Directory dir = newDirectory();
-		RandomIndexWriter iw = new RandomIndexWriter(random(), dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).setCodec(cp));
-		Document doc = new Document();
-		doc.add(new TextField("foo", "a b b c c c d e f g g h i i j j k", Field.Store.NO));
-		iw.addDocument(doc);
-		DirectoryReader ir = iw.Reader;
-		iw.close();
-
-		AtomicReader segment = getOnlySegmentReader(ir);
-		DocsEnum reuse = null;
-		IDictionary<DocsEnum, bool?> allEnums = new IdentityHashMap<DocsEnum, bool?>();
-		TermsEnum te = segment.terms("foo").iterator(null);
-		while (te.next() != null)
-		{
-		  reuse = te.docs(null, reuse, DocsEnum.FLAG_NONE);
-		  allEnums[reuse] = true;
-		}
-
-		assertEquals(2, allEnums.Count);
-
-		allEnums.Clear();
-		DocsAndPositionsEnum posReuse = null;
-		te = segment.terms("foo").iterator(null);
-		while (te.next() != null)
-		{
-		  posReuse = te.docsAndPositions(null, posReuse);
-		  allEnums[posReuse] = true;
-		}
-
-		assertEquals(2, allEnums.Count);
-
-		ir.close();
-		dir.close();
-	  }
-
-	  /// <summary>
-	  /// tests reuse with Pulsing1(Pulsing2(Standard)) </summary>
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: public void testNestedPulsing() throws Exception
-	  public virtual void testNestedPulsing()
-	  {
-		// we always run this test with pulsing codec.
-		Codec cp = TestUtil.alwaysPostingsFormat(new NestedPulsingPostingsFormat());
-		BaseDirectoryWrapper dir = newDirectory();
-		RandomIndexWriter iw = new RandomIndexWriter(random(), dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).setCodec(cp));
-		Document doc = new Document();
-		doc.add(new TextField("foo", "a b b c c c d e f g g g h i i j j k l l m m m", Field.Store.NO));
-		// note: the reuse is imperfect, here we would have 4 enums (lost reuse when we get an enum for 'm')
-		// this is because we only track the 'last' enum we reused (not all).
-		// but this seems 'good enough' for now.
-		iw.addDocument(doc);
-		DirectoryReader ir = iw.Reader;
-		iw.close();
-
-		AtomicReader segment = getOnlySegmentReader(ir);
-		DocsEnum reuse = null;
-		IDictionary<DocsEnum, bool?> allEnums = new IdentityHashMap<DocsEnum, bool?>();
-		TermsEnum te = segment.terms("foo").iterator(null);
-		while (te.next() != null)
-		{
-		  reuse = te.docs(null, reuse, DocsEnum.FLAG_NONE);
-		  allEnums[reuse] = true;
-		}
-
-		assertEquals(4, allEnums.Count);
-
-		allEnums.Clear();
-		DocsAndPositionsEnum posReuse = null;
-		te = segment.terms("foo").iterator(null);
-		while (te.next() != null)
-		{
-		  posReuse = te.docsAndPositions(null, posReuse);
-		  allEnums[posReuse] = true;
-		}
-
-		assertEquals(4, allEnums.Count);
-
-		ir.close();
-		dir.close();
-	  }
-	}
-
+    /// <summary>
+    /// Tests that pulsing codec reuses its enums and wrapped enums
+    /// </summary>
+    public class TestPulsingReuse : LuceneTestCase
+    {
+        // TODO: this is a basic test. this thing is complicated, add more
+        [Test]
+        public virtual void TestSophisticatedReuse()
+        {
+            // we always run this test with pulsing codec.
+            Codec cp = TestUtil.AlwaysPostingsFormat(new Pulsing41PostingsFormat(1));
+            Directory dir = NewDirectory();
+            RandomIndexWriter iw = new RandomIndexWriter(Random(), dir, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())).SetCodec(cp));
+            Document doc = new Document();
+            doc.Add(new TextField("foo", "a b b c c c d e f g g h i i j j k", Field.Store.NO));
+            iw.AddDocument(doc);
+            DirectoryReader ir = iw.Reader;
+            iw.Dispose();
+
+            AtomicReader segment = GetOnlySegmentReader(ir);
+            DocsEnum reuse = null;
+            IDictionary<DocsEnum, bool?> allEnums = new IdentityHashMap<DocsEnum, bool?>();
+            TermsEnum te = segment.Terms("foo").Iterator(null);
+            while (te.Next() != null)
+            {
+                reuse = te.Docs(null, reuse, DocsEnum.FLAG_NONE);
+                allEnums[reuse] = true;
+            }
+
+            assertEquals(2, allEnums.Count);
+
+            allEnums.Clear();
+            DocsAndPositionsEnum posReuse = null;
+            te = segment.Terms("foo").Iterator(null);
+            while (te.Next() != null)
+            {
+                posReuse = te.DocsAndPositions(null, posReuse);
+                allEnums[posReuse] = true;
+            }
+
+            assertEquals(2, allEnums.Count);
+
+            ir.Dispose();
+            dir.Dispose();
+        }
+
+        /// <summary>
+        /// tests reuse with Pulsing1(Pulsing2(Standard)) </summary>
+        [Test]
+        public virtual void TestNestedPulsing()
+        {
+            // we always run this test with pulsing codec.
+            Codec cp = TestUtil.AlwaysPostingsFormat(new NestedPulsingPostingsFormat());
+            BaseDirectoryWrapper dir = NewDirectory();
+            RandomIndexWriter iw = new RandomIndexWriter(Random(), dir, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())).SetCodec(cp));
+            Document doc = new Document();
+            doc.Add(new TextField("foo", "a b b c c c d e f g g g h i i j j k l l m m m", Field.Store.NO));
+            // note: the reuse is imperfect, here we would have 4 enums (lost reuse when we get an enum for 'm')
+            // this is because we only track the 'last' enum we reused (not all).
+            // but this seems 'good enough' for now.
+            iw.AddDocument(doc);
+            DirectoryReader ir = iw.Reader;
+            iw.Dispose();
+
+            AtomicReader segment = GetOnlySegmentReader(ir);
+            DocsEnum reuse = null;
+            IDictionary<DocsEnum, bool?> allEnums = new IdentityHashMap<DocsEnum, bool?>();
+            TermsEnum te = segment.Terms("foo").Iterator(null);
+            while (te.Next() != null)
+            {
+                reuse = te.Docs(null, reuse, DocsEnum.FLAG_NONE);
+                allEnums[reuse] = true;
+            }
+
+            assertEquals(4, allEnums.Count);
+
+            allEnums.Clear();
+            DocsAndPositionsEnum posReuse = null;
+            te = segment.Terms("foo").Iterator(null);
+            while (te.Next() != null)
+            {
+                posReuse = te.DocsAndPositions(null, posReuse);
+                allEnums[posReuse] = true;
+            }
+
+            assertEquals(4, allEnums.Count);
+
+            ir.Dispose();
+            dir.Dispose();
+        }
+    }
 }
\ No newline at end of file