예제 #1
0
 @SuppressWarnings("unchecked")
 public static Result route(Application app, RequestBuilder requestBuilder, long timeout) {
   final scala.Option<scala.concurrent.Future<play.api.mvc.Result>> opt =
       play.api.test.Helpers.jRoute(
           app.getWrappedApplication(),
           requestBuilder.build()._underlyingRequest(),
           requestBuilder.body());
   return wrapScalaResult(Scala.orNull(opt), timeout);
 }
예제 #2
0
 public static Result routeAndCall(Router router, RequestBuilder requestBuilder, long timeout) {
   try {
     Request request = requestBuilder.build();
     if (router.routes().isDefinedAt(request._underlyingRequest())) {
       return invokeHandler(router.routes().apply(request._underlyingRequest()), request, timeout);
     } else {
       return null;
     }
   } catch (RuntimeException e) {
     throw e;
   } catch (Throwable t) {
     throw new RuntimeException(t);
   }
 }
예제 #3
0
 public static Result routeAndCall(
     Class<? extends Router> router, RequestBuilder requestBuilder, long timeout) {
   try {
     Request request = requestBuilder.build();
     Router routes =
         (Router)
             router
                 .getClassLoader()
                 .loadClass(router.getName() + "$")
                 .getDeclaredField("MODULE$")
                 .get(null);
     if (routes.routes().isDefinedAt(request._underlyingRequest())) {
       return invokeHandler(routes.routes().apply(request._underlyingRequest()), request, timeout);
     } else {
       return null;
     }
   } catch (RuntimeException e) {
     throw e;
   } catch (Throwable t) {
     throw new RuntimeException(t);
   }
 }