MimeHelper { public static String getMimeTypeFromExtension( final String extension ) { return MimeHelper.extensions.get( extension.toLowerCase() ); }  static String getExtension( final String mimeType ); static String getMimeTypeFromExtension( final String extension ); static String getMimeTypeFromFileName( final String fileName ); static String getDefaultCharset( final String mimeType ); static final String MIMETYPE_RTF; static final String RTF_EXTENSION; static final String MIMETYPE_MS_WORD; static final String MS_WORD_EXTENSION; static final String MIMETYPE_PDF; static final String PDF_EXTENSION; static final String MIMETYPE_MS_EXCEL; static final String MS_EXCEL_EXTENSION; static final String MIMETYPE_MS_PPT; static final String MS_PPT_EXTENSION; static final String MIMETYPE_MS_PROJECT; static final String MS_PROJECT_EXTENSION; static final String MIMETYPE_ZIP; static final String ZIP_EXTENSION; static final String MIMETYPE_MP3; static final String MP3_EXTENSION; static final String MIMETYPE_WAV; static final String WAV_EXTENSION; static final String MIMETYPE_BMP; static final String BMP_EXTENSION; static final String MIMETYPE_GIF; static final String GIF_EXTENSION; static final String MIMETYPE_JPEG; static final String JPEG_EXTENSION_1; static final String JPEG_EXTENSION_2; static final String JPEG_EXTENSION_3; static final String MIMETYPE_PNG; static final String PNG_EXTENSION; static final String MIMETYPE_SVG; static final String SVG_EXTENSION; static final String MIMETYPE_TIFF; static final String TIFF_EXTENSION_1; static final String TIFF_EXTENSION_2; static final String MIMETYPE_CSV; static final String CSV_EXTENSION; static final String MIMETYPE_HTML; static final String HTML_EXTENSION_1; static final String HTML_EXTENSION_2; static final String MIMETYPE_TEXT; static final String TEXT_EXTENSION; static final String PROPERTIES_EXTENSION; static final String MIMETYPE_MPG; static final String MPG_EXTENSION_1; static final String MPG_EXTENSION_2; static final String MPG_EXTENSION_3; static final String MIMETYPE_AVI; static final String AVI_EXTENSION; static final String MIMETYPE_XACTION; static final String XACTION_EXTENSION; static final String MIMETYPE_CSS; static final String CSS_EXTENSION; static final String MIMETYPE_JS; static final String JS_EXTENSION; static final String MIMETYPE_XML; static final String XML_EXTENSION; static final String MIMETYPE_FLASH; static final String FLASH_EXTENSION; static final String MIMETYPE_MS_EXCEL_2007; static final String MS_EXCEL_2007_EXTENSION; static final String MIMETYPE_EMAIL_MSG; static final String EMAIL_MSG_EXTENSION; }
@Test public void getMimeTypeFromExtensionTest() { assertEquals( MimeHelper.MIMETYPE_RTF, MimeHelper.getMimeTypeFromExtension( MimeHelper.RTF_EXTENSION ) ); assertEquals( MimeHelper.MIMETYPE_MS_WORD, MimeHelper.getMimeTypeFromExtension( MimeHelper.MS_WORD_EXTENSION ) ); assertEquals( MimeHelper.MIMETYPE_PDF, MimeHelper.getMimeTypeFromExtension( MimeHelper.PDF_EXTENSION ) ); assertEquals( MimeHelper.MIMETYPE_MS_EXCEL, MimeHelper.getMimeTypeFromExtension( MimeHelper.MS_EXCEL_EXTENSION ) ); assertEquals( MimeHelper.MIMETYPE_MS_PPT, MimeHelper.getMimeTypeFromExtension( MimeHelper.MS_PPT_EXTENSION ) ); assertEquals( MimeHelper.MIMETYPE_MS_PROJECT, MimeHelper.getMimeTypeFromExtension( MimeHelper.MS_PROJECT_EXTENSION ) ); assertEquals( MimeHelper.MIMETYPE_ZIP, MimeHelper.getMimeTypeFromExtension( MimeHelper.ZIP_EXTENSION ) ); assertEquals( MimeHelper.MIMETYPE_MP3, MimeHelper.getMimeTypeFromExtension( MimeHelper.MP3_EXTENSION ) ); assertEquals( MimeHelper.MIMETYPE_WAV, MimeHelper.getMimeTypeFromExtension( MimeHelper.WAV_EXTENSION ) ); assertEquals( MimeHelper.MIMETYPE_BMP, MimeHelper.getMimeTypeFromExtension( MimeHelper.BMP_EXTENSION ) ); assertEquals( MimeHelper.MIMETYPE_GIF, MimeHelper.getMimeTypeFromExtension( MimeHelper.GIF_EXTENSION ) ); assertEquals( MimeHelper.MIMETYPE_JPEG, MimeHelper.getMimeTypeFromExtension( MimeHelper.JPEG_EXTENSION_1 ) ); assertEquals( MimeHelper.MIMETYPE_JPEG, MimeHelper.getMimeTypeFromExtension( MimeHelper.JPEG_EXTENSION_2 ) ); assertEquals( MimeHelper.MIMETYPE_JPEG, MimeHelper.getMimeTypeFromExtension( MimeHelper.JPEG_EXTENSION_3 ) ); assertEquals( MimeHelper.MIMETYPE_PNG, MimeHelper.getMimeTypeFromExtension( MimeHelper.PNG_EXTENSION ) ); assertEquals( MimeHelper.MIMETYPE_SVG, MimeHelper.getMimeTypeFromExtension( MimeHelper.SVG_EXTENSION ) ); assertEquals( MimeHelper.MIMETYPE_TIFF, MimeHelper.getMimeTypeFromExtension( MimeHelper.TIFF_EXTENSION_1 ) ); assertEquals( MimeHelper.MIMETYPE_TIFF, MimeHelper.getMimeTypeFromExtension( MimeHelper.TIFF_EXTENSION_2 ) ); assertEquals( MimeHelper.MIMETYPE_CSV, MimeHelper.getMimeTypeFromExtension( MimeHelper.CSV_EXTENSION ) ); assertEquals( MimeHelper.MIMETYPE_HTML, MimeHelper.getMimeTypeFromExtension( MimeHelper.HTML_EXTENSION_1 ) ); assertEquals( MimeHelper.MIMETYPE_HTML, MimeHelper.getMimeTypeFromExtension( MimeHelper.HTML_EXTENSION_2 ) ); assertEquals( MimeHelper.MIMETYPE_TEXT, MimeHelper.getMimeTypeFromExtension( MimeHelper.TEXT_EXTENSION ) ); assertEquals( MimeHelper.MIMETYPE_TEXT, MimeHelper.getMimeTypeFromExtension( MimeHelper.PROPERTIES_EXTENSION ) ); assertEquals( MimeHelper.MIMETYPE_MPG, MimeHelper.getMimeTypeFromExtension( MimeHelper.MPG_EXTENSION_1 ) ); assertEquals( MimeHelper.MIMETYPE_MPG, MimeHelper.getMimeTypeFromExtension( MimeHelper.MPG_EXTENSION_2 ) ); assertEquals( MimeHelper.MIMETYPE_MPG, MimeHelper.getMimeTypeFromExtension( MimeHelper.MPG_EXTENSION_3 ) ); assertEquals( MimeHelper.MIMETYPE_AVI, MimeHelper.getMimeTypeFromExtension( MimeHelper.AVI_EXTENSION ) ); assertEquals( MimeHelper.MIMETYPE_XACTION, MimeHelper.getMimeTypeFromExtension( MimeHelper.XACTION_EXTENSION ) ); assertEquals( MimeHelper.MIMETYPE_CSS, MimeHelper.getMimeTypeFromExtension( MimeHelper.CSS_EXTENSION ) ); assertEquals( MimeHelper.MIMETYPE_JS, MimeHelper.getMimeTypeFromExtension( MimeHelper.JS_EXTENSION ) ); assertEquals( MimeHelper.MIMETYPE_XML, MimeHelper.getMimeTypeFromExtension( MimeHelper.XML_EXTENSION ) ); assertEquals( MimeHelper.MIMETYPE_FLASH, MimeHelper.getMimeTypeFromExtension( MimeHelper.FLASH_EXTENSION ) ); assertEquals( MimeHelper.MIMETYPE_MS_EXCEL_2007, MimeHelper.getMimeTypeFromExtension( MimeHelper.MS_EXCEL_2007_EXTENSION ) ); assertEquals( MimeHelper.MIMETYPE_EMAIL_MSG, MimeHelper.getMimeTypeFromExtension( MimeHelper.EMAIL_MSG_EXTENSION ) ); }