Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-2588: Move VelocityResponseWriter back to contrib/velocity

Erik Hatcher426bc2d0b690
diff --git a/dev-tools/eclipse/dot.classpath b/dev-tools/eclipse/dot.classpath
index b144d596033..e5b9c161691 100644
--- a/dev-tools/eclipse/dot.classpath
+++ b/dev-tools/eclipse/dot.classpath
@@ -72,13 +72,16 @@
<classpathentry kind="src" path="solr/contrib/extraction/src/test"/>
<classpathentry kind="src" path="solr/contrib/extraction/src/test-files"/>
<classpathentry kind="src" path="solr/contrib/langid/src/java"/>
+ <classpathentry kind="src" path="solr/contrib/langid/src/resources"/>
<classpathentry kind="src" path="solr/contrib/langid/src/test"/>
<classpathentry kind="src" path="solr/contrib/langid/src/test-files"/>
<classpathentry kind="src" path="solr/contrib/uima/src/java"/>
<classpathentry kind="src" path="solr/contrib/uima/src/resources"/>
<classpathentry kind="src" path="solr/contrib/uima/src/test"/>
<classpathentry kind="src" path="solr/contrib/uima/src/test-files"/>
- <classpathentry kind="src" path="solr/contrib/langid/src/resources"/>
+ <classpathentry kind="src" path="solr/contrib/velocity/src/java"/>
+ <classpathentry kind="src" path="solr/contrib/velocity/src/test"/>
+ <classpathentry kind="src" path="solr/contrib/velocity/src/test-files"/>
<classpathentry kind="lib" path="lucene/lib/ant-1.7.1.jar"/>
<classpathentry kind="lib" path="lucene/lib/ant-junit-1.7.1.jar"/>
<classpathentry kind="lib" path="lucene/lib/junit-4.7.jar"/>
@@ -151,14 +154,16 @@
<classpathentry kind="lib" path="solr/contrib/extraction/lib/tika-core-0.10.jar"/>
<classpathentry kind="lib" path="solr/contrib/extraction/lib/tika-parsers-0.10.jar"/>
<classpathentry kind="lib" path="solr/contrib/extraction/lib/xmlbeans-2.3.0.jar"/>
+ <classpathentry kind="lib" path="solr/contrib/langid/lib/langdetect-r111.jar"/>
+ <classpathentry kind="lib" path="solr/contrib/langid/lib/jsonic-1.2.0.jar"/>
<classpathentry kind="lib" path="solr/contrib/uima/lib/commons-digester-2.0.jar"/>
<classpathentry kind="lib" path="solr/contrib/uima/lib/uima-an-alchemy-2.3.1.jar"/>
<classpathentry kind="lib" path="solr/contrib/uima/lib/uima-an-calais-2.3.1.jar"/>
<classpathentry kind="lib" path="solr/contrib/uima/lib/uima-an-tagger-2.3.1.jar"/>
<classpathentry kind="lib" path="solr/contrib/uima/lib/uima-an-wst-2.3.1.jar"/>
<classpathentry kind="lib" path="solr/contrib/uima/lib/uimaj-core-2.3.1.jar"/>
- <classpathentry kind="lib" path="solr/contrib/langid/lib/langdetect-r111.jar"/>
- <classpathentry kind="lib" path="solr/contrib/langid/lib/jsonic-1.2.0.jar"/>
+ <classpathentry kind="lib" path="solr/contrib/velocity/lib/velocity-1.6.4.jar"/>
+ <classpathentry kind="lib" path="solr/contrib/velocity/lib/velocity-tools-2.0.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/dev-tools/idea/.idea/ant.xml b/dev-tools/idea/.idea/ant.xml
index 298e5603279..6fcf2095d84 100644
--- a/dev-tools/idea/.idea/ant.xml
+++ b/dev-tools/idea/.idea/ant.xml
@@ -32,6 +32,7 @@
<buildFile url="file://$PROJECT_DIR$/solr/contrib/extraction/build.xml" />
<buildFile url="file://$PROJECT_DIR$/solr/contrib/langid/build.xml" />
<buildFile url="file://$PROJECT_DIR$/solr/contrib/uima/build.xml" />
+ <buildFile url="file://$PROJECT_DIR$/solr/contrib/velocity/build.xml" />
<buildFile url="file://$PROJECT_DIR$/solr/solrj/build.xml" />
<buildFile url="file://$PROJECT_DIR$/solr/test-framework/build.xml" />
<buildFile url="file://$PROJECT_DIR$/solr/webapp/build.xml" />
diff --git a/dev-tools/idea/.idea/libraries/Solr_velocity_library.xml b/dev-tools/idea/.idea/libraries/Solr_velocity_library.xml
new file mode 100644
index 00000000000..544e62a774c
--- /dev/null
+++ b/dev-tools/idea/.idea/libraries/Solr_velocity_library.xml
@@ -0,0 +1,10 @@
+<component name="libraryTable">
+ <library name="Solr velocity library">
+ <CLASSES>
+ <root url="file://$PROJECT_DIR$/solr/contrib/velocity/lib" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ <jarDirectory url="file://$PROJECT_DIR$/solr/contrib/velocity/lib" recursive="false" />
+ </library>
+</component>
diff --git a/dev-tools/idea/.idea/modules.xml b/dev-tools/idea/.idea/modules.xml
index d39204c3904..ac0924d9d2f 100644
--- a/dev-tools/idea/.idea/modules.xml
+++ b/dev-tools/idea/.idea/modules.xml
@@ -32,6 +32,7 @@
<module filepath="$PROJECT_DIR$/solr/contrib/extraction/extraction.iml" />
<module filepath="$PROJECT_DIR$/solr/contrib/langid/langid.iml" />
<module filepath="$PROJECT_DIR$/solr/contrib/uima/uima.iml" />
+ <module filepath="$PROJECT_DIR$/solr/contrib/velocity/velocity.iml" />
</modules>
</component>
</project>
diff --git a/dev-tools/idea/.idea/workspace.xml b/dev-tools/idea/.idea/workspace.xml
index a40d201770e..cfbf834a104 100644
--- a/dev-tools/idea/.idea/workspace.xml
+++ b/dev-tools/idea/.idea/workspace.xml
@@ -197,7 +197,14 @@
<option name="VM_PARAMETERS" value="-ea -Dtests.luceneMatchVersion=4.0 -DtempDir=temp -Djetty.testMode=1 -Djetty.insecurerandom=1 -Dsolr.directoryFactory=org.apache.solr.core.MockDirectoryFactory" />
<option name="TEST_SEARCH_SCOPE"><value defaultName="singleModule" /></option>
</configuration>
- <list size="28">
+ <configuration default="false" name="velocity contrib" type="JUnit" factoryName="JUnit">
+ <module name="velocity" />
+ <option name="TEST_OBJECT" value="package" />
+ <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$/solr/build/contrib/solr-velocity" />
+ <option name="VM_PARAMETERS" value="-ea" />
+ <option name="TEST_SEARCH_SCOPE"><value defaultName="singleModule" /></option>
+ </configuration>
+ <list size="29">
<item index="0" class="java.lang.String" itemvalue="JUnit.analysis-extras contrib" />
<item index="1" class="java.lang.String" itemvalue="JUnit.benchmark module" />
<item index="2" class="java.lang.String" itemvalue="JUnit.clustering contrib" />
@@ -226,6 +233,7 @@
<item index="25" class="java.lang.String" itemvalue="JUnit.stempel analysis module" />
<item index="26" class="java.lang.String" itemvalue="JUnit.suggest module" />
<item index="27" class="java.lang.String" itemvalue="JUnit.uima contrib" />
+ <item index="28" class="java.lang.String" itemvalue="JUnit.velocity contrib" />
</list>
</component>
</project>
diff --git a/dev-tools/idea/solr/contrib/velocity/velocity.iml b/dev-tools/idea/solr/contrib/velocity/velocity.iml
new file mode 100644
index 00000000000..3c78f318a2c
--- /dev/null
+++ b/dev-tools/idea/solr/contrib/velocity/velocity.iml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="JAVA_MODULE" version="4">
+ <component name="NewModuleRootManager" inherit-compiler-output="false">
+ <output url="file://$MODULE_DIR$/../../build/contrib/solr-velocity/classes/java" />
+ <output-test url="file://$MODULE_DIR$/../../build/contrib/solr-velocity/classes/test" />
+ <exclude-output />
+ <content url="file://$MODULE_DIR$">
+ <sourceFolder url="file://$MODULE_DIR$/src/test" isTestSource="true" />
+ <sourceFolder url="file://$MODULE_DIR$/src/test-files" isTestSource="true" />
+ <sourceFolder url="file://$MODULE_DIR$/src/java" isTestSource="false" />
+ </content>
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ <orderEntry type="library" name="Solr library" level="project" />
+ <orderEntry type="library" name="Solr velocity library" level="project" />
+ <orderEntry type="module" module-name="solr" />
+ <orderEntry type="module" module-name="lucene" scope="TEST" />
+ </component>
+</module>
+
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 3153be34acf..09a3f262614 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -56,6 +56,11 @@ Upgrading from Solr 3.5-dev
* FacetComponent no longer catches and embeds exceptions occurred during facet
processing, it throws HTTP 400 or 500 exceptions instead.
+
+* The VelocityResponseWriter is no longer built into the core. Its JAR and
+ dependencies now need to be added (via <lib> or solr/home lib inclusion),
+ and it needs to be registered in solrconfig.xml like this:
+ <queryResponseWriter name="velocity" class="solr.VelocityResponseWriter"/>
Detailed Change List
----------------------
@@ -334,6 +339,9 @@ Other Changes
* SOLR-2756: Maven configuration: Excluded transitive stax:stax-api dependency
from org.codehaus.woodstox:wstx-asl dependency. (David Smiley via Steve Rowe)
+* SOLR-2588: Moved VelocityResponseWriter back to contrib module in order to
+ remove it as a mandatory core dependency. (Erik Hatcher)
+
Documentation
----------------------
diff --git a/solr/contrib/velocity/build.xml b/solr/contrib/velocity/build.xml
new file mode 100644
index 00000000000..a6712afcd79
--- /dev/null
+++ b/solr/contrib/velocity/build.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0"?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<project name="solr-velocity" default="default">
+
+ <description>
+ Solr Velocity Response Writer
+ </description>
+
+ <import file="../contrib-build.xml"/>
+
+</project>
diff --git a/solr/lib/velocity-1.6.4.jar b/solr/contrib/velocity/lib/velocity-1.6.4.jar
similarity index 100%
rename from solr/lib/velocity-1.6.4.jar
rename to solr/contrib/velocity/lib/velocity-1.6.4.jar
diff --git a/solr/lib/velocity-LICENSE-ASL.txt b/solr/contrib/velocity/lib/velocity-LICENSE-ASL.txt
similarity index 100%
rename from solr/lib/velocity-LICENSE-ASL.txt
rename to solr/contrib/velocity/lib/velocity-LICENSE-ASL.txt
diff --git a/solr/lib/velocity-NOTICE.txt b/solr/contrib/velocity/lib/velocity-NOTICE.txt
similarity index 100%
rename from solr/lib/velocity-NOTICE.txt
rename to solr/contrib/velocity/lib/velocity-NOTICE.txt
diff --git a/solr/lib/velocity-tools-2.0.jar b/solr/contrib/velocity/lib/velocity-tools-2.0.jar
similarity index 100%
rename from solr/lib/velocity-tools-2.0.jar
rename to solr/contrib/velocity/lib/velocity-tools-2.0.jar
diff --git a/solr/lib/velocity-tools-LICENSE-ASL.txt b/solr/contrib/velocity/lib/velocity-tools-LICENSE-ASL.txt
similarity index 100%
rename from solr/lib/velocity-tools-LICENSE-ASL.txt
rename to solr/contrib/velocity/lib/velocity-tools-LICENSE-ASL.txt
diff --git a/solr/lib/velocity-tools-NOTICE.txt b/solr/contrib/velocity/lib/velocity-tools-NOTICE.txt
similarity index 100%
rename from solr/lib/velocity-tools-NOTICE.txt
rename to solr/contrib/velocity/lib/velocity-tools-NOTICE.txt
diff --git a/solr/core/src/java/org/apache/solr/response/PageTool.java b/solr/contrib/velocity/src/java/org/apache/solr/response/PageTool.java
similarity index 95%
rename from solr/core/src/java/org/apache/solr/response/PageTool.java
rename to solr/contrib/velocity/src/java/org/apache/solr/response/PageTool.java
index 42bf31e5a23..af00c33c745 100644
--- a/solr/core/src/java/org/apache/solr/response/PageTool.java
+++ b/solr/contrib/velocity/src/java/org/apache/solr/response/PageTool.java
@@ -24,6 +24,11 @@ import org.apache.solr.search.DocSlice;
import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.SolrException;
+/**
+ * This class is used by the Velocity response writer to provide a consistent paging tool for use by templates.
+ *
+ * TODO: add more details
+ */
public class PageTool {
private long start;
private int results_per_page = 10;
diff --git a/solr/core/src/java/org/apache/solr/response/SolrParamResourceLoader.java b/solr/contrib/velocity/src/java/org/apache/solr/response/SolrParamResourceLoader.java
similarity index 100%
rename from solr/core/src/java/org/apache/solr/response/SolrParamResourceLoader.java
rename to solr/contrib/velocity/src/java/org/apache/solr/response/SolrParamResourceLoader.java
diff --git a/solr/core/src/java/org/apache/solr/response/SolrVelocityResourceLoader.java b/solr/contrib/velocity/src/java/org/apache/solr/response/SolrVelocityResourceLoader.java
similarity index 100%
rename from solr/core/src/java/org/apache/solr/response/SolrVelocityResourceLoader.java
rename to solr/contrib/velocity/src/java/org/apache/solr/response/SolrVelocityResourceLoader.java
diff --git a/solr/core/src/java/org/apache/solr/response/VelocityResponseWriter.java b/solr/contrib/velocity/src/java/org/apache/solr/response/VelocityResponseWriter.java
similarity index 100%
rename from solr/core/src/java/org/apache/solr/response/VelocityResponseWriter.java
rename to solr/contrib/velocity/src/java/org/apache/solr/response/VelocityResponseWriter.java
diff --git a/solr/contrib/velocity/src/test-files/velocity/solr/conf/schema.xml b/solr/contrib/velocity/src/test-files/velocity/solr/conf/schema.xml
new file mode 100644
index 00000000000..ba663e71649
--- /dev/null
+++ b/solr/contrib/velocity/src/test-files/velocity/solr/conf/schema.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<schema name="minimal-velocity" version="1.4">
+ <types>
+ <fieldType name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true"/>
+ </types>
+
+
+ <fields>
+ <field name="id" type="string" indexed="true" stored="true" required="true" />
+ <dynamicField name="*_s" type="string" indexed="true" stored="true"/>
+ </fields>
+
+ <uniqueKey>id</uniqueKey>
+
+ <defaultSearchField>id</defaultSearchField>
+
+ <solrQueryParser defaultOperator="OR"/>
+
+</schema>
diff --git a/solr/contrib/velocity/src/test-files/velocity/solr/conf/solrconfig.xml b/solr/contrib/velocity/src/test-files/velocity/solr/conf/solrconfig.xml
new file mode 100644
index 00000000000..3f6d0b9cf8c
--- /dev/null
+++ b/solr/contrib/velocity/src/test-files/velocity/solr/conf/solrconfig.xml
@@ -0,0 +1,137 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!--
+ For more details about configurations options that may appear in
+ this file, see http://wiki.apache.org/solr/SolrConfigXml.
+-->
+<config>
+ <luceneMatchVersion>LUCENE_40</luceneMatchVersion>
+
+ <lib dir="../../contrib/velocity/lib" />
+ <lib dir="../../dist/" regex="apache-solr-velocity-\d.*\.jar" />
+ <dataDir>${solr.data.dir:}</dataDir>
+
+
+ <directoryFactory name="DirectoryFactory"
+ class="${solr.directoryFactory:solr.StandardDirectoryFactory}"/>
+
+
+ <indexDefaults>
+ <useCompoundFile>false</useCompoundFile>
+ <mergeFactor>10</mergeFactor>
+ <ramBufferSizeMB>32</ramBufferSizeMB>
+ <maxFieldLength>10000</maxFieldLength>
+ <writeLockTimeout>1000</writeLockTimeout>
+ <commitLockTimeout>10000</commitLockTimeout>
+ <lockType>native</lockType>
+ </indexDefaults>
+
+ <mainIndex>
+ <useCompoundFile>false</useCompoundFile>
+ <ramBufferSizeMB>32</ramBufferSizeMB>
+ <mergeFactor>10</mergeFactor>
+ <unlockOnStartup>false</unlockOnStartup>
+ <reopenReaders>true</reopenReaders>
+ <deletionPolicy class="solr.SolrDeletionPolicy">
+ <str name="maxCommitsToKeep">1</str>
+ <str name="maxOptimizedCommitsToKeep">0</str>
+ </deletionPolicy>
+ <infoStream file="INFOSTREAM.txt">false</infoStream>
+ </mainIndex>
+
+ <updateHandler class="solr.DirectUpdateHandler2">
+ </updateHandler>
+
+ <query>
+ <maxBooleanClauses>1024</maxBooleanClauses>
+ <filterCache class="solr.FastLRUCache"
+ size="512"
+ initialSize="512"
+ autowarmCount="0"/>
+ <queryResultCache class="solr.LRUCache"
+ size="512"
+ initialSize="512"
+ autowarmCount="0"/>
+ <documentCache class="solr.LRUCache"
+ size="512"
+ initialSize="512"
+ autowarmCount="0"/>
+ <enableLazyFieldLoading>true</enableLazyFieldLoading>
+
+ <queryResultWindowSize>20</queryResultWindowSize>
+ <queryResultMaxDocsCached>200</queryResultMaxDocsCached>
+ <listener event="newSearcher" class="solr.QuerySenderListener">
+ <arr name="queries">
+ </arr>
+ </listener>
+ <listener event="firstSearcher" class="solr.QuerySenderListener">
+ <arr name="queries">
+ <lst>
+ <str name="q">static firstSearcher warming in solrconfig.xml</str>
+ </lst>
+ </arr>
+ </listener>
+ <useColdSearcher>false</useColdSearcher>
+ <maxWarmingSearchers>2</maxWarmingSearchers>
+
+ </query>
+ <requestDispatcher handleSelect="true" >
+ <requestParsers enableRemoteStreaming="true"
+ multipartUploadLimitInKB="2048000" />
+ <httpCaching never304="true" />
+ </requestDispatcher>
+
+ <requestHandler name="search" class="solr.SearchHandler" default="true">
+ <lst name="defaults">
+ <str name="echoParams">explicit</str>
+ <int name="rows">10</int>
+ </lst>
+ </requestHandler>
+
+
+ <requestHandler name="/update"
+ class="solr.XmlUpdateRequestHandler">
+ </requestHandler>
+ <!-- Binary Update Request Handler
+ http://wiki.apache.org/solr/javabin
+ -->
+ <requestHandler name="/update/javabin"
+ class="solr.BinaryUpdateRequestHandler" />
+ <requestHandler name="/update/json"
+ class="solr.JsonUpdateRequestHandler"
+ startup="lazy" />
+ <!--
+ <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"/>
+ -->
+
+ <!-- Legacy config for the admin interface -->
+ <admin>
+ <defaultQuery>*:*</defaultQuery>
+ </admin>
+
+</config>
diff --git a/solr/core/src/test-files/solr/conf/velocity/VM_global_library.vm b/solr/contrib/velocity/src/test-files/velocity/solr/conf/velocity/VM_global_library.vm
similarity index 100%
rename from solr/core/src/test-files/solr/conf/velocity/VM_global_library.vm
rename to solr/contrib/velocity/src/test-files/velocity/solr/conf/velocity/VM_global_library.vm
diff --git a/solr/core/src/test/org/apache/solr/velocity/VelocityResponseWriterTest.java b/solr/contrib/velocity/src/test/org/apache/solr/velocity/VelocityResponseWriterTest.java
similarity index 71%
rename from solr/core/src/test/org/apache/solr/velocity/VelocityResponseWriterTest.java
rename to solr/contrib/velocity/src/test/org/apache/solr/velocity/VelocityResponseWriterTest.java
index ae220a0a852..79aeb42ff4d 100644
--- a/solr/core/src/test/org/apache/solr/velocity/VelocityResponseWriterTest.java
+++ b/solr/contrib/velocity/src/test/org/apache/solr/velocity/VelocityResponseWriterTest.java
@@ -17,21 +17,32 @@
package org.apache.solr.velocity;
+import org.apache.solr.SolrTestCaseJ4;
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 org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
import java.io.StringWriter;
import java.io.IOException;
-public class VelocityResponseWriterTest extends AbstractSolrTestCase {
- @Override
- public String getSchemaFile() { return "schema.xml"; }
- @Override
- public String getSolrConfigFile() { return "solrconfig.xml"; }
+public class VelocityResponseWriterTest extends SolrTestCaseJ4 {
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ 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 {
org.apache.solr.response.VelocityResponseWriter vrw = new VelocityResponseWriter();
SolrQueryRequest req = req("v.template","custom", "v.template.custom","$response.response.response_data");
@@ -41,4 +52,6 @@ public class VelocityResponseWriterTest extends AbstractSolrTestCase {
vrw.write(buf, req, rsp);
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
}
diff --git a/solr/core/src/java/org/apache/solr/core/SolrCore.java b/solr/core/src/java/org/apache/solr/core/SolrCore.java
index c932d343807..d93cc75477d 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrCore.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrCore.java
@@ -1525,7 +1525,6 @@ public final class SolrCore implements SolrInfoMBean {
m.put("ruby", new RubyResponseWriter());
m.put("raw", new RawResponseWriter());
m.put("javabin", new BinaryResponseWriter());
- m.put("velocity", new VelocityResponseWriter());
m.put("csv", new CSVResponseWriter());
DEFAULT_RESPONSE_WRITERS = Collections.unmodifiableMap(m);
}
diff --git a/solr/example/solr/conf/solrconfig.xml b/solr/example/solr/conf/solrconfig.xml
index 63e6c4e9fef..0a7b7859876 100755
--- a/solr/example/solr/conf/solrconfig.xml
+++ b/solr/example/solr/conf/solrconfig.xml
@@ -51,11 +51,15 @@
<lib dir="./lib" />
-->
+
<!-- A dir option by itself adds any files found in the directory to
the classpath, this is useful for including all jars in a
directory.
-->
<lib dir="../../contrib/extraction/lib" />
+ <lib dir="../../contrib/clustering/lib/" />
+ <lib dir="../../contrib/velocity/lib" />
+
<!-- When a regex is specified in addition to a directory, only the
files in that directory which completely match the regex
(anchored on both ends) will be included.
@@ -63,11 +67,13 @@
<lib dir="../../dist/" regex="apache-solr-cell-\d.*\.jar" />
<lib dir="../../dist/" regex="apache-solr-clustering-\d.*\.jar" />
<lib dir="../../dist/" regex="apache-solr-langid-\d.*\.jar" />
+ <lib dir="../../dist/" regex="apache-solr-velocity-\d.*\.jar" />
+
<!-- If a dir option (with or without a regex) is used and nothing
is found that matches, it will be ignored
-->
- <lib dir="../../contrib/clustering/lib/" />
<lib dir="/total/crap/dir/ignored" />
+
<!-- an exact path can be used to specify a specific file. This
will cause a serious error to be logged if it can't be loaded.
-->
@@ -1574,15 +1580,15 @@
<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"/>
-->
<!--
Custom response writers can be declared as needed...
-->
- <!--
- <queryResponseWriter name="custom" class="com.example.MyResponseWriter"/>
- -->
+ <!-- The solr.velocity.enabled flag is used by Solr's test cases so that this response writer is not
+ loaded (causing an error if contrib/velocity has not been built fully) -->
+ <queryResponseWriter name="velocity" class="solr.VelocityResponseWriter" enable="${solr.velocity.enabled:true}"/>
+
<!-- XSLT response writer transforms the XML output by any xslt file found
in Solr's conf/xslt directory. Changes to xslt files are checked for
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.java
index adfde3c8b0e..2bf16262f3d 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.java
@@ -55,6 +55,9 @@ public class JettyWebappTest extends LuceneTestCase
System.setProperty("solr.data.dir", dataDir.getCanonicalPath());
String path = ExternalPaths.WEBAPP_HOME;
+ // disable VelocityResponseWriter from example configuration
+ System.setProperty("solr.velocity.enabled", "false");
+
server = new Server(port);
// insecure: only use for tests!!!!
server.setSessionIdManager(new HashSessionIdManager(new Random(random.nextLong())));
diff --git a/solr/test-framework/src/java/org/apache/solr/SolrJettyTestBase.java b/solr/test-framework/src/java/org/apache/solr/SolrJettyTestBase.java
index cd10c76180e..b2121cc9ebe 100755
--- a/solr/test-framework/src/java/org/apache/solr/SolrJettyTestBase.java
+++ b/solr/test-framework/src/java/org/apache/solr/SolrJettyTestBase.java
@@ -47,6 +47,9 @@ abstract public class SolrJettyTestBase extends SolrTestCaseJ4
System.setProperty( "solr.solr.home", solrHome);
System.setProperty( "solr.data.dir", dataDir.getCanonicalPath() );
+ // disable VelocityResponseWriter from example configuration
+ System.setProperty("solr.velocity.enabled", "false");
+
context = context==null ? "/solr" : context;
SolrJettyTestBase.context = context;
jetty = new JettySolrRunner( context, 0, configFile );
diff --git a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
index 6b585493f4a..a500b4074bc 100755
--- a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
+++ b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
@@ -103,6 +103,7 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase {
if (solrHome != null) {
System.setProperty("solr.solr.home", solrHome);
}
+ System.setProperty("solr.velocity.enabled", "false");
initCore();
}