Search in sources :

Example 26 with GHRequest

use of com.graphhopper.GHRequest in project graphhopper by graphhopper.

the class GraphHopperServletIT method testGraphHopperWebRealExceptions.

@Test
public void testGraphHopperWebRealExceptions() {
    GraphHopperAPI hopper = new 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);
}
Also used : GraphHopperAPI(com.graphhopper.GraphHopperAPI) GHRequest(com.graphhopper.GHRequest) GHResponse(com.graphhopper.GHResponse) GHPoint(com.graphhopper.util.shapes.GHPoint) Test(org.junit.Test)

Aggregations

GHRequest (com.graphhopper.GHRequest)26 Test (org.junit.Test)23 GHResponse (com.graphhopper.GHResponse)22 GHPoint (com.graphhopper.util.shapes.GHPoint)11 PathWrapper (com.graphhopper.PathWrapper)8 GraphHopper (com.graphhopper.GraphHopper)4 GraphHopperAPI (com.graphhopper.GraphHopperAPI)3 Graph (com.graphhopper.storage.Graph)3 CmdArgs (com.graphhopper.util.CmdArgs)3 IOException (java.io.IOException)3 CHGraph (com.graphhopper.storage.CHGraph)2 NodeAccess (com.graphhopper.storage.NodeAccess)2 Downloader (com.graphhopper.util.Downloader)2 File (java.io.File)2 Random (java.util.Random)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 PrepareContractionHierarchies (com.graphhopper.routing.ch.PrepareContractionHierarchies)1 FlagEncoder (com.graphhopper.routing.util.FlagEncoder)1 FastestWeighting (com.graphhopper.routing.weighting.FastestWeighting)1 Weighting (com.graphhopper.routing.weighting.Weighting)1