Package com.gargoylesoftware.htmlunit

Examples of com.gargoylesoftware.htmlunit.Page


    }

    protected void verifyParameters() {
        super.verifyParameters();
        nullResponseCheck();
        final Page currentResponse = getContext().getCurrentResponse();

        String contentType = currentResponse.getWebResponse().getContentType();
        if (!MimeMap.EXCEL_MIME_TYPE.equals(contentType)) {
            throw new StepExecutionException("File does not have correct content type (not a '.xls' file?): "
                    + currentResponse.getWebResponse().getContentType(), this);
        }
    }
View Full Code Here


      if (fIgnoreForeignJSErrors && isForeignHost(url))
      {
        LOG.info("Ignore JS errors (if any) for " + url);
        webClient.setThrowExceptionOnScriptError(false);
      }
        final Page response = HtmlUnitBoundary.tryGetPageNoFail(url, webClient);
        webClient.setThrowExceptionOnScriptError(ignoreJSErrorsOriginal);

    fVisitedUrls.add(url);
        if (response == null) {
            fFailedVisits.add(new ZFailedLink(url, referingPage.getWebResponse().getRequestUrl()));
View Full Code Here

        for (final Iterator iter = steps.iterator(); iter.hasNext();) {
            final Step step = (Step) iter.next();
            executeContainedStep(step);
    }
        final WebClientContext.StoredResponses srcResponses = context.getResponses();
        final Page actualPage = context.getCurrentResponse();
        final WebResponse actualResponse = actualPage.getWebResponse();

        LOG.debug("Processig reference file: " + getReferenceFile());
      WebClientContext.StoredResponses referenceResponses = preProcessFiles(getReferenceFile(), context);
      if (isReadFiltered()) {
            LOG.debug("Applying filter on reference file too");
            context.restoreResponses(referenceResponses);
            for (final Iterator iter = steps.iterator(); iter.hasNext();) {
                final Step step = (Step) iter.next();
                step.execute();
        }
            referenceResponses = context.getResponses();
          context.restoreResponses(srcResponses);
      }

        LOG.debug("Source: " + actualResponse.getContentType() + " (" + actualResponse.getRequestUrl() + ")");
        context.restoreResponses(referenceResponses);
        final Page referencePage = context.getCurrentResponse();
        final WebResponse referenceResponse = referencePage.getWebResponse();
        LOG.debug("Reference: " + referenceResponse.getContentType() + " (" + referenceResponse.getRequestUrl() + ")");

        return produceDiffMessage(actualPage, referencePage);
    }
View Full Code Here

        LOG.debug("Selecting WebClient " + getName());

        final WebClientContext wcc = getContext().getCurrentWebClientContext();
        getContext().defineCurrentWebClientContext(getName());

        final Page currentResponse = getContext().getCurrentResponse();
        final String message;
        if (currentResponse == null)
        {
          message = "No current response";
        }
        else
        {
          message = "Current response is now: " + currentResponse.getWebResponse().getRequestUrl();
        }
        LOG.debug(message);

        if (!getSteps().isEmpty())
        {
View Full Code Here

        Repository.INSTANCE.clearCounters();
    }

    @Test
    public void onePathSegment() throws IOException {
        final Page page = new WebClient().getPage(base.toExternalForm() + "api/service/simple?ignored=true");
        assertEquals(HttpURLConnection.HTTP_OK, page.getWebResponse().getStatusCode());
        assertEquals("simple", page.getWebResponse().getContentAsString());

        assertEquals(1, Repository.INSTANCE.counters().size());

        final String name = "GET-/sirona-jaxrs2/api/service/{name}";
        assertEquals(name, Repository.INSTANCE.counters().iterator().next().getKey().getName());
View Full Code Here

        assertEquals(1, hitCounter.getHits());
    }

    @Test
    public void twoPathSegments() throws IOException {
        final Page page = new WebClient().getPage(base.toExternalForm() + "api/service/foo/bar");
        assertEquals(HttpURLConnection.HTTP_OK, page.getWebResponse().getStatusCode());
        assertEquals("foobar", page.getWebResponse().getContentAsString());

        assertEquals(1, Repository.INSTANCE.counters().size());

        final String name = "GET-/sirona-jaxrs2/api/service/{a}/{b}";
        assertEquals(name, Repository.INSTANCE.counters().iterator().next().getKey().getName());
View Full Code Here

        assertEquals(1, hitCounter.getHits());
    }

    @Test
    public void ambiguousPathSegments() throws IOException {
        final Page page = new WebClient().getPage(base.toExternalForm() + "api/service/foo/foo");
        assertEquals(HttpURLConnection.HTTP_OK, page.getWebResponse().getStatusCode());
        assertEquals("foofoo", page.getWebResponse().getContentAsString());

        assertEquals(1, Repository.INSTANCE.counters().size());

        final String name = "GET-/sirona-jaxrs2/api/service/{a}/{b}";
        assertEquals(name, Repository.INSTANCE.counters().iterator().next().getKey().getName());
View Full Code Here

        Repository.INSTANCE.clearCounters();
    }

    @Test
    public void onePathSegment() throws IOException {
        final Page page = new WebClient().getPage(base.toExternalForm() + "api/service/simple?ignored=true");
        assertEquals(HttpURLConnection.HTTP_OK, page.getWebResponse().getStatusCode());
        assertEquals("simple", page.getWebResponse().getContentAsString());

        assertEquals(1, Repository.INSTANCE.counters().size());

        final String name = "GET-/sirona-cxf26/api/service/{name}";
        assertEquals(name, Repository.INSTANCE.counters().iterator().next().getKey().getName());
View Full Code Here

        assertEquals(1, hitCounter.getHits());
    }

    @Test
    public void twoPathSegments() throws IOException {
        final Page page = new WebClient().getPage(base.toExternalForm() + "api/service/foo/bar");
        assertEquals(HttpURLConnection.HTTP_OK, page.getWebResponse().getStatusCode());
        assertEquals("foobar", page.getWebResponse().getContentAsString());

        assertEquals(1, Repository.INSTANCE.counters().size());

        final String name = "GET-/sirona-cxf26/api/service/{a}/{b}";
        assertEquals(name, Repository.INSTANCE.counters().iterator().next().getKey().getName());
View Full Code Here

        assertEquals(1, hitCounter.getHits());
    }

    @Test
    public void ambiguousPathSegments() throws IOException {
        final Page page = new WebClient().getPage(base.toExternalForm() + "api/service/foo/foo");
        assertEquals(HttpURLConnection.HTTP_OK, page.getWebResponse().getStatusCode());
        assertEquals("foofoo", page.getWebResponse().getContentAsString());

        assertEquals(1, Repository.INSTANCE.counters().size());

        final String name = "GET-/sirona-cxf26/api/service/{a}/{b}";
        assertEquals(name, Repository.INSTANCE.counters().iterator().next().getKey().getName());
View Full Code Here

TOP

Related Classes of com.gargoylesoftware.htmlunit.Page

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.