private void  PerformTestsWithExceptionInReopen(TestReopen_Renamed_Class test)
		{
			IndexReader index1 = test.OpenReader();
			IndexReader index2 = test.OpenReader();
			
			TestIndexReader.AssertIndexEquals(index1, index2);
			
			try
			{
				ReaderCouple couple = RefreshReader(index1, test, 0, true);
				Assert.Fail("Expected exception not thrown.");
			}
			catch (System.Exception)
			{
				// expected exception
			}
			
			// index2 should still be usable and unaffected by the failed reopen() call
			TestIndexReader.AssertIndexEquals(index1, index2);
		}
		private void  PerformDefaultTests(TestReopen_Renamed_Class test)
		{
			IndexReader index1 = test.OpenReader();
			IndexReader index2 = test.OpenReader();
			
			TestIndexReader.AssertIndexEquals(index1, index2);
			
			// verify that reopen() does not return a new reader instance
			// in case the index has no changes
			ReaderCouple couple = RefreshReader(index2, false);
			Assert.IsTrue(couple.refreshedReader == index2);
			
			couple = RefreshReader(index2, test, 0, true);
			index1 = couple.newReader;
			IndexReader index2_refreshed = couple.refreshedReader;
			index2.Close();
			
			// test if refreshed reader and newly opened reader return equal results
			TestIndexReader.AssertIndexEquals(index1, index2_refreshed);
			
			index1.Close();
			index2_refreshed.Close();
			AssertReaderClosed(index2, true, true);
			AssertReaderClosed(index2_refreshed, true, true);
			
			index2 = test.OpenReader();
			
			for (int i = 1; i < 4; i++)
			{
				
				index1.Close();
				couple = RefreshReader(index2, test, i, true);
				// refresh IndexReader
				index2.Close();
				
				index2 = couple.refreshedReader;
				index1 = couple.newReader;
				TestIndexReader.AssertIndexEquals(index1, index2);
			}
			
			index1.Close();
			index2.Close();
			AssertReaderClosed(index1, true, true);
			AssertReaderClosed(index2, true, true);
		}
			public AnonymousClassReaderThreadTask(int index, Lucene.Net.Index.IndexReader r, TestReopen_Renamed_Class test, System.Collections.Hashtable readersToClose, System.Collections.IList readers, System.Random rnd, TestIndexReaderReopen enclosingInstance)
			{
				InitBlock(index, r, test, readersToClose, readers, rnd, enclosingInstance);
			}
			private void  InitBlock(int index, Lucene.Net.Index.IndexReader r, TestReopen_Renamed_Class test, System.Collections.Hashtable readersToClose, System.Collections.IList readers, System.Random rnd, TestIndexReaderReopen enclosingInstance)
			{
				this.index = index;
				this.r = r;
				this.test = test;
				this.readersToClose = readersToClose;
				this.readers = readers;
				this.rnd = rnd;
				this.enclosingInstance = enclosingInstance;
			}
		private ReaderCouple RefreshReader(IndexReader reader, TestReopen_Renamed_Class test, int modify, bool hasChanges)
		{
			lock (createReaderMutex)
			{
				IndexReader r = null;
				if (test != null)
				{
					test.ModifyIndex(modify);
					r = test.OpenReader();
				}
				
				IndexReader refreshed = reader.Reopen();
				if (hasChanges)
				{
					if (refreshed == reader)
					{
						Assert.Fail("No new IndexReader instance created during refresh.");
					}
				}
				else
				{
					if (refreshed != reader)
					{
						Assert.Fail("New IndexReader instance created during refresh even though index had no changes.");
					}
				}
				
				return new ReaderCouple(r, refreshed);
			}
		}