@Test
    public void testEmbeddedStreamEmitter(@TempDir Path tmp) throws Exception {
        if (Files.isDirectory(tmp)) {
            FileUtils.deleteDirectory(tmp.toFile());
        }
        Files.createDirectories(tmp);
        Path tikaConfig = tmp.resolve("tika-config.xml");

        String xml = IOUtils.toString(
                PipesServerTest.class.getResourceAsStream("TIKA-4207.xml"),
                StandardCharsets.UTF_8);
        xml = xml.replace("BASE_PATH", tmp.toAbsolutePath().toString());
        Files.write(tikaConfig, xml.getBytes(StandardCharsets.UTF_8));

        Files.copy(PipesServerTest.class.getResourceAsStream("/test-documents/basic_embedded.xml"),
                tmp.resolve("mock.xml"));

        PipesServer pipesServer = new PipesServer(tikaConfig,
                UnsynchronizedByteArrayInputStream.builder().setByteArray(new byte[0]).get(),
                new PrintStream(UnsynchronizedByteArrayOutputStream.builder().get(), true,
                        StandardCharsets.UTF_8.name()),
                -1, 30000, 30000);

        pipesServer.initializeResources();
        EmbeddedDocumentBytesConfig embeddedDocumentBytesConfig =
                new EmbeddedDocumentBytesConfig(true);
        embeddedDocumentBytesConfig.setIncludeOriginal(true);
        ParseContext parseContext = new ParseContext();
        parseContext.set(HandlerConfig.class, HandlerConfig.DEFAULT_HANDLER_CONFIG);
        parseContext.set(EmbeddedDocumentBytesConfig.class, embeddedDocumentBytesConfig);
        FetchEmitTuple fetchEmitTuple = new FetchEmitTuple("id",
                new FetchKey("fs", "mock.xml"),
                new EmitKey("", ""), new Metadata(), parseContext);
        Fetcher fetcher = FetcherManager.load(tikaConfig).getFetcher();
        PipesServer.MetadataListAndEmbeddedBytes
                parseData = pipesServer.parseFromTuple(fetchEmitTuple, fetcher);
        assertEquals(2, parseData.metadataList.size());

        byte[] bytes0 =
                IOUtils.toByteArray(
                        ((BasicEmbeddedDocumentBytesHandler)parseData.getEmbeddedDocumentBytesHandler())
                        .getDocument(0));
        byte[] bytes1 =
                IOUtils.toByteArray(
                        ((BasicEmbeddedDocumentBytesHandler)parseData.getEmbeddedDocumentBytesHandler())
                                .getDocument(1));

        assertContains("is to trigger mock on the embedded",
                new String(bytes0, StandardCharsets.UTF_8));

        assertContains("embeddedAuthor</metadata>",
                new String(bytes1, StandardCharsets.UTF_8));
        assertEquals("fdaa937c96d1ed010b8d307ccddf9d11c3b48db732a8771eaafe99d59e076d0a",
                parseData.metadataList.get(0).get("X-TIKA:digest:SHA-256"));
    }
This test is useful for stepping through the debugger on PipesServer
without having to attach the debugger to the forked process.

@param tmp
@throws Exception
tika-core/src/test/java/org/apache/tika/pipes/PipesServerTest.java