@Test
    public void testAgeRecogniser() throws Exception {

        //test config is added to resources directory
        try (InputStream is = getResourceAsStream(CONFIG_FILE);
                InputStream bis = new ByteArrayInputStream(
                        TEST_TEXT.getBytes(StandardCharsets.UTF_8))) {
            TikaConfig config = new TikaConfig(is);
            Tika tika = new Tika(config);

            Metadata md = new Metadata();
            tika.parse(bis, md);

            assertArrayEquals(new String[]{CompositeParser.class.getCanonicalName(),
                            AgeRecogniser.class.getCanonicalName()},
                    md.getValues(TikaCoreProperties.TIKA_PARSED_BY),
                    "Age Parser not invoked.");
            assertArrayEquals(
                    new String[]{Double.toString(TEST_AGE)},
                    md.getValues(AgeRecogniser.MD_KEY_ESTIMATED_AGE),
                    "Wrong age predicted.");
        }
    }
Injecting mock AgeClassifer into AgeParser to generate test response
tika-parsers/tika-parsers-ml/tika-age-recogniser/src/test/java/org/apache/tika/parser/recognition/AgeRecogniserTest.java