@Test public void testResolver() { assertNull(MediaTypeResolver.getMediaType(null)); assertNull(MediaTypeResolver.getMediaType("noextension")); assertNull(MediaTypeResolver.getMediaType("124.")); assertEquals("application/javascript", MediaTypeResolver.getMediaType("file.js")); assertEquals("image/jpeg", MediaTypeResolver.getMediaType("file.jpg")); assertEquals("image/jpeg", MediaTypeResolver.getMediaType("file.jpeg")); assertEquals("image/jpeg", MediaTypeResolver.getMediaType("file.jpe")); assertEquals("text/css", MediaTypeResolver.getMediaType("file.css")); assertEquals("text/html", MediaTypeResolver.getMediaType("file.htm")); assertEquals("text/html", MediaTypeResolver.getMediaType("file.html")); assertEquals("application/java-archive", MediaTypeResolver.getMediaType("file.JAR")); }
public static String getMediaType(String fileName) { if (fileName == null) return null; int idx = fileName.lastIndexOf("."); if (idx == -1 || idx == fileName.length()) return null; return FILE_MAP.get(fileName.toLowerCase().substring(idx + 1)); }
MediaTypeResolver { public static String getMediaType(String fileName) { if (fileName == null) return null; int idx = fileName.lastIndexOf("."); if (idx == -1 || idx == fileName.length()) return null; return FILE_MAP.get(fileName.toLowerCase().substring(idx + 1)); } }
MediaTypeResolver { public static String getMediaType(String fileName) { if (fileName == null) return null; int idx = fileName.lastIndexOf("."); if (idx == -1 || idx == fileName.length()) return null; return FILE_MAP.get(fileName.toLowerCase().substring(idx + 1)); } private  MediaTypeResolver(); }
MediaTypeResolver { public static String getMediaType(String fileName) { if (fileName == null) return null; int idx = fileName.lastIndexOf("."); if (idx == -1 || idx == fileName.length()) return null; return FILE_MAP.get(fileName.toLowerCase().substring(idx + 1)); } private  MediaTypeResolver(); static String getMediaType(String fileName); }
MediaTypeResolver { public static String getMediaType(String fileName) { if (fileName == null) return null; int idx = fileName.lastIndexOf("."); if (idx == -1 || idx == fileName.length()) return null; return FILE_MAP.get(fileName.toLowerCase().substring(idx + 1)); } private  MediaTypeResolver(); static String getMediaType(String fileName);  }