@Test public void shouldReturnGivenDefaultIconWhenBundleDoesNotContainIcon() { setupBundleRetrieval(); BundleIcon bundleIcon = bundleIconService.getBundleIconById(BUNDLE_ID, DEFAULT_ICON_2); byte[] expectedIcon = readDefaultIcon(DEFAULT_PATH + DEFAULT_ICON_2); assertArrayEquals(expectedIcon, bundleIcon.getIcon()); assertEquals(ICON_MIME, bundleIcon.getMime()); }
@Test public void shouldReturnIconWhenGivenBundleName() { setupBundleRetrieval(); when(bundle.getResource("icon.gif")).thenReturn(getDefaultIconUrl(DEFAULT_PATH + DEFAULT_ICON)); BundleIcon bundleIcon = bundleIconService.getBundleIconByName(BUNDLE_NAME, null); byte[] expectedIcon = readDefaultIcon(DEFAULT_PATH + DEFAULT_ICON); assertArrayEquals(expectedIcon, bundleIcon.getIcon()); assertEquals(ICON_MIME, bundleIcon.getMime()); }
@Test public void shouldReturnIcon() throws IOException { setupBundleRetrieval(); byte[] expectedIcon = readDefaultIcon(DEFAULT_PATH + DEFAULT_ICON); when(bundle.getResource("icon.gif")).thenReturn(getDefaultIconUrl(DEFAULT_PATH + DEFAULT_ICON)); BundleIcon bundleIcon = bundleIconService.getBundleIconById(BUNDLE_ID, null); assertArrayEquals(expectedIcon, bundleIcon.getIcon()); assertEquals(expectedIcon.length, bundleIcon.getContentLength()); assertEquals(ICON_MIME, bundleIcon.getMime()); verify(bundleContext).getBundle(BUNDLE_ID); verify(bundle).getResource("icon.gif"); }
@Test public void shouldReturnDefaultIconWhenBundleDoesNotContainIcon() { setupBundleRetrieval(); BundleIcon bundleIcon = bundleIconService.getBundleIconById(BUNDLE_ID, null); byte[] expectedIcon = readDefaultIcon(DEFAULT_PATH + DEFAULT_ICON); assertArrayEquals(expectedIcon, bundleIcon.getIcon()); assertEquals(expectedIcon.length, bundleIcon.getContentLength()); assertEquals(ICON_MIME, bundleIcon.getMime()); for (String iconName : BundleIcon.ICON_LOCATIONS) { verify(bundle).getResource(iconName); } }