Package org.jboss.aerogear.controller.mocks

Examples of org.jboss.aerogear.controller.mocks.RouteTester


        assertThat(routeTester.getStringWriter().toString()).isEqualTo("[5,6,7,8,9]");
    }

    @Test
    public void testPagedEndpointBeyondLastPage() throws Exception {
        final RouteTester routeTester = RouteTester.from(new AbstractRoutingModule() {
            @Override
            public void configuration() {
                route()
                        .from("/ints")
                        .on(RequestMethod.GET)
                        .produces(JSON)
                        .to(SampleController.class).findByWithCustomParamNames(param(PaginationInfo.class), param("brand"));
            }
        }).acceptHeader(JSON).addResponder(new JsonResponder()).spyController(new SampleController());
        final InvocationResult result = routeTester.processGetRequest("/ints?brand=BMW&myoffset=50&mylimit=5");
        final HttpServletResponse response = result.getRouteContext().getResponse();
        verify(routeTester.<SampleController>getController()).findByWithCustomParamNames(any(PaginationInfo.class), eq("BMW"));
        verify(response).setHeader("TS-Links-Previous", "http://localhost:8080/test/ints?brand=BMW&myoffset=45&mylimit=5");
        verify(response, never()).setHeader(eq("TS-Links-Next"), anyString());
        assertThat(routeTester.getStringWriter().toString()).isEqualTo("[]");
    }
View Full Code Here


        assertThat(routeTester.getStringWriter().toString()).isEqualTo("[]");
    }
   
    @Test
    public void testMissingQueryParameter() throws Exception {
        final RouteTester routeTester = RouteTester.from(new AbstractRoutingModule() {
            @Override
            public void configuration() {
                route()
                        .from("/cars")
                        .on(RequestMethod.GET)
                        .produces(JSP)
                        .to(SampleController.class).find(param("color"), param("brand", "Ferrari"));
            }
        }).spyController(new SampleController());
        final InvocationResult result = routeTester.acceptHeader(JSP).processGetRequest("/cars");
        assertThat(result.getResult()).isInstanceOf(MissingRequestParameterException.class);
    }   
View Full Code Here

        assertThat(result.getResult()).isInstanceOf(MissingRequestParameterException.class);
    }   
   
    @Test
    public void testMvcRouteWithConstantAndPathParam() throws Exception {
        final RouteTester routeTester = RouteTester.from(new AbstractRoutingModule() {
            @Override
            public void configuration() {
                route()
                        .from("/car/{id}").roles("admin")
                        .on(GET)
                        .produces(JSP)
                        .to(SampleController.class).findWithConstant("constant", param("id"));
            }
        });
        routeTester.acceptHeader(HTML).processGetRequest("/car/3");
        verify(routeTester.<SampleController>getController()).findWithConstant("constant", "3");
        verify(routeTester.jspResponder()).respond(any(), any(RouteContext.class));
    }
View Full Code Here

        verify(routeTester.jspResponder()).respond(any(), any(RouteContext.class));
    }
   
    @Test
    public void testMvcRouteWithPathParamAndConstant() throws Exception {
        final RouteTester routeTester = RouteTester.from(new AbstractRoutingModule() {
            @Override
            public void configuration() {
                route()
                        .from("/car/{id}").roles("admin")
                        .on(GET)
                        .produces(JSP)
                        .to(SampleController.class).findWithConstantReversed(param("id"), "constant");
            }
        });
        routeTester.acceptHeader(HTML).processGetRequest("/car/3");
        verify(routeTester.<SampleController>getController()).findWithConstantReversed("3", "constant");
        verify(routeTester.jspResponder()).respond(any(), any(RouteContext.class));
    }
View Full Code Here

        verify(routeTester.jspResponder()).respond(any(), any(RouteContext.class));
    }
   
    @Test
    public void testMvcRouteWithMultipleConstants() throws Exception {
        final RouteTester routeTester = RouteTester.from(new AbstractRoutingModule() {
            @Override
            public void configuration() {
                route()
                        .from("/car")
                        .on(GET)
                        .produces(JSP)
                        .to(SampleController.class).findWithConstantReversed("constant1", "constant2");
            }
        });
        routeTester.acceptHeader(HTML).processGetRequest("/car");
        verify(routeTester.<SampleController>getController()).findWithConstantReversed("constant1", "constant2");
        verify(routeTester.jspResponder()).respond(any(), any(RouteContext.class));
    }
