lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ccurr...@apache.org
Subject [Lucene.Net] svn commit: r1294875 [45/45] - in /incubator/lucene.net/trunk: ./ build/ build/vs2010/contrib/ build/vs2010/test/ doc/ src/ src/contrib/Analyzers/ src/contrib/Analyzers/AR/ src/contrib/Analyzers/BR/ src/contrib/Analyzers/CJK/ src/contrib/Analyzers/Cn/ ...
Date Tue, 28 Feb 2012 22:43:28 GMT
Modified: incubator/lucene.net/trunk/test/core/Util/TestAttributeSource.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/core/Util/TestAttributeSource.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/core/Util/TestAttributeSource.cs (original)
+++ incubator/lucene.net/trunk/test/core/Util/TestAttributeSource.cs Tue Feb 28 22:43:08 2012
@@ -20,6 +20,7 @@ using System;
 using NUnit.Framework;
 
 using Token = Lucene.Net.Analysis.Token;
+using FlagsAttribute = Lucene.Net.Analysis.Tokenattributes.FlagsAttribute;
 using Lucene.Net.Analysis.Tokenattributes;
 
 namespace Lucene.Net.Util
@@ -34,8 +35,8 @@ namespace Lucene.Net.Util
         {
             // init a first instance
             AttributeSource src = new AttributeSource();
-            TermAttribute termAtt = (TermAttribute)src.AddAttribute(typeof(TermAttribute));
-            TypeAttribute typeAtt = (TypeAttribute)src.AddAttribute(typeof(TypeAttribute));
+            TermAttribute termAtt = src.AddAttribute<TermAttribute>();
+            TypeAttribute typeAtt = src.AddAttribute<TypeAttribute>();
             termAtt.SetTermBuffer("TestTerm");
             typeAtt.SetType("TestType");
             int hashCode = src.GetHashCode();
@@ -54,17 +55,17 @@ namespace Lucene.Net.Util
 
             // restore into an exact configured copy
             AttributeSource copy = new AttributeSource();
-            copy.AddAttribute(typeof(TermAttribute));
-            copy.AddAttribute(typeof(TypeAttribute));
+            copy.AddAttribute<TermAttribute>();
+            copy.AddAttribute<TypeAttribute>();
             copy.RestoreState(state);
             Assert.AreEqual(src.GetHashCode(), copy.GetHashCode(), "Both AttributeSources should have same hashCode after restore");
             Assert.AreEqual(src, copy, "Both AttributeSources should be equal after restore");
 
             // init a second instance (with attributes in different order and one additional attribute)
             AttributeSource src2 = new AttributeSource();
-            typeAtt = (TypeAttribute)src2.AddAttribute(typeof(TypeAttribute));
-            Lucene.Net.Analysis.Tokenattributes.FlagsAttribute flagsAtt = (Lucene.Net.Analysis.Tokenattributes.FlagsAttribute)src2.AddAttribute(typeof(Lucene.Net.Analysis.Tokenattributes.FlagsAttribute));
-            termAtt = (TermAttribute)src2.AddAttribute(typeof(TermAttribute));
+            typeAtt = src2.AddAttribute<TypeAttribute>();
+            FlagsAttribute flagsAtt = src2.AddAttribute<FlagsAttribute>();
+            termAtt = src2.AddAttribute<TermAttribute>();
             flagsAtt.SetFlags(12345);
 
             src2.RestoreState(state);
@@ -74,7 +75,7 @@ namespace Lucene.Net.Util
 
             // init a third instance missing one Attribute
             AttributeSource src3 = new AttributeSource();
-            termAtt = (TermAttribute)src3.AddAttribute(typeof(TermAttribute));
+            termAtt = src3.AddAttribute<TermAttribute>();
             try
             {
                 src3.RestoreState(state);
@@ -90,21 +91,21 @@ namespace Lucene.Net.Util
         public virtual void TestCloneAttributes()
         {
             AttributeSource src = new AttributeSource();
-            TermAttribute termAtt = (TermAttribute)src.AddAttribute(typeof(TermAttribute));
-            TypeAttribute typeAtt = (TypeAttribute)src.AddAttribute(typeof(TypeAttribute));
+            TermAttribute termAtt = src.AddAttribute<TermAttribute>();
+            TypeAttribute typeAtt = src.AddAttribute<TypeAttribute>();
             termAtt.SetTermBuffer("TestTerm");
             typeAtt.SetType("TestType");
 
             AttributeSource clone = src.CloneAttributes();
-            System.Collections.IEnumerator it = clone.GetAttributeClassesIterator().GetEnumerator();
+            System.Collections.Generic.IEnumerator<Type> it = clone.GetAttributeClassesIterator().GetEnumerator();
             Assert.IsTrue(it.MoveNext());
             Assert.AreEqual(typeof(TermAttribute), it.Current, "TermAttribute must be the first attribute");
             Assert.IsTrue(it.MoveNext());
             Assert.AreEqual(typeof(TypeAttribute), it.Current, "TypeAttribute must be the second attribute");
             Assert.IsFalse(it.MoveNext(), "No more attributes");
 
-            TermAttribute termAtt2 = (TermAttribute)clone.GetAttribute(typeof(TermAttribute));
-            TypeAttribute typeAtt2 = (TypeAttribute)clone.GetAttribute(typeof(TypeAttribute));
+            TermAttribute termAtt2 = clone.GetAttribute<TermAttribute>();
+            TypeAttribute typeAtt2 = clone.GetAttribute<TypeAttribute>();
             Assert.IsFalse(ReferenceEquals(termAtt2, termAtt), "TermAttribute of original and clone must be different instances");
             Assert.IsFalse(ReferenceEquals(typeAtt2, typeAtt), "TypeAttribute of original and clone must be different instances");
             Assert.AreEqual(termAtt2, termAtt, "TermAttribute of original and clone must be equal");
@@ -115,8 +116,8 @@ namespace Lucene.Net.Util
         public virtual void TestToStringAndMultiAttributeImplementations()
         {
             AttributeSource src = new AttributeSource();
-            TermAttribute termAtt = (TermAttribute)src.AddAttribute(typeof(TermAttribute));
-            TypeAttribute typeAtt = (TypeAttribute)src.AddAttribute(typeof(TypeAttribute));
+            TermAttribute termAtt = src.AddAttribute<TermAttribute>();
+            TypeAttribute typeAtt = src.AddAttribute<TypeAttribute>();
             termAtt.SetTermBuffer("TestTerm");
             typeAtt.SetType("TestType");
             Assert.AreEqual("(" + termAtt.ToString() + "," + typeAtt.ToString() + ")", src.ToString(), "Attributes should appear in original order");
@@ -130,7 +131,7 @@ namespace Lucene.Net.Util
             src = new AttributeSource();
             src.AddAttributeImpl(new Token());
             // this should not add a new attribute as Token implements TermAttribute, too
-            termAtt = (TermAttribute)src.AddAttribute(typeof(TermAttribute));
+            termAtt = src.AddAttribute<TermAttribute>();
             Assert.IsTrue(termAtt is Token, "TermAttribute should be implemented by Token");
             // get the Token attribute and check, that it is the only one
             it = src.GetAttributeImplsIterator().GetEnumerator();
@@ -143,23 +144,50 @@ namespace Lucene.Net.Util
         }
 
         [Test]
+        public void TestDefaultAttributeFactory()
+        {
+            AttributeSource src = new AttributeSource();
+
+            Assert.IsTrue(src.AddAttribute<TermAttribute>() is TermAttributeImpl,
+                          "TermAttribute is not implemented by TermAttributeImpl");
+            Assert.IsTrue(src.AddAttribute<OffsetAttribute>() is OffsetAttributeImpl,
+                          "OffsetAttribute is not implemented by OffsetAttributeImpl");
+            Assert.IsTrue(src.AddAttribute<FlagsAttribute>() is FlagsAttributeImpl,
+                          "FlagsAttribute is not implemented by FlagsAttributeImpl");
+            Assert.IsTrue(src.AddAttribute<PayloadAttribute>() is PayloadAttributeImpl,
+                          "PayloadAttribute is not implemented by PayloadAttributeImpl");
+            Assert.IsTrue(src.AddAttribute<PositionIncrementAttribute>() is PositionIncrementAttributeImpl,
+                          "PositionIncrementAttribute is not implemented by PositionIncrementAttributeImpl");
+            Assert.IsTrue(src.AddAttribute<TypeAttribute>() is TypeAttributeImpl,
+                          "TypeAttribute is not implemented by TypeAttributeImpl");
+        }
+
+        [Test]
         public void TestInvalidArguments()
         {
             try
             {
                 AttributeSource src = new AttributeSource();
-                src.AddAttribute(typeof(Token));
-                Assert.Fail("Should throw IllegalArgumentException");
+                src.AddAttribute<Token>();
+                Assert.Fail("Should throw ArgumentException");
             }
             catch (ArgumentException iae) { }
 
             try
             {
                 AttributeSource src = new AttributeSource();
-                src.AddAttribute(typeof(System.Collections.IEnumerator));
+                src.AddAttribute<Token>();
                 Assert.Fail("Should throw IllegalArgumentException");
             }
             catch (ArgumentException iae) { }
+
+            //try
+            //{
+            //    AttributeSource src = new AttributeSource();
+            //    src.AddAttribute<System.Collections.IEnumerator>(); //Doesn't compile.
+            //    Assert.Fail("Should throw IllegalArgumentException");
+            //}
+            //catch (ArgumentException iae) { }
         }
     }
     

Modified: incubator/lucene.net/trunk/test/core/Util/TestCloseableThreadLocal.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/core/Util/TestCloseableThreadLocal.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/core/Util/TestCloseableThreadLocal.cs (original)
+++ incubator/lucene.net/trunk/test/core/Util/TestCloseableThreadLocal.cs Tue Feb 28 22:43:08 2012
@@ -40,8 +40,8 @@ namespace Lucene.Net.Util
 		{
 			// Tests that null can be set as a valid value (LUCENE-1805). This
 			// previously failed in get().
-			CloseableThreadLocal ctl = new CloseableThreadLocal();
-			ctl.Set((System.Object) null);
+            CloseableThreadLocal<object> ctl = new CloseableThreadLocal<object>();
+			ctl.Set(null);
 			Assert.IsNull(ctl.Get());
 		}
 		
@@ -50,12 +50,12 @@ namespace Lucene.Net.Util
 		{
 			// LUCENE-1805: make sure default get returns null,
 			// twice in a row
-			CloseableThreadLocal ctl = new CloseableThreadLocal();
+            CloseableThreadLocal<object> ctl = new CloseableThreadLocal<object>();
 			Assert.IsNull(ctl.Get());
 			Assert.IsNull(ctl.Get());
 		}
-		
-		public class InitValueThreadLocal:CloseableThreadLocal
+
+        public class InitValueThreadLocal : CloseableThreadLocal<object>
 		{
 			public InitValueThreadLocal(TestCloseableThreadLocal enclosingInstance)
 			{

Modified: incubator/lucene.net/trunk/test/core/Util/TestFieldCacheSanityChecker.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/core/Util/TestFieldCacheSanityChecker.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/core/Util/TestFieldCacheSanityChecker.cs (original)
+++ incubator/lucene.net/trunk/test/core/Util/TestFieldCacheSanityChecker.cs Tue Feb 28 22:43:08 2012
@@ -80,8 +80,8 @@ namespace Lucene.Net.Util
 			}
 			wA.Close();
 			wB.Close();
-			readerA = IndexReader.Open(dirA);
-			readerB = IndexReader.Open(dirB);
+			readerA = IndexReader.Open(dirA, true);
+			readerB = IndexReader.Open(dirB, true);
 			readerX = new MultiReader(new IndexReader[]{readerA, readerB});
 		}
 		

Modified: incubator/lucene.net/trunk/test/core/Util/TestNumericUtils.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/core/Util/TestNumericUtils.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/core/Util/TestNumericUtils.cs (original)
+++ incubator/lucene.net/trunk/test/core/Util/TestNumericUtils.cs Tue Feb 28 22:43:08 2012
@@ -16,7 +16,9 @@
  */
 
 using System;
-
+using System.Collections.Generic;
+using System.Linq;
+using Lucene.Net.Support;
 using NUnit.Framework;
 
 namespace Lucene.Net.Util
@@ -71,37 +73,26 @@ namespace Lucene.Net.Util
 				// make unsigned longs for easier display and understanding
 				min ^= unchecked((long) 0x8000000000000000L);
 				max ^= unchecked((long) 0x8000000000000000L);
-				//System.out.println("new Long(0x"+Long.toHexString(min>>>shift)+"L),new Long(0x"+Long.toHexString(max>>>shift)+"L),");
+				//System.out.println("Long.valueOf(0x"+Long.toHexString(min>>>shift)+"L),Long.valueOf(0x"+Long.toHexString(max>>>shift)+"L)/*shift="+shift+"*/,");
                 neededShifts.MoveNext();
                 Assert.AreEqual(((Int32)neededShifts.Current), shift, "shift");
                 neededBounds.MoveNext();
-                try
-                {
-                    Assert.AreEqual(neededBounds.Current, (ulong)SupportClass.Number.URShift(min, shift), "inner min bound");
-                }
-                catch (OverflowException)
-                {
-                    Assert.AreEqual((long)neededBounds.Current, SupportClass.Number.URShift(min, shift), "inner min bound");
-                }
-                neededBounds.MoveNext();
-                try
+                unchecked
                 {
-                    Assert.AreEqual(neededBounds.Current, (ulong)SupportClass.Number.URShift(max, shift), "inner max bound");
+                    Assert.AreEqual((long)neededBounds.Current, Number.URShift(min, shift), "inner min bound");
+                    neededBounds.MoveNext();
+                    Assert.AreEqual((long)neededBounds.Current, Number.URShift(max, shift), "inner max bound");
                 }
-                catch (OverflowException)
-                {
-                    Assert.AreEqual((long)neededBounds.Current, SupportClass.Number.URShift(max, shift), "inner max bound");
-                }
-            }
+			}
 		}
 
 		private class AnonymousClassIntRangeBuilder:NumericUtils.IntRangeBuilder
 		{
-			public AnonymousClassIntRangeBuilder(int lower, int upper, bool useBitSet, Lucene.Net.Util.OpenBitSet bits, System.Collections.IEnumerator neededBounds, System.Collections.IEnumerator neededShifts,TestNumericUtils enclosingInstance)
+            public AnonymousClassIntRangeBuilder(int lower, int upper, bool useBitSet, Lucene.Net.Util.OpenBitSet bits, IEnumerator<int> neededBounds, IEnumerator<int> neededShifts, TestNumericUtils enclosingInstance)
 			{
                 InitBlock(lower, upper, useBitSet, bits, neededBounds, neededShifts,enclosingInstance);
 			}
-			private void  InitBlock(int lower, int upper, bool useBitSet, Lucene.Net.Util.OpenBitSet bits, System.Collections.IEnumerator neededBounds, System.Collections.IEnumerator neededShifts,TestNumericUtils enclosingInstance)
+            private void InitBlock(int lower, int upper, bool useBitSet, Lucene.Net.Util.OpenBitSet bits, IEnumerator<int> neededBounds, IEnumerator<int> neededShifts, TestNumericUtils enclosingInstance)
 			{
 				this.lower = lower;
 				this.upper = upper;
@@ -115,8 +106,8 @@ namespace Lucene.Net.Util
 			private int upper;
 			private bool useBitSet;
 			private Lucene.Net.Util.OpenBitSet bits;
-			private System.Collections.IEnumerator neededBounds;
-            private System.Collections.IEnumerator neededShifts;
+            private IEnumerator<int> neededBounds;
+            private IEnumerator<int> neededShifts;
 			private TestNumericUtils enclosingInstance;
 			public TestNumericUtils Enclosing_Instance
 			{
@@ -145,9 +136,9 @@ namespace Lucene.Net.Util
                 Assert.AreEqual(((int)neededShifts.Current), shift,"shift");
 				//System.out.println("new Integer(0x"+Integer.toHexString(min>>>shift)+"),new Integer(0x"+Integer.toHexString(max>>>shift)+"),");
                 neededBounds.MoveNext();
-				Assert.AreEqual(((System.Int32) neededBounds.Current), SupportClass.Number.URShift(min, shift), "inner min bound");
+				Assert.AreEqual(((System.Int32) neededBounds.Current), Number.URShift(min, shift), "inner min bound");
                 neededBounds.MoveNext();
-				Assert.AreEqual(((System.Int32) neededBounds.Current), SupportClass.Number.URShift(max, shift), "inner max bound");
+				Assert.AreEqual(((System.Int32) neededBounds.Current), Number.URShift(max, shift), "inner max bound");
 			}
 		}
 		
@@ -320,88 +311,90 @@ namespace Lucene.Net.Util
 		// INFO: Tests for trieCodeLong()/trieCodeInt() not needed because implicitely tested by range filter tests
 		
 		/// <summary>Note: The neededBounds iterator must be unsigned (easier understanding what's happening) </summary>
-		internal virtual void  AssertLongRangeSplit(long lower, long upper, int precisionStep, bool useBitSet, System.Collections.IEnumerator neededBounds, System.Collections.IEnumerator neededShifts)
+        internal virtual void AssertLongRangeSplit(long lower, long upper, int precisionStep, bool useBitSet, IEnumerator<long> neededBounds, IEnumerator<int> neededShifts)
 		{
-			OpenBitSet bits = useBitSet?new OpenBitSet(upper - lower + 1):null;
-			
-			NumericUtils.SplitLongRange(new AnonymousClassLongRangeBuilder(lower, upper, useBitSet, bits, neededBounds,neededShifts,this), precisionStep, lower, upper);
-			
-			if (useBitSet)
-			{
-				// after flipping all bits in the range, the cardinality should be zero
-				bits.Flip(0, upper - lower + 1);
-				Assert.IsTrue(bits.IsEmpty(), "The sub-range concenated should match the whole range");
-			}
+		    OpenBitSet bits = useBitSet ? new OpenBitSet(upper - lower + 1) : null;
+
+		    NumericUtils.SplitLongRange(
+		        new AnonymousClassLongRangeBuilder(lower, upper, useBitSet, bits, neededBounds, neededShifts, this),
+		        precisionStep, lower, upper);
+
+		    if (useBitSet)
+		    {
+		        // after flipping all bits in the range, the cardinality should be zero
+		        bits.Flip(0, upper - lower + 1);
+		        Assert.IsTrue(bits.IsEmpty(), "The sub-range concenated should match the whole range");
+		    }
 		}
-		
-         /** LUCENE-2541: NumericRangeQuery errors with endpoints near long min and max values */
+
+        /** LUCENE-2541: NumericRangeQuery errors with endpoints near long min and max values */
         [Test]
         public void TestLongExtremeValues()
         {
             // upper end extremes
             AssertLongRangeSplit(long.MaxValue, long.MaxValue, 1, true,
-                new ulong[] { 0xffffffffffffffffL, 0xffffffffffffffffL }.GetEnumerator(),
-                new int[] { 0 }.GetEnumerator());
+                new ulong[] { 0xffffffffffffffffL, 0xffffffffffffffffL }.Cast<long>().GetEnumerator(),
+                new int[] { 0 }.AsEnumerable().GetEnumerator());
 
             AssertLongRangeSplit(long.MaxValue, long.MaxValue, 2, true,
-                new ulong[] { 0xffffffffffffffffL, 0xffffffffffffffffL }.GetEnumerator(),
-                new int[] { 0 }.GetEnumerator());
+                new ulong[] { 0xffffffffffffffffL, 0xffffffffffffffffL }.Cast<long>().GetEnumerator(),
+                new int[] { 0 }.AsEnumerable().GetEnumerator());
 
             AssertLongRangeSplit(long.MaxValue, long.MaxValue, 4, true,
-                new ulong[] { 0xffffffffffffffffL, 0xffffffffffffffffL }.GetEnumerator(),
-                new int[] { 0 }.GetEnumerator());
+                new ulong[] { 0xffffffffffffffffL, 0xffffffffffffffffL }.Cast<long>().GetEnumerator(),
+                new int[] { 0 }.AsEnumerable().GetEnumerator());
 
             AssertLongRangeSplit(long.MaxValue, long.MaxValue, 6, true,
-                new ulong[] { 0xffffffffffffffffL, 0xffffffffffffffffL }.GetEnumerator(),
-                new int[] { 0 }.GetEnumerator());
+                new ulong[] { 0xffffffffffffffffL, 0xffffffffffffffffL }.Cast<long>().GetEnumerator(),
+                new int[] { 0 }.AsEnumerable().GetEnumerator());
 
             AssertLongRangeSplit(long.MaxValue, long.MaxValue, 8, true,
-                new ulong[] { 0xffffffffffffffffL, 0xffffffffffffffffL }.GetEnumerator(),
-                new int[] { 0 }.GetEnumerator());
+                new ulong[] { 0xffffffffffffffffL, 0xffffffffffffffffL }.Cast<long>().GetEnumerator(),
+                new int[] { 0 }.AsEnumerable().GetEnumerator());
 
             AssertLongRangeSplit(long.MaxValue, long.MaxValue, 64, true,
-                new ulong[] { 0xffffffffffffffffL, 0xffffffffffffffffL }.GetEnumerator(),
-                new int[] { 0 }.GetEnumerator());
+                new ulong[] { 0xffffffffffffffffL, 0xffffffffffffffffL }.Cast<long>().GetEnumerator(),
+                new int[] { 0 }.AsEnumerable().GetEnumerator());
             
             AssertLongRangeSplit(long.MaxValue - 0xfL, long.MaxValue, 4, true,
-                new ulong[] { 0xfffffffffffffffL, 0xfffffffffffffffL }.GetEnumerator(),
-                new int[] { 4 }.GetEnumerator());
+                new ulong[] { 0xfffffffffffffffL, 0xfffffffffffffffL }.Cast<long>().GetEnumerator(),
+                new int[] { 4 }.AsEnumerable().GetEnumerator());
             AssertLongRangeSplit(long.MaxValue - 0x10L, long.MaxValue, 4, true,
-                new ulong[] { 0xffffffffffffffefL, 0xffffffffffffffefL, 0xfffffffffffffffL, 0xfffffffffffffffL }.GetEnumerator(),
-                new int[] { 0, 4 }.GetEnumerator());
+                new ulong[] { 0xffffffffffffffefL, 0xffffffffffffffefL, 0xfffffffffffffffL, 0xfffffffffffffffL }.Cast<long>().GetEnumerator(),
+                new int[] { 0, 4 }.AsEnumerable().GetEnumerator());
 
             // lower end extremes
             AssertLongRangeSplit(long.MinValue, long.MinValue, 1, true,
-                new long[] { 0x0000000000000000L, 0x0000000000000000L }.GetEnumerator(),
-                new int[] { 0 }.GetEnumerator());
+                new long[] { 0x0000000000000000L, 0x0000000000000000L }.Cast<long>().GetEnumerator(),
+                new int[] { 0 }.AsEnumerable().GetEnumerator());
 
             AssertLongRangeSplit(long.MinValue, long.MinValue, 2, true,
-                new long[] { 0x0000000000000000L, 0x0000000000000000L }.GetEnumerator(),
-                new int[] { 0 }.GetEnumerator());
+                new long[] { 0x0000000000000000L, 0x0000000000000000L }.Cast<long>().GetEnumerator(),
+                new int[] { 0 }.AsEnumerable().GetEnumerator());
 
             AssertLongRangeSplit(long.MinValue, long.MinValue, 4, true,
-                new long[] { 0x0000000000000000L, 0x0000000000000000L }.GetEnumerator(),
-                new int[] { 0 }.GetEnumerator());
+                new long[] { 0x0000000000000000L, 0x0000000000000000L }.Cast<long>().GetEnumerator(),
+                new int[] { 0 }.AsEnumerable().GetEnumerator());
 
             AssertLongRangeSplit(long.MinValue, long.MinValue, 6, true,
-                new long[] { 0x0000000000000000L, 0x0000000000000000L }.GetEnumerator(),
-                new int[] { 0 }.GetEnumerator());
+                new long[] { 0x0000000000000000L, 0x0000000000000000L }.Cast<long>().GetEnumerator(),
+                new int[] { 0 }.AsEnumerable().GetEnumerator());
 
             AssertLongRangeSplit(long.MinValue, long.MinValue, 8, true,
-                new long[] { 0x0000000000000000L, 0x0000000000000000L }.GetEnumerator(),
-                new int[] { 0 }.GetEnumerator());
+                new long[] { 0x0000000000000000L, 0x0000000000000000L }.Cast<long>().GetEnumerator(),
+                new int[] { 0 }.AsEnumerable().GetEnumerator());
 
             AssertLongRangeSplit(long.MinValue, long.MinValue, 64, true,
-                new long[] { 0x0000000000000000L, 0x0000000000000000L }.GetEnumerator(),
-                new int[] { 0 }.GetEnumerator());
+                new long[] { 0x0000000000000000L, 0x0000000000000000L }.Cast<long>().GetEnumerator(),
+                new int[] { 0 }.AsEnumerable().GetEnumerator());
 
 
             AssertLongRangeSplit(long.MinValue, long.MinValue + 0xfL, 4, true,
-                new long[] { 0x000000000000000L, 0x000000000000000L }.GetEnumerator(),
-                new int[] { 4 }.GetEnumerator());
+                new long[] { 0x000000000000000L, 0x000000000000000L }.Cast<long>().GetEnumerator(),
+                new int[] { 4 }.AsEnumerable().GetEnumerator());
             AssertLongRangeSplit(long.MinValue, long.MinValue + 0x10L, 4, true,
-                new long[] { 0x0000000000000010L, 0x0000000000000010L, 0x000000000000000L, 0x000000000000000L }.GetEnumerator(),
-                new int[] { 0, 4 }.GetEnumerator());
+                new long[] { 0x0000000000000010L, 0x0000000000000010L, 0x000000000000000L, 0x000000000000000L }.Cast<long>().GetEnumerator(),
+                new int[] { 0, 4 }.AsEnumerable().GetEnumerator());
         }
 
         [Test]
