Пример #1
0
 public void TestExceptionOnMergeInit()
 {
     MockRAMDirectory dir = new MockRAMDirectory();
     MockIndexWriter2 w = new MockIndexWriter2(dir, false, new WhitespaceAnalyzer(), true);
     w.SetMaxBufferedDocs(2);
     w.SetMergeFactor(2);
     w.doFail = true;
     w.SetMergeScheduler(new ConcurrentMergeScheduler());
     Document doc = new Document();
     doc.Add(new Field("field", "a field", Field.Store.YES,
                       Field.Index.TOKENIZED));
     for (int i = 0; i < 10; i++)
         try
         {
             w.AddDocument(doc);
         }
         catch (System.Exception)
         {
             break;
         }
     ((ConcurrentMergeScheduler)w.GetMergeScheduler()).Sync();
     Assert.IsTrue(w.failed);
     w.Close();
     dir.Close();
 }
Пример #2
0
		public virtual void  TestExceptionOnMergeInit()
		{
			MockRAMDirectory dir = new MockRAMDirectory();
			MockIndexWriter2 w = new MockIndexWriter2(this, dir, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.UNLIMITED);
			w.SetMaxBufferedDocs(2);
			w.SetMergeFactor(2);
			w.doFail = true;
			w.SetMergeScheduler(new ConcurrentMergeScheduler());
			Document doc = new Document();
			doc.Add(new Field("field", "a field", Field.Store.YES, Field.Index.ANALYZED));
			for (int i = 0; i < 10; i++)
				try
				{
					w.AddDocument(doc);
				}
				catch (System.SystemException re)
				{
					break;
				}
			
			((ConcurrentMergeScheduler) w.GetMergeScheduler()).Sync();
            if (SupportClass.BuildType.Debug)
                Assert.IsTrue(w.failed);
            else
                Assert.Ignore("This test is not executed in release mode");
			w.Close();
			dir.Close();
		}