@Test public void getDefaultIconWithException() throws Exception { Exception exception = new MalformedURLException(); when(xwiki.getResourceAsStream(any())).thenThrow(exception); Exception exceptionCaught = null; try { mocker.getComponentUnderTest().getDefaultIconSet(); } catch (IconException e) { exceptionCaught = e; } assertNotNull(exceptionCaught); assertEquals(exception, exceptionCaught.getCause()); assertEquals("Failed to get the current default icon set.", exceptionCaught.getMessage()); }
@Override public IconSet getDefaultIconSet() throws IconException { XWikiContext xcontext = xcontextProvider.get(); XWiki xwiki = xcontext.getWiki(); IconSet iconSet = iconSetCache.get(DEFAULT_ICONSET_NAME); if (iconSet == null) { try { iconSet = iconSetLoader.loadIconSet(new InputStreamReader( xwiki.getResourceAsStream("/resources/icons/default.iconset")), DEFAULT_ICONSET_NAME); iconSetCache.put(DEFAULT_ICONSET_NAME, iconSet); } catch (IconException | MalformedURLException e) { throw new IconException("Failed to get the current default icon set.", e); } } return iconSet; }
DefaultIconSetManager implements IconSetManager { @Override public IconSet getDefaultIconSet() throws IconException { XWikiContext xcontext = xcontextProvider.get(); XWiki xwiki = xcontext.getWiki(); IconSet iconSet = iconSetCache.get(DEFAULT_ICONSET_NAME); if (iconSet == null) { try { iconSet = iconSetLoader.loadIconSet(new InputStreamReader( xwiki.getResourceAsStream("/resources/icons/default.iconset")), DEFAULT_ICONSET_NAME); iconSetCache.put(DEFAULT_ICONSET_NAME, iconSet); } catch (IconException | MalformedURLException e) { throw new IconException("Failed to get the current default icon set.", e); } } return iconSet; } }
DefaultIconSetManager implements IconSetManager { @Override public IconSet getDefaultIconSet() throws IconException { XWikiContext xcontext = xcontextProvider.get(); XWiki xwiki = xcontext.getWiki(); IconSet iconSet = iconSetCache.get(DEFAULT_ICONSET_NAME); if (iconSet == null) { try { iconSet = iconSetLoader.loadIconSet(new InputStreamReader( xwiki.getResourceAsStream("/resources/icons/default.iconset")), DEFAULT_ICONSET_NAME); iconSetCache.put(DEFAULT_ICONSET_NAME, iconSet); } catch (IconException | MalformedURLException e) { throw new IconException("Failed to get the current default icon set.", e); } } return iconSet; }  }
DefaultIconSetManager implements IconSetManager { @Override public IconSet getDefaultIconSet() throws IconException { XWikiContext xcontext = xcontextProvider.get(); XWiki xwiki = xcontext.getWiki(); IconSet iconSet = iconSetCache.get(DEFAULT_ICONSET_NAME); if (iconSet == null) { try { iconSet = iconSetLoader.loadIconSet(new InputStreamReader( xwiki.getResourceAsStream("/resources/icons/default.iconset")), DEFAULT_ICONSET_NAME); iconSetCache.put(DEFAULT_ICONSET_NAME, iconSet); } catch (IconException | MalformedURLException e) { throw new IconException("Failed to get the current default icon set.", e); } } return iconSet; }  @Override IconSet getCurrentIconSet(); @Override IconSet getDefaultIconSet(); @Override IconSet getIconSet(String name); @Override List<String> getIconSetNames(); }
DefaultIconSetManager implements IconSetManager { @Override public IconSet getDefaultIconSet() throws IconException { XWikiContext xcontext = xcontextProvider.get(); XWiki xwiki = xcontext.getWiki(); IconSet iconSet = iconSetCache.get(DEFAULT_ICONSET_NAME); if (iconSet == null) { try { iconSet = iconSetLoader.loadIconSet(new InputStreamReader( xwiki.getResourceAsStream("/resources/icons/default.iconset")), DEFAULT_ICONSET_NAME); iconSetCache.put(DEFAULT_ICONSET_NAME, iconSet); } catch (IconException | MalformedURLException e) { throw new IconException("Failed to get the current default icon set.", e); } } return iconSet; }  @Override IconSet getCurrentIconSet(); @Override IconSet getDefaultIconSet(); @Override IconSet getIconSet(String name); @Override List<String> getIconSetNames();  }