@@ -448,7 +441,7 @@ namespace Lucene.Net.Util
                 if (random.Next(2) == 1) val += random.Next(100) - 50;
                 if (random.Next(2) == 1) val = ~val;
                 if (random.Next(2) == 1) val = val << 1;
-                if (random.Next(2) == 1) val = SupportClass.Number.URShift(val, 1);
+                if (random.Next(2) == 1) val = Number.URShift(val, 1);
             }
 
             return val;
@@ -459,39 +452,66 @@ namespace Lucene.Net.Util
 		public void  TestSplitLongRange()
 		{
 			// a hard-coded "standard" range
-			AssertLongRangeSplit(- 5000L, 9500L, 4, true, new System.Collections.ArrayList(new System.Int64[]{0x7fffffffffffec78L, 0x7fffffffffffec7fL, unchecked((long) (0x8000000000002510L)), unchecked((long) (0x800000000000251cL)), 0x7fffffffffffec8L, 0x7fffffffffffecfL, 0x800000000000250L, 0x800000000000250L, 0x7fffffffffffedL, 0x7fffffffffffefL, 0x80000000000020L, 0x80000000000024L, 0x7ffffffffffffL, 0x8000000000001L}).GetEnumerator(),new int[]{0,0,4,4,8,8,12}.GetEnumerator());
+            AssertLongRangeSplit(- 5000L, 9500L, 4, true,
+                                 new System.Int64[]
+                                     {
+                                         0x7fffffffffffec78L, 0x7fffffffffffec7fL, unchecked((long) (0x8000000000002510L)),
+                                         unchecked((long) (0x800000000000251cL)), 0x7fffffffffffec8L, 0x7fffffffffffecfL,
+                                         0x800000000000250L, 0x800000000000250L, 0x7fffffffffffedL, 0x7fffffffffffefL,
+                                         0x80000000000020L, 0x80000000000024L, 0x7ffffffffffffL, 0x8000000000001L
+                                     }.Cast<long>().GetEnumerator(), new int[] {0, 0, 4, 4, 8, 8, 12}.Cast<int>().GetEnumerator());
 			
 			// the same with no range splitting
-            AssertLongRangeSplit(-5000L, 9500L, 64, true, new System.Collections.ArrayList(new System.Int64[] { 0x7fffffffffffec78L, unchecked((long)(0x800000000000251cL)) }).GetEnumerator(), new int[] { 0 }.GetEnumerator());
+            AssertLongRangeSplit(-5000L, 9500L, 64, true,
+                                 new System.Int64[] {0x7fffffffffffec78L, unchecked((long) (0x800000000000251cL))}.Cast
+                                     <long>().GetEnumerator(), new int[] { 0 }.Cast<int>().GetEnumerator());
 			
 			// this tests optimized range splitting, if one of the inner bounds
 			// is also the bound of the next lower precision, it should be used completely
-            AssertLongRangeSplit(0L, 1024L + 63L, 4, true, new System.Collections.ArrayList(new System.Int64[] { 0x800000000000040L, 0x800000000000043L, 0x80000000000000L, 0x80000000000003L }).GetEnumerator(), new int[] {4,8}.GetEnumerator());
+            AssertLongRangeSplit(0L, 1024L + 63L, 4, true,
+                                 new System.Int64[]
+                                     {0x800000000000040L, 0x800000000000043L, 0x80000000000000L, 0x80000000000003L}.Cast
+                                     <long>().GetEnumerator(), new int[] { 4, 8 }.Cast<int>().GetEnumerator());
 			
 			// the full long range should only consist of a lowest precision range; no bitset testing here, as too much memory needed :-)
-            AssertLongRangeSplit(System.Int64.MinValue, System.Int64.MaxValue, 8, false, new System.Collections.ArrayList(new System.Int64[] { 0x00L, 0xffL }).GetEnumerator(), new int[] {56}.GetEnumerator());
+            AssertLongRangeSplit(System.Int64.MinValue, System.Int64.MaxValue, 8, false,
+                                 new System.Int64[] {0x00L, 0xffL}.Cast<long>().GetEnumerator(),
+                                 new int[] { 56 }.Cast<int>().GetEnumerator());
 			
 			// the same with precisionStep=4
-            AssertLongRangeSplit(System.Int64.MinValue, System.Int64.MaxValue, 4, false, new System.Collections.ArrayList(new System.Int64[] { 0x0L, 0xfL }).GetEnumerator(), new int[] {60}.GetEnumerator());
+            AssertLongRangeSplit(System.Int64.MinValue, System.Int64.MaxValue, 4, false,
+                                 new System.Int64[] {0x0L, 0xfL}.Cast<long>().GetEnumerator(),
+                                 new int[] { 60 }.Cast<int>().GetEnumerator());
 			
 			// the same with precisionStep=2
-            AssertLongRangeSplit(System.Int64.MinValue, System.Int64.MaxValue, 2, false, new System.Collections.ArrayList(new System.Int64[] { 0x0L, 0x3L }).GetEnumerator(), new int[] {62}.GetEnumerator());
+            AssertLongRangeSplit(System.Int64.MinValue, System.Int64.MaxValue, 2, false,
+                                 new System.Int64[] {0x0L, 0x3L}.Cast<long>().GetEnumerator(),
+                                 new int[] {62}.Cast<int>().GetEnumerator());
 			
 			// the same with precisionStep=1
-            AssertLongRangeSplit(System.Int64.MinValue, System.Int64.MaxValue, 1, false, new System.Collections.ArrayList(new System.Int64[] { 0x0L, 0x1L }).GetEnumerator(), new int[] {63}.GetEnumerator());
+            AssertLongRangeSplit(System.Int64.MinValue, System.Int64.MaxValue, 1, false,
+                                 new System.Int64[] {0x0L, 0x1L}.ToList().GetEnumerator(),
+                                 new int[] {63}.Cast<int>().GetEnumerator());
 			
 			// a inverse range should produce no sub-ranges
-            AssertLongRangeSplit(9500L, -5000L, 4, false, ((System.Collections.IList)System.Collections.ArrayList.ReadOnly(new System.Collections.ArrayList())).GetEnumerator(), new int[] { }.GetEnumerator());
+            AssertLongRangeSplit(9500L, -5000L, 4, false,
+                                 Enumerable.Empty<long>().GetEnumerator(),
+                                 new int[] {}.Cast<int>().GetEnumerator());
 			
 			// a 0-length range should reproduce the range itsself
-            AssertLongRangeSplit(9500L, 9500L, 4, false, new System.Collections.ArrayList(new System.Int64[] { unchecked((long)(0x800000000000251cL)), unchecked((long)(0x800000000000251cL)) }).GetEnumerator(), new int[] {0}.GetEnumerator());
+            AssertLongRangeSplit(9500L, 9500L, 4, false, new long[]
+                                                             {
+                                                                 unchecked((long) (0x800000000000251cL)),
+                                                                 unchecked((long) (0x800000000000251cL))
+                                                             }.Cast<long>().GetEnumerator(),
+                                 new int[] {0}.Cast<int>().GetEnumerator());
 		}
 		
 
 		/// <summary>Note: The neededBounds iterator must be unsigned (easier understanding what's happening) </summary>
