IconUtils { public static String findMimeType( File imgFile ) { String result; String name = imgFile.getName().toLowerCase(); if( name.endsWith( ".jpg" ) || name.endsWith( ".jpeg" )) result = MIME_JPG; else if( name.endsWith( ".gif" )) result = MIME_GIF; else if( name.endsWith( ".png" )) result = MIME_PNG; else if( name.endsWith( ".svg" )) result = MIME_SVG; else result = MIME_BINARY; return result; } private  IconUtils(); static String encodeIconUrl( String name, String version, File iconFile ); static Map.Entry<String,String> decodeIconUrl( String path ); static File findIcon( AbstractApplication app ); static String findIconUrl( AbstractApplication app ); static String findMimeType( File imgFile ); static File findIcon( File rootDirectory ); static final String MIME_JPG; static final String MIME_PNG; static final String MIME_SVG; static final String MIME_GIF; static final String MIME_BINARY; }
@Test public void testFindMimeType() { Assert.assertEquals( IconUtils.MIME_BINARY, IconUtils.findMimeType( new File( "toto.mp4" ))); Assert.assertEquals( IconUtils.MIME_GIF, IconUtils.findMimeType( new File( "toto.gif" ))); Assert.assertEquals( IconUtils.MIME_JPG, IconUtils.findMimeType( new File( "toto.jpg" ))); Assert.assertEquals( IconUtils.MIME_JPG, IconUtils.findMimeType( new File( "toto.jpEg" ))); Assert.assertEquals( IconUtils.MIME_PNG, IconUtils.findMimeType( new File( "toto.png" ))); Assert.assertEquals( IconUtils.MIME_SVG, IconUtils.findMimeType( new File( "toto.svg" ))); }