apache/lucenenet

Meta: Add Support unit tests

Opened this issue · 1 comments

Is there an existing issue for this?

  • I have searched the existing issues

Task description

This is a meta-issue that should be broken out into separate issues.

From #914 via @NightOwl888:

I also noticed we don't have tests for the following types in the Support folder:

  • IndexableFieldExtensions
  • ByteArrayOutputStream - Patch to provide ToString() output for MemoryStream.
  • StreamExtensions - These methods were copied from Apache Harmony, and there are tests for them that didn't get ported over. Need to drill down in the code to find the location where these originated from.
  • ReferenceContext<T> - We added this to make it possible to use a using block instead of Acquire() with a try finally around Release(). We should convert this to a ref struct, so it doesn't cause a heap allocation to use. Ref structs cannot implement IDisposable, but the compiler allows a using block if Dispose() exists. Note that ReferenceManagerExtensions can be tested along with it.
    • Addressed in #925.
  • LimitedConcurrencyLevelTaskScheduler - We originally grabbed this from MSDN. We might be able to use tests from Apache Harmony to test this.
  • ReentrantLock - There are tests in Apache Harmony for this.
  • CastTo<T>
  • ExceptionExtensions - Apache Harmony should have tests for these.
  • ListExtensions
  • SystemConsole - .NET should have some tests we can use for this.
  • Arrays - Apache Harmony should have tests we can use for this.
  • AssemblyUtils
  • CollectionExtensions - We can base the tests off of Apache Harmony tests,, but we will need to check ISet<T>, JCG.List<T>, SCG.List<T> and a collection that does not implement ISet<T> or IList<T> (the slow path). All should produce the same result.
  • Collections - There should be tests in Apache Harmony for this.
  • ConcurrentDictionaryWrapper<TKey, TValue> - This is no longer in use, we can probably eliminate it along with the DictionaryExtensions.AsConcurrent() extension method. It may come in handy for a future version of Lucene, though.
  • ConcurrentHashSet<T> - Apache Harmony should have tests for this. Note that not all ISet<T> members are implemented. If they were, we could potentially move this to J2N. Note that 1 test was added in #938, but we should be more thorough than this.
  • ConcurrentSet<T> - This is a concurrent wrapper for any ISet<T>. It should pass the same tests as ConcurrentHashSet<T>. It is mainly used for wrapping LinkedHashSet<T>. If we had a ConcurrentLinkedHashSet<T> in J2N, we could eliminate this class.
  • DictionaryExtensions

@paulirwin - Perhaps eliminating ConcurrentDictionaryWrapper<TKey, TValue> and friends should be a separate issue. Alternatively, it could be rolled into #259. If there is a need for a "ConcurrentLinkedDictionary" in later versions of Lucene, perhaps the implementation should be tagged or put on its own branch so we can recover it later.