@Test
    public void withFallback() throws Exception {
        Set<MediaType> onlyOct = Collections.singleton(MediaType.OCTET_STREAM);
        Set<MediaType> octAndText =
                new HashSet<>(Arrays.asList(MediaType.OCTET_STREAM, MediaType.TEXT_PLAIN));

        ParseContext context = new ParseContext();
        BodyContentHandler handler;
        Metadata metadata;

        ErrorParser pFail = new ErrorParser();
        DummyParser pWork = new DummyParser(onlyOct, new HashMap<>(), "Fell back!");
        EmptyParser pNothing = new EmptyParser();

        // Create a combination which will fail first
        @SuppressWarnings("deprecation") Parser p =
                ParserDecorator.withFallbacks(Arrays.asList(pFail, pWork), octAndText);

        // Will claim to support the types given, not those on the child parsers
        Set<MediaType> types = p.getSupportedTypes(context);
        assertEquals(2, types.size());
        assertTrue(types.contains(MediaType.TEXT_PLAIN), types.toString());
        assertTrue(types.contains(MediaType.OCTET_STREAM), types.toString());

        // Parsing will make it to the second one
        metadata = new Metadata();
        handler = new BodyContentHandler();
        p.parse(new ByteArrayInputStream(new byte[]{0, 1, 2, 3, 4}), handler, metadata, context);
        assertEquals("Fell back!", handler.toString());


        // With a parser that will work with no output, will get nothing
        p = ParserDecorator.withFallbacks(Arrays.asList(pNothing, pWork), octAndText);
        metadata = new Metadata();
        handler = new BodyContentHandler();
        p.parse(new ByteArrayInputStream(new byte[]{0, 1, 2, 3, 4}), handler, metadata, context);
        assertEquals("", handler.toString());
    }
Testing one proposed implementation for TIKA-1509
tika-core/src/test/java/org/apache/tika/parser/ParserDecoratorTest.java