Search in sources :

Example 11 with TextBlock

use of com.meterware.httpunit.TextBlock in project maven-plugins by apache.

the class IndexReportTest method testReport.

/**
     * Test report
     *
     * @throws Exception if any
     */
public void testReport() throws Exception {
    generateReport("index", "index-plugin-config.xml");
    assertTrue("Test html generated", getGeneratedReport("index.html").exists());
    URL reportURL = getGeneratedReport("index.html").toURI().toURL();
    assertNotNull(reportURL);
    // HTTPUnit
    WebRequest request = new GetMethodWebRequest(reportURL.toString());
    WebResponse response = WEB_CONVERSATION.getResponse(request);
    // Basic HTML tests
    assertTrue(response.isHTML());
    assertTrue(response.getContentLength() > 0);
    // Test the Page title
    // Index does not have a 'name' but 'title' only
    String expectedTitle = prepareTitle(getString("report.index.title"), getString("report.index.title"));
    assertEquals(expectedTitle, response.getTitle());
    // Test the texts
    TextBlock[] textBlocks = response.getTextBlocks();
    assertEquals(getString("report.index.title") + " " + getTestMavenProject().getName(), textBlocks[0].getText());
    assertEquals(getString("report.index.nodescription"), textBlocks[1].getText());
}
Also used : WebResponse(com.meterware.httpunit.WebResponse) WebRequest(com.meterware.httpunit.WebRequest) GetMethodWebRequest(com.meterware.httpunit.GetMethodWebRequest) GetMethodWebRequest(com.meterware.httpunit.GetMethodWebRequest) TextBlock(com.meterware.httpunit.TextBlock) URL(java.net.URL)

Example 12 with TextBlock

use of com.meterware.httpunit.TextBlock in project maven-plugins by apache.

the class IssueManagementReportTest method testReport.

/**
     * Test report
     *
     * @throws Exception if any
     */
public void testReport() throws Exception {
    generateReport("issue-tracking", "issue-management-plugin-config.xml");
    assertTrue("Test html generated", getGeneratedReport("issue-tracking.html").exists());
    URL reportURL = getGeneratedReport("issue-tracking.html").toURI().toURL();
    assertNotNull(reportURL);
    // HTTPUnit
    WebRequest request = new GetMethodWebRequest(reportURL.toString());
    WebResponse response = WEB_CONVERSATION.getResponse(request);
    // Basic HTML tests
    assertTrue(response.isHTML());
    assertTrue(response.getContentLength() > 0);
    // Test the Page title
    String expectedTitle = prepareTitle(getString("report.issue-management.name"), getString("report.issue-management.title"));
    assertEquals(expectedTitle, response.getTitle());
    // Test the links
    WebLink[] weblinks = response.getLinks();
    assertEquals(3, weblinks.length);
    assertEquals("JIRA", weblinks[1].getText());
    assertEquals("http://localhost/jira", weblinks[2].getText());
    // Test the texts
    TextBlock[] textBlocks = response.getTextBlocks();
    assertEquals(getString("report.issue-management.overview.title"), textBlocks[0].getText());
    // due to link pattern
    assertEquals("This project uses JIRA.", textBlocks[1].getText());
    assertEquals(getString("report.issue-management.name"), textBlocks[2].getText());
}
Also used : WebResponse(com.meterware.httpunit.WebResponse) WebRequest(com.meterware.httpunit.WebRequest) GetMethodWebRequest(com.meterware.httpunit.GetMethodWebRequest) GetMethodWebRequest(com.meterware.httpunit.GetMethodWebRequest) TextBlock(com.meterware.httpunit.TextBlock) URL(java.net.URL) WebLink(com.meterware.httpunit.WebLink)

Example 13 with TextBlock

use of com.meterware.httpunit.TextBlock in project maven-plugins by apache.

the class LicensesReportTest method testReportLinksOnly.

