ParseService { @MutableCopy @NotNull @VisibleForTesting static List<String> getPossibleMimeTypes(@NotNull File file) throws IOException { InputStream in = null; try { in = new TFileInputStream(file); in = new BufferedInputStream(in); Collection<?> mimeTypes = mimeDetector.getMimeTypes(in); Collection<String> textTypes = textParser.getTypes(); List<String> result = Util.createEmptyList(mimeTypes, textTypes); for (Object mimeType : mimeTypes) result.add(mimeType.toString().toLowerCase(Locale.ENGLISH)); if (TextDetector.isText(in)) result.addAll(textTypes); return result; } finally { Closeables.closeQuietly(in); } } private  ParseService(); @Immutable @NotNull static List<Parser> getParsers(); @NotNull static ParseResult parse(@NotNull IndexingConfig config,
	                                @NotNull File file,
	                                @NotNull String filename,
	                                @NotNull Path filepath,
	                                @NotNull IndexingReporter reporter,
	                                @NotNull Cancelable cancelable); @NotNull static String renderText(@NotNull IndexingConfig config,
	                                @NotNull File file,
	                                @NotNull String filename,
									@NotNull String parserName); static boolean canParseByName(	@NotNull IndexingConfig config,
											@NotNull String filename); static boolean isBuiltInExtension(	@NotNull IndexingConfig config,
												@NotNull String extension);  }
@Test public void testMimeTypeDetection() throws Exception { ListMap<File, Parser> fileToParserMap = ListMap.<File, Parser>create() .add(TestFiles.lorem_ipsum_abw.get(), new AbiWordParser()) .add(TestFiles.lorem_ipsum_abw_gz.get(), new AbiWordParser()) .add(TestFiles.lorem_ipsum_docx.get(), new MSWord2007Parser()) .add(TestFiles.lorem_ipsum_html.get(), new HtmlParser()) .add(TestFiles.lorem_ipsum_odt.get(), new OpenOfficeWriterParser()) .add(TestFiles.lorem_ipsum_pdf.get(), new PdfParser()) .add(TestFiles.lorem_ipsum_rtf.get(), new RtfParser()) .add(TestFiles.lorem_ipsum_svg.get(), new SvgParser()) .add(TestFiles.lorem_ipsum_txt.get(), new TextParser()) .add(TestFiles.lorem_ipsum_doc_97.get(), new MSWordParser()) .add(TestFiles.lorem_ipsum_xls_5_0.get(), new MSExcelParser()) .add(TestFiles.lorem_ipsum_xls_95.get(), new MSExcelParser()) .add(TestFiles.lorem_ipsum_xls_97.get(), new MSExcelParser()) .add(TestFiles.lorem_ipsum_ppt_97.get(), new MSPowerPointParser()) ; for (Entry<File, Parser> entry : fileToParserMap) { Collection<String> expectedTypes = entry.getValue().getTypes(); Collection<String> actualTypes = ParseService.getPossibleMimeTypes(entry.getKey()); assertTrue(!Collections.disjoint(expectedTypes, actualTypes)); } }