### Question:
MimeTypeUtil { public String mimeTypeOf( String filename ) { if (filename == null || filename.length() == 0) return null; String trimmedName = filename.trim(); if (trimmedName.length() == 0) return null; int indexOfDelimiter = trimmedName.lastIndexOf('.'); if (indexOfDelimiter < 0) return null; String extension = trimmedName.substring(indexOfDelimiter).toLowerCase(); return mimeTypesByExtension.get(extension); } MimeTypeUtil();  MimeTypeUtil( ClassLoaderFactory classLoaderFactory );  MimeTypeUtil( Map<String, String> extensionsToMimeTypes );  MimeTypeUtil( Map<String, String> extensionsToMimeTypes,
                         boolean initWithDefaults );  MimeTypeUtil( Map<String, String> extensionsToMimeTypes,
                         boolean initWithDefaults, ClassLoader classLoader); static Map<String, String> load( InputStream stream,
                                            Map<String, Set<String>> duplicateMimeTypesByExtension ); String mimeTypeOf( String filename ); String mimeTypeOf( File file ); static final String MIME_TYPE_EXTENSIONS_RESOURCE_PATH; }### Answer:
@Test public void shouldFindMimeTypeForExtenionsInStandardPropertiesFile() { assertThat(detector.mimeTypeOf("something.txt"), is("text/plain")); }
@Test public void shouldFindMimeTypeForOneCharacterExtension() { assertThat(detector.mimeTypeOf("something.gzip.Z"), is("application/x-compress")); }
@Test public void shouldFindMimeTypeForTwoCharacterExtension() { assertThat(detector.mimeTypeOf("something.sh"), is("application/x-sh")); }
@Test public void shouldFindMimeTypeForThreeCharacterExtension() { assertThat(detector.mimeTypeOf("something.png"), is("image/png")); }
@Test public void shouldNotFindMimeTypeForNameWithoutExtension() { assertThat(detector.mimeTypeOf("something"), is(nullValue())); }
@Test public void shouldNotFindMimeTypeForNameUnknownExtension() { assertThat(detector.mimeTypeOf("something.thisExtensionIsNotKnown"), is(nullValue())); }
@Test public void shouldNotFindMimeTypeForZeroLengthName() { assertThat(detector.mimeTypeOf(""), is(nullValue())); }
@Test public void shouldNotFindMimeTypeForNameContainingWhitespace() { assertThat(detector.mimeTypeOf("/t /n "), is(nullValue())); }
@Test public void shouldNotFindMimeTypeForNullName() { assertThat(detector.mimeTypeOf((String)null), is(nullValue())); }
@Test public void shouldNotFindMimeTypeForNullFile() { assertThat(detector.mimeTypeOf((File)null), is(nullValue())); }
@Test public void shouldFindMimeTypeForUppercaseExtenionsInStandardPropertiesFile() { assertThat(detector.mimeTypeOf("something.TXT"), is("text/plain")); }
@Test public void shouldFindMimeTypeForNameWithTrailingWhitespace() { assertThat(detector.mimeTypeOf("something.txt \t"), is("text/plain")); }
@Test public void shouldFindMimeTypeOfHiddenFiles() { assertThat(this.detector.mimeTypeOf(".txt"), is("text/plain")); }