### Question:
NominatimGeocoder implements Geocoder { public GWTLatLng geocode(final String geolocation) throws GeocoderException { final HttpUriRequest method = new HttpGet(getUrl(geolocation)); method.addHeader("User-Agent", "OpenNMS-MapquestGeocoder/1.0"); if (m_referer != null) { method.addHeader("Referer", m_referer); } try { InputStream responseStream = m_httpClient.execute(method).getEntity().getContent(); final ElementTree tree = ElementTree.fromStream(responseStream); if (tree == null) { throw new GeocoderException("an error occurred connecting to the Nominatim geocoding service (no XML tree was found)"); } final List<ElementTree> places = tree.findAll(" if (places.size() > 1) { LogUtils.warnf(this, "more than one location returned for query: %s", geolocation); } else if (places.size() == 0) { throw new GeocoderException("Nominatim returned an OK status code, but no places"); } final ElementTree place = places.get(0); Double latitude = Double.valueOf(place.getAttribute("lat")); Double longitude = Double.valueOf(place.getAttribute("lon")); return new GWTLatLng(latitude, longitude); } catch (GeocoderException e) { throw e; } catch (Throwable e) { throw new GeocoderException("unable to get lat/lng from Nominatim", e); } } NominatimGeocoder();  NominatimGeocoder(final String emailAddress); GWTLatLng geocode(final String geolocation);  }### Answer:
@Test public void testLookupSuccess() throws Exception { if (shouldRun()) { Geocoder geocoder = new NominatimGeocoder("opennms@opennms.org"); final GWTLatLng remote = geocoder.geocode("220 Chatham Business Dr, Pittsboro, NC 27312"); final GWTLatLng local = new GWTLatLng(35.7182403203186, -79.1621859463074); assertEquals(local.hashCode(), remote.hashCode()); assertEquals(local, remote); } }
@Test public void testLookupFailure() throws Exception { if (shouldRun()) { Geocoder geocoder = new NominatimGeocoder("opennms@opennms.org"); try { geocoder.geocode("asdasdasdasdasdasdasdasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdf"); assertTrue("this should throw an exception", false); } catch (GeocoderException e) { assertEquals("Nominatim returned an OK status code, but no places", e.getMessage()); } } }