YahooPlaceFinderGeocoderService implements GeocoderService { @Override public GetLocationResult[] getLocation(List<String> location, int maxAlternatives, Locale locale) { try { String query = splitCommaReverseService.combine(location); List<GetLocationResult> locations = search(query, maxAlternatives, locale); return locations.toArray(new GetLocationResult[locations.size()]); } catch (Exception ex) { log.error("Search failed", ex); return null; } }  @Override String getName(); @Api void setName(String name); @Api void setAppId(String appId); @Api void setAppIdProperty(String appIdProperty); @Api void setSkipAppIdCheck(boolean skipAppIdCheck); @Override CoordinateReferenceSystem getCrs(); @Override GetLocationResult[] getLocation(List<String> location,
			int maxAlternatives, Locale locale); List<GetLocationResult> search(String q, int maxRows, Locale locale);  }
@Test public void testGeocoder1() { list.add("booischot"); result = geocoder.getLocation(list, 50, null); Assert.assertNotNull(result); Assert.assertEquals(1,result.length); Assert.assertNotNull(result[0].getCoordinate()); Assert.assertEquals(4.77397, result[0].getCoordinate().x, .00001); Assert.assertEquals(51.05125, result[0].getCoordinate().y, .00001); Assert.assertEquals(2, result[0].getCanonicalStrings().size()); Assert.assertEquals("Belgium", result[0].getCanonicalStrings().get(0)); Assert.assertEquals("2221 Boisschot", result[0].getCanonicalStrings().get(1)); Assert.assertEquals(4.75513, result[0].getEnvelope().getMinX(), .00001); Assert.assertEquals(4.79043, result[0].getEnvelope().getMaxX(), .00001); Assert.assertEquals(51.031898, result[0].getEnvelope().getMinY(), .00001); Assert.assertEquals(51.05677, result[0].getEnvelope().getMaxY(), .00001); }
@Test public void testGeocoder2() { list.add("booischot"); result = geocoder.getLocation(list, 50, new Locale("nl_BE")); Assert.assertNotNull(result); Assert.assertEquals(1,result.length); Assert.assertNotNull(result[0].getCoordinate()); Assert.assertEquals(4.77397, result[0].getCoordinate().x, .00001); Assert.assertEquals(51.05125, result[0].getCoordinate().y, .00001); Assert.assertEquals(2, result[0].getCanonicalStrings().size()); Assert.assertEquals("België", result[0].getCanonicalStrings().get(0)); Assert.assertEquals("2221 Booischot", result[0].getCanonicalStrings().get(1)); Assert.assertEquals(4.75513, result[0].getEnvelope().getMinX(), .00001); Assert.assertEquals(4.79043, result[0].getEnvelope().getMaxX(), .00001); Assert.assertEquals(51.031898, result[0].getEnvelope().getMinY(), .00001); Assert.assertEquals(51.05677, result[0].getEnvelope().getMaxY(), .00001); }
@Test public void testGeocoder3() { list.add("london"); result = geocoder.getLocation(list, 50, null); Assert.assertNotNull(result); Assert.assertEquals(1,result.length); Assert.assertNotNull(result[0].getCoordinate()); Assert.assertEquals(-0.127144, result[0].getCoordinate().x, .00001); Assert.assertEquals(51.506325, result[0].getCoordinate().y, .00001); Assert.assertEquals(2, result[0].getCanonicalStrings().size()); Assert.assertEquals("United Kingdom", result[0].getCanonicalStrings().get(0)); Assert.assertEquals("London", result[0].getCanonicalStrings().get(1)); }
@Test public void testGeocoder4() { list.add("london"); list.add("CA"); result = geocoder.getLocation(list, 50, null); Assert.assertNotNull(result); Assert.assertEquals(1,result.length); Assert.assertEquals("United States", result[0].getCanonicalStrings().get(0)); Assert.assertEquals("London, CA 93618", result[0].getCanonicalStrings().get(1)); }
@Test public void testGeocoder5() { list.add("thequickbrownfoxjumpsoverthelazydogloremipsumdolorsitamet"); result = geocoder.getLocation(list, 50, null); Assert.assertTrue(null == result || 0 == result.length); }
@Test public void testTranslatedLocale() { list.add("booischot"); result = geocoder.getLocation(list, 50, new Locale("fr")); Assert.assertNotNull(result); Assert.assertEquals(1,result.length); Assert.assertNotNull(result[0].getCoordinate()); Assert.assertEquals(4.77397, result[0].getCoordinate().x, .00001); Assert.assertEquals(51.05125, result[0].getCoordinate().y, .00001); Assert.assertEquals(2, result[0].getCanonicalStrings().size()); Assert.assertEquals("Belgique", result[0].getCanonicalStrings().get(0)); Assert.assertEquals("2221 Booischot", result[0].getCanonicalStrings().get(1)); Assert.assertEquals(4.75513, result[0].getEnvelope().getMinX(), .00001); Assert.assertEquals(4.79043, result[0].getEnvelope().getMaxX(), .00001); Assert.assertEquals(51.031898, result[0].getEnvelope().getMinY(), .00001); Assert.assertEquals(51.05677, result[0].getEnvelope().getMaxY(), .00001); }
@Test public void testException() { result = geocoder.getLocation(list, 50, null); Assert.assertTrue(null == result || 0 == result.length); }