From 800f5a54a68bf3750f4331d8639ef28cf10a443b Mon Sep 17 00:00:00 2001 From: Ryan McKinley Date: Tue, 8 May 2012 21:06:10 +0000 Subject: [PATCH] SOLR-2857: add UpdateRequestHandler that handles xml,csv,json, and javabin git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1335768 13f79535-47bb-0310-9956-ffa450edef68 --- .../clustering/solr/conf/solrconfig.xml | 5 +- .../solr/conf/dataimport-solrconfig.xml | 2 +- .../solr/conf/contentstream-solrconfig.xml | 2 +- .../dataimport-nodatasource-solrconfig.xml | 2 +- .../dih/solr/conf/dataimport-solrconfig.xml | 2 +- .../extraction/ExtractingDocumentLoader.java | 8 +- .../extraction/ExtractingRequestHandler.java | 2 +- .../extraction/solr/conf/solrconfig.xml | 5 +- .../ExtractingRequestHandlerTest.java | 2 +- .../conf/solrconfig-languageidentifier.xml | 2 +- .../test-files/uima/solr/conf/solrconfig.xml | 6 +- .../uima/uima-tokenizers-solrconfig.xml | 6 +- .../UIMAUpdateRequestProcessorTest.java | 4 +- .../velocity/solr/conf/solrconfig.xml | 14 +- .../handler/BinaryUpdateRequestHandler.java | 122 +---- .../solr/handler/CSVRequestHandler.java | 407 +-------------- .../handler/ContentStreamHandlerBase.java | 9 +- .../org/apache/solr/handler/JsonLoader.java | 460 ----------------- .../handler/JsonUpdateRequestHandler.java | 18 +- .../solr/handler/UpdateRequestHandler.java | 167 ++++++ .../solr/handler/XmlUpdateRequestHandler.java | 58 +-- .../handler/XsltUpdateRequestHandler.java | 49 +- .../apache/solr/handler/XsltXMLLoader.java | 119 ----- .../apache/solr/handler/loader/CSVLoader.java | 46 ++ .../solr/handler/loader/CSVLoaderBase.java | 399 +++++++++++++++ .../handler/loader/ContentStreamLoader.java | 57 +++ .../solr/handler/loader/JavabinLoader.java | 139 +++++ .../solr/handler/loader/JsonLoader.java | 479 ++++++++++++++++++ .../solr/handler/{ => loader}/XMLLoader.java | 205 ++++++-- .../solr/response/XSLTResponseWriter.java | 6 +- .../solr/conf/solrconfig-elevate.xml | 2 +- .../solr/conf/solrconfig-enableplugin.xml | 2 +- .../solr/conf/solrconfig-functionquery.xml | 2 +- .../solr/conf/solrconfig-master.xml | 2 +- .../conf/solrconfig-master1-keepOneBackup.xml | 2 +- .../solr/conf/solrconfig-master1.xml | 2 +- .../solr/conf/solrconfig-master2.xml | 2 +- .../solr/conf/solrconfig-master3.xml | 2 +- .../solr/conf/solrconfig-repeater.xml | 2 +- .../test-files/solr/conf/solrconfig-slave.xml | 2 +- .../solr/conf/solrconfig-slave1.xml | 5 +- .../conf/solrconfig-solcoreproperties.xml | 2 +- .../test-files/solr/conf/solrconfig-tlog.xml | 6 +- .../src/test-files/solr/conf/solrconfig.xml | 6 +- .../test-files/solr/conf/solrconfig_perf.xml | 6 +- .../test-files/solr/crazy-path-to-config.xml | 2 +- .../org/apache/solr/ConvertedLegacyTest.java | 6 +- .../solr/cloud/BasicDistributedZkTest.java | 4 +- .../apache/solr/core/RequestHandlersTest.java | 6 +- .../BinaryUpdateRequestHandlerTest.java | 7 +- .../solr/handler/CSVRequestHandlerTest.java | 7 +- .../apache/solr/handler/JsonLoaderTest.java | 17 +- .../apache/solr/handler/TestCSVLoader.java | 54 +- .../handler/XmlUpdateRequestHandlerTest.java | 15 +- .../handler/XsltUpdateRequestHandlerTest.java | 39 +- .../solr/servlet/CacheHeaderTestBase.java | 2 +- .../apache/solr/update/AutoCommitTest.java | 8 +- .../apache/solr/update/UpdateParamsTest.java | 4 +- .../SignatureUpdateProcessorFactoryTest.java | 7 +- .../UniqFieldsUpdateProcessorFactoryTest.java | 4 +- .../example-DIH/solr/db/conf/solrconfig.xml | 9 +- .../example-DIH/solr/mail/conf/solrconfig.xml | 9 +- .../example-DIH/solr/rss/conf/solrconfig.xml | 9 +- .../example-DIH/solr/solr/conf/solrconfig.xml | 9 +- .../example-DIH/solr/tika/conf/solrconfig.xml | 2 +- .../multicore/core0/conf/solrconfig.xml | 2 +- .../multicore/core1/conf/solrconfig.xml | 2 +- solr/example/solr/conf/solrconfig.xml | 44 +- .../solrj/impl/BinaryRequestWriter.java | 23 +- .../impl/ConcurrentUpdateSolrServer.java | 11 +- .../request/ContentStreamUpdateRequest.java | 6 +- .../solr/common/params/CommonParams.java | 3 + .../solr/common/params/UpdateParams.java | 3 + .../solr/common/util/ContentStreamBase.java | 32 +- .../solrj/solr/conf/solrconfig-slave1.xml | 5 +- .../solrj/solr/shared/conf/solrconfig.xml | 2 +- .../solr/client/solrj/SolrExampleTests.java | 8 +- .../solrj/impl/BasicHttpSolrServerTest.java | 2 +- .../org/apache/solr/util/TestHarness.java | 6 +- 79 files changed, 1691 insertions(+), 1525 deletions(-) delete mode 100644 solr/core/src/java/org/apache/solr/handler/JsonLoader.java create mode 100644 solr/core/src/java/org/apache/solr/handler/UpdateRequestHandler.java delete mode 100644 solr/core/src/java/org/apache/solr/handler/XsltXMLLoader.java create mode 100644 solr/core/src/java/org/apache/solr/handler/loader/CSVLoader.java create mode 100644 solr/core/src/java/org/apache/solr/handler/loader/CSVLoaderBase.java create mode 100644 solr/core/src/java/org/apache/solr/handler/loader/ContentStreamLoader.java create mode 100644 solr/core/src/java/org/apache/solr/handler/loader/JavabinLoader.java create mode 100644 solr/core/src/java/org/apache/solr/handler/loader/JsonLoader.java rename solr/core/src/java/org/apache/solr/handler/{ => loader}/XMLLoader.java (58%) diff --git a/solr/contrib/clustering/src/test-files/clustering/solr/conf/solrconfig.xml b/solr/contrib/clustering/src/test-files/clustering/solr/conf/solrconfig.xml index ba830d2a311..41787f82644 100644 --- a/solr/contrib/clustering/src/test-files/clustering/solr/conf/solrconfig.xml +++ b/solr/contrib/clustering/src/test-files/clustering/solr/conf/solrconfig.xml @@ -361,10 +361,7 @@ To enable solr1.1 behavior, remove the /update handler or change its path --> - - - - + - + diff --git a/solr/contrib/dataimporthandler/src/test-files/dih/solr/conf/contentstream-solrconfig.xml b/solr/contrib/dataimporthandler/src/test-files/dih/solr/conf/contentstream-solrconfig.xml index 5517aa9aba9..d5df80a3a36 100644 --- a/solr/contrib/dataimporthandler/src/test-files/dih/solr/conf/contentstream-solrconfig.xml +++ b/solr/contrib/dataimporthandler/src/test-files/dih/solr/conf/contentstream-solrconfig.xml @@ -300,7 +300,7 @@ "update.processor.class" is the class name for the UpdateRequestProcessor. It is initalized only once. This can not be changed for each request. --> - + diff --git a/solr/contrib/dataimporthandler/src/test-files/dih/solr/conf/dataimport-nodatasource-solrconfig.xml b/solr/contrib/dataimporthandler/src/test-files/dih/solr/conf/dataimport-nodatasource-solrconfig.xml index fd286262f78..925283c4df3 100644 --- a/solr/contrib/dataimporthandler/src/test-files/dih/solr/conf/dataimport-nodatasource-solrconfig.xml +++ b/solr/contrib/dataimporthandler/src/test-files/dih/solr/conf/dataimport-nodatasource-solrconfig.xml @@ -298,7 +298,7 @@ "update.processor.class" is the class name for the UpdateRequestProcessor. It is initalized only once. This can not be changed for each request. --> - + diff --git a/solr/contrib/dataimporthandler/src/test-files/dih/solr/conf/dataimport-solrconfig.xml b/solr/contrib/dataimporthandler/src/test-files/dih/solr/conf/dataimport-solrconfig.xml index 6d74921ac52..5d54c517cae 100644 --- a/solr/contrib/dataimporthandler/src/test-files/dih/solr/conf/dataimport-solrconfig.xml +++ b/solr/contrib/dataimporthandler/src/test-files/dih/solr/conf/dataimport-solrconfig.xml @@ -296,7 +296,7 @@ "update.processor.class" is the class name for the UpdateRequestProcessor. It is initalized only once. This can not be changed for each request. --> - + diff --git a/solr/contrib/extraction/src/java/org/apache/solr/handler/extraction/ExtractingDocumentLoader.java b/solr/contrib/extraction/src/java/org/apache/solr/handler/extraction/ExtractingDocumentLoader.java index 564cb508c61..1fef2e5fa63 100644 --- a/solr/contrib/extraction/src/java/org/apache/solr/handler/extraction/ExtractingDocumentLoader.java +++ b/solr/contrib/extraction/src/java/org/apache/solr/handler/extraction/ExtractingDocumentLoader.java @@ -28,7 +28,7 @@ import org.apache.solr.common.params.UpdateParams; import org.apache.solr.common.util.ContentStream; import org.apache.solr.common.util.ContentStreamBase; import org.apache.solr.common.util.NamedList; -import org.apache.solr.handler.ContentStreamLoader; +import org.apache.solr.handler.loader.ContentStreamLoader; import org.apache.solr.request.SolrQueryRequest; import org.apache.solr.response.SolrQueryResponse; import org.apache.solr.schema.IndexSchema; @@ -134,8 +134,8 @@ public class ExtractingDocumentLoader extends ContentStreamLoader { * @throws java.io.IOException */ @Override - public void load(SolrQueryRequest req, SolrQueryResponse rsp, ContentStream stream) throws IOException { - errHeader = "ExtractingDocumentLoader: " + stream.getSourceInfo(); + public void load(SolrQueryRequest req, SolrQueryResponse rsp, + ContentStream stream, UpdateRequestProcessor processor) throws Exception { Parser parser = null; String streamType = req.getParams().get(ExtractingParams.STREAM_TYPE, null); if (streamType != null) { @@ -240,6 +240,4 @@ public class ExtractingDocumentLoader extends ContentStreamLoader { throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Stream type of " + streamType + " didn't match any known parsers. Please supply the " + ExtractingParams.STREAM_TYPE + " parameter."); } } - - } diff --git a/solr/contrib/extraction/src/java/org/apache/solr/handler/extraction/ExtractingRequestHandler.java b/solr/contrib/extraction/src/java/org/apache/solr/handler/extraction/ExtractingRequestHandler.java index feeb46b63d5..c6c5c2f9f7a 100644 --- a/solr/contrib/extraction/src/java/org/apache/solr/handler/extraction/ExtractingRequestHandler.java +++ b/solr/contrib/extraction/src/java/org/apache/solr/handler/extraction/ExtractingRequestHandler.java @@ -26,7 +26,7 @@ import org.apache.solr.request.SolrQueryRequest; import org.apache.solr.update.processor.UpdateRequestProcessor; import org.apache.solr.util.plugin.SolrCoreAware; import org.apache.solr.handler.ContentStreamHandlerBase; -import org.apache.solr.handler.ContentStreamLoader; +import org.apache.solr.handler.loader.ContentStreamLoader; import org.apache.tika.config.TikaConfig; import org.apache.tika.mime.MimeTypeException; import org.slf4j.Logger; diff --git a/solr/contrib/extraction/src/test-files/extraction/solr/conf/solrconfig.xml b/solr/contrib/extraction/src/test-files/extraction/solr/conf/solrconfig.xml index 1bc4d31cdf7..674b9db11ee 100644 --- a/solr/contrib/extraction/src/test-files/extraction/solr/conf/solrconfig.xml +++ b/solr/contrib/extraction/src/test-files/extraction/solr/conf/solrconfig.xml @@ -194,10 +194,7 @@ - - - false - + diff --git a/solr/contrib/extraction/src/test/org/apache/solr/handler/extraction/ExtractingRequestHandlerTest.java b/solr/contrib/extraction/src/test/org/apache/solr/handler/extraction/ExtractingRequestHandlerTest.java index 0155a314fa6..b5045ff6650 100644 --- a/solr/contrib/extraction/src/test/org/apache/solr/handler/extraction/ExtractingRequestHandlerTest.java +++ b/solr/contrib/extraction/src/test/org/apache/solr/handler/extraction/ExtractingRequestHandlerTest.java @@ -301,7 +301,7 @@ public class ExtractingRequestHandlerTest extends SolrTestCaseJ4 { BufferingRequestProcessor p = new BufferingRequestProcessor(null); ExtractingDocumentLoader loader = (ExtractingDocumentLoader) handler.newLoader(req, p); - loader.load(req, rsp, new ContentStreamBase.FileStream(getFile("extraction/version_control.txt"))); + loader.load(req, rsp, new ContentStreamBase.FileStream(getFile("extraction/version_control.txt")),p); AddUpdateCommand add = p.addCommands.get(0); assertEquals(200, add.commitWithin); diff --git a/solr/contrib/langid/src/test-files/langid/solr/conf/solrconfig-languageidentifier.xml b/solr/contrib/langid/src/test-files/langid/solr/conf/solrconfig-languageidentifier.xml index 1650fbcac65..6b2fdcd0b3c 100644 --- a/solr/contrib/langid/src/test-files/langid/solr/conf/solrconfig-languageidentifier.xml +++ b/solr/contrib/langid/src/test-files/langid/solr/conf/solrconfig-languageidentifier.xml @@ -55,7 +55,7 @@ - + lang_id diff --git a/solr/contrib/uima/src/test-files/uima/solr/conf/solrconfig.xml b/solr/contrib/uima/src/test-files/uima/solr/conf/solrconfig.xml index f0fd14a34fb..5decc62731c 100644 --- a/solr/contrib/uima/src/test-files/uima/solr/conf/solrconfig.xml +++ b/solr/contrib/uima/src/test-files/uima/solr/conf/solrconfig.xml @@ -705,15 +705,13 @@ code. To enable solr1.1 behavior, remove the /update handler or change its path --> - + uima - - diff --git a/solr/contrib/uima/src/test-files/uima/uima-tokenizers-solrconfig.xml b/solr/contrib/uima/src/test-files/uima/uima-tokenizers-solrconfig.xml index 529cb6bcf44..54d8590a623 100644 --- a/solr/contrib/uima/src/test-files/uima/uima-tokenizers-solrconfig.xml +++ b/solr/contrib/uima/src/test-files/uima/uima-tokenizers-solrconfig.xml @@ -705,9 +705,7 @@ code. To enable solr1.1 behavior, remove the /update handler or change its path --> - - - + diff --git a/solr/contrib/uima/src/test/org/apache/solr/uima/processor/UIMAUpdateRequestProcessorTest.java b/solr/contrib/uima/src/test/org/apache/solr/uima/processor/UIMAUpdateRequestProcessorTest.java index eba0e09298e..00f01b137b5 100644 --- a/solr/contrib/uima/src/test/org/apache/solr/uima/processor/UIMAUpdateRequestProcessorTest.java +++ b/solr/contrib/uima/src/test/org/apache/solr/uima/processor/UIMAUpdateRequestProcessorTest.java @@ -31,7 +31,7 @@ import org.apache.solr.common.params.UpdateParams; import org.apache.solr.common.util.ContentStream; import org.apache.solr.common.util.ContentStreamBase; import org.apache.solr.core.SolrCore; -import org.apache.solr.handler.XmlUpdateRequestHandler; +import org.apache.solr.handler.UpdateRequestHandler; import org.apache.solr.request.SolrQueryRequestBase; import org.apache.solr.response.SolrQueryResponse; import org.apache.solr.uima.processor.SolrUIMAConfiguration.MapField; @@ -192,7 +192,7 @@ public class UIMAUpdateRequestProcessorTest extends SolrTestCaseJ4 { SolrQueryRequestBase req = new SolrQueryRequestBase(h.getCore(), (SolrParams) mmparams) { }; - XmlUpdateRequestHandler handler = new XmlUpdateRequestHandler(); + UpdateRequestHandler handler = new UpdateRequestHandler(); handler.init(null); ArrayList streams = new ArrayList(2); streams.add(new ContentStreamBase.StringStream(doc)); 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 index 8f9fd96a825..c770a3fb4af 100644 --- a/solr/contrib/velocity/src/test-files/velocity/solr/conf/solrconfig.xml +++ b/solr/contrib/velocity/src/test-files/velocity/solr/conf/solrconfig.xml @@ -83,18 +83,8 @@ - - - - - - + + diff --git a/solr/core/src/test-files/solr/conf/solrconfig-enableplugin.xml b/solr/core/src/test-files/solr/conf/solrconfig-enableplugin.xml index 5cb851f8b32..5d97ab11c42 100644 --- a/solr/core/src/test-files/solr/conf/solrconfig-enableplugin.xml +++ b/solr/core/src/test-files/solr/conf/solrconfig-enableplugin.xml @@ -55,7 +55,7 @@ - + diff --git a/solr/core/src/test-files/solr/conf/solrconfig-functionquery.xml b/solr/core/src/test-files/solr/conf/solrconfig-functionquery.xml index 461b31713c5..12bf3a24c10 100755 --- a/solr/core/src/test-files/solr/conf/solrconfig-functionquery.xml +++ b/solr/core/src/test-files/solr/conf/solrconfig-functionquery.xml @@ -28,7 +28,7 @@ - + diff --git a/solr/core/src/test-files/solr/conf/solrconfig-master.xml b/solr/core/src/test-files/solr/conf/solrconfig-master.xml index 38de374a3d0..cece0ab1d24 100644 --- a/solr/core/src/test-files/solr/conf/solrconfig-master.xml +++ b/solr/core/src/test-files/solr/conf/solrconfig-master.xml @@ -63,7 +63,7 @@ - + diff --git a/solr/core/src/test-files/solr/conf/solrconfig-master1-keepOneBackup.xml b/solr/core/src/test-files/solr/conf/solrconfig-master1-keepOneBackup.xml index 13a14dac232..5347975debc 100644 --- a/solr/core/src/test-files/solr/conf/solrconfig-master1-keepOneBackup.xml +++ b/solr/core/src/test-files/solr/conf/solrconfig-master1-keepOneBackup.xml @@ -38,7 +38,7 @@ 1 - + diff --git a/solr/core/src/test-files/solr/conf/solrconfig-master1.xml b/solr/core/src/test-files/solr/conf/solrconfig-master1.xml index ce3092cbe08..019f47ebbd8 100644 --- a/solr/core/src/test-files/solr/conf/solrconfig-master1.xml +++ b/solr/core/src/test-files/solr/conf/solrconfig-master1.xml @@ -63,7 +63,7 @@ - + diff --git a/solr/core/src/test-files/solr/conf/solrconfig-master2.xml b/solr/core/src/test-files/solr/conf/solrconfig-master2.xml index b662ec4a0d7..b088fb9beb1 100644 --- a/solr/core/src/test-files/solr/conf/solrconfig-master2.xml +++ b/solr/core/src/test-files/solr/conf/solrconfig-master2.xml @@ -63,7 +63,7 @@ - + diff --git a/solr/core/src/test-files/solr/conf/solrconfig-master3.xml b/solr/core/src/test-files/solr/conf/solrconfig-master3.xml index 4ed7b807724..cf3ee592ba0 100644 --- a/solr/core/src/test-files/solr/conf/solrconfig-master3.xml +++ b/solr/core/src/test-files/solr/conf/solrconfig-master3.xml @@ -64,7 +64,7 @@ - + diff --git a/solr/core/src/test-files/solr/conf/solrconfig-repeater.xml b/solr/core/src/test-files/solr/conf/solrconfig-repeater.xml index 94495535314..14d540c91f5 100644 --- a/solr/core/src/test-files/solr/conf/solrconfig-repeater.xml +++ b/solr/core/src/test-files/solr/conf/solrconfig-repeater.xml @@ -47,7 +47,7 @@ - + diff --git a/solr/core/src/test-files/solr/conf/solrconfig-slave.xml b/solr/core/src/test-files/solr/conf/solrconfig-slave.xml index aa7073d73db..67b3f1dc6c5 100644 --- a/solr/core/src/test-files/solr/conf/solrconfig-slave.xml +++ b/solr/core/src/test-files/solr/conf/solrconfig-slave.xml @@ -47,7 +47,7 @@ - + diff --git a/solr/core/src/test-files/solr/conf/solrconfig-slave1.xml b/solr/core/src/test-files/solr/conf/solrconfig-slave1.xml index 85978026d07..afcd2efe388 100644 --- a/solr/core/src/test-files/solr/conf/solrconfig-slave1.xml +++ b/solr/core/src/test-files/solr/conf/solrconfig-slave1.xml @@ -47,10 +47,7 @@ - - - - + diff --git a/solr/core/src/test-files/solr/conf/solrconfig-solcoreproperties.xml b/solr/core/src/test-files/solr/conf/solrconfig-solcoreproperties.xml index 895e414948a..39398ba796d 100644 --- a/solr/core/src/test-files/solr/conf/solrconfig-solcoreproperties.xml +++ b/solr/core/src/test-files/solr/conf/solrconfig-solcoreproperties.xml @@ -53,7 +53,7 @@ - + diff --git a/solr/core/src/test-files/solr/conf/solrconfig-tlog.xml b/solr/core/src/test-files/solr/conf/solrconfig-tlog.xml index 969e335b393..9933392047c 100644 --- a/solr/core/src/test-files/solr/conf/solrconfig-tlog.xml +++ b/solr/core/src/test-files/solr/conf/solrconfig-tlog.xml @@ -31,11 +31,7 @@ - - - - - + diff --git a/solr/core/src/test-files/solr/conf/solrconfig.xml b/solr/core/src/test-files/solr/conf/solrconfig.xml index b24ea70e590..8029801b701 100644 --- a/solr/core/src/test-files/solr/conf/solrconfig.xml +++ b/solr/core/src/test-files/solr/conf/solrconfig.xml @@ -260,11 +260,7 @@ - - - false - - + diff --git a/solr/core/src/test-files/solr/conf/solrconfig_perf.xml b/solr/core/src/test-files/solr/conf/solrconfig_perf.xml index b9a8a926c4e..0c5e2054bc2 100755 --- a/solr/core/src/test-files/solr/conf/solrconfig_perf.xml +++ b/solr/core/src/test-files/solr/conf/solrconfig_perf.xml @@ -70,10 +70,6 @@ - - - - - + diff --git a/solr/core/src/test-files/solr/crazy-path-to-config.xml b/solr/core/src/test-files/solr/crazy-path-to-config.xml index e4207f1d597..32b550a49d8 100644 --- a/solr/core/src/test-files/solr/crazy-path-to-config.xml +++ b/solr/core/src/test-files/solr/crazy-path-to-config.xml @@ -49,7 +49,7 @@ implicit - + diff --git a/solr/core/src/test/org/apache/solr/ConvertedLegacyTest.java b/solr/core/src/test/org/apache/solr/ConvertedLegacyTest.java index 2ae4df02891..ef7851ab555 100644 --- a/solr/core/src/test/org/apache/solr/ConvertedLegacyTest.java +++ b/solr/core/src/test/org/apache/solr/ConvertedLegacyTest.java @@ -1236,9 +1236,9 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 { // can mess up parsing (and it has in the past) - assertU(" 44 "); - assertU(" 44 hi "); - assertU(" "); + assertU(" 44 "); + assertU(" 44 hi "); + assertU(""); // test adding multiple docs per add command diff --git a/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java b/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java index bdd07b81ecb..58a74ee8724 100644 --- a/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java @@ -337,8 +337,8 @@ public class BasicDistributedZkTest extends AbstractDistributedZkTestCase { throws MalformedURLException, SolrServerException, IOException { long startCommits = getNumCommits((HttpSolrServer) clients.get(0)); - ContentStreamUpdateRequest up = new ContentStreamUpdateRequest("/update/csv"); - up.addFile(getFile("books_numeric_ids.csv")); + ContentStreamUpdateRequest up = new ContentStreamUpdateRequest("/update"); + up.addFile(getFile("books_numeric_ids.csv"), "application/csv"); up.setCommitWithin(900000); up.setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true); NamedList result = clients.get(0).request(up); diff --git a/solr/core/src/test/org/apache/solr/core/RequestHandlersTest.java b/solr/core/src/test/org/apache/solr/core/RequestHandlersTest.java index 213251931dd..d10440e3456 100755 --- a/solr/core/src/test/org/apache/solr/core/RequestHandlersTest.java +++ b/solr/core/src/test/org/apache/solr/core/RequestHandlersTest.java @@ -77,14 +77,14 @@ public class RequestHandlersTest extends SolrTestCaseJ4 { public void testPathNormalization() { SolrCore core = h.getCore(); - SolrRequestHandler h1 = core.getRequestHandler("/update/csv" ); + SolrRequestHandler h1 = core.getRequestHandler("/update" ); assertNotNull( h1 ); - SolrRequestHandler h2 = core.getRequestHandler("/update/csv/" ); + SolrRequestHandler h2 = core.getRequestHandler("/update/" ); assertNotNull( h2 ); assertEquals( h1, h2 ); // the same object - assertNull( core.getRequestHandler("/update/csv/asdgadsgas" ) ); // prefix + assertNull( core.getRequestHandler("/update/asdgadsgas" ) ); // prefix } } diff --git a/solr/core/src/test/org/apache/solr/handler/BinaryUpdateRequestHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/BinaryUpdateRequestHandlerTest.java index 71431e185eb..21d90b42d9e 100644 --- a/solr/core/src/test/org/apache/solr/handler/BinaryUpdateRequestHandlerTest.java +++ b/solr/core/src/test/org/apache/solr/handler/BinaryUpdateRequestHandlerTest.java @@ -21,6 +21,8 @@ import org.apache.solr.client.solrj.impl.BinaryRequestWriter; import org.apache.solr.client.solrj.request.UpdateRequest; import org.apache.solr.common.SolrInputDocument; import org.apache.solr.common.params.UpdateParams; +import org.apache.solr.common.util.NamedList; +import org.apache.solr.handler.loader.ContentStreamLoader; import org.apache.solr.request.SolrQueryRequest; import org.apache.solr.response.SolrQueryResponse; import org.apache.solr.update.AddUpdateCommand; @@ -47,11 +49,12 @@ public class BinaryUpdateRequestHandlerTest extends SolrTestCaseJ4 { BinaryRequestWriter brw = new BinaryRequestWriter(); BufferingRequestProcessor p = new BufferingRequestProcessor(null); SolrQueryResponse rsp = new SolrQueryResponse(); - BinaryUpdateRequestHandler handler = new BinaryUpdateRequestHandler(); + UpdateRequestHandler handler = new UpdateRequestHandler(); + handler.init(new NamedList()); SolrQueryRequest req = req(); ContentStreamLoader csl = handler.newLoader(req, p); - csl.load(req, rsp, brw.getContentStream(ureq)); + csl.load(req, rsp, brw.getContentStream(ureq), p); AddUpdateCommand add = p.addCommands.get(0); System.out.println(add.solrDoc); diff --git a/solr/core/src/test/org/apache/solr/handler/CSVRequestHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/CSVRequestHandlerTest.java index f208724d073..c7d860b3f3b 100644 --- a/solr/core/src/test/org/apache/solr/handler/CSVRequestHandlerTest.java +++ b/solr/core/src/test/org/apache/solr/handler/CSVRequestHandlerTest.java @@ -19,6 +19,7 @@ package org.apache.solr.handler; import org.apache.solr.SolrTestCaseJ4; import org.apache.solr.common.util.ContentStreamBase; +import org.apache.solr.handler.loader.CSVLoader; import org.apache.solr.request.SolrQueryRequest; import org.apache.solr.response.SolrQueryResponse; import org.apache.solr.update.AddUpdateCommand; @@ -36,16 +37,14 @@ public class CSVRequestHandlerTest extends SolrTestCaseJ4 { @Test public void testCommitWithin() throws Exception { - CSVRequestHandler handler = new CSVRequestHandler(); - String csvString = "id;name\n123;hello"; SolrQueryRequest req = req("separator", ";", "commitWithin", "200"); SolrQueryResponse rsp = new SolrQueryResponse(); BufferingRequestProcessor p = new BufferingRequestProcessor(null); - CSVLoader loader = (CSVLoader) handler.newLoader(req, p); - loader.load(req, rsp, new ContentStreamBase.StringStream.StringStream(csvString)); + CSVLoader loader = new CSVLoader(); + loader.load(req, rsp, new ContentStreamBase.StringStream.StringStream(csvString), p); AddUpdateCommand add = p.addCommands.get(0); assertEquals(200, add.commitWithin); diff --git a/solr/core/src/test/org/apache/solr/handler/JsonLoaderTest.java b/solr/core/src/test/org/apache/solr/handler/JsonLoaderTest.java index 90b2e8b048a..42cc9e4bc38 100644 --- a/solr/core/src/test/org/apache/solr/handler/JsonLoaderTest.java +++ b/solr/core/src/test/org/apache/solr/handler/JsonLoaderTest.java @@ -21,6 +21,7 @@ import org.apache.solr.SolrTestCaseJ4; import org.apache.solr.common.SolrInputDocument; import org.apache.solr.common.SolrInputField; import org.apache.solr.common.util.ContentStreamBase; +import org.apache.solr.handler.loader.JsonLoader; import org.apache.solr.request.SolrQueryRequest; import org.apache.solr.response.SolrQueryResponse; import org.apache.solr.update.AddUpdateCommand; @@ -84,8 +85,8 @@ public class JsonLoaderTest extends SolrTestCaseJ4 { SolrQueryRequest req = req(); SolrQueryResponse rsp = new SolrQueryResponse(); BufferingRequestProcessor p = new BufferingRequestProcessor(null); - JsonLoader loader = new JsonLoader( req, p ); - loader.load(req, rsp, new ContentStreamBase.StringStream(input)); + JsonLoader loader = new JsonLoader(); + loader.load(req, rsp, new ContentStreamBase.StringStream(input), p); assertEquals( 2, p.addCommands.size() ); @@ -153,8 +154,8 @@ public class JsonLoaderTest extends SolrTestCaseJ4 { SolrQueryRequest req = req("commitWithin","100", "overwrite","false"); SolrQueryResponse rsp = new SolrQueryResponse(); BufferingRequestProcessor p = new BufferingRequestProcessor(null); - JsonLoader loader = new JsonLoader( req, p ); - loader.load(req, rsp, new ContentStreamBase.StringStream(str)); + JsonLoader loader = new JsonLoader(); + loader.load(req, rsp, new ContentStreamBase.StringStream(str), p); assertEquals( 2, p.addCommands.size() ); @@ -181,8 +182,8 @@ public class JsonLoaderTest extends SolrTestCaseJ4 { SolrQueryRequest req = req(); SolrQueryResponse rsp = new SolrQueryResponse(); BufferingRequestProcessor p = new BufferingRequestProcessor(null); - JsonLoader loader = new JsonLoader( req, p ); - loader.load(req, rsp, new ContentStreamBase.StringStream(str)); + JsonLoader loader = new JsonLoader(); + loader.load(req, rsp, new ContentStreamBase.StringStream(str), p); assertEquals( 2, p.addCommands.size() ); @@ -208,8 +209,8 @@ public class JsonLoaderTest extends SolrTestCaseJ4 { SolrQueryRequest req = req(); SolrQueryResponse rsp = new SolrQueryResponse(); BufferingRequestProcessor p = new BufferingRequestProcessor(null); - JsonLoader loader = new JsonLoader( req, p ); - loader.load(req, rsp, new ContentStreamBase.StringStream(str)); + JsonLoader loader = new JsonLoader(); + loader.load(req, rsp, new ContentStreamBase.StringStream(str), p); assertEquals( 1, p.addCommands.size() ); diff --git a/solr/core/src/test/org/apache/solr/handler/TestCSVLoader.java b/solr/core/src/test/org/apache/solr/handler/TestCSVLoader.java index aebbd1e3726..2712615b158 100755 --- a/solr/core/src/test/org/apache/solr/handler/TestCSVLoader.java +++ b/solr/core/src/test/org/apache/solr/handler/TestCSVLoader.java @@ -88,16 +88,18 @@ public class TestCSVLoader extends SolrTestCaseJ4 { // TODO: stop using locally defined streams once stream.file and // stream.body work everywhere - List cs = new ArrayList(); - cs.add(new ContentStreamBase.FileStream(new File(filename))); + List cs = new ArrayList(1); + ContentStreamBase f = new ContentStreamBase.FileStream(new File(filename)); + f.setContentType("text/csv"); + cs.add(f); req.setContentStreams(cs); - h.query("/update/csv",req); + h.query("/update",req); } @Test public void testCSVLoad() throws Exception { makeFile("id\n100\n101\n102"); - loadLocal("stream.file",filename); + loadLocal(); // check default commit of false assertQ(req("id:[100 TO 110]"),"//*[@numFound='0']"); assertU(commit()); @@ -107,7 +109,7 @@ public class TestCSVLoader extends SolrTestCaseJ4 { @Test public void testCommitFalse() throws Exception { makeFile("id\n100\n101\n102"); - loadLocal("stream.file",filename,"commit","false"); + loadLocal("commit","false"); assertQ(req("id:[100 TO 110]"),"//*[@numFound='0']"); assertU(commit()); assertQ(req("id:[100 TO 110]"),"//*[@numFound='3']"); @@ -116,14 +118,14 @@ public class TestCSVLoader extends SolrTestCaseJ4 { @Test public void testCommitTrue() throws Exception { makeFile("id\n100\n101\n102"); - loadLocal("stream.file",filename,"commit","true"); + loadLocal("commit","true"); assertQ(req("id:[100 TO 110]"),"//*[@numFound='3']"); } @Test public void testLiteral() throws Exception { makeFile("id\n100"); - loadLocal("stream.file",filename,"commit","true", "literal.name","LITERAL_VALUE"); + loadLocal("commit","true", "literal.name","LITERAL_VALUE"); assertQ(req("*:*"),"//doc/str[@name='name'][.='LITERAL_VALUE']"); } @@ -133,7 +135,7 @@ public class TestCSVLoader extends SolrTestCaseJ4 { lrf.args.put(CommonParams.VERSION,"2.2"); makeFile("id,str_s\n100,\"quoted\"\n101,\n102,\"\"\n103,"); - loadLocal("stream.file",filename,"commit","true"); + loadLocal("commit","true"); assertQ(req("id:[100 TO 110]"),"//*[@numFound='4']"); assertQ(req("id:100"),"//arr[@name='str_s']/str[.='quoted']"); assertQ(req("id:101"),"count(//str[@name='str_s'])=0"); @@ -145,23 +147,23 @@ public class TestCSVLoader extends SolrTestCaseJ4 { assertQ(req("id:103"),"count(//str[@name='str_s'])=0"); // test overwrite by default - loadLocal("stream.file",filename, "commit","true"); + loadLocal("commit","true"); assertQ(req("id:[100 TO 110]"),"//*[@numFound='4']"); // test explicitly adding header=true (the default) - loadLocal("stream.file",filename, "commit","true","header","true"); + loadLocal("commit","true","header","true"); assertQ(req("id:[100 TO 110]"),"//*[@numFound='4']"); // test no overwrites - loadLocal("stream.file",filename, "commit","true", "overwrite","false"); + loadLocal("commit","true", "overwrite","false"); assertQ(req("id:[100 TO 110]"),"//*[@numFound='8']"); // test overwrite - loadLocal("stream.file",filename, "commit","true"); + loadLocal("commit","true"); assertQ(req("id:[100 TO 110]"),"//*[@numFound='4']"); // test global value mapping - loadLocal("stream.file",filename, "commit","true", "map","quoted:QUOTED"); + loadLocal("commit","true", "map","quoted:QUOTED"); assertQ(req("id:[100 TO 110]"),"//*[@numFound='4']"); assertQ(req("id:100"),"//arr[@name='str_s']/str[.='QUOTED']"); assertQ(req("id:101"),"count(//str[@name='str_s'])=0"); @@ -169,12 +171,12 @@ public class TestCSVLoader extends SolrTestCaseJ4 { assertQ(req("id:103"),"count(//str[@name='str_s'])=0"); // test value mapping to empty (remove) - loadLocal("stream.file",filename, "commit","true", "map","quoted:"); + loadLocal("commit","true", "map","quoted:"); assertQ(req("id:[100 TO 110]"),"//*[@numFound='4']"); assertQ(req("id:100"),"count(//str[@name='str_s'])=0"); // test value mapping from empty - loadLocal("stream.file",filename, "commit","true", "map",":EMPTY"); + loadLocal("commit","true", "map",":EMPTY"); assertQ(req("id:[100 TO 110]"),"//*[@numFound='4']"); assertQ(req("id:100"),"//arr[@name='str_s']/str[.='quoted']"); assertQ(req("id:101"),"//arr[@name='str_s']/str[.='EMPTY']"); @@ -182,7 +184,7 @@ public class TestCSVLoader extends SolrTestCaseJ4 { assertQ(req("id:103"),"//arr[@name='str_s']/str[.='EMPTY']"); // test multiple map rules - loadLocal("stream.file",filename, "commit","true", "map",":EMPTY", "map","quoted:QUOTED"); + loadLocal("commit","true", "map",":EMPTY", "map","quoted:QUOTED"); assertQ(req("id:[100 TO 110]"),"//*[@numFound='4']"); assertQ(req("id:100"),"//arr[@name='str_s']/str[.='QUOTED']"); assertQ(req("id:101"),"//arr[@name='str_s']/str[.='EMPTY']"); @@ -190,7 +192,7 @@ public class TestCSVLoader extends SolrTestCaseJ4 { assertQ(req("id:103"),"//arr[@name='str_s']/str[.='EMPTY']"); // test indexing empty fields - loadLocal("stream.file",filename, "commit","true", "f.str_s.keepEmpty","true"); + loadLocal("commit","true", "f.str_s.keepEmpty","true"); assertQ(req("id:[100 TO 110]"),"//*[@numFound='4']"); assertQ(req("id:100"),"//arr[@name='str_s']/str[.='quoted']"); assertQ(req("id:101"),"//arr[@name='str_s']/str[.='']"); @@ -198,7 +200,7 @@ public class TestCSVLoader extends SolrTestCaseJ4 { assertQ(req("id:103"),"//arr[@name='str_s']/str[.='']"); // test overriding the name of fields - loadLocal("stream.file",filename, "commit","true", + loadLocal("commit","true", "fieldnames","id,my_s", "header","true", "f.my_s.map",":EMPTY"); assertQ(req("id:[100 TO 110]"),"//*[@numFound='4']"); @@ -214,23 +216,23 @@ public class TestCSVLoader extends SolrTestCaseJ4 { assertQ(req("id:id"),"//*[@numFound='0']"); // test skipping a field via the "skip" parameter - loadLocal("stream.file",filename,"commit","true","keepEmpty","true","skip","str_s"); + loadLocal("commit","true","keepEmpty","true","skip","str_s"); assertQ(req("id:[100 TO 110]"),"//*[@numFound='4']"); assertQ(req("id:[100 TO 110]"),"count(//str[@name='str_s']/str)=0"); // test skipping a field by specifying an empty name - loadLocal("stream.file",filename,"commit","true","keepEmpty","true","fieldnames","id,"); + loadLocal("commit","true","keepEmpty","true","fieldnames","id,"); assertQ(req("id:[100 TO 110]"),"//*[@numFound='4']"); assertQ(req("id:[100 TO 110]"),"count(//str[@name='str_s']/str)=0"); // test loading file as if it didn't have a header - loadLocal("stream.file",filename, "commit","true", + loadLocal("commit","true", "fieldnames","id,my_s", "header","false"); assertQ(req("id:id"),"//*[@numFound='1']"); assertQ(req("id:100"),"//arr[@name='my_s']/str[.='quoted']"); // test skipLines - loadLocal("stream.file",filename, "commit","true", + loadLocal("commit","true", "fieldnames","id,my_s", "header","false", "skipLines","1"); assertQ(req("id:id"),"//*[@numFound='1']"); assertQ(req("id:100"),"//arr[@name='my_s']/str[.='quoted']"); @@ -242,7 +244,7 @@ public class TestCSVLoader extends SolrTestCaseJ4 { +"101,\"a,b,c\"\n" +"102,\"a,,b\"\n" +"103,\n"); - loadLocal("stream.file",filename, "commit","true", + loadLocal("commit","true", "f.str_s.map",":EMPTY", "f.str_s.split","true"); assertQ(req("id:[100 TO 110]"),"//*[@numFound='4']"); @@ -263,7 +265,7 @@ public class TestCSVLoader extends SolrTestCaseJ4 { +"104|a\\\\b\n" // no backslash escaping should be done by default ); - loadLocal("stream.file",filename, "commit","true", + loadLocal("commit","true", "separator","|", "encapsulator","^", "f.str_s.map",":EMPTY", @@ -286,7 +288,7 @@ public class TestCSVLoader extends SolrTestCaseJ4 { +"101,unquoted \"\" \\ string\n" // double encap shouldn't be an escape outside encap +"102,end quote \\\n" ); - loadLocal("stream.file",filename, "commit","true" + loadLocal("commit","true" ); assertQ(req("id:100"),"//arr[@name='str_s']/str[.='quoted \" \\ string']"); assertQ(req("id:101"),"//arr[@name='str_s']/str[.='unquoted \"\" \\ string']"); @@ -298,7 +300,7 @@ public class TestCSVLoader extends SolrTestCaseJ4 { +"100,\"quoted \"\" \\\" \\\\ string\"\n" // quotes should be part of value +"101,unquoted \"\" \\\" \\, \\\\ string\n" ); - loadLocal("stream.file",filename, "commit","true" + loadLocal("commit","true" ,"escape","\\" ); assertQ(req("id:100"),"//arr[@name='str_s']/str[.='\"quoted \"\" \" \\ string\"']"); diff --git a/solr/core/src/test/org/apache/solr/handler/XmlUpdateRequestHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/XmlUpdateRequestHandlerTest.java index 5f6c574c886..7f3cb9de657 100644 --- a/solr/core/src/test/org/apache/solr/handler/XmlUpdateRequestHandlerTest.java +++ b/solr/core/src/test/org/apache/solr/handler/XmlUpdateRequestHandlerTest.java @@ -20,6 +20,7 @@ import org.apache.solr.SolrTestCaseJ4; import org.apache.commons.lang.ObjectUtils; import org.apache.solr.common.SolrInputDocument; import org.apache.solr.common.util.ContentStreamBase; +import org.apache.solr.handler.loader.XMLLoader; import org.apache.solr.request.SolrQueryRequest; import org.apache.solr.response.SolrQueryResponse; import org.apache.solr.update.AddUpdateCommand; @@ -40,12 +41,12 @@ import javax.xml.stream.XMLStreamReader; public class XmlUpdateRequestHandlerTest extends SolrTestCaseJ4 { private static XMLInputFactory inputFactory = XMLInputFactory.newInstance(); - protected static XmlUpdateRequestHandler handler; + protected static UpdateRequestHandler handler; @BeforeClass public static void beforeTests() throws Exception { initCore("solrconfig.xml","schema.xml"); - handler = new XmlUpdateRequestHandler(); + handler = new UpdateRequestHandler(); } @Test @@ -65,7 +66,7 @@ public class XmlUpdateRequestHandlerTest extends SolrTestCaseJ4 { inputFactory.createXMLStreamReader( new StringReader( xml ) ); parser.next(); // read the START document... //null for the processor is all right here - XMLLoader loader = new XMLLoader(null, inputFactory); + XMLLoader loader = new XMLLoader(); SolrInputDocument doc = loader.readDoc( parser ); // Read boosts @@ -100,8 +101,8 @@ public class XmlUpdateRequestHandlerTest extends SolrTestCaseJ4 { SolrQueryResponse rsp = new SolrQueryResponse(); BufferingRequestProcessor p = new BufferingRequestProcessor(null); - XMLLoader loader = new XMLLoader(p, inputFactory); - loader.load(req, rsp, new ContentStreamBase.StringStream(xml)); + XMLLoader loader = new XMLLoader().init(null); + loader.load(req, rsp, new ContentStreamBase.StringStream(xml), p); AddUpdateCommand add = p.addCommands.get(0); assertEquals(100, add.commitWithin); @@ -135,8 +136,8 @@ public class XmlUpdateRequestHandlerTest extends SolrTestCaseJ4 { p.expectDelete(null, "id:150", 500); p.expectDelete("150", null, -1); - XMLLoader loader = new XMLLoader(p, inputFactory); - loader.load(req(), new SolrQueryResponse(), new ContentStreamBase.StringStream(xml)); + XMLLoader loader = new XMLLoader().init(null); + loader.load(req(), new SolrQueryResponse(), new ContentStreamBase.StringStream(xml), p); p.assertNoCommandsPending(); } diff --git a/solr/core/src/test/org/apache/solr/handler/XsltUpdateRequestHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/XsltUpdateRequestHandlerTest.java index 4ee9e19110c..f2e210f16b7 100644 --- a/solr/core/src/test/org/apache/solr/handler/XsltUpdateRequestHandlerTest.java +++ b/solr/core/src/test/org/apache/solr/handler/XsltUpdateRequestHandlerTest.java @@ -22,6 +22,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Map; +import org.apache.solr.common.params.CommonParams; import org.apache.solr.common.params.MapSolrParams; import org.apache.solr.common.util.ContentStream; import org.apache.solr.common.util.ContentStreamBase; @@ -35,12 +36,10 @@ import org.junit.BeforeClass; import org.junit.Test; public class XsltUpdateRequestHandlerTest extends SolrTestCaseJ4 { - protected static XsltUpdateRequestHandler handler; @BeforeClass public static void beforeTests() throws Exception { initCore("solrconfig.xml","schema.xml"); - handler = new XsltUpdateRequestHandler(); } @Override @@ -65,24 +64,24 @@ public class XsltUpdateRequestHandlerTest extends SolrTestCaseJ4 { " " + ""; - Map args = new HashMap(); - args.put("tr", "xsl-update-handler-test.xsl"); - - SolrCore core = h.getCore(); - LocalSolrQueryRequest req = new LocalSolrQueryRequest( core, new MapSolrParams( args) ); - ArrayList streams = new ArrayList(); - streams.add(new ContentStreamBase.StringStream(xml)); - req.setContentStreams(streams); - SolrQueryResponse rsp = new SolrQueryResponse(); - XsltUpdateRequestHandler handler = new XsltUpdateRequestHandler(); - handler.init(new NamedList()); - handler.handleRequestBody(req, rsp); - StringWriter sw = new StringWriter(32000); - QueryResponseWriter responseWriter = core.getQueryResponseWriter(req); - responseWriter.write(sw,req,rsp); - req.close(); - String response = sw.toString(); - assertU(response); + Map args = new HashMap(); + args.put(CommonParams.TR, "xsl-update-handler-test.xsl"); + + SolrCore core = h.getCore(); + LocalSolrQueryRequest req = new LocalSolrQueryRequest( core, new MapSolrParams( args) ); + ArrayList streams = new ArrayList(); + streams.add(new ContentStreamBase.StringStream(xml)); + req.setContentStreams(streams); + SolrQueryResponse rsp = new SolrQueryResponse(); + UpdateRequestHandler handler = new UpdateRequestHandler(); + handler.init(new NamedList()); + handler.handleRequestBody(req, rsp); + StringWriter sw = new StringWriter(32000); + QueryResponseWriter responseWriter = core.getQueryResponseWriter(req); + responseWriter.write(sw,req,rsp); + req.close(); + String response = sw.toString(); + assertU(response); assertU(commit()); assertQ("test document was correctly committed", req("q","*:*") diff --git a/solr/core/src/test/org/apache/solr/servlet/CacheHeaderTestBase.java b/solr/core/src/test/org/apache/solr/servlet/CacheHeaderTestBase.java index 1f550ba9fdc..2271f60fde4 100644 --- a/solr/core/src/test/org/apache/solr/servlet/CacheHeaderTestBase.java +++ b/solr/core/src/test/org/apache/solr/servlet/CacheHeaderTestBase.java @@ -75,7 +75,7 @@ public abstract class CacheHeaderTestBase extends SolrJettyTestBase { } java.net.URI uri = URIUtils.createURI("http", new URI(httpserver.getBaseURL()).getHost(), - new URI(httpserver.getBaseURL()).getPort(), "/solr/update/csv", + new URI(httpserver.getBaseURL()).getPort(), "/solr/update", URLEncodedUtils.format(qparams, "UTF-8"), null); if ("GET".equals(method)) { diff --git a/solr/core/src/test/org/apache/solr/update/AutoCommitTest.java b/solr/core/src/test/org/apache/solr/update/AutoCommitTest.java index d6b4c77a42b..fcf0042b475 100644 --- a/solr/core/src/test/org/apache/solr/update/AutoCommitTest.java +++ b/solr/core/src/test/org/apache/solr/update/AutoCommitTest.java @@ -27,7 +27,7 @@ import org.apache.solr.common.util.ContentStreamBase; import org.apache.solr.common.util.NamedList; import org.apache.solr.core.SolrCore; import org.apache.solr.core.SolrEventListener; -import org.apache.solr.handler.XmlUpdateRequestHandler; +import org.apache.solr.handler.UpdateRequestHandler; import org.apache.solr.request.SolrQueryRequestBase; import org.apache.solr.response.SolrQueryResponse; import org.apache.solr.search.SolrIndexSearcher; @@ -150,7 +150,7 @@ public class AutoCommitTest extends AbstractSolrTestCase { core.registerNewSearcherListener(trigger); - XmlUpdateRequestHandler handler = new XmlUpdateRequestHandler(); + UpdateRequestHandler handler = new UpdateRequestHandler(); handler.init( null ); MapSolrParams params = new MapSolrParams( new HashMap() ); @@ -198,7 +198,7 @@ public class AutoCommitTest extends AbstractSolrTestCase { tracker.setDocsUpperBound(-1); // updater.commitCallbacks.add(trigger); - XmlUpdateRequestHandler handler = new XmlUpdateRequestHandler(); + UpdateRequestHandler handler = new UpdateRequestHandler(); handler.init( null ); MapSolrParams params = new MapSolrParams( new HashMap() ); @@ -268,7 +268,7 @@ public class AutoCommitTest extends AbstractSolrTestCase { tracker.setTimeUpperBound(0); tracker.setDocsUpperBound(-1); - XmlUpdateRequestHandler handler = new XmlUpdateRequestHandler(); + UpdateRequestHandler handler = new UpdateRequestHandler(); handler.init( null ); MapSolrParams params = new MapSolrParams( new HashMap() ); diff --git a/solr/core/src/test/org/apache/solr/update/UpdateParamsTest.java b/solr/core/src/test/org/apache/solr/update/UpdateParamsTest.java index bbfdebe04e8..8b3e537a174 100644 --- a/solr/core/src/test/org/apache/solr/update/UpdateParamsTest.java +++ b/solr/core/src/test/org/apache/solr/update/UpdateParamsTest.java @@ -22,7 +22,7 @@ import java.util.HashMap; import org.apache.solr.common.params.MapSolrParams; import org.apache.solr.common.params.UpdateParams; import org.apache.solr.core.*; -import org.apache.solr.handler.XmlUpdateRequestHandler; +import org.apache.solr.handler.UpdateRequestHandler; import org.apache.solr.request.SolrQueryRequestBase; import org.apache.solr.response.SolrQueryResponse; import org.apache.solr.util.AbstractSolrTestCase; @@ -42,7 +42,7 @@ public class UpdateParamsTest extends AbstractSolrTestCase { public void testUpdateProcessorParamDeprecationRemoved() throws Exception { SolrCore core = h.getCore(); - XmlUpdateRequestHandler handler = new XmlUpdateRequestHandler(); + UpdateRequestHandler handler = new UpdateRequestHandler(); handler.init( null ); MapSolrParams params = new MapSolrParams( new HashMap() ); diff --git a/solr/core/src/test/org/apache/solr/update/processor/SignatureUpdateProcessorFactoryTest.java b/solr/core/src/test/org/apache/solr/update/processor/SignatureUpdateProcessorFactoryTest.java index 753f59f34ef..9c5b018b91e 100755 --- a/solr/core/src/test/org/apache/solr/update/processor/SignatureUpdateProcessorFactoryTest.java +++ b/solr/core/src/test/org/apache/solr/update/processor/SignatureUpdateProcessorFactoryTest.java @@ -33,7 +33,7 @@ import org.apache.solr.common.util.ContentStream; import org.apache.solr.common.util.ContentStreamBase; import org.apache.solr.core.SolrCore; import org.apache.solr.handler.BinaryUpdateRequestHandler; -import org.apache.solr.handler.XmlUpdateRequestHandler; +import org.apache.solr.handler.UpdateRequestHandler; import org.apache.solr.request.SolrQueryRequest; import org.apache.solr.request.SolrQueryRequestBase; import org.apache.solr.request.LocalSolrQueryRequest; @@ -328,7 +328,8 @@ public class SignatureUpdateProcessorFactoryTest extends SolrTestCaseJ4 { LocalSolrQueryRequest req = new LocalSolrQueryRequest(h.getCore(), mmparams); try { req.setContentStreams(streams); - BinaryUpdateRequestHandler h = new BinaryUpdateRequestHandler(); + UpdateRequestHandler h = new UpdateRequestHandler(); + h.init(new NamedList()); h.handleRequestBody(req, new SolrQueryResponse()); } finally { req.close(); @@ -359,7 +360,7 @@ public class SignatureUpdateProcessorFactoryTest extends SolrTestCaseJ4 { (SolrParams) mmparams) { }; - XmlUpdateRequestHandler handler = new XmlUpdateRequestHandler(); + UpdateRequestHandler handler = new UpdateRequestHandler(); handler.init(null); ArrayList streams = new ArrayList(2); streams.add(new ContentStreamBase.StringStream(doc)); diff --git a/solr/core/src/test/org/apache/solr/update/processor/UniqFieldsUpdateProcessorFactoryTest.java b/solr/core/src/test/org/apache/solr/update/processor/UniqFieldsUpdateProcessorFactoryTest.java index 4d3634eb54a..e503dc150eb 100644 --- a/solr/core/src/test/org/apache/solr/update/processor/UniqFieldsUpdateProcessorFactoryTest.java +++ b/solr/core/src/test/org/apache/solr/update/processor/UniqFieldsUpdateProcessorFactoryTest.java @@ -28,7 +28,7 @@ import org.apache.solr.common.params.UpdateParams; import org.apache.solr.common.util.ContentStream; import org.apache.solr.common.util.ContentStreamBase; import org.apache.solr.core.SolrCore; -import org.apache.solr.handler.XmlUpdateRequestHandler; +import org.apache.solr.handler.UpdateRequestHandler; import org.apache.solr.request.SolrQueryRequest; import org.apache.solr.request.SolrQueryRequestBase; import org.apache.solr.response.SolrQueryResponse; @@ -112,7 +112,7 @@ public class UniqFieldsUpdateProcessorFactoryTest extends SolrTestCaseJ4 { (SolrParams) mmparams) { }; - XmlUpdateRequestHandler handler = new XmlUpdateRequestHandler(); + UpdateRequestHandler handler = new UpdateRequestHandler(); handler.init(null); ArrayList streams = new ArrayList(2); streams.add(new ContentStreamBase.StringStream(doc)); diff --git a/solr/example/example-DIH/solr/db/conf/solrconfig.xml b/solr/example/example-DIH/solr/db/conf/solrconfig.xml index 13cdd1c248e..c9fd9fa0965 100644 --- a/solr/example/example-DIH/solr/db/conf/solrconfig.xml +++ b/solr/example/example-DIH/solr/db/conf/solrconfig.xml @@ -390,14 +390,7 @@ "update.processor.class" is the class name for the UpdateRequestProcessor. It is initalized only once. This can not be changed for each request. --> - - - - - - + - - - - - - - - + - - - - - - + - - - - - - + - + diff --git a/solr/example/multicore/core0/conf/solrconfig.xml b/solr/example/multicore/core0/conf/solrconfig.xml index 64ea8fa2d76..81c52bbe88e 100644 --- a/solr/example/multicore/core0/conf/solrconfig.xml +++ b/solr/example/multicore/core0/conf/solrconfig.xml @@ -36,7 +36,7 @@ - + diff --git a/solr/example/multicore/core1/conf/solrconfig.xml b/solr/example/multicore/core1/conf/solrconfig.xml index 9d2c68ecd7b..73e816f00e6 100644 --- a/solr/example/multicore/core1/conf/solrconfig.xml +++ b/solr/example/multicore/core1/conf/solrconfig.xml @@ -36,7 +36,7 @@ - + diff --git a/solr/example/solr/conf/solrconfig.xml b/solr/example/solr/conf/solrconfig.xml index 1fa30bd4169..787b078c119 100755 --- a/solr/example/solr/conf/solrconfig.xml +++ b/solr/example/solr/conf/solrconfig.xml @@ -894,19 +894,25 @@ - - + - - - - - - - - - - - json - true - - + - diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java b/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java index 77301a4cea0..6023d08aa1f 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java @@ -588,8 +588,8 @@ abstract public class SolrExampleTests extends SolrJettyTestBase QueryResponse rsp = server.query( new SolrQuery( "*:*") ); Assert.assertEquals( 0, rsp.getResults().getNumFound() ); - ContentStreamUpdateRequest up = new ContentStreamUpdateRequest("/update/csv"); - up.addFile(getFile("solrj/books.csv")); + ContentStreamUpdateRequest up = new ContentStreamUpdateRequest("/update"); + up.addFile(getFile("solrj/books.csv"), "application/csv"); up.setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true); NamedList result = server.request(up); assertNotNull("Couldn't upload books.csv", result); @@ -606,8 +606,8 @@ abstract public class SolrExampleTests extends SolrJettyTestBase Assert.assertEquals( 0, rsp.getResults().getNumFound() ); ContentStreamUpdateRequest up = new ContentStreamUpdateRequest("/update"); - up.addFile(getFile("solrj/docs1.xml")); // 2 - up.addFile(getFile("solrj/docs2.xml")); // 3 + up.addFile(getFile("solrj/docs1.xml"),"application/xml"); // 2 + up.addFile(getFile("solrj/docs2.xml"),"application/xml"); // 3 up.setParam("a", "\u1234"); up.setParam(CommonParams.HEADER_ECHO_PARAMS, CommonParams.EchoParamStyle.ALL.toString()); up.setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true); diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/BasicHttpSolrServerTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/BasicHttpSolrServerTest.java index 90fdd5cef5c..d9d2e9e2fd9 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/BasicHttpSolrServerTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/BasicHttpSolrServerTest.java @@ -332,7 +332,7 @@ public class BasicHttpSolrServerTest extends SolrJettyTestBase { assertEquals("javabin", DebugServlet.parameters.get(CommonParams.WT)[0]); assertEquals(1, DebugServlet.parameters.get(CommonParams.VERSION).length); assertEquals(server.getParser().getVersion(), DebugServlet.parameters.get(CommonParams.VERSION)[0]); - assertEquals("application/octet-stream", DebugServlet.headers.get("Content-Type")); + assertEquals("application/javabin", DebugServlet.headers.get("Content-Type")); assertEquals(1, DebugServlet.parameters.get("a").length); assertEquals("\u1234", DebugServlet.parameters.get("a")[0]); } diff --git a/solr/test-framework/src/java/org/apache/solr/util/TestHarness.java b/solr/test-framework/src/java/org/apache/solr/util/TestHarness.java index 4ad7e9d8d7e..3d7a80aa7ef 100644 --- a/solr/test-framework/src/java/org/apache/solr/util/TestHarness.java +++ b/solr/test-framework/src/java/org/apache/solr/util/TestHarness.java @@ -26,7 +26,7 @@ import org.apache.solr.core.SolrCore; import org.apache.solr.core.CoreContainer; import org.apache.solr.core.CoreDescriptor; import org.apache.solr.core.SolrResourceLoader; -import org.apache.solr.handler.XmlUpdateRequestHandler; +import org.apache.solr.handler.UpdateRequestHandler; import org.apache.solr.logging.ListenerConfig; import org.apache.solr.logging.LogWatcher; import org.apache.solr.logging.jul.JulWatcher; @@ -74,7 +74,7 @@ public class TestHarness { private SolrCore core; private final ThreadLocal builderTL = new ThreadLocal(); private final ThreadLocal xpathTL = new ThreadLocal(); - public XmlUpdateRequestHandler updater; + public UpdateRequestHandler updater; public static SolrConfig createConfig(String confFile) { // set some system properties for use by tests @@ -147,7 +147,7 @@ public class TestHarness { if (core != null) core.close(); - updater = new XmlUpdateRequestHandler(); + updater = new UpdateRequestHandler(); updater.init( null ); } catch (Exception e) { throw new RuntimeException(e);