Package com.github.restdriver.clientdriver

Examples of com.github.restdriver.clientdriver.HttpRealRequest


        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


    }
   
    private synchronized ClientDriverRequestResponsePair getMatchingRequestPair(HttpServletRequest request) {
       
        ClientDriverExpectation matchedExpectation = null;
        HttpRealRequest realRequest = new HttpRealRequest(request);
       
        int index;
        for (index = 0; index < expectations.size(); index++) {
            ClientDriverExpectation thisExpectation = expectations.get(index);
            ClientDriverRequestResponsePair thisPair = thisExpectation.getPair();
           
            if (matcher.isMatch(realRequest, thisPair.getRequest())) {
                thisExpectation.match(realRequest);
                matchedExpectation = thisExpectation;
                break;
            }
        }
       
        if (matchedExpectation == null) {
            this.unexpectedRequests.add(new HttpRealRequest(request));
           
            if (failFastOnUnexpectedRequest) {
                throw new ClientDriverFailedExpectationException(unexpectedRequests, expectations);
            } else {
                return null;
View Full Code Here

        ClientDriverExpectation expectation = new ClientDriverExpectation(PAIR);
        expectation.times(3);
       
        assertThat(expectation.isSatisfied(), is(false));
       
        HttpRealRequest realRequest = mock(HttpRealRequest.class);
       
        expectation.match(realRequest);
        assertThat(expectation.isSatisfied(), is(false));
        expectation.match(realRequest);
        assertThat(expectation.isSatisfied(), is(false));
View Full Code Here

    public void matchingExpectationCallsMatcher() {
        MatchedRequestHandler matchHandlerMock = mock(MatchedRequestHandler.class);
        ClientDriverExpectation expectation = new ClientDriverExpectation(PAIR);
        expectation.whenMatched(matchHandlerMock);
       
        HttpRealRequest realRequest = mock(HttpRealRequest.class);
       
        expectation.match(realRequest);
        verify(matchHandlerMock).onMatch(realRequest);
    }
View Full Code Here

            when(mock.getInputStream()).thenReturn(createInputStream());
        } catch (IOException e) {
            // Should never happen
        }
       
        return new HttpRealRequest(mock);
    }
View Full Code Here

TOP

Related Classes of com.github.restdriver.clientdriver.HttpRealRequest

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.