FileTypeIconTag extends TagSupport { protected String extractIconFromMapping(final String mapping) { if (mapping == null) { return fallbackIcon; } final String[] s = mapping.trim().split(";"); return StringUtils.isEmpty(s[0]) ? fallbackIcon : s[0]; }  @Override int doStartTag(); void setFallbackIcon(final String fallbackIcon); void setFilename(final String filename);  }
@Test public void testExtractIconFromMapping() throws Exception { final FileTypeIconTag iconTag = new FileTypeIconTag(); assertEquals("images/icon_file.png", iconTag.extractIconFromMapping(null)); assertEquals("images/icon_file.png", iconTag.extractIconFromMapping("")); assertEquals("images/icon_file_zip.png", iconTag.extractIconFromMapping("images/icon_file_zip.png")); assertEquals("images/icon_file_zip.png", iconTag.extractIconFromMapping("images/icon_file_zip.png ")); assertEquals("images/icon_file_zip.png", iconTag.extractIconFromMapping("images/icon_file_zip.png;")); assertEquals("images/icon_file_zip.png", iconTag.extractIconFromMapping("images/icon_file_zip.png;Web archive")); }