You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by di...@apache.org on 2011/03/21 22:38:28 UTC
[Lucene.Net] svn commit: r1083970 - in /incubator/lucene.net/trunk/C#/src/Test/Index:
TestNewestSegment.cs TestRollback.cs
Author: digy
Date: Mon Mar 21 21:38:27 2011
New Revision: 1083970
URL: http://svn.apache.org/viewvc?rev=1083970&view=rev
Log:
[LUCENENET-399] All core files + test cases have been ported for 2.9.4
Added:
incubator/lucene.net/trunk/C#/src/Test/Index/TestNewestSegment.cs
incubator/lucene.net/trunk/C#/src/Test/Index/TestRollback.cs
Added: incubator/lucene.net/trunk/C#/src/Test/Index/TestNewestSegment.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Index/TestNewestSegment.cs?rev=1083970&view=auto
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Index/TestNewestSegment.cs (added)
+++ incubator/lucene.net/trunk/C#/src/Test/Index/TestNewestSegment.cs Mon Mar 21 21:38:27 2011
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+using Lucene.Net.Index;
+using Lucene.Net.Analysis;
+using Lucene.Net.Documents;
+using Lucene.Net.Store;
+using Lucene.Net.Util;
+
+using NUnit.Framework;
+
+namespace Lucene.Net.Index
+{
+ [TestFixture]
+ public class TestNewestSegment : LuceneTestCase
+ {
+ [Test]
+ public void TestNewestSegment_Renamed()
+ {
+ RAMDirectory directory = new RAMDirectory();
+ IndexWriter writer = new IndexWriter(directory, new SimpleAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
+ Assert.IsNull(writer.NewestSegment());
+ }
+ }
+}
Added: incubator/lucene.net/trunk/C#/src/Test/Index/TestRollback.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Index/TestRollback.cs?rev=1083970&view=auto
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Index/TestRollback.cs (added)
+++ incubator/lucene.net/trunk/C#/src/Test/Index/TestRollback.cs Mon Mar 21 21:38:27 2011
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+using Lucene.Net.Index;
+using Lucene.Net.Analysis;
+using Lucene.Net.Documents;
+using Lucene.Net.Store;
+using Lucene.Net.Util;
+
+using NUnit.Framework;
+
+namespace Lucene.Net.Index
+{
+ [TestFixture]
+ public class TestRollback : LuceneTestCase
+ {
+
+ // LUCENE-2536
+ [Test]
+ public void TestRollbackIntegrityWithBufferFlush()
+ {
+ Directory dir = new MockRAMDirectory();
+ IndexWriter w = new IndexWriter(dir, new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.UNLIMITED);
+ for (int i = 0; i < 5; i++)
+ {
+ Document doc = new Document();
+ doc.Add(new Field("pk", i.ToString(), Field.Store.YES, Field.Index.ANALYZED_NO_NORMS));
+ w.AddDocument(doc);
+ }
+ w.Close();
+
+ // If buffer size is small enough to cause a flush, errors ensue...
+ w = new IndexWriter(dir, new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.UNLIMITED);
+ w.SetMaxBufferedDocs(2);
+
+ Term pkTerm = new Term("pk", "");
+ for (int i = 0; i < 3; i++)
+ {
+ Document doc = new Document();
+ String value = i.ToString();
+ doc.Add(new Field("pk", value, Field.Store.YES, Field.Index.ANALYZED_NO_NORMS));
+ doc.Add(new Field("text", "foo", Field.Store.YES, Field.Index.ANALYZED_NO_NORMS));
+ w.UpdateDocument(pkTerm.CreateTerm(value), doc);
+ }
+ w.Rollback();
+
+ IndexReader r = IndexReader.Open(dir, true);
+ Assert.AreEqual(5, r.NumDocs(), "index should contain same number of docs post rollback");
+ r.Close();
+ dir.Close();
+ }
+ }
+}