Ejemplo n.º 1
0
        public virtual void TestSingleCollector()
        {
            // Tests that if a single Collector is input, it is returned (and not MultiCollector).
            DummyCollector dc = new DummyCollector();

            Assert.AreSame(dc, MultiCollector.Wrap(dc));
            Assert.AreSame(dc, MultiCollector.Wrap(dc, null));
        }
Ejemplo n.º 2
0
        public virtual void TestCollector()
        {
            // Tests that the collector delegates calls to input collectors properly.

            // Tests that the collector handles some null collectors well. If it
            // doesn't, an NPE would be thrown.
            DummyCollector[] dcs = new DummyCollector[] { new DummyCollector(), new DummyCollector() };
            ICollector       c   = MultiCollector.Wrap(dcs);

            Assert.IsTrue(c.AcceptsDocsOutOfOrder);
            c.Collect(1);
            c.SetNextReader(null);
            c.SetScorer(null);

            foreach (DummyCollector dc in dcs)
            {
                Assert.IsTrue(dc.AcceptsDocsOutOfOrderCalled);
                Assert.IsTrue(dc.CollectCalled);
                Assert.IsTrue(dc.SetNextReaderCalled);
                Assert.IsTrue(dc.SetScorerCalled);
            }
        }
Ejemplo n.º 3
0
        public virtual void TestNullCollectors()
        {
            // Tests that the collector rejects all null collectors.
            try
            {
                MultiCollector.Wrap(null, null);
                Assert.Fail("only null collectors should not be supported");
            }
            catch (Exception e) when(e.IsIllegalArgumentException())
            {
                // expected
            }

            // Tests that the collector handles some null collectors well. If it
            // doesn't, an NPE would be thrown.
            ICollector c = MultiCollector.Wrap(new DummyCollector(), null, new DummyCollector());

            Assert.IsTrue(c is MultiCollector);
            Assert.IsTrue(c.AcceptsDocsOutOfOrder);
            c.Collect(1);
            c.SetNextReader(null);
            c.SetScorer(null);
        }