Apache Solr open-source search software
SOLR-2470: Added more tests for VelocityResponseWriter (merged from lucene_4x r1449183)
Erik Hatcher1082bf8a71d8
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex a61504bf8ef..ae4c71cf86c 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -197,6 +197,8 @@ Other Changes* SOLR-3060: SurroundQParserPlugin highlighting tests(Ahmet Arslan via hossman)+* SOLR-2470: Added more tests for VelocityResponseWriter+================== 4.1.0 ==================Versions of Major Componentsdiff --git a/solr/contrib/velocity/src/test-files/velocity/solr/collection1/conf/solrconfig.xml b/solr/contrib/velocity/src/test-files/velocity/solr/collection1/conf/solrconfig.xmlindex a5befb22a48..8d77ee13015 100644--- a/solr/contrib/velocity/src/test-files/velocity/solr/collection1/conf/solrconfig.xml+++ b/solr/contrib/velocity/src/test-files/velocity/solr/collection1/conf/solrconfig.xml@@ -84,19 +84,8 @@</requestHandler><requestHandler name="/update" class="solr.UpdateRequestHandler" />-- <!--- <queryResponseWriter name="xml"- default="true"- class="solr.XMLResponseWriter" />- <queryResponseWriter name="json" class="solr.JSONResponseWriter"/>- <queryResponseWriter name="python" class="solr.PythonResponseWriter"/>- <queryResponseWriter name="ruby" class="solr.RubyResponseWriter"/>- <queryResponseWriter name="php" class="solr.PHPResponseWriter"/>- <queryResponseWriter name="phps" class="solr.PHPSerializedResponseWriter"/>- <queryResponseWriter name="velocity" class="solr.VelocityResponseWriter"/>- <queryResponseWriter name="csv" class="solr.CSVResponseWriter"/>- -->++ <queryResponseWriter name="velocity" class="solr.VelocityResponseWriter"/><!-- Legacy config for the admin interface --><admin>diff --git a/solr/contrib/velocity/src/test-files/velocity/solr/collection1/conf/velocity/numFound.vm b/solr/contrib/velocity/src/test-files/velocity/solr/collection1/conf/velocity/numFound.vmnew file mode 100644index 00000000000..7bafdcdd648--- /dev/null+++ b/solr/contrib/velocity/src/test-files/velocity/solr/collection1/conf/velocity/numFound.vm@@ -0,0 +1 @@+$response.response.response.numFound\ No newline at end of filediff --git a/solr/contrib/velocity/src/test/org/apache/solr/velocity/VelocityResponseWriterTest.java b/solr/contrib/velocity/src/test/org/apache/solr/velocity/VelocityResponseWriterTest.javaindex 23046eaa0f5..e6f389aee67 100644--- a/solr/contrib/velocity/src/test/org/apache/solr/velocity/VelocityResponseWriterTest.java+++ b/solr/contrib/velocity/src/test/org/apache/solr/velocity/VelocityResponseWriterTest.java@@ -18,6 +18,7 @@package org.apache.solr.velocity;import org.apache.solr.SolrTestCaseJ4;+import org.apache.solr.response.QueryResponseWriter;import org.apache.solr.response.SolrQueryResponse;import org.apache.solr.response.VelocityResponseWriter;import org.apache.solr.request.SolrQueryRequest;@@ -34,16 +35,10 @@ public class VelocityResponseWriterTest extends SolrTestCaseJ4 {initCore("solrconfig.xml", "schema.xml", getFile("velocity/solr").getAbsolutePath());}- @Override- @Before- public void setUp() throws Exception {- super.setUp();- clearIndex();- assertU(commit());- }-@Test- public void testTemplateName() throws IOException {+ public void testCustomParamTemplate() throws Exception {+ // This test doesn't use the Solr core, just the response writer directly+org.apache.solr.response.VelocityResponseWriter vrw = new VelocityResponseWriter();SolrQueryRequest req = req("v.template","custom", "v.template.custom","$response.response.response_data");SolrQueryResponse rsp = new SolrQueryResponse();@@ -53,5 +48,15 @@ public class VelocityResponseWriterTest extends SolrTestCaseJ4 {assertEquals("testing", buf.toString());}- // TODO: add test that works with true Solr requests and wt=velocity to ensure the test tests that it's registered properly, etc+ @Test+ public void testVelocityResponseWriterRegistered() {+ QueryResponseWriter writer = h.getCore().getQueryResponseWriter("velocity");++ assertTrue("VrW registered check", writer instanceof VelocityResponseWriter);+ }++ @Test+ public void testSolrResourceLoaderTemplate() throws Exception {+ assertEquals("0", h.query(req("q","*:*", "wt","velocity","v.template","numFound")));+ }}