-		protected internal virtual void  AssertIntRangeSplit(int lower, int upper, int precisionStep, bool useBitSet, System.Collections.IEnumerator neededBounds,System.Collections.IEnumerator neededShifts)
+		protected internal virtual void  AssertIntRangeSplit(int lower, int upper, int precisionStep, bool useBitSet, IEnumerator<int> neededBounds, IEnumerator<int> neededShifts)
 		{
-			OpenBitSet bits = useBitSet?new OpenBitSet(upper - lower + 1):null;
+		    OpenBitSet bits = useBitSet ? new OpenBitSet(upper - lower + 1) : null;
 
             NumericUtils.SplitIntRange(new AnonymousClassIntRangeBuilder(lower, upper, useBitSet, bits, neededBounds, neededShifts,this), precisionStep, lower, upper);
 			
@@ -507,32 +527,57 @@ namespace Lucene.Net.Util
 		public virtual void  TestSplitIntRange()
 		{
 			// a hard-coded "standard" range
-			AssertIntRangeSplit(- 5000, 9500, 4, true, new System.Collections.ArrayList(new System.Int32[]{0x7fffec78, 0x7fffec7f, unchecked((System.Int32) 0x80002510), unchecked((System.Int32) 0x8000251c), 0x7fffec8, 0x7fffecf, 0x8000250, 0x8000250, 0x7fffed, 0x7fffef, 0x800020, 0x800024, 0x7ffff, 0x80001}).GetEnumerator(),new int[]{0,0,4,4,8,8,12}.GetEnumerator());
+            AssertIntRangeSplit(- 5000, 9500, 4, true,
+                                new System.Int32[]
+                                    {
+                                        0x7fffec78, 0x7fffec7f, unchecked((System.Int32) 0x80002510),
+                                        unchecked((System.Int32) 0x8000251c), 0x7fffec8, 0x7fffecf, 0x8000250, 0x8000250,
+                                        0x7fffed, 0x7fffef, 0x800020, 0x800024, 0x7ffff, 0x80001
+                                    }.Cast<int>().GetEnumerator
+                                    (), new int[] { 0, 0, 4, 4, 8, 8, 12 }.Cast<int>().GetEnumerator());
 			
 			// the same with no range splitting
-            AssertIntRangeSplit(-5000, 9500, 32, true, new System.Collections.ArrayList(new System.Int32[] { 0x7fffec78, unchecked((System.Int32)0x8000251c) }).GetEnumerator(), new int[] { 0}.GetEnumerator());
+            AssertIntRangeSplit(-5000, 9500, 32, true,
+                                new System.Int32[] {0x7fffec78, unchecked((System.Int32) 0x8000251c)}.Cast<int>().
+                                    GetEnumerator(), new int[] { 0 }.Cast<int>().GetEnumerator());
 			
 			// this tests optimized range splitting, if one of the inner bounds
 			// is also the bound of the next lower precision, it should be used completely
-            AssertIntRangeSplit(0, 1024 + 63, 4, true, new System.Collections.ArrayList(new System.Int32[] { 0x8000040, 0x8000043, 0x800000, 0x800003 }).GetEnumerator(), new int[] {4,8 }.GetEnumerator());
+            AssertIntRangeSplit(0, 1024 + 63, 4, true,
+                                new System.Int32[] {0x8000040, 0x8000043, 0x800000, 0x800003}.Cast<int>().GetEnumerator(),
+                                new int[] { 4, 8 }.Cast<int>().GetEnumerator());
 			
 			// the full int range should only consist of a lowest precision range; no bitset testing here, as too much memory needed :-)
-            AssertIntRangeSplit(System.Int32.MinValue, System.Int32.MaxValue, 8, false, new System.Collections.ArrayList(new System.Int32[] { 0x00, 0xff }).GetEnumerator(), new int[] { 24}.GetEnumerator());
+            AssertIntRangeSplit(System.Int32.MinValue, System.Int32.MaxValue, 8, false,
+                                new System.Int32[] {0x00, 0xff}.Cast<int>().GetEnumerator(),
+                                new int[] { 24 }.Cast<int>().GetEnumerator());
 			
 			// the same with precisionStep=4
-            AssertIntRangeSplit(System.Int32.MinValue, System.Int32.MaxValue, 4, false, new System.Collections.ArrayList(new System.Int32[] { 0x0, 0xf }).GetEnumerator(), new int[] { 28}.GetEnumerator());
+            AssertIntRangeSplit(System.Int32.MinValue, System.Int32.MaxValue, 4, false,
+                                new System.Int32[] {0x0, 0xf}.Cast<int>().GetEnumerator(),
+                                new int[] {28}.Cast<int>().GetEnumerator());
 			
 			// the same with precisionStep=2
-            AssertIntRangeSplit(System.Int32.MinValue, System.Int32.MaxValue, 2, false, new System.Collections.ArrayList(new System.Int32[] { 0x0, 0x3 }).GetEnumerator(), new int[] {30 }.GetEnumerator());
+            AssertIntRangeSplit(System.Int32.MinValue, System.Int32.MaxValue, 2, false,
+                                new System.Int32[] {0x0, 0x3}.Cast<int>().GetEnumerator(),
+                                new int[] {30}.Cast<int>().GetEnumerator());
 			
 			// the same with precisionStep=1
-            AssertIntRangeSplit(System.Int32.MinValue, System.Int32.MaxValue, 1, false, new System.Collections.ArrayList(new System.Int32[] { 0x0, 0x1 }).GetEnumerator(), new int[] {31 }.GetEnumerator());
+            AssertIntRangeSplit(System.Int32.MinValue, System.Int32.MaxValue, 1, false,
+                                new System.Int32[] {0x0, 0x1}.Cast<int>().GetEnumerator(),
+                                new int[] {31}.Cast<int>().GetEnumerator());
 			
 			// a inverse range should produce no sub-ranges
-            AssertIntRangeSplit(9500, -5000, 4, false, ((System.Collections.IList)System.Collections.ArrayList.ReadOnly(new System.Collections.ArrayList())).GetEnumerator(), new int[] { }.GetEnumerator());
+            AssertIntRangeSplit(9500, -5000, 4, false, Enumerable.Empty<int>().GetEnumerator(),
+                                new int[] {}.Cast<int>().GetEnumerator());
 			
 			// a 0-length range should reproduce the range itsself
-            AssertIntRangeSplit(9500, 9500, 4, false, new System.Collections.ArrayList(new System.Int32[] { unchecked((System.Int32)0x8000251c), unchecked((System.Int32)0x8000251c) }).GetEnumerator(), new int[] {0 }.GetEnumerator());
+            AssertIntRangeSplit(9500, 9500, 4, false, new System.Int32[]
+                                                          {
+                                                              unchecked((System.Int32) 0x8000251c),
+                                                              unchecked((System.Int32) 0x8000251c)
+                                                          }.Cast<int>().GetEnumerator(),
+                                new int[] {0}.Cast<int>().GetEnumerator());
 		}
 	}
 }
