Package com.gargoylesoftware.htmlunit.xml

Examples of com.gargoylesoftware.htmlunit.xml.XmlPage


        // this fresh WebClient doesn't have a login cookie and represent JNLP launcher
        HudsonTestCase.WebClient jnlpAgent = new WebClient();

        // parse the JNLP page into DOM to list up the jars.
        XmlPage jnlp = (XmlPage) wc.goTo("computer/test/slave-agent.jnlp","application/x-java-jnlp-file");
        URL baseUrl = jnlp.getWebResponse().getUrl();
        Document dom = new DOMReader().read(jnlp.getXmlDocument());
        for( Element jar : (List<Element>)dom.selectNodes("//jar") ) {
            URL url = new URL(baseUrl,jar.attributeValue("href"));
            System.out.println(url);
           
            // now make sure that these URLs are unprotected
View Full Code Here


    public void testApi() throws Exception {
        MatrixProject project = createMatrixProject();
        project.setAxes(new AxisList(
                new Axis("FOO", "abc", "def"),
                new Axis("BAR", "uvw", "xyz")));
        XmlPage xml = new WebClient().goToXml(project.getUrl() + "api/xml");
        assertEquals(4, xml.getByXPath("//matrixProject/activeConfiguration").size());
    }
View Full Code Here

    @Email("http://jenkins.361315.n4.nabble.com/Change-remote-API-visibility-for-CaseResult-getStdout-getStderr-td395102.html")
    public void testRemoteApiDefaultVisibility() throws Exception {
        FreeStyleBuild b = configureTestBuild("test-remoteapi");

        XmlPage page = (XmlPage) new WebClient().goTo("job/test-remoteapi/1/testReport/org.twia.vendor/VendorManagerTest/testCreateAdjustingFirm/api/xml","application/xml");

        int found = 0;

        found = page.getByXPath(composeXPath(MAX_VISIBILITY_FIELDS)).size();
        assertTrue("Should have found an element, but found " + found, found > 0);

        found = page.getByXPath(composeXPath(REDUCED_VISIBILITY_FIELDS)).size();
        assertTrue("Should have found an element, but found " + found, found > 0);

        found = page.getByXPath(composeXPath(OTHER_FIELDS)).size();
        assertTrue("Should have found an element, but found " + found, found > 0);
    }
View Full Code Here

   
    @Email("http://jenkins.361315.n4.nabble.com/Change-remote-API-visibility-for-CaseResult-getStdout-getStderr-td395102.html")
    public void testRemoteApiNoDetails() throws Exception {
        FreeStyleBuild b = configureTestBuild("test-remoteapi");

        XmlPage page = (XmlPage) new WebClient().goTo("job/test-remoteapi/1/testReport/org.twia.vendor/VendorManagerTest/testCreateAdjustingFirm/api/xml?depth=-1","application/xml");

        int found = 0;

        found = page.getByXPath(composeXPath(MAX_VISIBILITY_FIELDS)).size();
        assertTrue("Should have found an element, but found " + found, found > 0);

        found = page.getByXPath(composeXPath(REDUCED_VISIBILITY_FIELDS)).size();
        assertTrue("Should have found 0 elements, but found " + found, found == 0);

        found = page.getByXPath(composeXPath(OTHER_FIELDS)).size();
        assertTrue("Should have found an element, but found " + found, found > 0);
   }
View Full Code Here

   
    @Email("http://jenkins.361315.n4.nabble.com/Change-remote-API-visibility-for-CaseResult-getStdout-getStderr-td395102.html")
    public void testRemoteApiNameOnly() throws Exception {
        FreeStyleBuild b = configureTestBuild("test-remoteapi");

        XmlPage page = (XmlPage) new WebClient().goTo("job/test-remoteapi/1/testReport/org.twia.vendor/VendorManagerTest/testCreateAdjustingFirm/api/xml?depth=-10","application/xml");

        int found = 0;

        found = page.getByXPath(composeXPath(MAX_VISIBILITY_FIELDS)).size();
        assertTrue("Should have found an element, but found " + found, found > 0);

        found = page.getByXPath(composeXPath(REDUCED_VISIBILITY_FIELDS)).size();
        assertTrue("Should have found 0 elements, but found " + found, found == 0);

        found = page.getByXPath(composeXPath(OTHER_FIELDS)).size();
        assertTrue("Should have found 0 elements, but found " + found, found == 0);
    }
View Full Code Here

        Object imageNode = projectPage.getFirstByXPath("//img[@src='test/trend']");
        assertNotNull("couldn't find any matching nodes", imageNode);
        assertTrue("image node should be an HtmlImage object", imageNode instanceof HtmlImage);
        // TODO: Check that we can click on the graph and get to a particular run. How do I do this with HtmlUnit?

        XmlPage xmlProjectPage = wc.goToXml(proj.getUrl() + "/lastBuild/testReport/api/xml");
        assertXPath(xmlProjectPage, "/testResult");
        assertXPath(xmlProjectPage, "/testResult/suite");
        assertXPath(xmlProjectPage, "/testResult/failCount");
        assertXPathValue(xmlProjectPage, "/testResult/failCount", "0");
        assertXPathValue(xmlProjectPage, "/testResult/passCount", "4");
        assertXPathValue(xmlProjectPage, "/testResult/skipCount", "0");
        String[] packages = {"org.jvnet.hudson.examples.small.AppTest", "org.jvnet.hudson.examples.small.MiscTest", "org.jvnet.hudson.examples.small.deep.DeepTest"};
        for (String packageName : packages) {
            assertXPath(xmlProjectPage, "/testResult/suite/case/className[text()='" + packageName + "']");
        }

        // Go to a page that we know has a failure
        HtmlPage buildPage = wc.getPage(proj.getBuildByNumber(3));
        assertGoodStatus(buildPage);
        // We expect to see one failure, for com.yahoo.breakable.misc.UglyTest.becomeUglier
        // which should link to http://localhost:8080/job/wonky/3/testReport/org.jvnet.hudson.examples.small/MiscTest/testEleanor/
        assertXPathResultsContainText(buildPage, "//a", "org.jvnet.hudson.examples.small.MiscTest.testEleanor");
        HtmlAnchor failingTestLink = buildPage.getFirstAnchorByText("org.jvnet.hudson.examples.small.MiscTest.testEleanor");
        assertNotNull(failingTestLink);
        Page failingTestPage = failingTestLink.click();
        assertGoodStatus(failingTestPage);

        // Go to the xml page for a build we know has failures
        XmlPage xmlBuildPage = wc.goToXml(proj.getBuildByNumber(3).getUrl() + "/api/xml");
        assertXPathValue(xmlBuildPage, "//failCount", "2");
        assertXPathValue(xmlBuildPage, "//skipCount", "0");
        assertXPathValue(xmlBuildPage, "//totalCount", "4");
        assertXPathValue(xmlBuildPage, "//result", "FAILURE");

        // Check overall test result counts
        XmlPage xmlTestReportPage = wc.goToXml(proj.getBuildByNumber(3).getUrl() + "/testReport/api/xml");
        assertXPathValue(xmlTestReportPage, "/testResult/failCount", "2");
        assertXPathValue(xmlTestReportPage, "/testResult/passCount", "2");
        assertXPathValue(xmlTestReportPage, "/testResult/skipCount", "0");

        // Make sure the right tests passed and failed
View Full Code Here

                                     int expectedSkipCount, int expectedSkipDiff) throws IOException, SAXException {

        // TODO: verify expectedResult
        // TODO: verify expectedDuration

        XmlPage xmlPage = wc.goToXml(run.getUrl() + restOfUrl + "/" + packageName + "/api/xml");
        int expectedPassCount = expectedTotalTests - expectedFailCount - expectedSkipCount;
        // Verify xml results
        assertXPathValue(xmlPage, "/packageResult/failCount", Integer.toString(expectedFailCount));
        assertXPathValue(xmlPage, "/packageResult/skipCount", Integer.toString(expectedSkipCount));
        assertXPathValue(xmlPage, "/packageResult/passCount", Integer.toString(expectedPassCount));
View Full Code Here

        final Page currentResponse = getContext().getCurrentResponse();
        if (currentResponse instanceof HtmlPage) {
            final HtmlPage page = (HtmlPage) currentResponse;
            processHtml(page.getDocumentElement().getChildren(), buf);
        } else if (currentResponse instanceof XmlPage) {
            final XmlPage page = (XmlPage) currentResponse;
            processXml(page.getXmlDocument().getChildNodes(), buf);
        }
        defineAsCurrentResponse(buf.toString(), "text/plain");
    }
View Full Code Here

              // tree should work
    else if (page instanceof HtmlPage)
      return page;
    else if (page instanceof XmlPage)
    {
      final XmlPage xmlPage = (XmlPage) page;
      if (xmlPage.getXmlDocument() == null) // when content type was xml
                          // but document couldn't be
                          // parsed
        throw new StepFailedException(
            "The xml document couldn't be parsed as it is not well formed");
      return xmlPage.getXmlDocument();
    }
    else
    {
      throw buildInvalidDocumentException(page);
    }
View Full Code Here

            processHtml(page.getDocumentElement().getChildren(), buf);
            buf.append("</html>");
        }
        else if (currentResponse instanceof XmlPage)
        {
            final XmlPage page = (XmlPage) currentResponse;
            final Document xmlDocument = page.getXmlDocument();
            if (xmlDocument != null) {
                processXml(xmlDocument.getChildNodes().item(0), buf);
            }
        }
        else
View Full Code Here

TOP

Related Classes of com.gargoylesoftware.htmlunit.xml.XmlPage

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.