Skip to content

Apache Lucene open-source search software

Adding overdue unit test and adjusting build file accordingly

Erik Hatchera45422f66ace
diff --git a/contrib/velocity/build.xml b/contrib/velocity/build.xml
index deec7c026ad..3f2b71209f4 100644
--- a/contrib/velocity/build.xml
+++ b/contrib/velocity/build.xml
@@ -69,27 +69,27 @@
<target name="compileTests" depends="compile">
<solr-javac destdir="target/test-classes"
classpathref="test.classpath">
- <src path="src/test/java" />
+ <src path="src/test" />
</solr-javac>
</target>
<target name="test" depends="compileTests">
<mkdir dir="${junit.output.dir}"/>
- <junit printsummary="on"
+ <junit printsummary="true" showoutput="true"
haltonfailure="no"
errorProperty="tests.failed"
failureProperty="tests.failed"
- dir="src/test/resources/"
+ dir="src/main"
>
- <formatter type="brief" usefile="false" if="junit.details"/>
+ <formatter type="brief" usefile="false"/>
<classpath refid="test.classpath"/>
- <formatter type="xml"/>
+ <!--<formatter type="xml" usefile="false"/>-->
<batchtest fork="yes" todir="${junit.output.dir}" unless="testcase">
- <fileset dir="src/test/java" includes="${junit.includes}"/>
+ <fileset dir="src/test" includes="${junit.includes}"/>
</batchtest>
<batchtest fork="yes" todir="${junit.output.dir}" if="testcase">
- <fileset dir="src/test/java" includes="**/${testcase}.java"/>
+ <fileset dir="src/test" includes="**/${testcase}.java"/>
</batchtest>
</junit>
diff --git a/contrib/velocity/src/test/java/TODO.txt b/contrib/velocity/src/test/java/TODO.txt
deleted file mode 100644
index f05d4ec0567..00000000000
--- a/contrib/velocity/src/test/java/TODO.txt
+++ /dev/null
@@ -1 +0,0 @@
-Yes, tests are forthcoming! Sorry Hudson.
\ No newline at end of file
diff --git a/contrib/velocity/src/test/org/apache/solr/velocity/VelocityResponseWriterTest.java b/contrib/velocity/src/test/org/apache/solr/velocity/VelocityResponseWriterTest.java
new file mode 100644
index 00000000000..911ca19b1ad
--- /dev/null
+++ b/contrib/velocity/src/test/org/apache/solr/velocity/VelocityResponseWriterTest.java
@@ -0,0 +1,25 @@
+package org.apache.solr.velocity;
+
+import org.apache.solr.response.SolrQueryResponse;
+import org.apache.solr.response.VelocityResponseWriter;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.util.AbstractSolrTestCase;
+
+import java.io.StringWriter;
+import java.io.IOException;
+
+public class VelocityResponseWriterTest extends AbstractSolrTestCase {
+ public String getSchemaFile() { return "schema.xml"; }
+ public String getSolrConfigFile() { return "solrconfig.xml"; }
+
+
+ public void testTemplateName() throws IOException {
+ 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();
+ StringWriter buf = new StringWriter();
+ rsp.add("response_data", "testing");
+ vrw.write(buf, req, rsp);
+ assertEquals("testing", buf.toString());
+ }
+}