public void testReportLinksOnly() throws Exception {
    generateReport("license", "licenses-plugin-config-linkonly.xml");
    assertTrue("Test html generated", getGeneratedReport("license.html").exists());
    URL reportURL = getGeneratedReport("license.html").toURI().toURL();
    assertNotNull(reportURL);
    // HTTPUnit
    WebRequest request = new GetMethodWebRequest(reportURL.toString());
    WebResponse response = WEB_CONVERSATION.getResponse(request);
    // Basic HTML tests
    assertTrue(response.isHTML());
    assertTrue(response.getContentLength() > 0);
    // Test the Page title
    String expectedTitle = prepareTitle(getString("report.licenses.name"), getString("report.licenses.title"));
    assertEquals(expectedTitle, response.getTitle());
    // Test the texts
    TextBlock[] textBlocks = response.getTextBlocks();
    assertEquals(getString("report.licenses.overview.title"), textBlocks[0].getText());
    assertEquals(getString("report.licenses.overview.intro"), textBlocks[1].getText());
    assertEquals(getString("report.licenses.title"), textBlocks[2].getText());
    assertEquals("The Apache Software License, Version 2.0", textBlocks[3].getText());
    // here's our specific test
    final WebLink[] links = response.getLinks();
    assertEquals(2, links.length);
    assertEquals("http://maven.apache.org/", links[0].getURLString());
    assertEquals("http://www.apache.org/licenses/LICENSE-2.0.txt", links[1].getURLString());
    assertEquals("http://www.apache.org/licenses/LICENSE-2.0.txt", links[1].getText());
}
Also used : WebResponse(com.meterware.httpunit.WebResponse) WebRequest(com.meterware.httpunit.WebRequest) GetMethodWebRequest(com.meterware.httpunit.GetMethodWebRequest) GetMethodWebRequest(com.meterware.httpunit.GetMethodWebRequest) TextBlock(com.meterware.httpunit.TextBlock) URL(java.net.URL) WebLink(com.meterware.httpunit.WebLink)

Example 14 with TextBlock

use of com.meterware.httpunit.TextBlock in project maven-plugins by apache.

the class ModulesReportTest method testReport.

/**
     * Test report
     *
     * @throws Exception if any
     */
public void testReport() throws Exception {
    generateReport("modules", "modules-plugin-config.xml");
    assertTrue("Test html generated", getGeneratedReport("modules.html").exists());
    URL reportURL = getGeneratedReport("modules.html").toURI().toURL();
    assertNotNull(reportURL);
    // HTTPUnit
    WebRequest request = new GetMethodWebRequest(reportURL.toString());
    WebResponse response = WEB_CONVERSATION.getResponse(request);
    // Basic HTML tests
    assertTrue(response.isHTML());
    assertTrue(response.getContentLength() > 0);
    // Test the Page title
    String expectedTitle = prepareTitle(getString("report.modules.name"), getString("report.modules.title"));
    assertEquals(expectedTitle, response.getTitle());
    // Test the texts
    TextBlock[] textBlocks = response.getTextBlocks();
    assertEquals(2, textBlocks.length);
    assertEquals(getString("report.modules.title"), textBlocks[0].getText());
    assertEquals(getString("report.modules.intro"), textBlocks[1].getText());
    String[][] cellTexts = response.getTables()[0].asText();
    assertEquals(3, cellTexts.length);
    assertEquals(2, cellTexts[0].length);
    assertEquals(getString("report.modules.header.name"), cellTexts[0][0]);
    assertEquals(getString("report.modules.header.description"), cellTexts[0][1]);
    assertEquals("project1", cellTexts[1][0]);
    assertEquals("-", cellTexts[1][1]);
    assertEquals("project2", cellTexts[2][0]);
    assertEquals("project2 description", cellTexts[2][1]);
}
Also used : WebResponse(com.meterware.httpunit.WebResponse) WebRequest(com.meterware.httpunit.WebRequest) GetMethodWebRequest(com.meterware.httpunit.GetMethodWebRequest) GetMethodWebRequest(com.meterware.httpunit.GetMethodWebRequest) TextBlock(com.meterware.httpunit.TextBlock) URL(java.net.URL)

Aggregations

GetMethodWebRequest (com.meterware.httpunit.GetMethodWebRequest)14 TextBlock (com.meterware.httpunit.TextBlock)14 WebRequest (com.meterware.httpunit.WebRequest)14 WebResponse (com.meterware.httpunit.WebResponse)14 URL (java.net.URL)14 WebLink (com.meterware.httpunit.WebLink)3 WebTable (com.meterware.httpunit.WebTable)3 File (java.io.File)1