IconsLoader { public static void loadIcons() { Field[] fields = Icons.class.getFields(); for (Field field : fields) { Path annotation = field.getAnnotation(Path.class); InputStream stream = IconsLoader.class.getResourceAsStream(annotation.path()); if (stream != null) { try { ImageIcon imageIcon; Image image = ImageIO.read(stream); if (annotation.gray()) { image = GrayFilter.createDisabledImage(image); } imageIcon = new ImageIcon(image); field.set(null, imageIcon); LOGGER.debug("Icon " + annotation.path() + " for field " + field.getName() + " loaded"); } catch (Exception e) { LOGGER.error("Can't load icon " + annotation.path() + " for field " + field.getName()); } } } }  static void loadIcons();  }
@Test public void testLoadIcons() throws IllegalArgumentException, IllegalAccessException { IconsLoader.loadIcons(); Field[] fields = Icons.class.getFields(); for (Field field : fields) { if (field.getAnnotation(Path.class) != null) { assertNotNull("Icon " + field.getName() + " not loaded", field.get(null)); } } }