### Question:
GeonamesLocationSource extends SingleQueryLocationSource { static List<Location> parseLocations(Document document) { checkError(document); List<Location> result = new ArrayList<>(); List<Node> geonames = XPathHelper.getNodes(document, " for (Node node : geonames) { Location location = parseLocation(node); result.add(location); } return result; } @Deprecated  GeonamesLocationSource(String username);  GeonamesLocationSource(String username, boolean retrieveHierarchy); static LocationSource newCachedLocationSource(String username); static LocationSource newCachedLocationSource(String username, boolean retrieveHierarchy); @Override List<Location> getLocations(String locationName, Set<Language> languages); @Override Location getLocation(int locationId); @Override List<Location> getLocations(GeoCoordinate coordinate, double distance); static void main(String[] args);  }### Answer:
@Test public void testParse() throws Exception { Document document = xmlParser.parse(ResourceHelper.getResourceFile("/apiResponse/geonamesResult.xml")); List<Location> result = GeonamesLocationSource.parseLocations(document); assertEquals(8, result.size()); Location location = CollectionHelper.getLast(result); assertEquals("Stuttgart", location.getPrimaryName()); GeoCoordinate coordinate = location.getCoordinate(); assertNotNull(coordinate); assertEquals(48.78232, coordinate.getLatitude(), 0); assertEquals(9.17702, coordinate.getLongitude(), 0); assertEquals(2825297, location.getId()); assertEquals(59, location.getAlternativeNames().size()); assertTrue(location.getAlternativeNames().contains(new AlternativeName("Stoccarda", Language.ITALIAN))); }
@Test(expected = IllegalStateException.class) public void testParseLimitExceeded() throws Exception { Document document = xmlParser.parse(ResourceHelper.getResourceFile("/apiResponse/geonamesResultExceeded.xml")); GeonamesLocationSource.parseLocations(document); }