Github user tflobbe commented on a diff in the pull request: https://github.com/apache/lucene-solr/pull/202#discussion_r137335651 --- Diff: solr/core/src/test/org/apache/solr/response/TestCustomDocTransformer.java --- @@ -68,6 +69,51 @@ public void testCustomTransformer() throws Exception { "//str[.='xx#title_2#']", "//str[.='xx#title_3#']"); } + + @Test + public void testFinishCallInCustomFinishTransformer() throws Exception { + // Build a simple index + int max = 10; + for(int i=0; i<max; i++) { + SolrInputDocument sdoc = new SolrInputDocument(); + sdoc.addField("id", i); + sdoc.addField("subject", "xx"); + sdoc.addField("title", "title_"+i); + updateJ(jsonAdd(sdoc), null); + } + assertU(commit()); + assertQ(req("q", "*:*"), "//*[@numFound='" + max + "']"); + + assertQ( req( + "q", "*:*", + "fl", "id,[customFinish]", + "rows", String.valueOf(max) + ), + // Check that the concatenated fields make it in the results + "//*[@numFound='" + max + "']"); + + // finish() will double the number of documents + assertEquals(max*2, CustomFinishTransformerFactory.finishTrasformer.counter); + CustomFinishTransformerFactory.finishTrasformer.counter = 0; + + // test binary writer + h.query(req( + "q", "*:*", + "fl", "id,[customFinish]", + "rows", String.valueOf(max), + "wt", "javabin" + )); + assertEquals(max*2, CustomFinishTransformerFactory.finishTrasformer.counter); + + // test that a transformer that throws an exception doesn't affect the other transformers + h.query(req( + "q", "*:*", + "fl", "id,[exceptionFinish],[customFinish]", + "rows", String.valueOf(max), + "wt", "javabin" + )); + assertEquals(max*2, CustomFinishTransformerFactory.finishTrasformer.counter); --- End diff -- Suggestion: Assert that the exception was actually thrown, and add a "ignoreException" to not pollute the logs
--- --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org For additional commands, e-mail: dev-h...@lucene.apache.org