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 2026/08/07 15:12:55 UTC
(tika) 06/07: TIKA-4809: Delete disabled, non-asserting TikaServerAsyncIntegrationTest
This is an automated email from the ASF dual-hosted git repository.
tballison pushed a commit to branch TIKA-4809-stage-1
in repository https://gitbox.apache.org/repos/asf/tika.git
commit 12cdd944b339343a80371c013968cb11257731a8
Author: tallison <ta...@apache.org>
AuthorDate: Fri Aug 7 10:41:39 2026 -0400
TIKA-4809: Delete disabled, non-asserting TikaServerAsyncIntegrationTest
---
.../core/TikaServerAsyncIntegrationTest.java | 180 ---------------------
1 file changed, 180 deletions(-)
diff --git a/tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/TikaServerAsyncIntegrationTest.java b/tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/TikaServerAsyncIntegrationTest.java
deleted file mode 100644
index fb7aaf554b..0000000000
--- a/tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/TikaServerAsyncIntegrationTest.java
+++ /dev/null
@@ -1,180 +0,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.
- */
-package org.apache.tika.server.core;
-
-
-import static java.nio.charset.StandardCharsets.UTF_8;
-import static org.apache.tika.server.core.CXFTestBase.EMITTER_JSON_ID;
-import static org.apache.tika.server.core.CXFTestBase.FETCHER_ID;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.fail;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Random;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import jakarta.ws.rs.core.Response;
-import org.apache.cxf.jaxrs.client.WebClient;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Disabled;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.io.TempDir;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.tika.metadata.Metadata;
-import org.apache.tika.parser.ParseContext;
-import org.apache.tika.pipes.api.FetchEmitTuple;
-import org.apache.tika.pipes.api.ParseMode;
-import org.apache.tika.pipes.api.emitter.EmitKey;
-import org.apache.tika.pipes.api.fetcher.FetchKey;
-import org.apache.tika.pipes.core.serialization.JsonFetchEmitTupleList;
-import org.apache.tika.sax.BasicContentHandlerFactory;
-import org.apache.tika.sax.ContentHandlerFactory;
-
-@Disabled("useful for development...need to turn it into a real unit test")
-public class TikaServerAsyncIntegrationTest extends IntegrationTestBase {
-
- private static final Logger LOG = LoggerFactory.getLogger(TikaServerAsyncIntegrationTest.class);
- private static final int NUM_FILES = 100;
- private static FetchEmitTuple.ON_PARSE_EXCEPTION ON_PARSE_EXCEPTION = FetchEmitTuple.ON_PARSE_EXCEPTION.EMIT;
-
- @TempDir
- private static Path TMP_DIR;
- private static Path TMP_OUTPUT_DIR;
- private static Path TIKA_CONFIG;
- private static List<String> FILE_LIST = new ArrayList<>();
- private static String[] FILES = new String[]{"hello_world.xml", "null_pointer.xml",
- // "heavy_hang_30000.xml", "real_oom.xml",
- "system_exit.xml"};
-
- @BeforeAll
- public static void setUpBeforeClass() throws Exception {
- Path inputDir = TMP_DIR.resolve("input");
- TMP_OUTPUT_DIR = TMP_DIR.resolve("output");
- Files.createDirectories(inputDir);
- Files.createDirectories(TMP_OUTPUT_DIR);
- Random rand = new Random();
- for (int i = 0; i < NUM_FILES; i++) {
- for (String mockFile : FILES) {
- if (mockFile.equals("system_exit.xml")) {
- if (rand.nextFloat() > 0.1) {
- continue;
- }
- }
- String targetName = i + "-" + mockFile;
- Path target = inputDir.resolve(targetName);
- FILE_LIST.add(targetName);
- Files.copy(TikaPipesTest.class.getResourceAsStream("/test-documents/mock/" + mockFile), target);
-
- }
- }
- TIKA_CONFIG = TMP_DIR.resolve("tika-config.json");
-
- CXFTestBase.createPluginsConfig(TIKA_CONFIG, inputDir, TMP_OUTPUT_DIR, null, null);
- }
-
-
- @BeforeEach
- public void setUpEachTest() throws Exception {
- for (String problemFile : FILES) {
- Path targ = TMP_OUTPUT_DIR.resolve(problemFile + ".json");
-
- if (Files.exists(targ)) {
- Files.delete(targ);
- assertFalse(Files.isRegularFile(targ));
- }
- }
- }
-
-
- @Test
- public void testBasic() throws Exception {
-
- Thread serverThread = new Thread(() -> TikaServerCli.main(new String[]{
- //for debugging/development, use no fork; otherwise go with the default
- //"-noFork",
- "-p", INTEGRATION_TEST_PORT, "-config", TIKA_CONFIG.toAbsolutePath().toString() }));
- serverThread.start();
-
- try {
- long start = System.currentTimeMillis();
-
- JsonNode response = sendAsync(FILE_LIST);
-
- String status = response
- .get("status")
- .asText();
-
- if (!"ok".equals(status)) {
- fail("bad status: '" + status + "' -> " + response.toPrettyString());
- }
- int expected = (ON_PARSE_EXCEPTION == FetchEmitTuple.ON_PARSE_EXCEPTION.EMIT) ? FILE_LIST.size() : FILE_LIST.size() / 3;
- int targets = 0;
- while (targets < NUM_FILES * 2) {
- targets = countTargets();
- Thread.sleep(100);
- }
-// System.out.println("elapsed : " + (System.currentTimeMillis() - start));
- } finally {
- serverThread.interrupt();
- }
- }
-
- private int countTargets() {
- return TMP_OUTPUT_DIR
- .toFile()
- .listFiles().length;
- }
-
- private JsonNode sendAsync(List<String> fileNames) throws Exception {
- awaitServerStartup();
- List<FetchEmitTuple> tuples = new ArrayList<>();
- for (String f : fileNames) {
- tuples.add(getFetchEmitTuple(f));
- }
- String json = JsonFetchEmitTupleList.toJson(tuples);
-
- Response response = WebClient
- .create(endPoint + "/async")
- .accept("application/json")
- .post(json);
- if (response.getStatus() != 200) {
- throw new IllegalArgumentException("status must be 200, but I got: " + response.getStatus());
- }
- Reader reader = new InputStreamReader((InputStream) response.getEntity(), UTF_8);
- return new ObjectMapper().readTree(reader);
- }
-
- private FetchEmitTuple getFetchEmitTuple(String fileName) throws IOException {
- ParseContext parseContext = new ParseContext();
- parseContext.set(ContentHandlerFactory.class,
- new BasicContentHandlerFactory(BasicContentHandlerFactory.HANDLER_TYPE.XML, -1));
- parseContext.set(ParseMode.class, ParseMode.RMETA);
-
- return new FetchEmitTuple(fileName, new FetchKey(FETCHER_ID, fileName), new EmitKey(EMITTER_JSON_ID, ""), new Metadata(), parseContext, ON_PARSE_EXCEPTION);
- }
-}