You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tika.apache.org by ta...@apache.org on 2022/05/16 14:16:04 UTC
[tika] branch main updated: TIKA-3764 -- add unit tests for Solr 9
This is an automated email from the ASF dual-hosted git repository.
tallison pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tika.git
The following commit(s) were added to refs/heads/main by this push:
new acfa13465 TIKA-3764 -- add unit tests for Solr 9
acfa13465 is described below
commit acfa13465a55ace46914801973cd45c8e224a297
Author: tallison <ta...@apache.org>
AuthorDate: Mon May 16 10:15:51 2022 -0400
TIKA-3764 -- add unit tests for Solr 9
---
.../tika/pipes/solr/tests/TikaPipesSolr9Test.java | 30 ++++++++++++++++
.../pipes/solr/tests/TikaPipesSolr9ZkTest.java | 41 ++++++++++++++++++++++
.../pipes/solr/tests/TikaPipesSolrTestBase.java | 18 ++++++++++
3 files changed, 89 insertions(+)
diff --git a/tika-integration-tests/tika-pipes-solr-integration-tests/src/test/java/org/apache/tika/pipes/solr/tests/TikaPipesSolr9Test.java b/tika-integration-tests/tika-pipes-solr-integration-tests/src/test/java/org/apache/tika/pipes/solr/tests/TikaPipesSolr9Test.java
new file mode 100644
index 000000000..4ea8ca7b2
--- /dev/null
+++ b/tika-integration-tests/tika-pipes-solr-integration-tests/src/test/java/org/apache/tika/pipes/solr/tests/TikaPipesSolr9Test.java
@@ -0,0 +1,30 @@
+/*
+ * 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.tika.pipes.solr.tests;
+
+public class TikaPipesSolr9Test extends TikaPipesSolrTestBase {
+
+ @Override
+ public String getSolrImageName() {
+ return "solr:9.0";
+ }
+
+ @Override
+ public boolean useZk() {
+ return false;
+ }
+}
diff --git a/tika-integration-tests/tika-pipes-solr-integration-tests/src/test/java/org/apache/tika/pipes/solr/tests/TikaPipesSolr9ZkTest.java b/tika-integration-tests/tika-pipes-solr-integration-tests/src/test/java/org/apache/tika/pipes/solr/tests/TikaPipesSolr9ZkTest.java
new file mode 100644
index 000000000..7ac937391
--- /dev/null
+++ b/tika-integration-tests/tika-pipes-solr-integration-tests/src/test/java/org/apache/tika/pipes/solr/tests/TikaPipesSolr9ZkTest.java
@@ -0,0 +1,41 @@
+/*
+ * 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.tika.pipes.solr.tests;
+
+import static org.junit.Assume.assumeTrue;
+
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.jupiter.api.Disabled;
+
+import org.apache.tika.utils.SystemUtils;
+
+@Ignore("until we can fix SessionExpiredException")
+public class TikaPipesSolr9ZkTest extends TikaPipesSolr9Test {
+
+ @BeforeClass
+ public static void setUp() {
+ assumeTrue("zk test only works on linux (and not mac os x)",
+ SystemUtils.IS_OS_UNIX && ! SystemUtils.IS_OS_MAC_OSX);
+ }
+
+ @Override
+ public boolean useZk() {
+ return true;
+ }
+
+}
diff --git a/tika-integration-tests/tika-pipes-solr-integration-tests/src/test/java/org/apache/tika/pipes/solr/tests/TikaPipesSolrTestBase.java b/tika-integration-tests/tika-pipes-solr-integration-tests/src/test/java/org/apache/tika/pipes/solr/tests/TikaPipesSolrTestBase.java
index 12a234f3a..49e51c9ff 100644
--- a/tika-integration-tests/tika-pipes-solr-integration-tests/src/test/java/org/apache/tika/pipes/solr/tests/TikaPipesSolrTestBase.java
+++ b/tika-integration-tests/tika-pipes-solr-integration-tests/src/test/java/org/apache/tika/pipes/solr/tests/TikaPipesSolrTestBase.java
@@ -109,6 +109,7 @@ public abstract class TikaPipesSolrTestBase {
try (SolrClient solrClient = new LBHttpSolrClient.Builder().withBaseSolrUrls(solrEndpoint)
.build()) {
+ addBasicSchemaFields(solrEndpoint + "/" + collection);
addSchemaFieldsForNestedDocs(solrEndpoint + "/" + collection);
for (int i = 0; i < numDocs; ++i) {
SolrInputDocument solrDoc = new SolrInputDocument();
@@ -126,6 +127,23 @@ public abstract class TikaPipesSolrTestBase {
}
}
+ private void addBasicSchemaFields(String solrUrl) throws IOException {
+ try (CloseableHttpClient client = HttpClients.createMinimal()) {
+ HttpPost postAddRoot = new HttpPost(solrUrl + "/schema");
+ postAddRoot.setHeader("Content-Type", "application/json");
+ postAddRoot.setEntity(new StringEntity("{\n" +
+ " \"add-field\":{\n" +
+ " \"name\":\"path\",\n" +
+ " \"type\":\"string\",\n" +
+ " \"indexed\":true,\n" +
+ " \"stored\":true, \n" +
+ " \"docValues\":false \n" +
+ " }\n" +
+ "}"));
+ CloseableHttpResponse resp = client.execute(postAddRoot);
+ Assert.assertEquals(200, resp.getStatusLine().getStatusCode());
+ }
+ }
private void addSchemaFieldsForNestedDocs(String solrUrl) throws IOException {
try (CloseableHttpClient client = HttpClients.createMinimal()) {
HttpPost postAddRoot = new HttpPost(solrUrl + "/schema");