GoogleMapsDirectionDistanceCalculator implements
		DistanceCalculator { public double getDistanceBetweenPoints(GpsPoint p1, GpsPoint p2) { HttpGet httpRequest = new HttpGet(appendParameterToUrl(GOOGLE_API, p1, p2)); HttpClient httpclient = new DefaultHttpClient(); HttpResponse response = null; GoogleRoutes pl = null; try { response = httpclient.execute(httpRequest); String jsonString = inputStreamAsString(response.getEntity() .getContent()); pl = getGoogleRoutes(jsonString); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } if (pl != null) { return pl.getLeg(0).getDistance(); } return -1; }  double getDistanceBetweenPoints(GpsPoint p1, GpsPoint p2);  }
@Test @Ignore("Use network for testing") public void testGetOnlineGoogleRoutes() throws IOException { GpsPoint p1 = new GpsPoint(47.2208, -1.5584); GpsPoint p2 = new GpsPoint(48.4116, -1.7525); GoogleMapsDirectionDistanceCalculator dist = new GoogleMapsDirectionDistanceCalculator(); double distance = dist.getDistanceBetweenPoints(p1, p2); double expectedDistance = 146000; double tolerance = 100.0d; assertEquals(expectedDistance, distance, tolerance); }