[
https://issues.apache.org/jira/browse/NIFI-4516?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16392254#comment-16392254
]
ASF GitHub Bot commented on NIFI-4516:
--------------------------------------
Github user MikeThomsen commented on a diff in the pull request:
https://github.com/apache/nifi/pull/2517#discussion_r173346825
--- Diff:
nifi-nar-bundles/nifi-solr-bundle/nifi-solr-processors/src/test/java/org/apache/nifi/processors/solr/TestFetchSolr.java
---
@@ -0,0 +1,380 @@
+/*
+ * 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.
+ */
+
+package org.apache.nifi.processors.solr;
+
+import com.google.gson.stream.JsonReader;
+import org.apache.nifi.json.JsonRecordSetWriter;
+import org.apache.nifi.processor.ProcessContext;
+import org.apache.nifi.reporting.InitializationException;
+import org.apache.nifi.schema.access.SchemaAccessUtils;
+import org.apache.nifi.util.MockFlowFile;
+import org.apache.nifi.util.TestRunner;
+import org.apache.nifi.util.TestRunners;
+import org.apache.solr.client.solrj.SolrClient;
+import org.apache.solr.common.SolrInputDocument;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.xmlunit.matchers.CompareMatcher;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.TimeZone;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThat;
+
+public class TestFetchSolr {
+ static final String DEFAULT_SOLR_CORE = "testCollection";
+
+ private static final SimpleDateFormat df = new
SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US);
+ static {
+ df.setTimeZone(TimeZone.getTimeZone("GMT"));
+ }
+
+ private SolrClient solrClient;
+
+ @Before
+ public void setup() {
+
+ try {
+
+ // create an EmbeddedSolrServer for the processor to use
+ String relPath =
getClass().getProtectionDomain().getCodeSource()
+ .getLocation().getFile() + "../../target";
+
+ solrClient =
EmbeddedSolrServerFactory.create(EmbeddedSolrServerFactory.DEFAULT_SOLR_HOME,
+ DEFAULT_SOLR_CORE, relPath);
+
+ for (int i = 0; i < 10; i++) {
+ SolrInputDocument doc = new SolrInputDocument();
+ doc.addField("id", "doc" + i);
+ Date date = new Date();
+ doc.addField("created", df.format(date));
+ doc.addField("string_single", "single" + i + ".1");
+ doc.addField("string_multi", "multi" + i + ".1");
+ doc.addField("string_multi", "multi" + i + ".2");
+ doc.addField("integer_single", i);
+ doc.addField("integer_multi", 1);
+ doc.addField("integer_multi", 2);
+ doc.addField("integer_multi", 3);
+ doc.addField("double_single", 0.5 + i);
+
+ solrClient.add(doc);
+ System.out.println(doc.getField("created").getValue());
+
+ }
+ solrClient.commit();
+ } catch (Exception e) {
+ e.printStackTrace();
+ Assert.fail(e.getMessage());
+ }
+ }
+
+ @After
+ public void teardown() {
+ try {
+ solrClient.close();
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testAllFacetCategories() throws IOException {
+ final TestableProcessor proc = new TestableProcessor(solrClient);
+
+ TestRunner runner = TestRunners.newTestRunner(proc);
+ runner.setProperty(SolrUtils.SOLR_TYPE,
SolrUtils.SOLR_TYPE_CLOUD.getValue());
+ runner.setProperty(SolrUtils.SOLR_LOCATION,
"http://localhost:8443/solr");
+ runner.setProperty(SolrUtils.COLLECTION, "testCollection");
+ runner.setProperty(FetchSolr.SOLR_QUERY_STRING, "q=*:*" +
--- End diff --
Again, might want to think about multiple query-related fields so that this
can be spread out and tested piece by piece by the user.
> Add FetchSolr processor
> -----------------------
>
> Key: NIFI-4516
> URL: https://issues.apache.org/jira/browse/NIFI-4516
> Project: Apache NiFi
> Issue Type: Improvement
> Components: Extensions
> Reporter: Johannes Peter
> Assignee: Johannes Peter
> Priority: Major
> Labels: features
>
> The processor shall be capable
> * to query Solr within a workflow,
> * to make use of standard functionalities of Solr such as faceting,
> highlighting, result grouping, etc.,
> * to make use of NiFis expression language to build Solr queries,
> * to handle results as records.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)