@Test public void testTraverseOnEmptyBundleWhenReturningNull() { Bundle bundle = mock(Bundle.class); when(bundle.getEntryPaths(anyString())).thenReturn(null); List<I18nExtension> list; list = ExtenderUtils.analyze("/i18n/", bundle); assertThat(list.size()).isEqualTo(0); }
public static List<I18nExtension> analyze(String path, Bundle bundle) { List<I18nExtension> list = new ArrayList<>(); Enumeration<String> paths = bundle.getEntryPaths(path); if (paths != null) { while (paths.hasMoreElements()) { String entry = paths.nextElement(); if (! entry.endsWith("/")) { String file = entry.substring(path.length() - 1); Locale locale = getLocaleFromResourceName(file); URL url = bundle.getEntry(entry); if (url != null) { I18nExtension extension = new I18nExtension(url, locale, bundle); try { extension.load(); list.add(extension); } catch (IOException e) { LOGGER.error("Cannot load resource bundle from " + path + " within " + bundle.getSymbolicName(), e); } } else { LOGGER.error("Cannot open " + entry + " from " + bundle.getSymbolicName()); } } } } return list; }
ExtenderUtils { public static List<I18nExtension> analyze(String path, Bundle bundle) { List<I18nExtension> list = new ArrayList<>(); Enumeration<String> paths = bundle.getEntryPaths(path); if (paths != null) { while (paths.hasMoreElements()) { String entry = paths.nextElement(); if (! entry.endsWith("/")) { String file = entry.substring(path.length() - 1); Locale locale = getLocaleFromResourceName(file); URL url = bundle.getEntry(entry); if (url != null) { I18nExtension extension = new I18nExtension(url, locale, bundle); try { extension.load(); list.add(extension); } catch (IOException e) { LOGGER.error("Cannot load resource bundle from " + path + " within " + bundle.getSymbolicName(), e); } } else { LOGGER.error("Cannot open " + entry + " from " + bundle.getSymbolicName()); } } } } return list; } }
ExtenderUtils { public static List<I18nExtension> analyze(String path, Bundle bundle) { List<I18nExtension> list = new ArrayList<>(); Enumeration<String> paths = bundle.getEntryPaths(path); if (paths != null) { while (paths.hasMoreElements()) { String entry = paths.nextElement(); if (! entry.endsWith("/")) { String file = entry.substring(path.length() - 1); Locale locale = getLocaleFromResourceName(file); URL url = bundle.getEntry(entry); if (url != null) { I18nExtension extension = new I18nExtension(url, locale, bundle); try { extension.load(); list.add(extension); } catch (IOException e) { LOGGER.error("Cannot load resource bundle from " + path + " within " + bundle.getSymbolicName(), e); } } else { LOGGER.error("Cannot open " + entry + " from " + bundle.getSymbolicName()); } } } } return list; } private  ExtenderUtils(); }
ExtenderUtils { public static List<I18nExtension> analyze(String path, Bundle bundle) { List<I18nExtension> list = new ArrayList<>(); Enumeration<String> paths = bundle.getEntryPaths(path); if (paths != null) { while (paths.hasMoreElements()) { String entry = paths.nextElement(); if (! entry.endsWith("/")) { String file = entry.substring(path.length() - 1); Locale locale = getLocaleFromResourceName(file); URL url = bundle.getEntry(entry); if (url != null) { I18nExtension extension = new I18nExtension(url, locale, bundle); try { extension.load(); list.add(extension); } catch (IOException e) { LOGGER.error("Cannot load resource bundle from " + path + " within " + bundle.getSymbolicName(), e); } } else { LOGGER.error("Cannot open " + entry + " from " + bundle.getSymbolicName()); } } } } return list; } private  ExtenderUtils(); static List<I18nExtension> analyze(String path, Bundle bundle); static Locale getLocaleFromResourceName(String name); }
ExtenderUtils { public static List<I18nExtension> analyze(String path, Bundle bundle) { List<I18nExtension> list = new ArrayList<>(); Enumeration<String> paths = bundle.getEntryPaths(path); if (paths != null) { while (paths.hasMoreElements()) { String entry = paths.nextElement(); if (! entry.endsWith("/")) { String file = entry.substring(path.length() - 1); Locale locale = getLocaleFromResourceName(file); URL url = bundle.getEntry(entry); if (url != null) { I18nExtension extension = new I18nExtension(url, locale, bundle); try { extension.load(); list.add(extension); } catch (IOException e) { LOGGER.error("Cannot load resource bundle from " + path + " within " + bundle.getSymbolicName(), e); } } else { LOGGER.error("Cannot open " + entry + " from " + bundle.getSymbolicName()); } } } } return list; } private  ExtenderUtils(); static List<I18nExtension> analyze(String path, Bundle bundle); static Locale getLocaleFromResourceName(String name);  }