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 2021/08/18 16:20:09 UTC

[tika] branch main updated: TIKA-3529 -- fix failing test on windows and refactor integration tests.

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 8474f39  TIKA-3529 -- fix failing test on windows and refactor integration tests.
8474f39 is described below

commit 8474f391e0647c64d85d34dd742aaa2a718d92b4
Author: tballison <ta...@apache.org>
AuthorDate: Wed Aug 18 12:17:28 2021 -0400

    TIKA-3529 -- fix failing test on windows and refactor integration tests.
---
 .../tika/server/core/IntegrationTestBase.java      |  13 +-
 .../server/core/TikaServerIntegrationTest.java     | 377 ++++++++-------------
 .../core/TikaServerPipesIntegrationTest.java       | 101 ++----
 3 files changed, 187 insertions(+), 304 deletions(-)

diff --git a/tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/IntegrationTestBase.java b/tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/IntegrationTestBase.java
index 6d36b64..4187500 100644
--- a/tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/IntegrationTestBase.java
+++ b/tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/IntegrationTestBase.java
@@ -25,6 +25,7 @@ import java.time.Instant;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
+import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 import javax.ws.rs.core.Response;
 
@@ -61,6 +62,7 @@ public class IntegrationTestBase extends TikaTest {
     static Path LOG_FILE;
     static Path STREAMS_DIR;
     private SecurityManager existingSecurityManager = null;
+    protected Process process = null;
 
     @BeforeAll
     public static void staticSetup() throws Exception {
@@ -101,9 +103,16 @@ public class IntegrationTestBase extends TikaTest {
     @AfterEach
     public void tearDown() throws Exception {
         System.setSecurityManager(existingSecurityManager);
+        if (process != null) {
+            process.destroyForcibly();
+            process.waitFor(30, TimeUnit.SECONDS);
+            if (process.isAlive()) {
+                throw new RuntimeException("process still alive!");
+            }
+        }
     }
 
-    public Process startProcess(String[] extraArgs) throws IOException {
+    public void startProcess(String[] extraArgs) throws IOException {
         String[] base = new String[]{"java", "-cp", System.getProperty("java.class.path"),
                 "org.apache.tika.server.core.TikaServerCli",};
         List<String> args = new ArrayList<>(Arrays.asList(base));
@@ -113,7 +122,7 @@ public class IntegrationTestBase extends TikaTest {
 //        pb.redirectInput(Files.createTempFile(STREAMS_DIR, "tika-stream-out", ".log").toFile());
         //      pb.redirectError(Files.createTempFile(STREAMS_DIR,
         //      "tika-stream-err", ".log").toFile());
-        return pb.start();
+        process = pb.start();
     }
 
     void awaitServerStartup() throws Exception {
diff --git a/tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/TikaServerIntegrationTest.java b/tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/TikaServerIntegrationTest.java
index 4232af2..f9b21a0 100644
--- a/tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/TikaServerIntegrationTest.java
+++ b/tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/TikaServerIntegrationTest.java
@@ -18,6 +18,7 @@ package org.apache.tika.server.core;
 
 import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.junit.jupiter.api.Assertions.fail;
 
 import java.io.InputStream;
@@ -35,7 +36,6 @@ import javax.ws.rs.core.Response;
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import org.apache.cxf.jaxrs.client.WebClient;
-import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.Timeout;
@@ -50,108 +50,77 @@ public class TikaServerIntegrationTest extends IntegrationTestBase {
 
     private static final Logger LOG = LoggerFactory.getLogger(TikaServerIntegrationTest.class);
 
-    @AfterEach
-    public void tearDown() throws Exception {
-        //wait just a bit for the servers to shutdown
-        Thread.sleep(500);
-    }
-
     @Test
     public void testBasic() throws Exception {
 
-        Process p = null;
-        try {
-            p = startProcess(new String[]{"-config", getConfig("tika-config-server-basic.xml")});
-            testBaseline();
-        } finally {
-            if (p != null) {
-                p.destroyForcibly();
-            }
-        }
+        startProcess(new String[]{"-config", getConfig("tika-config-server-basic.xml")});
+        testBaseline();
     }
 
     @Test
     public void testOOM() throws Exception {
 
-        Process p = null;
-        try {
-            p = startProcess(new String[]{"-config", getConfig("tika-config-server-basic.xml")});
+        startProcess(new String[]{"-config", getConfig("tika-config-server-basic.xml")});
 
-            awaitServerStartup();
+        awaitServerStartup();
 
-            Response response = null;
-            try {
-                response = WebClient.create(endPoint + META_PATH).accept("application/json")
-                        .put(ClassLoader.getSystemResourceAsStream(TEST_OOM));
-            } catch (Exception e) {
-                //oom may or may not cause an exception depending
-                //on the timing
-            }
-            //give some time for the server to crash/terminate itself
-            Thread.sleep(2000);
-            testBaseline();
-        } finally {
-            if (p != null) {
-                p.destroyForcibly();
-            }
+        Response response = null;
+        try {
+            response = WebClient.create(endPoint + META_PATH).accept("application/json")
+                    .put(ClassLoader.getSystemResourceAsStream(TEST_OOM));
+        } catch (Exception e) {
+            //oom may or may not cause an exception depending
+            //on the timing
         }
+        //give some time for the server to crash/terminate itself
+        Thread.sleep(2000);
+        testBaseline();
+
     }
 
     @Test
     public void testSameServerIdAfterOOM() throws Exception {
 
-        Process p = null;
+        startProcess(new String[]{"-config", getConfig(
+                "tika-config-server-basic.xml")});
+        awaitServerStartup();
+        String serverId = getServerId();
+        Response response = null;
         try {
-            p = startProcess(new String[]{"-config", getConfig(
-                    "tika-config-server-basic.xml")});
-            awaitServerStartup();
-            String serverId = getServerId();
-            Response response = null;
-            try {
-                response = WebClient.create(endPoint + META_PATH).accept("application/json")
-                        .put(ClassLoader.getSystemResourceAsStream(TEST_OOM));
-            } catch (Exception e) {
-                //oom may or may not cause an exception depending
-                //on the timing
-            }
-            //give some time for the server to crash/terminate itself
-            Thread.sleep(2000);
-            testBaseline();
-            assertEquals(serverId, getServerId());
-            assertEquals(1, getNumRestarts());
-        } finally {
-            if (p != null) {
-                p.destroyForcibly();
-            }
+            response = WebClient.create(endPoint + META_PATH).accept("application/json")
+                    .put(ClassLoader.getSystemResourceAsStream(TEST_OOM));
+        } catch (Exception e) {
+            //oom may or may not cause an exception depending
+            //on the timing
         }
+        //give some time for the server to crash/terminate itself
+        Thread.sleep(2000);
+        testBaseline();
+        assertEquals(serverId, getServerId());
+        assertTrue(getNumRestarts() > 0);
+        assertTrue(getNumRestarts() < 3);
     }
 
     @Test
     public void testSameDeclaredServerIdAfterOOM() throws Exception {
         String serverId = "qwertyuiop";
-        Process p = null;
+        startProcess(
+                new String[]{"-config", getConfig("tika-config-server-basic.xml"), "-id",
+                        serverId});
+        awaitServerStartup();
+        Response response = null;
         try {
-            p = startProcess(
-                    new String[]{"-config", getConfig("tika-config-server-basic.xml"), "-id",
-                            serverId});
-            awaitServerStartup();
-            Response response = null;
-            try {
-                response = WebClient.create(endPoint + META_PATH).accept("application/json")
-                        .put(ClassLoader.getSystemResourceAsStream(TEST_OOM));
-            } catch (Exception e) {
-                //oom may or may not cause an exception depending
-                //on the timing
-            }
-            //give some time for the server to crash/terminate itself
-            Thread.sleep(2000);
-            testBaseline();
-            assertEquals(serverId, getServerId());
-        } finally {
-            if (p != null) {
-                p.destroyForcibly();
-            }
+            response = WebClient.create(endPoint + META_PATH).accept("application/json")
+                    .put(ClassLoader.getSystemResourceAsStream(TEST_OOM));
+        } catch (Exception e) {
+            //oom may or may not cause an exception depending
+            //on the timing
         }
+        //give some time for the server to crash/terminate itself
+        Thread.sleep(2000);
+        testBaseline();
+        assertEquals(serverId, getServerId());
+
     }
 
     private String getServerId() throws Exception {
@@ -174,100 +143,71 @@ public class TikaServerIntegrationTest extends IntegrationTestBase {
 
     @Test
     public void testSystemExit() throws Exception {
+        startProcess(new String[]{"-config", getConfig("tika-config-server-basic.xml")});
 
-        Process p = null;
+        awaitServerStartup();
+        Response response = null;
         try {
-            p = startProcess(new String[]{"-config", getConfig("tika-config-server-basic.xml")});
-
-            awaitServerStartup();
-            Response response = null;
-            try {
-                response = WebClient.create(endPoint + META_PATH).accept("application/json")
-                        .put(ClassLoader.getSystemResourceAsStream(TEST_SYSTEM_EXIT));
-            } catch (Exception e) {
-                //sys exit causes catchable problems for the client
-            }
-            //give some time for the server to crash/terminate itself
-            Thread.sleep(2000);
+            response = WebClient.create(endPoint + META_PATH).accept("application/json")
+                    .put(ClassLoader.getSystemResourceAsStream(TEST_SYSTEM_EXIT));
+        } catch (Exception e) {
+            //sys exit causes catchable problems for the client
+        }
+        //give some time for the server to crash/terminate itself
+        Thread.sleep(2000);
 
-            testBaseline();
-        } finally {
-            if (p != null) {
-                p.destroyForcibly();
-            }
+        testBaseline();
 
-        }
     }
 
     @Test
     public void testTimeoutOk() throws Exception {
-        Process p = null;
+        startProcess(
+                new String[]{"-config", getConfig("tika-config-server-timeout-10000.xml")});
+        awaitServerStartup();
+        Response response = null;
         try {
-            p = startProcess(
-                    new String[]{"-config", getConfig("tika-config-server-timeout-10000.xml")});
-            awaitServerStartup();
-            Response response = null;
-            try {
-                response = WebClient.create(endPoint + META_PATH).accept("application/json")
-                        .put(ClassLoader.getSystemResourceAsStream(TEST_HEAVY_HANG_SHORT));
-            } catch (Exception e) {
-                //potential exception depending on timing
-            }
-            testBaseline();
-        } finally {
-            if (p != null) {
-                p.destroyForcibly();
-            }
+            response = WebClient.create(endPoint + META_PATH).accept("application/json")
+                    .put(ClassLoader.getSystemResourceAsStream(TEST_HEAVY_HANG_SHORT));
+        } catch (Exception e) {
+            //potential exception depending on timing
         }
+        testBaseline();
+
     }
 
     @Test
     @Timeout(60000)
     public void testTimeout() throws Exception {
-
-        Process p = null;
+        startProcess(
+                new String[]{"-config", getConfig("tika-config-server-timeout-10000.xml")});
+        awaitServerStartup();
+        Response response = null;
         try {
-            p = startProcess(
-                    new String[]{"-config", getConfig("tika-config-server-timeout-10000.xml")});
-            awaitServerStartup();
-            Response response = null;
-            try {
-                response = WebClient.create(endPoint + META_PATH).accept("application/json")
-                        .put(ClassLoader.getSystemResourceAsStream(TEST_HEAVY_HANG));
-            } catch (Exception e) {
-                //catchable exception when server shuts down.
-            }
-            testBaseline();
-        } finally {
-            if (p != null) {
-                p.destroyForcibly();
-            }
+            response = WebClient.create(endPoint + META_PATH).accept("application/json")
+                    .put(ClassLoader.getSystemResourceAsStream(TEST_HEAVY_HANG));
+        } catch (Exception e) {
+            //catchable exception when server shuts down.
         }
+        testBaseline();
+
     }
 
     @Test
     public void testBadJVMArgs() throws Exception {
 
-        Process p = null;
-        try {
-            p = startProcess(
-                    new String[]{"-config", getConfig("tika-config-server-badjvmargs.xml"),});
+        startProcess(
+                new String[]{"-config", getConfig("tika-config-server-badjvmargs.xml"),});
 
-            boolean finished = p.waitFor(10000, TimeUnit.MILLISECONDS);
-            if (!finished) {
-                fail("should have completed by now");
-            }
-            String os = System.getProperty("os.name");
-            if (os.startsWith("Windows")) {
-                assertEquals(-1, p.exitValue());
-            }
-            else {
-                assertEquals(255, p.exitValue());
-            }
-        } finally {
-            if (p != null) {
-                p.destroyForcibly();
-            }
+        boolean finished = process.waitFor(10000, TimeUnit.MILLISECONDS);
+        if (!finished) {
+            fail("should have completed by now");
+        }
+        String os = System.getProperty("os.name");
+        if (os.startsWith("Windows")) {
+            assertEquals(-1, process.exitValue());
+        } else {
+            assertEquals(255, process.exitValue());
         }
     }
 
@@ -282,49 +222,36 @@ public class TikaServerIntegrationTest extends IntegrationTestBase {
 
     @Test
     public void testStdErrOutBasic() throws Exception {
-        Process p = null;
-        try {
-            p = startProcess(
-                    new String[]{"-config", getConfig("tika-config-server-timeout-10000.xml")});
-            awaitServerStartup();
+        startProcess(
+                new String[]{"-config", getConfig("tika-config-server-timeout-10000.xml")});
+        awaitServerStartup();
+
+        Response response = WebClient.create(endPoint + META_PATH).accept("application/json")
+                .put(ClassLoader.getSystemResourceAsStream(TEST_STDOUT_STDERR));
+        Reader reader = new InputStreamReader((InputStream) response.getEntity(), UTF_8);
+        List<Metadata> metadataList = JsonMetadataList.fromJson(reader);
+        assertEquals(1, metadataList.size());
+        assertContains("quick brown fox", metadataList.get(0).get("X-TIKA:content"));
+        testBaseline();
 
-            Response response = WebClient.create(endPoint + META_PATH).accept("application/json")
-                    .put(ClassLoader.getSystemResourceAsStream(TEST_STDOUT_STDERR));
-            Reader reader = new InputStreamReader((InputStream) response.getEntity(), UTF_8);
-            List<Metadata> metadataList = JsonMetadataList.fromJson(reader);
-            assertEquals(1, metadataList.size());
-            assertContains("quick brown fox", metadataList.get(0).get("X-TIKA:content"));
-            testBaseline();
-        } finally {
-            if (p != null) {
-                p.destroyForcibly();
-            }
-        }
     }
 
     @Test
     @Disabled("This works, but prints too much junk to the console.  " +
             "Figure out how to gobble/redirect.")
     public void testStaticStdErrOutBasic() throws Exception {
-        Process p = null;
-        try {
-            p = startProcess(
-                    new String[]{"-config", getConfig("tika-config-server-timeout-10000.xml")});
-            awaitServerStartup();
+        startProcess(
+                new String[]{"-config", getConfig("tika-config-server-timeout-10000.xml")});
+        awaitServerStartup();
 
-            Response response = WebClient.create(endPoint + META_PATH).accept("application/json")
-                    .put(ClassLoader.getSystemResourceAsStream(TEST_STATIC_STDOUT_STDERR));
-            Reader reader = new InputStreamReader((InputStream) response.getEntity(), UTF_8);
-            List<Metadata> metadataList = JsonMetadataList.fromJson(reader);
-            assertEquals(1, metadataList.size());
-            assertContains("quick brown fox", metadataList.get(0).get("X-TIKA:content"));
-            testBaseline();
-        } finally {
-            if (p != null) {
-                p.destroyForcibly();
-            }
+        Response response = WebClient.create(endPoint + META_PATH).accept("application/json")
+                .put(ClassLoader.getSystemResourceAsStream(TEST_STATIC_STDOUT_STDERR));
+        Reader reader = new InputStreamReader((InputStream) response.getEntity(), UTF_8);
+        List<Metadata> metadataList = JsonMetadataList.fromJson(reader);
+        assertEquals(1, metadataList.size());
+        assertContains("quick brown fox", metadataList.get(0).get("X-TIKA:content"));
+        testBaseline();
 
-        }
     }
 
 
@@ -334,11 +261,11 @@ public class TikaServerIntegrationTest extends IntegrationTestBase {
         final AtomicInteger i = new AtomicInteger();
         Thread serverThread = new Thread(() -> TikaServerCli.main(
                 new String[]{
-                    "-p", INTEGRATION_TEST_PORT, "-taskTimeoutMillis",
-                    "10000", "-taskPulseMillis", "500", "-pingPulseMillis", "100",
-                    "-maxRestarts", "0",
-                    "-JDlog4j.configuration=file:" + LOG_FILE.toAbsolutePath(),
-                    "-tmpFilePrefix", "tika-server-stderrlogging"
+                        "-p", INTEGRATION_TEST_PORT, "-taskTimeoutMillis",
+                        "10000", "-taskPulseMillis", "500", "-pingPulseMillis", "100",
+                        "-maxRestarts", "0",
+                        "-JDlog4j.configuration=file:" + LOG_FILE.toAbsolutePath(),
+                        "-tmpFilePrefix", "tika-server-stderrlogging"
                 }));
         serverThread.start();
         awaitServerStartup();
@@ -365,52 +292,46 @@ public class TikaServerIntegrationTest extends IntegrationTestBase {
         //Can watch logs at least for confirmation of behavior
         //TODO: convert to real test
 
-        Process p = null;
-        try {
-            p = startProcess(
-                    new String[]{"-config", getConfig("tika-config-server-timeout-10000.xml")});
-            awaitServerStartup();
+        startProcess(
+                new String[]{"-config", getConfig("tika-config-server-timeout-10000.xml")});
+        awaitServerStartup();
 
 
-            Random r = new Random();
-            for (int i = 0; i < 100; i++) {
-                boolean ex = false;
-                Response response = null;
-                String file = TEST_HELLO_WORLD;
-                try {
-                    if (r.nextFloat() < 0.01) {
-                        file = TEST_SYSTEM_EXIT;
-                    } else if (r.nextFloat() < 0.015) {
-                        file = TEST_OOM;
-                    } else if (r.nextFloat() < 0.02) {
-                        file = TEST_HEAVY_HANG;
-                    }
-                    response = WebClient.create(endPoint + META_PATH).accept("application/json")
-                            .put(ClassLoader.getSystemResourceAsStream(file));
-                } catch (Exception e) {
-                    ex = true;
+        Random r = new Random();
+        for (int i = 0; i < 100; i++) {
+            boolean ex = false;
+            Response response = null;
+            String file = TEST_HELLO_WORLD;
+            try {
+                if (r.nextFloat() < 0.01) {
+                    file = TEST_SYSTEM_EXIT;
+                } else if (r.nextFloat() < 0.015) {
+                    file = TEST_OOM;
+                } else if (r.nextFloat() < 0.02) {
+                    file = TEST_HEAVY_HANG;
                 }
+                response = WebClient.create(endPoint + META_PATH).accept("application/json")
+                        .put(ClassLoader.getSystemResourceAsStream(file));
+            } catch (Exception e) {
+                ex = true;
+            }
 
-                if (ex || response.getStatus() != 200) {
-                    i--;
-                    awaitServerStartup();
-                    continue;
-                }
-                if (file.equals(TEST_HELLO_WORLD)) {
-                    Reader reader =
-                            new InputStreamReader((InputStream) response.getEntity(), UTF_8);
-                    List<Metadata> metadataList = JsonMetadataList.fromJson(reader);
-                    assertEquals(1, metadataList.size());
-                    assertEquals("Nikolai Lobachevsky", metadataList.get(0).get("author"));
-                    assertContains("hello world", metadataList.get(0).get("X-TIKA:content"));
-                }
-                //assertEquals("a38e6c7b38541af87148dee9634cb811",
-                // metadataList.get(10).get("X-TIKA:digest:MD5"));
+            if (ex || response.getStatus() != 200) {
+                i--;
+                awaitServerStartup();
+                continue;
             }
-        } finally {
-            p.destroyForcibly();
+            if (file.equals(TEST_HELLO_WORLD)) {
+                Reader reader =
+                        new InputStreamReader((InputStream) response.getEntity(), UTF_8);
+                List<Metadata> metadataList = JsonMetadataList.fromJson(reader);
+                assertEquals(1, metadataList.size());
+                assertEquals("Nikolai Lobachevsky", metadataList.get(0).get("author"));
+                assertContains("hello world", metadataList.get(0).get("X-TIKA:content"));
+            }
+            //assertEquals("a38e6c7b38541af87148dee9634cb811",
+            // metadataList.get(10).get("X-TIKA:digest:MD5"));
         }
-
     }
 
     private void testBaseline() throws Exception {
diff --git a/tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/TikaServerPipesIntegrationTest.java b/tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/TikaServerPipesIntegrationTest.java
index 38cef19..2b84825 100644
--- a/tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/TikaServerPipesIntegrationTest.java
+++ b/tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/TikaServerPipesIntegrationTest.java
@@ -21,7 +21,6 @@ import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.fail;
 
 import java.io.IOException;
 import java.io.InputStream;
@@ -137,83 +136,48 @@ public class TikaServerPipesIntegrationTest extends IntegrationTestBase {
 
     @Test
     public void testBasic() throws Exception {
-        Process p = null;
-        try {
-            p = startProcess(new String[]{"-config",
-                    ProcessUtils.escapeCommandLine(TIKA_CONFIG.toAbsolutePath().toString())});
-            JsonNode node = testOne("hello_world.xml", true);
-            assertEquals("ok", node.get("status").asText());
-        } catch (Exception e) {
-            e.printStackTrace();
-            fail("shouldn't have an exception" + e.getMessage());
-        } finally {
-            if (p != null) {
-                p.destroyForcibly();
-            }
-        }
+        startProcess(new String[]{"-config",
+                ProcessUtils.escapeCommandLine(TIKA_CONFIG.toAbsolutePath().toString())});
+        JsonNode node = testOne("hello_world.xml", true);
+        assertEquals("ok", node.get("status").asText());
+
     }
 
     @Test
     public void testNPEDefault() throws Exception {
 
-        Process p = null;
-        try {
-            p = startProcess(new String[]{"-config",
-                    ProcessUtils.escapeCommandLine(TIKA_CONFIG.toAbsolutePath().toString())});
-            JsonNode node = testOne("null_pointer.xml", true);
-            assertEquals("ok", node.get("status").asText());
-            assertContains("java.lang.NullPointerException", node.get("parse_exception").asText());
-        } catch (Exception e) {
-            fail("shouldn't have an exception" + e.getMessage());
-        } finally {
-            if (p != null) {
-                p.destroyForcibly();
-            }
-        }
+        startProcess(new String[]{"-config",
+                ProcessUtils.escapeCommandLine(TIKA_CONFIG.toAbsolutePath().toString())});
+        JsonNode node = testOne("null_pointer.xml", true);
+        assertEquals("ok", node.get("status").asText());
+        assertContains("java.lang.NullPointerException", node.get("parse_exception").asText());
     }
 
     @Test
     public void testNPESkip() throws Exception {
 
-        Process p = null;
-        try {
-            p = startProcess(new String[]{"-config",
-                    ProcessUtils.escapeCommandLine(TIKA_CONFIG.toAbsolutePath().toString())});
-            JsonNode node =
-                    testOne("null_pointer.xml", false, FetchEmitTuple.ON_PARSE_EXCEPTION.SKIP);
-            assertEquals("ok", node.get("status").asText());
-            assertContains("java.lang.NullPointerException", node.get("parse_exception").asText());
-        } catch (Exception e) {
-            fail("shouldn't have an exception" + e.getMessage());
-        } finally {
-            if (p != null) {
-                p.destroyForcibly();
-            }
-        }
+        startProcess(new String[]{"-config",
+                ProcessUtils.escapeCommandLine(TIKA_CONFIG.toAbsolutePath().toString())});
+        JsonNode node =
+                testOne("null_pointer.xml", false, FetchEmitTuple.ON_PARSE_EXCEPTION.SKIP);
+        assertEquals("ok", node.get("status").asText());
+        assertContains("java.lang.NullPointerException", node.get("parse_exception").asText());
     }
 
     @Test
     public void testSystemExit() throws Exception {
-        Process p = null;
-        try {
-            p = startProcess(new String[]{"-config",
-                    ProcessUtils.escapeCommandLine(TIKA_CONFIG.toAbsolutePath().toString())});
-            JsonNode node = testOne("system_exit.xml", false);
-            assertEquals("parse_error", node.get("status").asText());
-            assertContains("unknown_crash", node.get("parse_error").asText());
-        } finally {
-            if (p != null) {
-                p.destroyForcibly();
-            }
-        }
+        startProcess(new String[]{"-config",
+                ProcessUtils.escapeCommandLine(TIKA_CONFIG.toAbsolutePath().toString())});
+        JsonNode node = testOne("system_exit.xml", false);
+        assertEquals("parse_error", node.get("status").asText());
+        assertContains("unknown_crash", node.get("parse_error").asText());
     }
 
     @Test
     public void testOOM() throws Exception {
 
-        Process p = null;
         try {
-            p = startProcess(new String[]{"-config",
+            startProcess(new String[]{"-config",
                     ProcessUtils.escapeCommandLine(TIKA_CONFIG.toAbsolutePath().toString())});
             JsonNode node = testOne("fake_oom.xml", false);
             assertEquals("parse_error", node.get("status").asText());
@@ -222,27 +186,16 @@ public class TikaServerPipesIntegrationTest extends IntegrationTestBase {
             //depending on timing, there may be a connection exception --
             // TODO add more of a delay to server shutdown to ensure message is sent
             // before shutdown.
-        } finally {
-            if (p != null) {
-                p.destroyForcibly();
-            }
         }
     }
 
     @Test
     public void testTimeout() throws Exception {
-        Process p = null;
-        try {
-            p = startProcess(new String[]{"-config", ProcessUtils.escapeCommandLine(
-                    TIKA_CONFIG_TIMEOUT.toAbsolutePath().toString())});
-            JsonNode node = testOne("heavy_hang_30000.xml", false);
-            assertEquals("parse_error", node.get("status").asText());
-            assertContains("timeout", node.get("parse_error").asText());
-        } finally {
-            if (p != null) {
-                p.destroyForcibly();
-            }
-        }
+        startProcess(new String[]{"-config", ProcessUtils.escapeCommandLine(
+                TIKA_CONFIG_TIMEOUT.toAbsolutePath().toString())});
+        JsonNode node = testOne("heavy_hang_30000.xml", false);
+        assertEquals("parse_error", node.get("status").asText());
+        assertContains("timeout", node.get("parse_error").asText());
     }