private void testStream(String expected, String urlOrFileName, InputStream in)
            throws IOException {
        assertNotNull(in, "Test stream: [" + urlOrFileName + "] is null!");
        if (!in.markSupported()) {
            in = new java.io.BufferedInputStream(in);
        }
        try {
            Metadata metadata = new Metadata();
            String mime = this.detector.detect(in, metadata).toString();
            assertEquals(expected, mime,
                    urlOrFileName + " is not properly detected: detected.");

            // Add resource name and test again
            // metadata.set(TikaCoreProperties.RESOURCE_NAME_KEY, urlOrFileName);
            mime = this.detector.detect(in, metadata).toString();
            assertEquals(expected, mime,
                    urlOrFileName + " is not properly detected after adding resource name.");
        } finally {
            in.close();
        }
    }
The test case only works on the detector that only has grb model as
currently the grb model is used as an example; if more models are added
in the TrainedModelDetector, the following tests will need to modified to reflect
the corresponding type instead of test-equal with the "OCTET_STREAM";

@throws Exception
tika-core/src/test/java/org/apache/tika/detect/MimeDetectionWithNNTest.java