Exemple #1
0
        public virtual void TestEvilSearcherFactory()
        {
            Random            random = Random;
            Directory         dir    = NewDirectory();
            RandomIndexWriter w      = new RandomIndexWriter(random, dir);

            w.Commit();

            IndexReader other = DirectoryReader.Open(dir);

            SearcherFactory theEvilOne = new SearcherFactoryAnonymousClass3(this, other);

            try
            {
                new SearcherManager(dir, theEvilOne);
            }
            catch (Exception ise) when(ise.IsIllegalStateException())
            {
                // expected
            }
            try
            {
                new SearcherManager(w.IndexWriter, random.NextBoolean(), theEvilOne);
            }
            catch (Exception ise) when(ise.IsIllegalStateException())
            {
                // expected
            }
            w.Dispose();
            other.Dispose();
            dir.Dispose();
        }
Exemple #2
0
        public virtual void TestEvilSearcherFactory()
        {
            Random            random = Random;
            Directory         dir    = NewDirectory();
            RandomIndexWriter w      = new RandomIndexWriter(
#if FEATURE_INSTANCE_TESTDATA_INITIALIZATION
                this,
#endif
                random, dir);

            w.Commit();

            IndexReader other = DirectoryReader.Open(dir);

            SearcherFactory theEvilOne = new SearcherFactoryAnonymousClass3(this, other);

            try
            {
                new SearcherManager(dir, theEvilOne);
            }
#pragma warning disable 168
            catch (InvalidOperationException ise)
#pragma warning restore 168
            {
                // expected
            }
            try
            {
                new SearcherManager(w.IndexWriter, random.NextBoolean(), theEvilOne);
            }
#pragma warning disable 168
            catch (InvalidOperationException ise)
#pragma warning restore 168
            {
                // expected
            }
            w.Dispose();
            other.Dispose();
            dir.Dispose();
        }