Package com.github.restdriver.clientdriver

Examples of com.github.restdriver.clientdriver.ClientDriverRequestResponsePair


    @Override
    public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
       
        LOGGER.info("Handling: {} {}", request.getMethod(), request.getPathInfo());
       
        ClientDriverRequestResponsePair matchingPair = getMatchingRequestPair(request);
       
        if (matchingPair != null) {
            matchedResponses.add(matchingPair);
           
            ClientDriverResponse matchedResponse = matchingPair.getResponse();
           
            response.setContentType(matchedResponse.getContentType());
            response.setStatus(matchedResponse.getStatus());
            response.setHeader("Server", "rest-client-driver(" + RestDriverProperties.getVersion() + ")");
           
            for (Entry<String, String> thisHeader : matchedResponse.getHeaders().entrySet()) {
                response.setHeader(thisHeader.getKey(), thisHeader.getValue());
            }
           
            if (matchedResponse.hasBody()) {
                OutputStream output = response.getOutputStream();
                output.write(matchedResponse.getContentAsBytes());
            }
           
            delayIfNecessary(matchingPair.getResponse());
        } else {
            response.setStatus(404);
        }
       
        baseRequest.setHandled(true);
View Full Code Here


        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;
            }
        }
View Full Code Here

     *            The response to serve to that request
     * @return The added expectation
     */
    @Override
    public ClientDriverExpectation addExpectation(ClientDriverRequest request, ClientDriverResponse response) {
        ClientDriverRequestResponsePair pair = new ClientDriverRequestResponsePair(request, response);
        ClientDriverExpectation expectation = new ClientDriverExpectation(pair);
        expectations.add(expectation);
        return expectation;
    }
View Full Code Here

    private ClientDriverExpectation createExpectation(String path) {
        return new ClientDriverExpectation(createPair(path));
    }
   
    private ClientDriverRequestResponsePair createPair(String path) {
        return new ClientDriverRequestResponsePair(createRequest(path), null);
    }
View Full Code Here

TOP

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

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.