@Test
    public void testParserHandlingOfNonSerializable() throws Exception {
        ForkParser parser =
                new ForkParser(ForkParserIntegrationTest.class.getClassLoader(), tika.getParser());

        ParseContext context = new ParseContext();
        context.set(Detector.class, new Detector() {
            public MediaType detect(InputStream input, Metadata metadata) {
                return MediaType.OCTET_STREAM;
            }
        });

        try {
            ContentHandler output = new BodyContentHandler();
            InputStream stream = getResourceAsStream("/test-documents/testTXT.txt");
            parser.parse(stream, output, new Metadata(), context);
            fail("Should have blown up with a non serializable ParseContext");
        } catch (TikaException e) {
            // Check the right details
            assertNotNull(e.getCause());
            assertEquals(NotSerializableException.class, e.getCause().getClass());
            assertEquals("Unable to serialize ParseContext to pass to the Forked Parser",e.getMessage());
        } finally {
            parser.close();
        }
    }
If we supply a non serializable object on the ParseContext,
check we get a helpful exception back
tika-parsers/tika-parsers-standard/tika-parsers-standard-package/src/test/java/org/apache/tika/parser/fork/ForkParserIntegrationTest.java