@Test
public void testParallelParsing() throws Exception {

    try (ForkParser parser = new ForkParser(ForkParserTest.class.getClassLoader(), new ForkTestParser())) {
        final ParseContext context = new ParseContext();
        Thread[] threads = new Thread[10];
        ContentHandler[] output = new ContentHandler[threads.length];
        for (int i = 0; i < threads.length; i++) {
            final ContentHandler o = new BodyContentHandler();
            output[i] = o;
            threads[i] = new Thread() {
                public void run() {
                    try {
                        InputStream stream =
                            new ByteArrayInputStream(new byte[0]);
                        parser.parse(stream, o, new Metadata(), context);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            };
            threads[i].start();
        }
        for (int i = 0; i < threads.length; i++) {
            threads[i].join();
            assertEquals("Hello, World!", output[i].toString().trim());
        }
    }
}