\ No newline at end of file

Modified: incubator/lucene.net/trunk/test/core/Util/TestOpenBitSet.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/core/Util/TestOpenBitSet.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/core/Util/TestOpenBitSet.cs (original)
+++ incubator/lucene.net/trunk/test/core/Util/TestOpenBitSet.cs Tue Feb 28 22:43:08 2012
@@ -16,7 +16,7 @@
  */
 
 using System;
-
+using Lucene.Net.Support;
 using NUnit.Framework;
 
 using DocIdSetIterator = Lucene.Net.Search.DocIdSetIterator;
@@ -48,7 +48,7 @@ namespace Lucene.Net.Util
 			int aa = - 1, bb = - 1;
 			do 
 			{
-				aa = SupportClass.BitSetSupport.NextSetBit(a, aa + 1);
+				aa = BitSetSupport.NextSetBit(a, aa + 1);
 				bb = b.NextSetBit(bb + 1);
 				Assert.AreEqual(aa, bb);
 			}
@@ -70,7 +70,7 @@ namespace Lucene.Net.Util
 			OpenBitSetIterator iterator = new OpenBitSetIterator(b);
 			do 
 			{
-				aa = SupportClass.BitSetSupport.NextSetBit(a, aa + 1);
+				aa = BitSetSupport.NextSetBit(a, aa + 1);
 				bb = rand.NextDouble() > 0.5 ? iterator.NextDoc() : iterator.Advance(bb + 1);
 				Assert.AreEqual(aa == - 1?DocIdSetIterator.NO_MORE_DOCS:aa, bb);
 			}
