Package org.jboss.aerogear.controller.mocks

Examples of org.jboss.aerogear.controller.mocks.RouteTester.process()


                        .on(RequestMethod.GET)
                        .produces(JSP, JSON)
                        .to(SampleController.class).find(param("id"));
            }
        }).requestMethod(GET).acceptHeader(ANY);
        routeTester.process("/cars/10");
        verify(routeTester.<SampleController>getController()).find("10");
        verify(routeTester.jspResponder()).respond(anyObject(), any(RouteContext.class));
    }

    @Test
View Full Code Here


                        .on(RequestMethod.GET)
                        .produces(JSP)
                        .to(SampleController.class).find(param("id"));
            }
        }).requestMethod(GET);
        routeTester.process("/cars/10");
        verify(routeTester.<SampleController>getController()).find("10");
        verify(routeTester.jspResponder()).respond(anyObject(), any(RouteContext.class));
    }

    @Test
View Full Code Here

                        .consumes(JSON)
                        .produces(MediaType.JSON)
                        .to(SampleController.class).save(param(Car.class));
            }
        }).requestMethod(POST).acceptHeader(JSON).body("{\"color\":\"red\", \"brand\":\"mini\"}");
        routeTester.process("/cars");
        verify(routeTester.<SampleController>getController()).save(any(Car.class));
    }
   
    @Test
    public void testConsumesWithInvalidContentType() throws Exception {
View Full Code Here

                        .on(GET)
                        .produces(JSP, JSON)
                        .to(SampleController.class).find(param("id"));
            }
        }).requestMethod(GET).acceptHeader("application/json, text/html");
        routeTester.process("/cars/10");
        verify(routeTester.<SampleController>getController()).find("10");
        verify(routeTester.jsonResponder()).respond(anyObject(), any(RouteContext.class));
    }

    @Test(expected = RuntimeException.class)
View Full Code Here

                        .consumes(JSON)
                        .produces(JSON)
                        .to(SampleController.class).save(param(Car.class));
            }
        }).requestMethod(POST).acceptHeader("application/bogus").body("{\"color\":\"red\", \"brand\":\"mini\"}");
        routeTester.process("/cars");
    }

    @Test
    public void testPagedEndpointWithWebLinking() throws Exception {
        final RouteTester routeTester = RouteTester.from(new AbstractRoutingModule() {
View Full Code Here

                        .to(SampleController.class).find(param("id"));
            }
        }).requestMethod(GET).acceptHeader(HTML);
        final Route route = routeTester.routeFor("/car/3");
        doThrow(new ServletException("RouteForbiddenTest")).when(routeTester.getSecurityProvider()).isRouteAllowed(route);
        final InvocationResult processResult = routeTester.process(route);
        assertThat(processResult.getResult()).isInstanceOf(ServletException.class);
    }

    @Test
    public void testMvcRouteWithPathParam() throws Exception {
View Full Code Here

                        .produces(JSP)
                        .to(SampleController.class).save(param("color"), param("brand"));
            }
        }).requestMethod(POST).acceptHeader(HTML).param("color", "red").param("brand", "Ferrari");
        routeTester.spyController(new SampleController());
        final InvocationResult r = routeTester.process("/cars");
        final Car car = (Car) r.getResult();
        assertThat(car.getColor()).isEqualTo("red");
        assertThat(car.getBrand()).isEqualTo("Ferrari");
        verify(routeTester.jspResponder()).respond(any(), any(RouteContext.class));
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.