You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by jp...@apache.org on 2019/09/05 17:31:42 UTC
[lucene-solr] branch branch_8x updated: Harden Up
TestDiversifiedTopDocsCollector (#858)
This is an automated email from the ASF dual-hosted git repository.
jpountz pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
The following commit(s) were added to refs/heads/branch_8x by this push:
new 321dc80 Harden Up TestDiversifiedTopDocsCollector (#858)
321dc80 is described below
commit 321dc809275b53bd735eddb85f645d415b28d058
Author: Atri Sharma <at...@gmail.com>
AuthorDate: Thu Sep 5 23:01:10 2019 +0530
Harden Up TestDiversifiedTopDocsCollector (#858)
TestDiversifiedTopDocsCollector.testInvalidArguments should check for
exceptions and corresponding messages, post LUCENE-8905
---
.../lucene/search/TestDiversifiedTopDocsCollector.java | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/lucene/misc/src/test/org/apache/lucene/search/TestDiversifiedTopDocsCollector.java b/lucene/misc/src/test/org/apache/lucene/search/TestDiversifiedTopDocsCollector.java
index af2597d..5abe613 100644
--- a/lucene/misc/src/test/org/apache/lucene/search/TestDiversifiedTopDocsCollector.java
+++ b/lucene/misc/src/test/org/apache/lucene/search/TestDiversifiedTopDocsCollector.java
@@ -94,7 +94,11 @@ public class TestDiversifiedTopDocsCollector extends LuceneTestCase {
DiversifiedTopDocsCollector tdc = doDiversifiedSearch(numResults, 15);
// start < 0
- assertEquals(0, tdc.topDocs(-1).scoreDocs.length);
+ IllegalArgumentException expected = expectThrows(IllegalArgumentException.class, () -> {
+ tdc.topDocs(-1);
+ });
+
+ assertEquals("Expected value of starting position is between 0 and 5, got -1", expected.getMessage());
// start > pq.size()
assertEquals(0, tdc.topDocs(numResults + 1).scoreDocs.length);
@@ -103,7 +107,11 @@ public class TestDiversifiedTopDocsCollector extends LuceneTestCase {
assertEquals(0, tdc.topDocs(numResults).scoreDocs.length);
// howMany < 0
- assertEquals(0, tdc.topDocs(0, -1).scoreDocs.length);
+ expected = expectThrows(IllegalArgumentException.class, () -> {
+ tdc.topDocs(0, -1);
+ });
+
+ assertEquals("Number of hits requested must be greater than 0 but value was -1", expected.getMessage());
// howMany == 0
assertEquals(0, tdc.topDocs(0, 0).scoreDocs.length);