diff --git a/solr/src/test/org/apache/solr/update/processor/SignatureUpdateProcessorFactoryTest.java b/solr/src/test/org/apache/solr/update/processor/SignatureUpdateProcessorFactoryTest.java index 597521e7e8b..9d88e716dab 100755 --- a/solr/src/test/org/apache/solr/update/processor/SignatureUpdateProcessorFactoryTest.java +++ b/solr/src/test/org/apache/solr/update/processor/SignatureUpdateProcessorFactoryTest.java @@ -30,6 +30,7 @@ import org.apache.solr.common.util.ContentStream; import org.apache.solr.common.util.ContentStreamBase; import org.apache.solr.core.SolrCore; import org.apache.solr.handler.XmlUpdateRequestHandler; +import org.apache.solr.request.SolrQueryRequest; import org.apache.solr.request.SolrQueryRequestBase; import org.apache.solr.response.SolrQueryResponse; import org.junit.Before; @@ -60,6 +61,15 @@ public class SignatureUpdateProcessorFactoryTest extends SolrTestCaseJ4 { processor = "dedupe"; // set the default that most tests expect } + void checkNumDocs(int n) { + SolrQueryRequest req = req(); + try { + assertEquals(n, req.getSearcher().getReader().numDocs()); + } finally { + req.close(); + } + } + @Test public void testDupeDetection() throws Exception { SolrCore core = h.getCore(); @@ -79,14 +89,14 @@ public class SignatureUpdateProcessorFactoryTest extends SolrTestCaseJ4 { addDoc(commit()); - assertEquals(1l, core.getSearcher().get().getReader().numDocs()); + checkNumDocs(1); addDoc(adoc("id", "3b", "v_t", "Hello Dude man!", "t_field", "fake value galore")); addDoc(commit()); - assertEquals(2l, core.getSearcher().get().getReader().numDocs()); + checkNumDocs(2); assertU(adoc("id", "5a", "name", "ali babi", "v_t", "MMMMM")); @@ -96,14 +106,14 @@ public class SignatureUpdateProcessorFactoryTest extends SolrTestCaseJ4 { addDoc(commit()); - assertEquals(3l, core.getSearcher().get().getReader().numDocs()); + checkNumDocs(3); addDoc(adoc("id", "same", "name", "baryy white", "v_t", "random1")); addDoc(adoc("id", "same", "name", "bishop black", "v_t", "random2")); addDoc(commit()); - assertEquals(4l, core.getSearcher().get().getReader().numDocs()); + checkNumDocs(4); factory.setEnabled(false); } @@ -180,7 +190,7 @@ public class SignatureUpdateProcessorFactoryTest extends SolrTestCaseJ4 { assertU(commit()); - assertEquals(1l, core.getSearcher().get().getReader().numDocs()); + checkNumDocs(1); factory.setEnabled(false); } @@ -191,16 +201,14 @@ public class SignatureUpdateProcessorFactoryTest extends SolrTestCaseJ4 { public void testNonIndexedSignatureField() throws Exception { SolrCore core = h.getCore(); - assertEquals("docs found when none are expected at start", - 0l, core.getSearcher().get().getReader().numDocs()); + checkNumDocs(0); processor = "stored_sig"; addDoc(adoc("id", "2a", "v_t", "Hello Dude man!", "name", "ali babi'")); addDoc(adoc("id", "2b", "v_t", "Hello Dude man!", "name", "ali babi'")); addDoc(commit()); - assertEquals("did not find exepcted docs", - 2l, core.getSearcher().get().getReader().numDocs()); + checkNumDocs(2); } @Test