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 2017/02/26 23:37:34 UTC

[46/72] [abbrv] [partial] lucenenet git commit: Lucene.Net.Tests: Removed \core directory and put its contents in root directory

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/96822396/src/Lucene.Net.Tests/Codecs/Lucene45/TestLucene45DocValuesFormat.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/Codecs/Lucene45/TestLucene45DocValuesFormat.cs b/src/Lucene.Net.Tests/Codecs/Lucene45/TestLucene45DocValuesFormat.cs
new file mode 100644
index 0000000..dc18580
--- /dev/null
+++ b/src/Lucene.Net.Tests/Codecs/Lucene45/TestLucene45DocValuesFormat.cs
@@ -0,0 +1,565 @@
+using NUnit.Framework;
+
+namespace Lucene.Net.Codecs.Lucene45
+{
+    /*
+         * 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 BaseCompressingDocValuesFormatTestCase = Lucene.Net.Index.BaseCompressingDocValuesFormatTestCase;
+    using TestUtil = Lucene.Net.Util.TestUtil;
+
+    /// <summary>
+    /// Tests Lucene45DocValuesFormat
+    /// </summary>
+    public class TestLucene45DocValuesFormat : BaseCompressingDocValuesFormatTestCase
+    {
+        private readonly Codec Codec_Renamed = TestUtil.AlwaysDocValuesFormat(new Lucene45DocValuesFormat());
+
+        protected override Codec Codec
+        {
+            get
+            {
+                return Codec_Renamed;
+            }
+        }
+
+        #region BaseCompressingDocValuesFormatTestCase
+        // LUCENENET NOTE: Tests in an abstract base class are not pulled into the correct
+        // context in Visual Studio. This fixes that with the minimum amount of code necessary
+        // to run them in the correct context without duplicating all of the tests.
+
+        [Test]
+        public override void TestUniqueValuesCompression()
+        {
+            base.TestUniqueValuesCompression();
+        }
+
+        [Test]
+        public override void TestDateCompression()
+        {
+            base.TestDateCompression();
+        }
+
+        [Test]
+        public override void TestSingleBigValueCompression()
+        {
+            base.TestSingleBigValueCompression();
+        }
+
+        #endregion
+
+        #region BaseDocValuesFormatTestCase
+        // LUCENENET NOTE: Tests in an abstract base class are not pulled into the correct
+        // context in Visual Studio. This fixes that with the minimum amount of code necessary
+        // to run them in the correct context without duplicating all of the tests.
+
+        [Test]
+        public override void TestOneNumber()
+        {
+            base.TestOneNumber();
+        }
+
+        [Test]
+        public override void TestOneFloat()
+        {
+            base.TestOneFloat();
+        }
+
+        [Test]
+        public override void TestTwoNumbers()
+        {
+            base.TestTwoNumbers();
+        }
+
+        [Test]
+        public override void TestTwoBinaryValues()
+        {
+            base.TestTwoBinaryValues();
+        }
+
+        [Test]
+        public override void TestTwoFieldsMixed()
+        {
+            base.TestTwoFieldsMixed();
+        }
+
+        [Test]
+        public override void TestThreeFieldsMixed()
+        {
+            base.TestThreeFieldsMixed();
+        }
+
+        [Test]
+        public override void TestThreeFieldsMixed2()
+        {
+            base.TestThreeFieldsMixed2();
+        }
+
+        [Test]
+        public override void TestTwoDocumentsNumeric()
+        {
+            base.TestTwoDocumentsNumeric();
+        }
+
+        [Test]
+        public override void TestTwoDocumentsMerged()
+        {
+            base.TestTwoDocumentsMerged();
+        }
+
+        [Test]
+        public override void TestBigNumericRange()
+        {
+            base.TestBigNumericRange();
+        }
+
+        [Test]
+        public override void TestBigNumericRange2()
+        {
+            base.TestBigNumericRange2();
+        }
+
+        [Test]
+        public override void TestBytes()
+        {
+            base.TestBytes();
+        }
+
+        [Test]
+        public override void TestBytesTwoDocumentsMerged()
+        {
+            base.TestBytesTwoDocumentsMerged();
+        }
+
+        [Test]
+        public override void TestSortedBytes()
+        {
+            base.TestSortedBytes();
+        }
+
+        [Test]
+        public override void TestSortedBytesTwoDocuments()
+        {
+            base.TestSortedBytesTwoDocuments();
+        }
+
+        [Test]
+        public override void TestSortedBytesThreeDocuments()
+        {
+            base.TestSortedBytesThreeDocuments();
+        }
+
+        [Test]
+        public override void TestSortedBytesTwoDocumentsMerged()
+        {
+            base.TestSortedBytesTwoDocumentsMerged();
+        }
+
+        [Test]
+        public override void TestSortedMergeAwayAllValues()
+        {
+            base.TestSortedMergeAwayAllValues();
+        }
+
+        [Test]
+        public override void TestBytesWithNewline()
+        {
+            base.TestBytesWithNewline();
+        }
+
+        [Test]
+        public override void TestMissingSortedBytes()
+        {
+            base.TestMissingSortedBytes();
+        }
+
+        [Test]
+        public override void TestSortedTermsEnum()
+        {
+            base.TestSortedTermsEnum();
+        }
+
+        [Test]
+        public override void TestEmptySortedBytes()
+        {
+            base.TestEmptySortedBytes();
+        }
+
+        [Test]
+        public override void TestEmptyBytes()
+        {
+            base.TestEmptyBytes();
+        }
+
+        [Test]
+        public override void TestVeryLargeButLegalBytes()
+        {
+            base.TestVeryLargeButLegalBytes();
+        }
+
+        [Test]
+        public override void TestVeryLargeButLegalSortedBytes()
+        {
+            base.TestVeryLargeButLegalSortedBytes();
+        }
+
+        [Test]
+        public override void TestCodecUsesOwnBytes()
+        {
+            base.TestCodecUsesOwnBytes();
+        }
+
+        [Test]
+        public override void TestCodecUsesOwnSortedBytes()
+        {
+            base.TestCodecUsesOwnSortedBytes();
+        }
+
+        [Test]
+        public override void TestCodecUsesOwnBytesEachTime()
+        {
+            base.TestCodecUsesOwnBytesEachTime();
+        }
+
+        [Test]
+        public override void TestCodecUsesOwnSortedBytesEachTime()
+        {
+            base.TestCodecUsesOwnSortedBytesEachTime();
+        }
+
+        /*
+         * Simple test case to show how to use the API
+         */
+        [Test]
+        public override void TestDocValuesSimple()
+        {
+            base.TestDocValuesSimple();
+        }
+
+        [Test]
+        public override void TestRandomSortedBytes()
+        {
+            base.TestRandomSortedBytes();
+        }
+
+        [Test]
+        public override void TestBooleanNumericsVsStoredFields()
+        {
+            base.TestBooleanNumericsVsStoredFields();
+        }
+
+        [Test]
+        public override void TestByteNumericsVsStoredFields()
+        {
+            base.TestByteNumericsVsStoredFields();
+        }
+
+        [Test]
+        public override void TestByteMissingVsFieldCache()
+        {
+            base.TestByteMissingVsFieldCache();
+        }
+
+        [Test]
+        public override void TestShortNumericsVsStoredFields()
+        {
+            base.TestShortNumericsVsStoredFields();
+        }
+
+        [Test]
+        public override void TestShortMissingVsFieldCache()
+        {
+            base.TestShortMissingVsFieldCache();
+        }
+
+        [Test]
+        public override void TestIntNumericsVsStoredFields()
+        {
+            base.TestIntNumericsVsStoredFields();
+        }
+
+        [Test]
+        public override void TestIntMissingVsFieldCache()
+        {
+            base.TestIntMissingVsFieldCache();
+        }
+
+        [Test]
+        public override void TestLongNumericsVsStoredFields()
+        {
+            base.TestLongNumericsVsStoredFields();
+        }
+
+        [Test]
+        public override void TestLongMissingVsFieldCache()
+        {
+            base.TestLongMissingVsFieldCache();
+        }
+
+        [Test]
+        public override void TestBinaryFixedLengthVsStoredFields()
+        {
+            base.TestBinaryFixedLengthVsStoredFields();
+        }
+
+        [Test]
+        public override void TestBinaryVariableLengthVsStoredFields()
+        {
+            base.TestBinaryVariableLengthVsStoredFields();
+        }
+
+        [Test]
+        public override void TestSortedFixedLengthVsStoredFields()
+        {
+            base.TestSortedFixedLengthVsStoredFields();
+        }
+
+        [Test]
+        public override void TestSortedFixedLengthVsFieldCache()
+        {
+            base.TestSortedFixedLengthVsFieldCache();
+        }
+
+        [Test]
+        public override void TestSortedVariableLengthVsFieldCache()
+        {
+            base.TestSortedVariableLengthVsFieldCache();
+        }
+
+        [Test]
+        public override void TestSortedVariableLengthVsStoredFields()
+        {
+            base.TestSortedVariableLengthVsStoredFields();
+        }
+
+        [Test]
+        public override void TestSortedSetOneValue()
+        {
+            base.TestSortedSetOneValue();
+        }
+
+        [Test]
+        public override void TestSortedSetTwoFields()
+        {
+            base.TestSortedSetTwoFields();
+        }
+
+        [Test]
+        public override void TestSortedSetTwoDocumentsMerged()
+        {
+            base.TestSortedSetTwoDocumentsMerged();
+        }
+
+        [Test]
+        public override void TestSortedSetTwoValues()
+        {
+            base.TestSortedSetTwoValues();
+        }
+
+        [Test]
+        public override void TestSortedSetTwoValuesUnordered()
+        {
+            base.TestSortedSetTwoValuesUnordered();
+        }
+
+        [Test]
+        public override void TestSortedSetThreeValuesTwoDocs()
+        {
+            base.TestSortedSetThreeValuesTwoDocs();
+        }
+
+        [Test]
+        public override void TestSortedSetTwoDocumentsLastMissing()
+        {
+            base.TestSortedSetTwoDocumentsLastMissing();
+        }
+
+        [Test]
+        public override void TestSortedSetTwoDocumentsLastMissingMerge()
+        {
+            base.TestSortedSetTwoDocumentsLastMissingMerge();
+        }
+
+        [Test]
+        public override void TestSortedSetTwoDocumentsFirstMissing()
+        {
+            base.TestSortedSetTwoDocumentsFirstMissing();
+        }
+
+        [Test]
+        public override void TestSortedSetTwoDocumentsFirstMissingMerge()
+        {
+            base.TestSortedSetTwoDocumentsFirstMissingMerge();
+        }
+
+        [Test]
+        public override void TestSortedSetMergeAwayAllValues()
+        {
+            base.TestSortedSetMergeAwayAllValues();
+        }
+
+        [Test]
+        public override void TestSortedSetTermsEnum()
+        {
+            base.TestSortedSetTermsEnum();
+        }
+
+        [Test]
+        public override void TestSortedSetFixedLengthVsStoredFields()
+        {
+            base.TestSortedSetFixedLengthVsStoredFields();
+        }
+
+        [Test]
+        public override void TestSortedSetVariableLengthVsStoredFields()
+        {
+            base.TestSortedSetVariableLengthVsStoredFields();
+        }
+
+        [Test]
+        public override void TestSortedSetFixedLengthSingleValuedVsStoredFields()
+        {
+            base.TestSortedSetFixedLengthSingleValuedVsStoredFields();
+        }
+
+        [Test]
+        public override void TestSortedSetVariableLengthSingleValuedVsStoredFields()
+        {
+            base.TestSortedSetVariableLengthSingleValuedVsStoredFields();
+        }
+
+        [Test]
+        public override void TestSortedSetFixedLengthVsUninvertedField()
+        {
+            base.TestSortedSetFixedLengthVsUninvertedField();
+        }
+
+        [Test]
+        public override void TestSortedSetVariableLengthVsUninvertedField()
+        {
+            base.TestSortedSetVariableLengthVsUninvertedField();
+        }
+
+        [Test]
+        public override void TestGCDCompression()
+        {
+            base.TestGCDCompression();
+        }
+
+        [Test]
+        public override void TestZeros()
+        {
+            base.TestZeros();
+        }
+
+        [Test]
+        public override void TestZeroOrMin()
+        {
+            base.TestZeroOrMin();
+        }
+
+        [Test]
+        public override void TestTwoNumbersOneMissing()
+        {
+            base.TestTwoNumbersOneMissing();
+        }
+
+        [Test]
+        public override void TestTwoNumbersOneMissingWithMerging()
+        {
+            base.TestTwoNumbersOneMissingWithMerging();
+        }
+
+        [Test]
+        public override void TestThreeNumbersOneMissingWithMerging()
+        {
+            base.TestThreeNumbersOneMissingWithMerging();
+        }
+
+        [Test]
+        public override void TestTwoBytesOneMissing()
+        {
+            base.TestTwoBytesOneMissing();
+        }
+
+        [Test]
+        public override void TestTwoBytesOneMissingWithMerging()
+        {
+            base.TestTwoBytesOneMissingWithMerging();
+        }
+
+        [Test]
+        public override void TestThreeBytesOneMissingWithMerging()
+        {
+            base.TestThreeBytesOneMissingWithMerging();
+        }
+
+        // LUCENE-4853
+        [Test]
+        public override void TestHugeBinaryValues()
+        {
+            base.TestHugeBinaryValues();
+        }
+
+        // TODO: get this out of here and into the deprecated codecs (4.0, 4.2)
+        [Test]
+        public override void TestHugeBinaryValueLimit()
+        {
+            base.TestHugeBinaryValueLimit();
+        }
+
+        /// <summary>
+        /// Tests dv against stored fields with threads (binary/numeric/sorted, no missing)
+        /// </summary>
+        [Test]
+        public override void TestThreads()
+        {
+            base.TestThreads();
+        }
+
+        /// <summary>
+        /// Tests dv against stored fields with threads (all types + missing)
+        /// </summary>
+        [Test]
+        public override void TestThreads2()
+        {
+            base.TestThreads2();
+        }
+
+        // LUCENE-5218
+        [Test]
+        public override void TestEmptyBinaryValueOnPageSizes()
+        {
+            base.TestEmptyBinaryValueOnPageSizes();
+        }
+
+        #endregion
+
+        #region BaseIndexFileFormatTestCase
+        // LUCENENET NOTE: Tests in an abstract base class are not pulled into the correct
+        // context in Visual Studio. This fixes that with the minimum amount of code necessary
+        // to run them in the correct context without duplicating all of the tests.
+
+        [Test]
+        public override void TestMergeStability()
+        {
+            base.TestMergeStability();
+        }
+
+        #endregion
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/96822396/src/Lucene.Net.Tests/Codecs/PerField/TestPerFieldDocValuesFormat.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/Codecs/PerField/TestPerFieldDocValuesFormat.cs b/src/Lucene.Net.Tests/Codecs/PerField/TestPerFieldDocValuesFormat.cs
new file mode 100644
index 0000000..ddb4527
--- /dev/null
+++ b/src/Lucene.Net.Tests/Codecs/PerField/TestPerFieldDocValuesFormat.cs
@@ -0,0 +1,658 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using Lucene.Net.Documents;
+
+namespace Lucene.Net.Codecs.PerField
+{
+    using Lucene.Net.Index;
+    using NUnit.Framework;
+
+    /*
+         * 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 Analyzer = Lucene.Net.Analysis.Analyzer;
+    using BaseDocValuesFormatTestCase = Lucene.Net.Index.BaseDocValuesFormatTestCase;
+    using BinaryDocValues = Lucene.Net.Index.BinaryDocValues;
+    using BinaryDocValuesField = BinaryDocValuesField;
+    using BytesRef = Lucene.Net.Util.BytesRef;
+    using Directory = Lucene.Net.Store.Directory;
+    using DirectoryReader = Lucene.Net.Index.DirectoryReader;
+    using Document = Documents.Document;
+    using Field = Field;
+    using IndexReader = Lucene.Net.Index.IndexReader;
+    using IndexSearcher = Lucene.Net.Search.IndexSearcher;
+    using IndexWriter = Lucene.Net.Index.IndexWriter;
+    using IndexWriterConfig = Lucene.Net.Index.IndexWriterConfig;
+    using Lucene46Codec = Lucene.Net.Codecs.Lucene46.Lucene46Codec;
+    using MockAnalyzer = Lucene.Net.Analysis.MockAnalyzer;
+    using NumericDocValues = Lucene.Net.Index.NumericDocValues;
+    using NumericDocValuesField = NumericDocValuesField;
+    using Query = Lucene.Net.Search.Query;
+    using RandomCodec = Lucene.Net.Index.RandomCodec;
+    using Term = Lucene.Net.Index.Term;
+    using TermQuery = Lucene.Net.Search.TermQuery;
+    using TestUtil = Lucene.Net.Util.TestUtil;
+    using TopDocs = Lucene.Net.Search.TopDocs;
+
+    /// <summary>
+    /// Basic tests of PerFieldDocValuesFormat
+    /// </summary>
+    [TestFixture]
+    public class TestPerFieldDocValuesFormat : BaseDocValuesFormatTestCase
+    {
+        private Codec Codec_Renamed;
+
+        [SetUp]
+        public override void SetUp()
+        {
+            Codec_Renamed = new RandomCodec(new Random(Random().Next()), new HashSet<string>());
+            base.SetUp();
+        }
+
+        protected override Codec Codec
+        {
+            get
+            {
+                return Codec_Renamed;
+            }
+        }
+
+        protected internal override bool CodecAcceptsHugeBinaryValues(string field)
+        {
+            return TestUtil.FieldSupportsHugeBinaryDocValues(field);
+        }
+
+        // just a simple trivial test
+        // TODO: we should come up with a test that somehow checks that segment suffix
+        // is respected by all codec apis (not just docvalues and postings)
+        [Test]
+        public virtual void TestTwoFieldsTwoFormats()
+        {
+            Analyzer analyzer = new MockAnalyzer(Random());
+
+            Directory directory = NewDirectory();
+            // we don't use RandomIndexWriter because it might add more docvalues than we expect !!!!1
+            IndexWriterConfig iwc = NewIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
+            DocValuesFormat fast = DocValuesFormat.ForName("Lucene45");
+            DocValuesFormat slow = DocValuesFormat.ForName("Lucene45");
+            iwc.SetCodec(new Lucene46CodecAnonymousInnerClassHelper(this, fast, slow));
+            IndexWriter iwriter = new IndexWriter(directory, iwc);
+            Document doc = new Document();
+            string longTerm = "longtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongterm";
+            string text = "this is the text to be indexed. " + longTerm;
+            doc.Add(NewTextField("fieldname", text, Field.Store.YES));
+            doc.Add(new NumericDocValuesField("dv1", 5));
+            doc.Add(new BinaryDocValuesField("dv2", new BytesRef("hello world")));
+            iwriter.AddDocument(doc);
+            iwriter.Dispose();
+
+            // Now search the index:
+            IndexReader ireader = DirectoryReader.Open(directory); // read-only=true
+            IndexSearcher isearcher = NewSearcher(ireader);
+
+            Assert.AreEqual(1, isearcher.Search(new TermQuery(new Term("fieldname", longTerm)), 1).TotalHits);
+            Query query = new TermQuery(new Term("fieldname", "text"));
+            TopDocs hits = isearcher.Search(query, null, 1);
+            Assert.AreEqual(1, hits.TotalHits);
+            BytesRef scratch = new BytesRef();
+            // Iterate through the results:
+            for (int i = 0; i < hits.ScoreDocs.Length; i++)
+            {
+                Document hitDoc = isearcher.Doc(hits.ScoreDocs[i].Doc);
+                Assert.AreEqual(text, hitDoc.Get("fieldname"));
+                Debug.Assert(ireader.Leaves.Count == 1);
+                NumericDocValues dv = ((AtomicReader)ireader.Leaves[0].Reader).GetNumericDocValues("dv1");
+                Assert.AreEqual(5, dv.Get(hits.ScoreDocs[i].Doc));
+                BinaryDocValues dv2 = ((AtomicReader)ireader.Leaves[0].Reader).GetBinaryDocValues("dv2");
+                dv2.Get(hits.ScoreDocs[i].Doc, scratch);
+                Assert.AreEqual(new BytesRef("hello world"), scratch);
+            }
+
+            ireader.Dispose();
+            directory.Dispose();
+        }
+
+        private class Lucene46CodecAnonymousInnerClassHelper : Lucene46Codec
+        {
+            private readonly TestPerFieldDocValuesFormat OuterInstance;
+
+            private DocValuesFormat Fast;
+            private DocValuesFormat Slow;
+
+            public Lucene46CodecAnonymousInnerClassHelper(TestPerFieldDocValuesFormat outerInstance, DocValuesFormat fast, DocValuesFormat slow)
+            {
+                this.OuterInstance = outerInstance;
+                this.Fast = fast;
+                this.Slow = slow;
+            }
+
+            public override DocValuesFormat GetDocValuesFormatForField(string field)
+            {
+                if ("dv1".Equals(field))
+                {
+                    return Fast;
+                }
+                else
+                {
+                    return Slow;
+                }
+            }
+        }
+
+
+        #region BaseDocValuesFormatTestCase
+        // LUCENENET NOTE: Tests in an abstract base class are not pulled into the correct
+        // context in Visual Studio. This fixes that with the minimum amount of code necessary
+        // to run them in the correct context without duplicating all of the tests.
+
+        [Test]
+        public override void TestOneNumber()
+        {
+            base.TestOneNumber();
+        }
+
+        [Test]
+        public override void TestOneFloat()
+        {
+            base.TestOneFloat();
+        }
+
+        [Test]
+        public override void TestTwoNumbers()
+        {
+            base.TestTwoNumbers();
+        }
+
+        [Test]
+        public override void TestTwoBinaryValues()
+        {
+            base.TestTwoBinaryValues();
+        }
+
+        [Test]
+        public override void TestTwoFieldsMixed()
+        {
+            base.TestTwoFieldsMixed();
+        }
+
+        [Test]
+        public override void TestThreeFieldsMixed()
+        {
+            base.TestThreeFieldsMixed();
+        }
+
+        [Test]
+        public override void TestThreeFieldsMixed2()
+        {
+            base.TestThreeFieldsMixed2();
+        }
+
+        [Test]
+        public override void TestTwoDocumentsNumeric()
+        {
+            base.TestTwoDocumentsNumeric();
+        }
+
+        [Test]
+        public override void TestTwoDocumentsMerged()
+        {
+            base.TestTwoDocumentsMerged();
+        }
+
+        [Test]
+        public override void TestBigNumericRange()
+        {
+            base.TestBigNumericRange();
+        }
+
+        [Test]
+        public override void TestBigNumericRange2()
+        {
+            base.TestBigNumericRange2();
+        }
+
+        [Test]
+        public override void TestBytes()
+        {
+            base.TestBytes();
+        }
+
+        [Test]
+        public override void TestBytesTwoDocumentsMerged()
+        {
+            base.TestBytesTwoDocumentsMerged();
+        }
+
+        [Test]
+        public override void TestSortedBytes()
+        {
+            base.TestSortedBytes();
+        }
+
+        [Test]
+        public override void TestSortedBytesTwoDocuments()
+        {
+            base.TestSortedBytesTwoDocuments();
+        }
+
+        [Test]
+        public override void TestSortedBytesThreeDocuments()
+        {
+            base.TestSortedBytesThreeDocuments();
+        }
+
+        [Test]
+        public override void TestSortedBytesTwoDocumentsMerged()
+        {
+            base.TestSortedBytesTwoDocumentsMerged();
+        }
+
+        [Test]
+        public override void TestSortedMergeAwayAllValues()
+        {
+            base.TestSortedMergeAwayAllValues();
+        }
+
+        [Test]
+        public override void TestBytesWithNewline()
+        {
+            base.TestBytesWithNewline();
+        }
+
+        [Test]
+        public override void TestMissingSortedBytes()
+        {
+            base.TestMissingSortedBytes();
+        }
+
+        [Test]
+        public override void TestSortedTermsEnum()
+        {
+            base.TestSortedTermsEnum();
+        }
+
+        [Test]
+        public override void TestEmptySortedBytes()
+        {
+            base.TestEmptySortedBytes();
+        }
+
+        [Test]
+        public override void TestEmptyBytes()
+        {
+            base.TestEmptyBytes();
+        }
+
+        [Test]
+        public override void TestVeryLargeButLegalBytes()
+        {
+            base.TestVeryLargeButLegalBytes();
+        }
+
+        [Test]
+        public override void TestVeryLargeButLegalSortedBytes()
+        {
+            base.TestVeryLargeButLegalSortedBytes();
+        }
+
+        [Test]
+        public override void TestCodecUsesOwnBytes()
+        {
+            base.TestCodecUsesOwnBytes();
+        }
+
+        [Test]
+        public override void TestCodecUsesOwnSortedBytes()
+        {
+            base.TestCodecUsesOwnSortedBytes();
+        }
+
+        [Test]
+        public override void TestCodecUsesOwnBytesEachTime()
+        {
+            base.TestCodecUsesOwnBytesEachTime();
+        }
+
+        [Test]
+        public override void TestCodecUsesOwnSortedBytesEachTime()
+        {
+            base.TestCodecUsesOwnSortedBytesEachTime();
+        }
+
+        /*
+         * Simple test case to show how to use the API
+         */
+        [Test]
+        public override void TestDocValuesSimple()
+        {
+            base.TestDocValuesSimple();
+        }
+
+        [Test]
+        public override void TestRandomSortedBytes()
+        {
+            base.TestRandomSortedBytes();
+        }
+
+        [Test]
+        public override void TestBooleanNumericsVsStoredFields()
+        {
+            base.TestBooleanNumericsVsStoredFields();
+        }
+
+        [Test]
+        public override void TestByteNumericsVsStoredFields()
+        {
+            base.TestByteNumericsVsStoredFields();
+        }
+
+        [Test]
+        public override void TestByteMissingVsFieldCache()
+        {
+            base.TestByteMissingVsFieldCache();
+        }
+
+        [Test]
+        public override void TestShortNumericsVsStoredFields()
+        {
+            base.TestShortNumericsVsStoredFields();
+        }
+
+        [Test]
+        public override void TestShortMissingVsFieldCache()
+        {
+            base.TestShortMissingVsFieldCache();
+        }
+
+        [Test]
+        public override void TestIntNumericsVsStoredFields()
+        {
+            base.TestIntNumericsVsStoredFields();
+        }
+
+        [Test]
+        public override void TestIntMissingVsFieldCache()
+        {
+            base.TestIntMissingVsFieldCache();
+        }
+
+        [Test]
+        public override void TestLongNumericsVsStoredFields()
+        {
+            base.TestLongNumericsVsStoredFields();
+        }
+
+        [Test]
+        public override void TestLongMissingVsFieldCache()
+        {
+            base.TestLongMissingVsFieldCache();
+        }
+
+        [Test]
+        public override void TestBinaryFixedLengthVsStoredFields()
+        {
+            base.TestBinaryFixedLengthVsStoredFields();
+        }
+
+        [Test]
+        public override void TestBinaryVariableLengthVsStoredFields()
+        {
+            base.TestBinaryVariableLengthVsStoredFields();
+        }
+
+        [Test]
+        public override void TestSortedFixedLengthVsStoredFields()
+        {
+            base.TestSortedFixedLengthVsStoredFields();
+        }
+
+        [Test]
+        public override void TestSortedFixedLengthVsFieldCache()
+        {
+            base.TestSortedFixedLengthVsFieldCache();
+        }
+
+        [Test]
+        public override void TestSortedVariableLengthVsFieldCache()
+        {
+            base.TestSortedVariableLengthVsFieldCache();
+        }
+
+        [Test]
+        public override void TestSortedVariableLengthVsStoredFields()
+        {
+            base.TestSortedVariableLengthVsStoredFields();
+        }
+
+        [Test]
+        public override void TestSortedSetOneValue()
+        {
+            base.TestSortedSetOneValue();
+        }
+
+        [Test]
+        public override void TestSortedSetTwoFields()
+        {
+            base.TestSortedSetTwoFields();
+        }
+
+        [Test]
+        public override void TestSortedSetTwoDocumentsMerged()
+        {
+            base.TestSortedSetTwoDocumentsMerged();
+        }
+
+        [Test]
+        public override void TestSortedSetTwoValues()
+        {
+            base.TestSortedSetTwoValues();
+        }
+
+        [Test]
+        public override void TestSortedSetTwoValuesUnordered()
+        {
+            base.TestSortedSetTwoValuesUnordered();
+        }
+
+        [Test]
+        public override void TestSortedSetThreeValuesTwoDocs()
+        {
+            base.TestSortedSetThreeValuesTwoDocs();
+        }
+
+        [Test]
+        public override void TestSortedSetTwoDocumentsLastMissing()
+        {
+            base.TestSortedSetTwoDocumentsLastMissing();
+        }
+
+        [Test]
+        public override void TestSortedSetTwoDocumentsLastMissingMerge()
+        {
+            base.TestSortedSetTwoDocumentsLastMissingMerge();
+        }
+
+        [Test]
+        public override void TestSortedSetTwoDocumentsFirstMissing()
+        {
+            base.TestSortedSetTwoDocumentsFirstMissing();
+        }
+
+        [Test]
+        public override void TestSortedSetTwoDocumentsFirstMissingMerge()
+        {
+            base.TestSortedSetTwoDocumentsFirstMissingMerge();
+        }
+
+        [Test]
+        public override void TestSortedSetMergeAwayAllValues()
+        {
+            base.TestSortedSetMergeAwayAllValues();
+        }
+
+        [Test]
+        public override void TestSortedSetTermsEnum()
+        {
+            base.TestSortedSetTermsEnum();
+        }
+
+        [Test]
+        public override void TestSortedSetFixedLengthVsStoredFields()
+        {
+            base.TestSortedSetFixedLengthVsStoredFields();
+        }
+
+        [Test]
+        public override void TestSortedSetVariableLengthVsStoredFields()
+        {
+            base.TestSortedSetVariableLengthVsStoredFields();
+        }
+
+        [Test]
+        public override void TestSortedSetFixedLengthSingleValuedVsStoredFields()
+        {
+            base.TestSortedSetFixedLengthSingleValuedVsStoredFields();
+        }
+
+        [Test]
+        public override void TestSortedSetVariableLengthSingleValuedVsStoredFields()
+        {
+            base.TestSortedSetVariableLengthSingleValuedVsStoredFields();
+        }
+
+        [Test]
+        public override void TestSortedSetFixedLengthVsUninvertedField()
+        {
+            base.TestSortedSetFixedLengthVsUninvertedField();
+        }
+
+        [Test]
+        public override void TestSortedSetVariableLengthVsUninvertedField()
+        {
+            base.TestSortedSetVariableLengthVsUninvertedField();
+        }
+
+        [Test]
+        public override void TestGCDCompression()
+        {
+            base.TestGCDCompression();
+        }
+
+        [Test]
+        public override void TestZeros()
+        {
+            base.TestZeros();
+        }
+
+        [Test]
+        public override void TestZeroOrMin()
+        {
+            base.TestZeroOrMin();
+        }
+
+        [Test]
+        public override void TestTwoNumbersOneMissing()
+        {
+            base.TestTwoNumbersOneMissing();
+        }
+
+        [Test]
+        public override void TestTwoNumbersOneMissingWithMerging()
+        {
+            base.TestTwoNumbersOneMissingWithMerging();
+        }
+
+        [Test]
+        public override void TestThreeNumbersOneMissingWithMerging()
+        {
+            base.TestThreeNumbersOneMissingWithMerging();
+        }
+
+        [Test]
+        public override void TestTwoBytesOneMissing()
+        {
+            base.TestTwoBytesOneMissing();
+        }
+
+        [Test]
+        public override void TestTwoBytesOneMissingWithMerging()
+        {
+            base.TestTwoBytesOneMissingWithMerging();
+        }
+
+        [Test]
+        public override void TestThreeBytesOneMissingWithMerging()
+        {
+            base.TestThreeBytesOneMissingWithMerging();
+        }
+
+        // LUCENE-4853
+        [Test]
+        public override void TestHugeBinaryValues()
+        {
+            base.TestHugeBinaryValues();
+        }
+
+        // TODO: get this out of here and into the deprecated codecs (4.0, 4.2)
+        [Test]
+        public override void TestHugeBinaryValueLimit()
+        {
+            base.TestHugeBinaryValueLimit();
+        }
+
+        /// <summary>
+        /// Tests dv against stored fields with threads (binary/numeric/sorted, no missing)
+        /// </summary>
+        [Test]
+        public override void TestThreads()
+        {
+            base.TestThreads();
+        }
+
+        /// <summary>
+        /// Tests dv against stored fields with threads (all types + missing)
+        /// </summary>
+        [Test]
+        public override void TestThreads2()
+        {
+            base.TestThreads2();
+        }
+
+        // LUCENE-5218
+        [Test]
+        public override void TestEmptyBinaryValueOnPageSizes()
+        {
+            base.TestEmptyBinaryValueOnPageSizes();
+        }
+
+        #endregion
+
+        #region BaseIndexFileFormatTestCase
+        // LUCENENET NOTE: Tests in an abstract base class are not pulled into the correct
+        // context in Visual Studio. This fixes that with the minimum amount of code necessary
+        // to run them in the correct context without duplicating all of the tests.
+
+        [Test]
+        public override void TestMergeStability()
+        {
+            base.TestMergeStability();
+        }
+
+        #endregion
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/96822396/src/Lucene.Net.Tests/Codecs/PerField/TestPerFieldPostingsFormat.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/Codecs/PerField/TestPerFieldPostingsFormat.cs b/src/Lucene.Net.Tests/Codecs/PerField/TestPerFieldPostingsFormat.cs
new file mode 100644
index 0000000..a6d5dd2
--- /dev/null
+++ b/src/Lucene.Net.Tests/Codecs/PerField/TestPerFieldPostingsFormat.cs
@@ -0,0 +1,100 @@
+using System;
+using System.Collections.Generic;
+
+namespace Lucene.Net.Codecs.PerField
+{
+    using NUnit.Framework;
+
+    /*
+             * 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 BasePostingsFormatTestCase = Lucene.Net.Index.BasePostingsFormatTestCase;
+    using RandomCodec = Lucene.Net.Index.RandomCodec;
+
+    /// <summary>
+    /// Basic tests of PerFieldPostingsFormat
+    /// </summary>
+    [TestFixture]
+    public class TestPerFieldPostingsFormat : BasePostingsFormatTestCase
+    {
+        protected override Codec Codec
+        {
+            get
+            {
+                return new RandomCodec(new Random(Random().Next()), new HashSet<string>());
+            }
+        }
+
+        [Test]
+        public override void TestMergeStability()
+        {
+            //LUCENE TO-DO
+            AssumeTrue("The MockRandom PF randomizes content on the fly, so we can't check it", false);
+        }
+
+
+        #region BasePostingsFormatTestCase
+        // LUCENENET NOTE: Tests in an abstract base class are not pulled into the correct
+        // context in Visual Studio. This fixes that with the minimum amount of code necessary
+        // to run them in the correct context without duplicating all of the tests.
+
+        [Test]
+        public override void TestDocsOnly()
+        {
+            base.TestDocsOnly();
+        }
+
+        [Test]
+        public override void TestDocsAndFreqs()
+        {
+            base.TestDocsAndFreqs();
+        }
+
+        [Test]
+        public override void TestDocsAndFreqsAndPositions()
+        {
+            base.TestDocsAndFreqsAndPositions();
+        }
+
+        [Test]
+        public override void TestDocsAndFreqsAndPositionsAndPayloads()
+        {
+            base.TestDocsAndFreqsAndPositionsAndPayloads();
+        }
+
+        [Test]
+        public override void TestDocsAndFreqsAndPositionsAndOffsets()
+        {
+            base.TestDocsAndFreqsAndPositionsAndOffsets();
+        }
+
+        [Test]
+        public override void TestDocsAndFreqsAndPositionsAndOffsetsAndPayloads()
+        {
+            base.TestDocsAndFreqsAndPositionsAndOffsetsAndPayloads();
+        }
+
+        [Test]
+        public override void TestRandom()
+        {
+            base.TestRandom();
+        }
+
+        #endregion
+
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/96822396/src/Lucene.Net.Tests/Codecs/PerField/TestPerFieldPostingsFormat2.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/Codecs/PerField/TestPerFieldPostingsFormat2.cs b/src/Lucene.Net.Tests/Codecs/PerField/TestPerFieldPostingsFormat2.cs
new file mode 100644
index 0000000..f758532
--- /dev/null
+++ b/src/Lucene.Net.Tests/Codecs/PerField/TestPerFieldPostingsFormat2.cs
@@ -0,0 +1,372 @@
+using System;
+using Lucene.Net.Documents;
+using Lucene.Net.Codecs.Lucene41;
+using Lucene.Net.Codecs.Lucene46;
+using Lucene.Net.Codecs.SimpleText;
+using Lucene.Net.Codecs.Pulsing;
+using Lucene.Net.Codecs.MockSep;
+using Lucene.Net.Util;
+using Lucene.Net.Index;
+using Lucene.Net.Search;
+using Lucene.Net.Analysis;
+using Lucene.Net.Randomized.Generators;
+using NUnit.Framework;
+using Lucene.Net.Store;
+
+namespace Lucene.Net.Codecs.PerField
+{
+    /*
+    * 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 Document = Documents.Document;
+
+    //TODO: would be better in this test to pull termsenums and instanceof or something?
+    // this way we can verify PFPF is doing the right thing.
+    // for now we do termqueries.
+    [TestFixture]
+    public class TestPerFieldPostingsFormat2 : LuceneTestCase
+    {
+        private IndexWriter NewWriter(Directory dir, IndexWriterConfig conf)
+        {
+            LogDocMergePolicy logByteSizeMergePolicy = new LogDocMergePolicy();
+            logByteSizeMergePolicy.NoCFSRatio = 0.0; // make sure we use plain
+            // files
+            conf.SetMergePolicy(logByteSizeMergePolicy);
+
+            IndexWriter writer = new IndexWriter(dir, conf);
+            return writer;
+        }
+
+        private void AddDocs(IndexWriter writer, int numDocs)
+        {
+            for (int i = 0; i < numDocs; i++)
+            {
+                Document doc = new Document();
+                doc.Add(NewTextField("content", "aaa", Field.Store.NO));
+                writer.AddDocument(doc);
+            }
+        }
+
+        private void AddDocs2(IndexWriter writer, int numDocs)
+        {
+            for (int i = 0; i < numDocs; i++)
+            {
+                Document doc = new Document();
+                doc.Add(NewTextField("content", "bbb", Field.Store.NO));
+                writer.AddDocument(doc);
+            }
+        }
+
+        private void AddDocs3(IndexWriter writer, int numDocs)
+        {
+            for (int i = 0; i < numDocs; i++)
+            {
+                Document doc = new Document();
+                doc.Add(NewTextField("content", "ccc", Field.Store.NO));
+                doc.Add(NewStringField("id", "" + i, Field.Store.YES));
+                writer.AddDocument(doc);
+            }
+        }
+
+        /// <summary>
+        /// Test that heterogeneous index segments are merge successfully
+        /// </summary>
+        [Test]
+        public virtual void TestMergeUnusedPerFieldCodec()
+        {
+            Directory dir = NewDirectory();
+            IndexWriterConfig iwconf = NewIndexWriterConfig(TEST_VERSION_CURRENT, 
+                new MockAnalyzer(Random())).SetOpenMode(OpenMode.CREATE).SetCodec(new MockCodec());
+            IndexWriter writer = NewWriter(dir, iwconf);
+            AddDocs(writer, 10);
+            writer.Commit();
+            AddDocs3(writer, 10);
+            writer.Commit();
+            AddDocs2(writer, 10);
+            writer.Commit();
+            Assert.AreEqual(30, writer.MaxDoc);
+            TestUtil.CheckIndex(dir);
+            writer.ForceMerge(1);
+            Assert.AreEqual(30, writer.MaxDoc);
+            writer.Dispose();
+            dir.Dispose();
+        }
+
+        /// <summary>
+        /// Test that heterogeneous index segments are merged sucessfully
+        /// </summary>
+        // TODO: not sure this test is that great, we should probably peek inside PerFieldPostingsFormat or something?!
+        [Test]
+        public virtual void TestChangeCodecAndMerge()
+        {
+            Directory dir = NewDirectory();
+            if (VERBOSE)
+            {
+                Console.WriteLine("TEST: make new index");
+            }
+            IndexWriterConfig iwconf = NewIndexWriterConfig(TEST_VERSION_CURRENT, 
+                new MockAnalyzer(Random())).SetOpenMode(OpenMode.CREATE).SetCodec(new MockCodec());
+            iwconf.SetMaxBufferedDocs(IndexWriterConfig.DISABLE_AUTO_FLUSH);
+            // ((LogMergePolicy)iwconf.getMergePolicy()).setMergeFactor(10);
+            IndexWriter writer = NewWriter(dir, iwconf);
+
+            AddDocs(writer, 10);
+            writer.Commit();
+            AssertQuery(new Term("content", "aaa"), dir, 10);
+            if (VERBOSE)
+            {
+                Console.WriteLine("TEST: addDocs3");
+            }
+            AddDocs3(writer, 10);
+            writer.Commit();
+            writer.Dispose();
+
+            AssertQuery(new Term("content", "ccc"), dir, 10);
+            AssertQuery(new Term("content", "aaa"), dir, 10);
+            Codec codec = iwconf.Codec;
+
+            iwconf = NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random()))
+                .SetOpenMode(OpenMode.APPEND).SetCodec(codec);
+            // ((LogMergePolicy)iwconf.getMergePolicy()).setNoCFSRatio(0.0);
+            // ((LogMergePolicy)iwconf.getMergePolicy()).setMergeFactor(10);
+            iwconf.SetMaxBufferedDocs(IndexWriterConfig.DISABLE_AUTO_FLUSH);
+
+            iwconf.SetCodec(new MockCodec2()); // uses standard for field content
+            writer = NewWriter(dir, iwconf);
+            // swap in new codec for currently written segments
+            if (VERBOSE)
+            {
+                Console.WriteLine("TEST: add docs w/ Standard codec for content field");
+            }
+            AddDocs2(writer, 10);
+            writer.Commit();
+            codec = iwconf.Codec;
+            Assert.AreEqual(30, writer.MaxDoc);
+            AssertQuery(new Term("content", "bbb"), dir, 10);
+            AssertQuery(new Term("content", "ccc"), dir, 10); ////
+            AssertQuery(new Term("content", "aaa"), dir, 10);
+
+            if (VERBOSE)
+            {
+                Console.WriteLine("TEST: add more docs w/ new codec");
+            }
+            AddDocs2(writer, 10);
+            writer.Commit();
+            AssertQuery(new Term("content", "ccc"), dir, 10);
+            AssertQuery(new Term("content", "bbb"), dir, 20);
+            AssertQuery(new Term("content", "aaa"), dir, 10);
+            Assert.AreEqual(40, writer.MaxDoc);
+
+            if (VERBOSE)
+            {
+                Console.WriteLine("TEST: now optimize");
+            }
+            writer.ForceMerge(1);
+            Assert.AreEqual(40, writer.MaxDoc);
+            writer.Dispose();
+            AssertQuery(new Term("content", "ccc"), dir, 10);
+            AssertQuery(new Term("content", "bbb"), dir, 20);
+            AssertQuery(new Term("content", "aaa"), dir, 10);
+
+            dir.Dispose();
+        }
+
+        public virtual void AssertQuery(Term t, Directory dir, int num)
+        {
+            if (VERBOSE)
+            {
+                Console.WriteLine("\nTEST: assertQuery " + t);
+            }
+            IndexReader reader = DirectoryReader.Open(dir, 1);
+            IndexSearcher searcher = NewSearcher(reader);
+            TopDocs search = searcher.Search(new TermQuery(t), num + 10);
+            Assert.AreEqual(num, search.TotalHits);
+            reader.Dispose();
+        }
+
+        private class MockCodec : Lucene46Codec
+        {
+            internal readonly PostingsFormat Lucene40 = new Lucene41PostingsFormat();
+            internal readonly PostingsFormat SimpleText = new SimpleTextPostingsFormat();
+            internal readonly PostingsFormat MockSep = new MockSepPostingsFormat();
+
+            public override PostingsFormat GetPostingsFormatForField(string field)
+            {
+                if (field.Equals("id"))
+                {
+                    return SimpleText;
+                }
+                else if (field.Equals("content"))
+                {
+                    return MockSep;
+                }
+                else
+                {
+                    return Lucene40;
+                }
+            }
+        }
+
+        private class MockCodec2 : Lucene46Codec
+        {
+            internal readonly PostingsFormat Lucene40 = new Lucene41PostingsFormat();
+            internal readonly PostingsFormat SimpleText = new SimpleTextPostingsFormat();
+
+            public override PostingsFormat GetPostingsFormatForField(string field)
+            {
+                if (field.Equals("id"))
+                {
+                    return SimpleText;
+                }
+                else
+                {
+                    return Lucene40;
+                }
+            }
+        }
+
+        /// <summary>
+        /// Test per field codec support - adding fields with random codecs
+        /// </summary>
+        [Test]
+        public virtual void TestStressPerFieldCodec()
+        {
+            Directory dir = NewDirectory(Random());
+            const int docsPerRound = 97;
+            int numRounds = AtLeast(1);
+            for (int i = 0; i < numRounds; i++)
+            {
+                int num = TestUtil.NextInt(Random(), 30, 60);
+                IndexWriterConfig config = NewIndexWriterConfig(Random(), TEST_VERSION_CURRENT, new MockAnalyzer(Random()));
+                config.SetOpenMode(OpenMode.CREATE_OR_APPEND);
+                IndexWriter writer = NewWriter(dir, config);
+                for (int j = 0; j < docsPerRound; j++)
+                {
+                    Document doc = new Document();
+                    for (int k = 0; k < num; k++)
+                    {
+                        FieldType customType = new FieldType(TextField.TYPE_NOT_STORED);
+                        customType.IsTokenized = Random().NextBoolean();
+                        customType.OmitNorms = Random().NextBoolean();
+                        Field field = NewField("" + k, TestUtil.RandomRealisticUnicodeString(Random(), 128), customType);
+                        doc.Add(field);
+                    }
+                    writer.AddDocument(doc);
+                }
+                if (Random().NextBoolean())
+                {
+                    writer.ForceMerge(1);
+                }
+                writer.Commit();
+                Assert.AreEqual((i + 1) * docsPerRound, writer.MaxDoc);
+                writer.Dispose();
+            }
+            dir.Dispose();
+        }
+
+        [Test]
+        public virtual void TestSameCodecDifferentInstance()
+        {
+            Codec codec = new Lucene46CodecAnonymousInnerClassHelper(this);
+            DoTestMixedPostings(codec);
+        }
+
+        private class Lucene46CodecAnonymousInnerClassHelper : Lucene46Codec
+        {
+            private readonly TestPerFieldPostingsFormat2 OuterInstance;
+
+            public Lucene46CodecAnonymousInnerClassHelper(TestPerFieldPostingsFormat2 outerInstance)
+            {
+                this.OuterInstance = outerInstance;
+            }
+
+            public override PostingsFormat GetPostingsFormatForField(string field)
+            {
+                if ("id".Equals(field))
+                {
+                    return new Pulsing41PostingsFormat(1);
+                }
+                else if ("date".Equals(field))
+                {
+                    return new Pulsing41PostingsFormat(1);
+                }
+                else
+                {
+                    return base.GetPostingsFormatForField(field);
+                }
+            }
+        }
+
+        [Test]
+        public virtual void TestSameCodecDifferentParams()
+        {
+          Codec codec = new Lucene46CodecAnonymousInnerClassHelper2(this);
+          DoTestMixedPostings(codec);
+        }
+
+        private class Lucene46CodecAnonymousInnerClassHelper2 : Lucene46Codec
+        {
+            private readonly TestPerFieldPostingsFormat2 OuterInstance;
+
+            public Lucene46CodecAnonymousInnerClassHelper2(TestPerFieldPostingsFormat2 outerInstance)
+            {
+                this.OuterInstance = outerInstance;
+            }
+
+            public override PostingsFormat GetPostingsFormatForField(string field)
+            {
+                if ("id".Equals(field))
+                {
+                    return new Pulsing41PostingsFormat(1);
+                }
+                else if ("date".Equals(field))
+                {
+                    return new Pulsing41PostingsFormat(2);
+                }
+                else
+                {
+                    return base.GetPostingsFormatForField(field);
+                }
+            }
+        }
+
+        private void DoTestMixedPostings(Codec codec)
+        {
+            Directory dir = NewDirectory();
+            IndexWriterConfig iwc = NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random()));
+            iwc.SetCodec(codec);
+            RandomIndexWriter iw = new RandomIndexWriter(Random(), dir, iwc);
+            Document doc = new Document();
+            FieldType ft = new FieldType(TextField.TYPE_NOT_STORED);
+            // turn on vectors for the checkindex cross-check
+            ft.StoreTermVectors = true;
+            ft.StoreTermVectorOffsets = true;
+            ft.StoreTermVectorPositions = true;
+            Field idField = new Field("id", "", ft);
+            Field dateField = new Field("date", "", ft);
+            doc.Add(idField);
+            doc.Add(dateField);
+            for (int i = 0; i < 100; i++)
+            {
+                idField.SetStringValue(Convert.ToString(Random().Next(50)));
+                dateField.SetStringValue(Convert.ToString(Random().Next(100)));
+                iw.AddDocument(doc);
+            }
+            iw.Dispose();
+            dir.Dispose(); // checkindex
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/96822396/src/Lucene.Net.Tests/Document/TestBinaryDocument.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/Document/TestBinaryDocument.cs b/src/Lucene.Net.Tests/Document/TestBinaryDocument.cs
new file mode 100644
index 0000000..839fa30
--- /dev/null
+++ b/src/Lucene.Net.Tests/Document/TestBinaryDocument.cs
@@ -0,0 +1,122 @@
+using Lucene.Net.Support;
+using NUnit.Framework;
+using System;
+using System.Text;
+
+namespace Lucene.Net.Documents
+{
+    /*
+     * 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 BytesRef = Lucene.Net.Util.BytesRef;
+    using Directory = Lucene.Net.Store.Directory;
+    using IIndexableField = Lucene.Net.Index.IIndexableField;
+    using IndexReader = Lucene.Net.Index.IndexReader;
+    using LuceneTestCase = Lucene.Net.Util.LuceneTestCase;
+    using RandomIndexWriter = Lucene.Net.Index.RandomIndexWriter;
+
+    /// <summary>
+    /// Tests <seealso cref="Document"/> class.
+    /// </summary>
+    [TestFixture]
+    public class TestBinaryDocument : LuceneTestCase
+    {
+        internal string BinaryValStored = "this text will be stored as a byte array in the index";
+        internal string BinaryValCompressed = "this text will be also stored and compressed as a byte array in the index";
+
+        [Test]
+        public virtual void TestBinaryFieldInIndex()
+        {
+            FieldType ft = new FieldType();
+            ft.IsStored = true;
+            IIndexableField binaryFldStored = new StoredField("binaryStored", System.Text.UTF8Encoding.UTF8.GetBytes(BinaryValStored));
+            IIndexableField stringFldStored = new Field("stringStored", BinaryValStored, ft);
+
+            Documents.Document doc = new Documents.Document();
+
+            doc.Add(binaryFldStored);
+
+            doc.Add(stringFldStored);
+
+            /// <summary>
+            /// test for field count </summary>
+            Assert.AreEqual(2, doc.Fields.Count);
+
+            /// <summary>
+            /// add the doc to a ram index </summary>
+            Directory dir = NewDirectory();
+            Random r = Random();
+            RandomIndexWriter writer = new RandomIndexWriter(r, dir, Similarity, TimeZone);
+            writer.AddDocument(doc);
+
+            /// <summary>
+            /// open a reader and fetch the document </summary>
+            IndexReader reader = writer.Reader;
+            Documents.Document docFromReader = reader.Document(0);
+            Assert.IsTrue(docFromReader != null);
+
+            /// <summary>
+            /// fetch the binary stored field and compare it's content with the original one </summary>
+            BytesRef bytes = docFromReader.GetBinaryValue("binaryStored");
+            Assert.IsNotNull(bytes);
+
+            string binaryFldStoredTest = Encoding.UTF8.GetString((byte[])(Array)bytes.Bytes).Substring(bytes.Offset, bytes.Length);
+            //new string(bytes.Bytes, bytes.Offset, bytes.Length, IOUtils.CHARSET_UTF_8);
+            Assert.IsTrue(binaryFldStoredTest.Equals(BinaryValStored));
+
+            /// <summary>
+            /// fetch the string field and compare it's content with the original one </summary>
+            string stringFldStoredTest = docFromReader.Get("stringStored");
+            Assert.IsTrue(stringFldStoredTest.Equals(BinaryValStored));
+
+            writer.Dispose();
+            reader.Dispose();
+            dir.Dispose();
+        }
+
+        [Test]
+        public virtual void TestCompressionTools()
+        {
+            IIndexableField binaryFldCompressed = new StoredField("binaryCompressed", CompressionTools.Compress(BinaryValCompressed.GetBytes(Encoding.UTF8)));
+            IIndexableField stringFldCompressed = new StoredField("stringCompressed", CompressionTools.CompressString(BinaryValCompressed));
+
+            var doc = new Documents.Document {binaryFldCompressed, stringFldCompressed};
+
+            using (Directory dir = NewDirectory())
+            using (RandomIndexWriter writer = new RandomIndexWriter(Random(), dir, Similarity, TimeZone))
+            {
+                writer.AddDocument(doc);
+
+                using (IndexReader reader = writer.Reader)
+                {
+                    Documents.Document docFromReader = reader.Document(0);
+                    Assert.IsTrue(docFromReader != null);
+
+                    string binaryFldCompressedTest =
+                        Encoding.UTF8.GetString(
+                            CompressionTools.Decompress(docFromReader.GetBinaryValue("binaryCompressed")));
+                    //new string(CompressionTools.Decompress(docFromReader.GetBinaryValue("binaryCompressed")), IOUtils.CHARSET_UTF_8);
+                    Assert.IsTrue(binaryFldCompressedTest.Equals(BinaryValCompressed));
+                    Assert.IsTrue(
+                        CompressionTools.DecompressString(docFromReader.GetBinaryValue("stringCompressed"))
+                            .Equals(BinaryValCompressed));
+                }
+
+            }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/96822396/src/Lucene.Net.Tests/Document/TestDateTools.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/Document/TestDateTools.cs b/src/Lucene.Net.Tests/Document/TestDateTools.cs
new file mode 100644
index 0000000..8a4d823
--- /dev/null
+++ b/src/Lucene.Net.Tests/Document/TestDateTools.cs
@@ -0,0 +1,244 @@
+using Lucene.Net.Util;
+using NUnit.Framework;
+using System;
+using System.Globalization;
+
+namespace Lucene.Net.Documents
+{
+    /*
+     * 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.
+     */
+
+    [TestFixture]
+    public class TestDateTools : LuceneTestCase
+    {
+        //public TestRule TestRules = RuleChain.outerRule(new SystemPropertiesRestoreRule());
+
+        [Test]
+        public virtual void TestStringToDate()
+        {
+            DateTime d = default(DateTime);
+            d = DateTools.StringToDate("2004");
+            Assert.AreEqual("2004-01-01 00:00:00:000", IsoFormat(d));
+            d = DateTools.StringToDate("20040705");
+            Assert.AreEqual("2004-07-05 00:00:00:000", IsoFormat(d));
+            d = DateTools.StringToDate("200407050910");
+            Assert.AreEqual("2004-07-05 09:10:00:000", IsoFormat(d));
+            d = DateTools.StringToDate("20040705091055990");
+            Assert.AreEqual("2004-07-05 09:10:55:990", IsoFormat(d));
+
+            try
+            {
+                d = DateTools.StringToDate("97"); // no date
+                Assert.Fail();
+            } // expected exception
+#pragma warning disable 168
+            catch (Exception e)
+#pragma warning restore 168
+            {
+            }
+            try
+            {
+                d = DateTools.StringToDate("200401011235009999"); // no date
+                Assert.Fail();
+            } // expected exception
+#pragma warning disable 168
+            catch (Exception e)
+#pragma warning restore 168
+            {
+            }
+            try
+            {
+                d = DateTools.StringToDate("aaaa"); // no date
+                Assert.Fail();
+            } // expected exception
+#pragma warning disable 168
+            catch (Exception e)
+#pragma warning restore 168
+            {
+            }
+        }
+
+        [Test]
+        public virtual void TestStringtoTime()
+        {
+            long time = DateTools.StringToTime("197001010000");
+
+            // we use default locale since LuceneTestCase randomizes it
+            //Calendar cal = new GregorianCalendar(TimeZone.GetTimeZone("GMT"), Locale.Default);
+            //cal.Clear();
+           
+            DateTime cal = new GregorianCalendar().ToDateTime(1970, 1, 1, 0, 0, 0, 0); // hour, minute, second -  year=1970, month=january, day=1
+            //cal.set(DateTime.MILLISECOND, 0);
+            Assert.AreEqual(cal.Ticks, time);
+
+            cal = new GregorianCalendar().ToDateTime(1980, 2, 2, 11, 5, 0, 0); // hour, minute, second -  year=1980, month=february, day=2
+            //cal.set(DateTime.MILLISECOND, 0);
+            time = DateTools.StringToTime("198002021105");
+            Assert.AreEqual(cal.Ticks, time);
+        }
+
+        [Test]
+        public virtual void TestDateAndTimetoString()
+        {
+            // we use default locale since LuceneTestCase randomizes it
+            //Calendar cal = new GregorianCalendar(TimeZone.getTimeZone("GMT"), Locale.Default);
+            DateTime cal = new GregorianCalendar().ToDateTime(2004, 2, 3, 22, 8, 56, 333);
+
+            /*cal.clear();
+            cal = new DateTime(2004, 1, 3, 22, 8, 56); // hour, minute, second -  year=2004, month=february(!), day=3
+            cal.set(DateTime.MILLISECOND, 333);*/
+
+            string dateString = DateTools.DateToString(cal, DateTools.Resolution.YEAR);
+            Assert.AreEqual("2004", dateString);
+            Assert.AreEqual("2004-01-01 00:00:00:000", IsoFormat(DateTools.StringToDate(dateString)));
+
+            dateString = DateTools.DateToString(cal, DateTools.Resolution.MONTH);
+            Assert.AreEqual("200402", dateString);
+            Assert.AreEqual("2004-02-01 00:00:00:000", IsoFormat(DateTools.StringToDate(dateString)));
+
+            dateString = DateTools.DateToString(cal, DateTools.Resolution.DAY);
+            Assert.AreEqual("20040203", dateString);
+            Assert.AreEqual("2004-02-03 00:00:00:000", IsoFormat(DateTools.StringToDate(dateString)));
+
+            dateString = DateTools.DateToString(cal, DateTools.Resolution.HOUR);
+            Assert.AreEqual("2004020322", dateString);
+            Assert.AreEqual("2004-02-03 22:00:00:000", IsoFormat(DateTools.StringToDate(dateString)));
+
+            dateString = DateTools.DateToString(cal, DateTools.Resolution.MINUTE);
+            Assert.AreEqual("200402032208", dateString);
+            Assert.AreEqual("2004-02-03 22:08:00:000", IsoFormat(DateTools.StringToDate(dateString)));
+
+            dateString = DateTools.DateToString(cal, DateTools.Resolution.SECOND);
+            Assert.AreEqual("20040203220856", dateString);
+            Assert.AreEqual("2004-02-03 22:08:56:000", IsoFormat(DateTools.StringToDate(dateString)));
+
+            dateString = DateTools.DateToString(cal, DateTools.Resolution.MILLISECOND);
+            Assert.AreEqual("20040203220856333", dateString);
+            Assert.AreEqual("2004-02-03 22:08:56:333", IsoFormat(DateTools.StringToDate(dateString)));
+
+            // date before 1970:
+            cal = new GregorianCalendar().ToDateTime(1961, 3, 5, 23, 9, 51, 444); // hour, minute, second -  year=1961, month=march(!), day=5
+            //cal.set(DateTime.MILLISECOND, 444);
+            dateString = DateTools.DateToString(cal, DateTools.Resolution.MILLISECOND);
+            Assert.AreEqual("19610305230951444", dateString);
+            Assert.AreEqual("1961-03-05 23:09:51:444", IsoFormat(DateTools.StringToDate(dateString)));
+
+            dateString = DateTools.DateToString(cal, DateTools.Resolution.HOUR);
+            Assert.AreEqual("1961030523", dateString);
+            Assert.AreEqual("1961-03-05 23:00:00:000", IsoFormat(DateTools.StringToDate(dateString)));
+
+            // timeToString:
+            cal = new GregorianCalendar().ToDateTime(1970, 1, 1, 0, 0, 0, 0); // hour, minute, second -  year=1970, month=january, day=1
+            //cal.set(DateTime.MILLISECOND, 0);
+            dateString = DateTools.TimeToString(cal.Ticks / TimeSpan.TicksPerMillisecond, DateTools.Resolution.MILLISECOND);
+            Assert.AreEqual("19700101000000000", dateString);
+
+            cal = new GregorianCalendar().ToDateTime(1970, 1, 1, 1, 2, 3, 0); // hour, minute, second -  year=1970, month=january, day=1
+            //cal.set(DateTime.MILLISECOND, 0);
+            dateString = DateTools.TimeToString(cal.Ticks / TimeSpan.TicksPerMillisecond, DateTools.Resolution.MILLISECOND);
+            Assert.AreEqual("19700101010203000", dateString);
+        }
+
+        [Test]
+        public virtual void TestRound()
+        {
+            // we use default locale since LuceneTestCase randomizes it
+            //Calendar cal = new GregorianCalendar(TimeZone.getTimeZone("GMT"), Locale.Default);
+            //cal.clear();
+            DateTime cal = new GregorianCalendar().ToDateTime(2004, 2, 3, 22, 8, 56, 333); // hour, minute, second -  year=2004, month=february(!), day=3
+            //cal.set(DateTime.MILLISECOND, 333);
+            DateTime date = cal;
+            Assert.AreEqual("2004-02-03 22:08:56:333", IsoFormat(date));
+
+            DateTime dateYear = DateTools.Round(date, DateTools.Resolution.YEAR);
+            Assert.AreEqual("2004-01-01 00:00:00:000", IsoFormat(dateYear));
+
+            DateTime dateMonth = DateTools.Round(date, DateTools.Resolution.MONTH);
+            Assert.AreEqual("2004-02-01 00:00:00:000", IsoFormat(dateMonth));
+
+            DateTime dateDay = DateTools.Round(date, DateTools.Resolution.DAY);
+            Assert.AreEqual("2004-02-03 00:00:00:000", IsoFormat(dateDay));
+
+            DateTime dateHour = DateTools.Round(date, DateTools.Resolution.HOUR);
+            Assert.AreEqual("2004-02-03 22:00:00:000", IsoFormat(dateHour));
+
+            DateTime dateMinute = DateTools.Round(date, DateTools.Resolution.MINUTE);
+            Assert.AreEqual("2004-02-03 22:08:00:000", IsoFormat(dateMinute));
+
+            DateTime dateSecond = DateTools.Round(date, DateTools.Resolution.SECOND);
+            Assert.AreEqual("2004-02-03 22:08:56:000", IsoFormat(dateSecond));
+
+            DateTime dateMillisecond = DateTools.Round(date, DateTools.Resolution.MILLISECOND);
+            Assert.AreEqual("2004-02-03 22:08:56:333", IsoFormat(dateMillisecond));
+
+            // long parameter:
+            long dateYearLong = DateTools.Round(date.Ticks / TimeSpan.TicksPerMillisecond, DateTools.Resolution.YEAR);
+            Assert.AreEqual("2004-01-01 00:00:00:000", IsoFormat(new DateTime(dateYearLong)));
+
+            long dateMillisecondLong = DateTools.Round(date.Ticks / TimeSpan.TicksPerMillisecond, DateTools.Resolution.MILLISECOND);
+            Assert.AreEqual("2004-02-03 22:08:56:333", IsoFormat(new DateTime(dateMillisecondLong)));
+        }
+
+        private string IsoFormat(DateTime date)
+        {
+            /*SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS", Locale.ROOT);
+            sdf.TimeZone = TimeZone.getTimeZone("GMT");
+            return sdf.Format(date);*/
+            return date.ToString("yyyy-MM-dd HH:mm:ss:fff", System.Globalization.CultureInfo.InvariantCulture);
+        }
+
+        [Test]
+        public virtual void TestDateToolsUTC()
+        {
+            /*// Sun, 30 Oct 2005 00:00:00 +0000 -- the last second of 2005's DST in Europe/London
+            long time = 1130630400;
+            try
+            {
+                TimeZone.Default = TimeZone.getTimeZone("Europe/London"); // "GMT"
+                string d1 = DateTools.DateToString(new DateTime(time * 1000), DateTools.Resolution.MINUTE);
+                string d2 = DateTools.DateToString(new DateTime((time+3600) * 1000), DateTools.Resolution.MINUTE);
+                Assert.IsFalse(d1.Equals(d2), "different times");
+                Assert.AreEqual(DateTools.StringToTime(d1), time * 1000, "midnight");
+                Assert.AreEqual(DateTools.StringToTime(d2), (time+3600) * 1000, "later");
+            }
+            finally
+            {
+                TimeZone.Default = null;
+            }*/
+
+            // Sun, 30 Oct 2005 00:00:00 +0000 -- the last second of 2005's DST in Europe/London
+            //long time = 1130630400;
+            DateTime time1 = new DateTime(2005, 10, 30);
+            DateTime time2 = time1.AddHours(1);
+            try
+            {
+                //TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); // {{Aroush-2.0}} need porting 'java.util.TimeZone.getTimeZone'
+                System.DateTime tempAux = time1;
+                System.String d1 = DateTools.DateToString(tempAux, DateTools.Resolution.MINUTE);
+                System.DateTime tempAux2 = time2;
+                System.String d2 = DateTools.DateToString(tempAux2, DateTools.Resolution.MINUTE);
+                Assert.IsFalse(d1.Equals(d2), "different times");
+                Assert.AreEqual(DateTools.StringToTime(d1), time1.Ticks, "midnight");
+                Assert.AreEqual(DateTools.StringToTime(d2), time2.Ticks, "later");
+            }
+            finally
+            {
+                //TimeZone.SetDefault(null);    // {{Aroush-2.0}} need porting 'java.util.TimeZone.setDefault'
+            }
+        }
+    }
+}
\ No newline at end of file