Package net.sf.sahi.response

Examples of net.sf.sahi.response.HttpResponse.data()


public class Substituter {

    public HttpResponse replaceHttps(final HttpRequest request) {
        HttpResponse response = new RemoteRequestProcessor().processHttp(request);
        byte[] bytes = response.data();
        String data = new String(bytes);
        data = data.replaceAll("https", "http");
        response.setData(data.getBytes());
        return response;
    }
View Full Code Here


          }
          response = process401(connection, inputStreamFromHost);
        }else {
          response = getResponse(inputStreamFromHost, connection);
          TrafficLogger.storeResponseHeader(response.headers().toString().getBytes(), "unmodified");
          TrafficLogger.storeResponseBody(response.data(), "unmodified");
        }
       
        if (requestFromBrowser.isAjax() && responseCode > 300 && responseCode < 308){
          String redirectedTo = response.getLastSetValueOfHeader("Location");
          if (redirectedTo != null) session.addAjaxRedirect(redirectedTo);
View Full Code Here

    }

    public void xtestExecuteRunsACommand() throws InterruptedException {
        assertTrue(HELPFILE.exists());
        HttpResponse response = commandInvoker.execute(prepareMockHttpRequest(getCommandPath("test.cmd"), true));
        String actualResponse = new String(response.data());
        assertEquals(CommandInvoker.SUCCESS, actualResponse);
        assertFalse(HELPFILE.exists());
    }

    public void xtestExecuteReturnsFailureForInvalidCommand() throws InterruptedException {
View Full Code Here

        assertFalse(HELPFILE.exists());
    }

    public void xtestExecuteReturnsFailureForInvalidCommand() throws InterruptedException {
        HttpResponse response = commandInvoker.execute(prepareMockHttpRequest("invalid", true));
        String actualResponse = new String(response.data());
        assertEquals(CommandInvoker.FAILURE, actualResponse);
    }

    public void xtestExecuteRunsACommandInAsyncMode() throws InterruptedException {
        HttpResponse response = commandInvoker.execute(prepareMockHttpRequest(getCommandPath("test.cmd"), false));
View Full Code Here

        assertEquals(CommandInvoker.FAILURE, actualResponse);
    }

    public void xtestExecuteRunsACommandInAsyncMode() throws InterruptedException {
        HttpResponse response = commandInvoker.execute(prepareMockHttpRequest(getCommandPath("test.cmd"), false));
        String actualResponse = new String(response.data());
        assertEquals(CommandInvoker.SUCCESS, actualResponse);
    }

    private HttpRequest prepareMockHttpRequest(String commandToExecute, boolean sync) {
        Mock mock = mock(HttpRequest.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.