Package com.gargoylesoftware.htmlunit

Examples of com.gargoylesoftware.htmlunit.MockWebConnection


    public static void defineAsCurrentResponse(final Context context, final byte[] responseBytes,
                                               final String contentType, final String urlStr) {
        final WebClient webClient = context.getWebClient();
        final WebConnection originalConnection = webClient.getWebConnection();
        try {
            final MockWebConnection mockConnection = new MockWebConnection();
            webClient.setWebConnection(mockConnection);
            mockConnection.setDefaultResponse(responseBytes, 200, "ok", contentType);
           
            // htmlUnit does't currently follow the "current window"
            // check that our faked content will be loaded in what WebTest considers as the "current window"
            // cf WT-293
            final WebWindow currentTopWindow = context.getCurrentResponse().getEnclosingWindow().getTopWindow();
View Full Code Here


      throws FailingHttpStatusCodeException, MalformedURLException, IOException {
    WebClient webClient = new WebClient();

    // Make a mock web connection that can return the host page and the test
    // script
    MockWebConnection webConnection = new MockWebConnection();
    webConnection.setDefaultResponse(hostPage, "text/html");
    webConnection.setResponse(new URL(
        "http://foo.test/foo/test.Module.nocache.js"), testScript.toString(),
        "application/javascript");
    webClient.setWebConnection(webConnection);

    final List<String> alerts = new ArrayList<String>();
View Full Code Here

    assertThat(html, containsScriptTagWithSource(expected));
  }

  private HtmlPage getPage(String html) throws Exception {
    MockWebConnection webConnection = new MockWebConnection();
    webConnection.setDefaultResponse(html);
    WebClient webClient = new WebClient();
    webClient.setWebConnection(webConnection);
    webClient.getOptions().setThrowExceptionOnScriptError(false);
    webClient.setIncorrectnessListener(new IncorrectnessListener() {
      @Override
View Full Code Here

   */
  protected void setupWebClient() {
    ajaxContext = null;
    // setup webClient for got response content.
    webClient = createWebClient();
    webConnection = new MockWebConnection(webClient) {
      public WebResponse getResponse(WebRequestSettings settings)
      throws IOException {
        String resourceKey = WebXml.getInstance(facesContext).getFacesResourceKey(settings.getURL().getFile().substring(
            request.getContextPath().length()));
        if (resourceKey != null) {
View Full Code Here

   */
  protected void setupWebClient() {
    ajaxContext = null;
    // setup webClient for got response content.
    webClient = createWebClient();
    webConnection = new MockWebConnection(webClient) {
      public WebResponse getResponse(WebRequestSettings settings)
      throws IOException {
        String resourceKey = WebXml.getInstance(facesContext).getFacesResourceKey(settings.getURL().getFile().substring(
            request.getContextPath().length()));
        if (resourceKey != null) {
View Full Code Here

    protected WebClient client;
    protected MockWebConnection connection;

    public HtmlUnitTest() throws Exception {
        client = new WebClient(BrowserVersion.FIREFOX_3);
        connection = new MockWebConnection();
    }
View Full Code Here

TOP

Related Classes of com.gargoylesoftware.htmlunit.MockWebConnection

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.