XmlConverter implements Converter { @Override public Resources fromReader(Reader reader) throws IOException { try { Document document = read(reader); Resources resources = new Resources(); Element root = document.getDocumentElement(); for (int i = 0; i < root.getChildNodes().getLength(); i++) { Node node = root.getChildNodes().item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { SimpleEntry<String, Resource> entry = get(node); if (null != entry) { resources.add(entry.getKey(), entry.getValue()); } } } return resources; } catch (ParserConfigurationException | SAXException e) { throw new IOException(e); } }  @Override Resources fromReader(Reader reader); @SuppressWarnings("unused") Resources fromString(String string);  }
@Test public void testFromReader() throws Exception { Resources resources = new XmlConverter().fromReader(resourcesSteamReader); assertTrue("hello key exists", resources.has("hello")); assertTrue("screen_small key exists", resources.has("screen_small")); assertTrue("adjust_view_bounds key exists", resources.has("adjust_view_bounds")); assertTrue("max_speed key exists", resources.has("max_speed")); assertTrue("min_speed key exists", resources.has("min_speed")); assertTrue("planets_array key exists", resources.has("planets_array")); assertTrue("planets_array is array", resources.get("planets_array").isArray()); assertTrue("bits key exists", resources.has("bits")); assertTrue("bits is array", resources.get("bits").isArray()); }