View Full Code Here

        verify(routeTester.jspResponder()).respond(any(), any(RouteContext.class));
    }
   
    @Test
    public void testMvcRouteWithParamsInConstantString() throws Exception {
        final RouteTester routeTester = RouteTester.from(new AbstractRoutingModule() {
            @Override
            public void configuration() {
                route()
                        .from("/car/{id}")
                        .on(GET)
                        .produces(JSP)
                        .to(SampleController.class).processPath("{id}?title={title}&lastname={lastname}?propertyName=value");
            }
        });
        routeTester.acceptHeader(HTML).processGetRequest("/car/10?title=Mr&lastname=Babar");
        verify(routeTester.<SampleController>getController()).processPath("10?title=Mr&lastname=Babar?propertyName=value");
        verify(routeTester.jspResponder()).respond(any(), any(RouteContext.class));
    }
View Full Code Here

        verify(routeTester.jspResponder()).respond(any(), any(RouteContext.class));
    }
   
    @Test
    public void testMvcRouteWithConstantWithParam() throws Exception {
        final RouteTester routeTester = RouteTester.from(new AbstractRoutingModule() {
            @Override
            public void configuration() {
                route()
                        .from("/car/{id}")
                        .on(GET)
                        .produces(JSP)
                        .to(SampleController.class).processPathWithType("/remoteserver/{id}?title={title}&lastname={lastname}?propertyName=value", String.class);
            }
        });
        routeTester.acceptHeader(HTML).processGetRequest("/car/10?title=Mr&lastname=Babar");
        verify(routeTester.<SampleController>getController()).processPathWithType("/remoteserver/10?title=Mr&lastname=Babar?propertyName=value", String.class);
        verify(routeTester.jspResponder()).respond(any(), any(RouteContext.class));
    }
View Full Code Here

        verify(routeTester.jspResponder()).respond(any(), any(RouteContext.class));
    }
   
    @Test
    public void testRouteWithMultiplePathParams() throws Exception {
        final RouteTester routeTester = RouteTester.from(new AbstractRoutingModule() {
            @Override
            public void configuration() {
                route()
                        .from("/car/{color}/{brand}")
                        .on(GET)
                        .to(SampleController.class).save(param("color"), param("brand"));
            }
        });
        routeTester.acceptHeader(HTML).processGetRequest("/car/red/ferrari");
        verify(routeTester.<SampleController>getController()).save("red", "ferrari");
        verify(routeTester.jspResponder()).respond(any(), any(RouteContext.class));
    }
View Full Code Here

        verify(routeTester.jspResponder()).respond(any(), any(RouteContext.class));
    }
   
    @Test
    public void testRestRouteWithAcceptMediaRange() throws Exception {
        final RouteTester routeTester = RouteTester.from(new AbstractRoutingModule() {
            @Override
            public void configuration() {
                route()
                        .from("/car/{id}").roles("admin")
                        .on(GET)
                        .produces(JSP, JSON)
                        .to(SampleController.class).find(param("id",Long.class));
            }
        });
        routeTester.acceptHeader("application/*;limit=500, text/*").processGetRequest("/car/3");
        verify(routeTester.<SampleController>getController()).find(new Long(3));
        verify(routeTester.jsonResponder()).respond(any(), any(RouteContext.class));
    }
View Full Code Here

        verify(routeTester.jsonResponder()).respond(any(), any(RouteContext.class));
    }
   
    @Test
    public void testRouteWithMultiplePathParamsAndSubpath() throws Exception {
        final RouteTester routeTester = RouteTester.from(new AbstractRoutingModule() {
            @Override
            public void configuration() {
                route()
                        .from("/car/{color}/somepath/{brand}")
                        .on(GET)
                        .to(SampleController.class).save(param("color"), param("brand"));
            }
        });
        routeTester.acceptHeader(HTML).processGetRequest("/car/red/somepath/ferrari");
        verify(routeTester.<SampleController>getController()).save("red", "ferrari");
        verify(routeTester.jspResponder()).respond(any(), any(RouteContext.class));
    }
View Full Code Here

TOP

Related Classes of org.jboss.aerogear.controller.mocks.RouteTester

Copyright © 2018 www.massapicom. 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.