Examples of RealRequest


Examples of com.github.restdriver.clientdriver.RealRequest

        when(mockRequest.getHeaderNames()).thenReturn(expectedHeaderNames);
        when(mockRequest.getHeader("header1")).thenReturn("thisIsHeader1");
        when(mockRequest.getInputStream()).thenReturn(new DummyServletInputStream(IOUtils.toInputStream(bodyContent)));
        when(mockRequest.getContentType()).thenReturn(expectedContentType);
       
        RealRequest realRequest = new HttpRealRequest(mockRequest);
       
        assertThat((String) realRequest.getPath(), is(expectedPathInfo));
        assertThat(realRequest.getMethod(), is(Method.GET));
        assertThat(realRequest.getParams().size(), is(1));
        assertThat((String) realRequest.getParams().get("hello").iterator().next(), is("world"));
        assertThat((String) realRequest.getHeaders().get("header1"), is("thisIsHeader1"));
        assertThat((String) realRequest.getBodyContentType(), is(expectedContentType));
       
    }
View Full Code Here

Examples of com.github.restdriver.clientdriver.RealRequest

        sut = new DefaultRequestMatcher();
    }
   
    private RealRequest mockRealRequest(String path, Method method, Map<String, Object> headers,
            Map<String, Collection<String>> params, byte[] content, String contentType) {
        RealRequest real = mock(RealRequest.class);
        when(real.getPath()).thenReturn(path);
        when(real.getMethod()).thenReturn(method);
        when(real.getHeaders()).thenReturn(headers);
        when(real.getParams()).thenReturn(params);
        when(real.getBodyContent()).thenReturn(content);
        when(real.getBodyContentType()).thenReturn(contentType);
        return real;
    }
View Full Code Here

Examples of com.github.restdriver.clientdriver.RealRequest

    }
   
    @Test
    public void testMatchNoParams() {
       
        RealRequest real = mockRealRequest("aaaaa", Method.GET, headers, params, content, contentType);
        ClientDriverRequest expected = new ClientDriverRequest("aaaaa").withMethod(Method.GET);
       
        assertThat(sut.isMatch(real, expected), is(true));
    }
View Full Code Here

Examples of com.github.restdriver.clientdriver.RealRequest

    }
   
    @Test
    public void testMatchNoParamsPattern() {
       
        RealRequest real = mockRealRequest("aaaaa", Method.GET, headers, params, content, contentType);
        ClientDriverRequest expected = new ClientDriverRequest(Pattern.compile("[a]{5}")).withMethod(Method.GET);
       
        assertThat(sut.isMatch(real, expected), is(true));
    }
View Full Code Here

Examples of com.github.restdriver.clientdriver.RealRequest

    @Test
    public void testMatchWithParams() {
       
        params = asMap("kk", "vv", "k2", "v2");
       
        RealRequest real = mockRealRequest("aaaaa", Method.GET, headers, params, content, contentType);
        ClientDriverRequest expected = new ClientDriverRequest("aaaaa")
                .withMethod(Method.GET)
                .withParam("kk", "vv")
                .withParam("k2", "v2");
       
View Full Code Here

Examples of com.github.restdriver.clientdriver.RealRequest

    @Test
    public void testMatchWithParamsPattern() throws IOException {
       
        params = asMap("kk", "vv", "k2", "v2");
       
        RealRequest real = mockRealRequest("aaaaa", Method.GET, headers, params, content, contentType);
        ClientDriverRequest expected = new ClientDriverRequest("aaaaa")
                .withMethod(Method.GET)
                .withParam("kk", Pattern.compile("[v]{2}")).withParam("k2", Pattern.compile("v[0-9]"));
       
        assertThat(sut.isMatch(real, expected), is(true));
View Full Code Here

Examples of com.github.restdriver.clientdriver.RealRequest

    @Test
    public void testMatchWithIntegerParam() throws IOException {
       
        params = asMap("number", "10");
       
        RealRequest real = mockRealRequest("aaaaa", Method.GET, headers, params, content, contentType);
        ClientDriverRequest expected = new ClientDriverRequest("aaaaa")
                .withMethod(Method.GET)
                .withParam("number", 10);
       
        assertThat(sut.isMatch(real, expected), is(true));
View Full Code Here

Examples of com.github.restdriver.clientdriver.RealRequest

    @Test
    public void testMatchWithLongParam() throws IOException {
       
        params = asMap("number", "10");
       
        RealRequest real = mockRealRequest("aaaaa", Method.GET, headers, params, content, contentType);
        ClientDriverRequest expected = new ClientDriverRequest("aaaaa")
                .withMethod(Method.GET)
                .withParam("number", 10L);
       
        assertThat(sut.isMatch(real, expected), is(true));
View Full Code Here

Examples of com.github.restdriver.clientdriver.RealRequest

    @Test
    public void testMatchWithBooleanParam() throws IOException {
       
        params = asMap("number", "true");
       
        RealRequest real = mockRealRequest("aaaaa", Method.GET, headers, params, content, contentType);
        ClientDriverRequest expected = new ClientDriverRequest("aaaaa")
                .withMethod(Method.GET)
                .withParam("number", true);
       
        assertThat(sut.isMatch(real, expected), is(true));
View Full Code Here

Examples of com.github.restdriver.clientdriver.RealRequest

       
        Object param = Method.POST;
       
        params = asMap("number", "POST");
       
        RealRequest real = mockRealRequest("aaaaa", Method.GET, headers, params, content, contentType);
        ClientDriverRequest expected = new ClientDriverRequest("aaaaa")
                .withMethod(Method.GET)
                .withParam("number", param);
       
        assertThat(sut.isMatch(real, expected), is(true));
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.