This method uses the default
javax.activation.FileTypeMap#getDefaultFileTypeMap()from the Java Activation Framework to resolve MIME types.
The Java Activation Framework returns
"application/octet-stream"if the MIME type is unknown (i.e., it never returns
null). Thus, in
order to honor the
ServletContext#getMimeType(String) contract,
this method returns
null if the MIME type is
"application/octet-stream".
MockServletContext does not provide a direct mechanism for
setting a custom MIME type; however, if the default
FileTypeMapis an instance of
javax.activation.MimetypesFileTypeMap, a custom
MIME type named
text/enigma can be registered for a custom
.puzzle file extension in the following manner:
MimetypesFileTypeMap mimetypesFileTypeMap = (MimetypesFileTypeMap) FileTypeMap.getDefaultFileTypeMap();
mimetypesFileTypeMap.addMimeTypes("text/enigma puzzle");