Search in sources :

Example 1 with Router

use of org.forgerock.http.routing.Router in project OpenAM by OpenRock.

the class HttpRouterProvider method get.

@Override
public Router get() {
    Router router = new Router();
    for (HttpRouteProvider routeProvider : routeProviders) {
        injector.injectMembers(routeProvider);
        Set<HttpRoute> routes = routeProvider.get();
        for (HttpRoute route : routes) {
            router.addRoute(requestUriMatcher(route.getMode(), route.getUriTemplate()), route.getHandler());
        }
    }
    return router;
}
Also used : Router(org.forgerock.http.routing.Router)

Example 2 with Router

use of org.forgerock.http.routing.Router in project OpenAM by OpenRock.

the class HttpRouterProviderTest method shouldAddRoutesToRouter.

@Test(dataProvider = "routeRequestsData")
public void shouldAddRoutesToRouter(String requestUri, Handler exceptedHandler) {
    //Given
    Context context = new RootContext();
    Request request = new Request().setUri(URI.create(requestUri));
    Router router = httpRouterProvider.get();
    //When
    router.handle(context, request);
    //Then
    verify(exceptedHandler).handle(any(Context.class), eq(request));
}
Also used : RootContext(org.forgerock.services.context.RootContext) Context(org.forgerock.services.context.Context) RootContext(org.forgerock.services.context.RootContext) Request(org.forgerock.http.protocol.Request) Router(org.forgerock.http.routing.Router) Test(org.testng.annotations.Test)

Aggregations

Router (org.forgerock.http.routing.Router)2 Request (org.forgerock.http.protocol.Request)1 Context (org.forgerock.services.context.Context)1 RootContext (org.forgerock.services.context.RootContext)1 Test (org.testng.annotations.Test)1