use of com.graphhopper.GraphHopperAPI in project graphhopper by graphhopper.
the class GraphHopperServletIT method testGraphHopperWebRealExceptions.
@Test
public void testGraphHopperWebRealExceptions() {
GraphHopperAPI hopper = new com.graphhopper.api.GraphHopperWeb();
assertTrue(hopper.load(getTestRouteAPIUrl()));
// IllegalArgumentException (Wrong Request)
GHResponse rsp = hopper.route(new GHRequest());
assertFalse("Errors expected but not found.", rsp.getErrors().isEmpty());
Throwable ex = rsp.getErrors().get(0);
assertTrue("Wrong exception found: " + ex.getClass().getName() + ", IllegalArgumentException expected.", ex instanceof IllegalArgumentException);
// IllegalArgumentException (Wrong Points)
rsp = hopper.route(new GHRequest(0.0, 0.0, 0.0, 0.0));
assertFalse("Errors expected but not found.", rsp.getErrors().isEmpty());
List<Throwable> errs = rsp.getErrors();
for (int i = 0; i < errs.size(); i++) {
assertEquals(((PointOutOfBoundsException) errs.get(i)).getPointIndex(), i);
}
// IllegalArgumentException (Vehicle not supported)
rsp = hopper.route(new GHRequest(42.554851, 1.536198, 42.510071, 1.548128).setVehicle("SPACE-SHUTTLE"));
assertFalse("Errors expected but not found.", rsp.getErrors().isEmpty());
ex = rsp.getErrors().get(0);
assertTrue("Wrong exception found: " + ex.getClass().getName() + ", IllegalArgumentException expected.", ex instanceof IllegalArgumentException);
}
Aggregations