@@ -83,7 +83,7 @@ namespace Lucene.Net.Util
 			OpenBitSetIterator iterator = new OpenBitSetIterator(b);
 			do 
 			{
-				aa = SupportClass.BitSetSupport.NextSetBit(a, aa + 1);
+				aa = BitSetSupport.NextSetBit(a, aa + 1);
 				bb = rand.NextDouble() > 0.5 ? iterator.NextDoc() : iterator.Advance(bb + 1);
 				Assert.AreEqual(aa == - 1?DocIdSetIterator.NO_MORE_DOCS:aa, bb);
 			}
@@ -219,7 +219,7 @@ namespace Lucene.Net.Util
 				{
                     Assert.AreEqual(a.Equals(a0), b.Equals(b0));
 
-                    Assert.AreEqual(SupportClass.BitSetSupport.Cardinality(a), b.Cardinality());
+                    Assert.AreEqual(BitSetSupport.Cardinality(a), b.Cardinality());
 
                     // {{dougsale-2.4.0}}
                     //
@@ -293,10 +293,10 @@ namespace Lucene.Net.Util
                     DoIterate(a_xor, b_xor, mode);
                     DoIterate(a_andn, b_andn, mode);
 
-                    Assert.AreEqual(SupportClass.BitSetSupport.Cardinality(a_and), b_and.Cardinality());
-                    Assert.AreEqual(SupportClass.BitSetSupport.Cardinality(a_or), b_or.Cardinality());
-                    Assert.AreEqual(SupportClass.BitSetSupport.Cardinality(a_xor), b_xor.Cardinality());
-                    Assert.AreEqual(SupportClass.BitSetSupport.Cardinality(a_andn), b_andn.Cardinality());
+                    Assert.AreEqual(BitSetSupport.Cardinality(a_and), b_and.Cardinality());
+                    Assert.AreEqual(BitSetSupport.Cardinality(a_or), b_or.Cardinality());
+                    Assert.AreEqual(BitSetSupport.Cardinality(a_xor), b_xor.Cardinality());
+                    Assert.AreEqual(BitSetSupport.Cardinality(a_andn), b_andn.Cardinality());
 
                     // test non-mutating popcounts
                     Assert.AreEqual(b_and.Cardinality(), OpenBitSet.IntersectionCount(b, b0));

Modified: incubator/lucene.net/trunk/test/core/Util/TestPriorityQueue.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/core/Util/TestPriorityQueue.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/core/Util/TestPriorityQueue.cs (original)
+++ incubator/lucene.net/trunk/test/core/Util/TestPriorityQueue.cs Tue Feb 28 22:43:08 2012
@@ -25,20 +25,19 @@ namespace Lucene.Net.Util
 	[TestFixture]
 	public class TestPriorityQueue:LuceneTestCase
 	{
-		
-		private class IntegerQueue:PriorityQueue
-		{
-			public IntegerQueue(int count):base()
-			{
-				Initialize(count);
-			}
-			
-			public override bool LessThan(System.Object a, System.Object b)
-			{
-				return ((System.Int32) a) < ((System.Int32) b);
-			}
-		}
-		
+        private class IntegerQueue : PriorityQueue<int?>
+        {
+            public IntegerQueue(int count)
+            {
+                Initialize(count);
+            }
+
+            public override bool LessThan(int? a, int? b)
+            {
+                return (a < b);
+            }
+        }
+
 		[Test]
 		public virtual void  TestPQ()
 		{
@@ -47,14 +46,15 @@ namespace Lucene.Net.Util
 		
 		public static void  TestPQ(int count, System.Random gen)
 		{
-			PriorityQueue pq = new IntegerQueue(count);
-			int sum = 0, sum2 = 0;
+			PriorityQueue<int?> pq = new IntegerQueue(count);
+		    int sum = 0;
+            int? sum2 = 0;
 			
 			for (int i = 0; i < count; i++)
 			{
 				int next = gen.Next();
 				sum += next;
-				pq.Put((System.Object) next);
+				pq.Add(next);
 			}
 			
 			//      Date end = new Date();
@@ -64,10 +64,10 @@ namespace Lucene.Net.Util
 			
 			//      start = new Date();
 			
-			int last = System.Int32.MinValue;
+			int? last = int.MinValue;
 			for (int i = 0; i < count; i++)
 			{
-				System.Int32 next = (System.Int32) pq.Pop();
+				int? next = pq.Pop();
 				Assert.IsTrue(next >= last);
 				last = next;
 				sum2 += last;
@@ -83,10 +83,10 @@ namespace Lucene.Net.Util
 		[Test]
 		public virtual void  TestClear()
 		{
-			PriorityQueue pq = new IntegerQueue(3);
-			pq.Put((System.Object) 2);
-			pq.Put((System.Object) 3);
-			pq.Put((System.Object) 1);
+			PriorityQueue<int?> pq = new IntegerQueue(3);
+			pq.Add(2);
+            pq.Add(3);
+            pq.Add(1);
 			Assert.AreEqual(3, pq.Size());
 			pq.Clear();
 			Assert.AreEqual(0, pq.Size());
@@ -95,22 +95,22 @@ namespace Lucene.Net.Util
 		[Test]
 		public virtual void  TestFixedSize()
 		{
-			PriorityQueue pq = new IntegerQueue(3);
-			pq.Insert((System.Object) 2);
-			pq.Insert((System.Object) 3);
-			pq.Insert((System.Object) 1);
-			pq.Insert((System.Object) 5);
-			pq.Insert((System.Object) 7);
-			pq.Insert((System.Object) 1);
+			PriorityQueue<int?> pq = new IntegerQueue(3);
+			pq.InsertWithOverflow(2);
+            pq.InsertWithOverflow(3);
+            pq.InsertWithOverflow(1);
+            pq.InsertWithOverflow(5);
+            pq.InsertWithOverflow(7);
+            pq.InsertWithOverflow(1);
 			Assert.AreEqual(3, pq.Size());
-			Assert.AreEqual(3, ((System.Int32) pq.Top()));
+			Assert.AreEqual(3, pq.Top());
 		}
 		
 		[Test]
 		public virtual void  TestInsertWithOverflow()
 		{
 			int size = 4;
-			PriorityQueue pq = new IntegerQueue(size);
+			PriorityQueue<int?> pq = new IntegerQueue(size);
 			System.Int32 i1 = 2;
 			System.Int32 i2 = 3;
 			System.Int32 i3 = 1;
@@ -125,7 +125,7 @@ namespace Lucene.Net.Util
 			Assert.IsTrue((int) pq.InsertWithOverflow(i5) == i3); // i3 should have been dropped
 			Assert.IsTrue((int) pq.InsertWithOverflow(i6) == i6); // i6 should not have been inserted
 			Assert.AreEqual(size, pq.Size());
-			Assert.AreEqual(2, ((System.Int32) pq.Top()));
+			Assert.AreEqual(2, pq.Top());
 		}
 	}
 }
\ No newline at end of file

Modified: incubator/lucene.net/trunk/test/core/Util/_TestUtil.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/core/Util/_TestUtil.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/core/Util/_TestUtil.cs (original)
+++ incubator/lucene.net/trunk/test/core/Util/_TestUtil.cs Tue Feb 28 22:43:08 2012
@@ -16,7 +16,8 @@
  */
 
 using System;
-
+using System.IO;
+using Lucene.Net.Support;
 using NUnit.Framework;
 
 using CheckIndex = Lucene.Net.Index.CheckIndex;
@@ -34,64 +35,67 @@ namespace Lucene.Net.Util
 		/// <summary>Returns temp dir, containing String arg in its name;
 		/// does not create the directory. 
 		/// </summary>
-		public static System.IO.FileInfo GetTempDir(System.String desc)
+		public static System.IO.DirectoryInfo GetTempDir(System.String desc)
 		{
 			System.String tempDir = System.IO.Path.GetTempPath();
 			if (tempDir == null)
 				throw new System.SystemException("java.io.tmpdir undefined, cannot run test");
-			return new System.IO.FileInfo(System.IO.Path.Combine(tempDir, desc + "." + (new System.Random()).Next(System.Int32.MaxValue)));
-		}
-		
-		public static void  RmDir(System.IO.FileInfo dir)
-		{
-			bool tmpBool;
-			if (System.IO.File.Exists(dir.FullName))
-				tmpBool = true;
-			else
-				tmpBool = System.IO.Directory.Exists(dir.FullName);
-			if (tmpBool)
-			{
-				System.IO.FileInfo[] files = SupportClass.FileSupport.GetFiles(dir);
-				for (int i = 0; i < files.Length; i++)
-				{
-					bool tmpBool2;
-					if (System.IO.File.Exists(files[i].FullName))
-					{
-						System.IO.File.Delete(files[i].FullName);
-						tmpBool2 = true;
-					}
-					else if (System.IO.Directory.Exists(files[i].FullName))
-					{
-						System.IO.Directory.Delete(files[i].FullName);
-						tmpBool2 = true;
-					}
-					else
-						tmpBool2 = false;
-					if (!tmpBool2)
-					{
-						throw new System.IO.IOException("could not delete " + files[i]);
-					}
-				}
-				bool tmpBool3;
-				if (System.IO.File.Exists(dir.FullName))
-				{
-					System.IO.File.Delete(dir.FullName);
-					tmpBool3 = true;
-				}
-				else if (System.IO.Directory.Exists(dir.FullName))
-				{
-					System.IO.Directory.Delete(dir.FullName);
-					tmpBool3 = true;
-				}
-				else
-					tmpBool3 = false;
-				bool generatedAux = tmpBool3;
-			}
+            return new System.IO.DirectoryInfo(System.IO.Path.Combine(tempDir, desc + "." + (new System.Random()).Next(System.Int32.MaxValue)));
 		}
+
+        // TODO: This was a bit overkill? -cc
+        public static void RmDir(System.IO.DirectoryInfo dir)
+        {
+            RmDir(dir.FullName);
+            //bool tmpBool;
+            //if (System.IO.File.Exists(dir.FullName))
+            //    tmpBool = true;
+            //else
+            //    tmpBool = System.IO.Directory.Exists(dir.FullName);
+            //if (tmpBool)
+            //{
+            //    System.IO.FileInfo[] files = FileSupport.GetFiles(dir);
+            //    for (int i = 0; i < files.Length; i++)
+            //    {
+            //        bool tmpBool2;
+            //        if (System.IO.File.Exists(files[i].FullName))
+            //        {
+            //            System.IO.File.Delete(files[i].FullName);
+            //            tmpBool2 = true;
+            //        }
+            //        else if (System.IO.Directory.Exists(files[i].FullName))
+            //        {
+            //            System.IO.Directory.Delete(files[i].FullName);
+            //            tmpBool2 = true;
+            //        }
+            //        else
+            //            tmpBool2 = false;
+            //        if (!tmpBool2)
+            //        {
+            //            throw new System.IO.IOException("could not delete " + files[i]);
+            //        }
+            //    }
+            //    bool tmpBool3;
+            //    if (System.IO.File.Exists(dir.FullName))
+            //    {
+            //        System.IO.File.Delete(dir.FullName);
+            //        tmpBool3 = true;
+            //    }
+            //    else if (System.IO.Directory.Exists(dir.FullName))
+            //    {
+            //        System.IO.Directory.Delete(dir.FullName);
+            //        tmpBool3 = true;
+            //    }
+            //    else
+            //        tmpBool3 = false;
+            //    bool generatedAux = tmpBool3;
+            //}
+        }
 		
 		public static void  RmDir(System.String dir)
-		{
-			RmDir(new System.IO.FileInfo(dir));
+        {
+            if(System.IO.Directory.Exists(dir))
+                System.IO.Directory.Delete(dir, true);
 		}
 		
 		public static void  SyncConcurrentMerges(IndexWriter writer)



Mime
View raw message