Search in sources :

Example 96 with WebResponse

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

the class PluginManagementReportTest method testReport.

/**
     * Test report
     *
     * @throws Exception if any
     */
public void testReport() throws Exception {
    generateReport("plugin-management", "plugin-management-plugin-config.xml");
    assertTrue("Test html generated", getGeneratedReport("plugin-management.html").exists());
    URL reportURL = getGeneratedReport("plugin-management.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.plugin-management.name"), getString("report.plugin-management.title"));
    assertEquals(expectedTitle, response.getTitle());
    // Test the tables
    WebTable[] webTables = response.getTables();
    assertEquals(1, webTables.length);
    assertEquals(3, webTables[0].getColumnCount());
    assertEquals(3, webTables[0].getRowCount());
    // Test the texts
    TextBlock[] textBlocks = response.getTextBlocks();
    assertEquals(getString("report.plugin-management.title"), textBlocks[0].getText());
}
Also used : WebResponse(com.meterware.httpunit.WebResponse) WebRequest(com.meterware.httpunit.WebRequest) GetMethodWebRequest(com.meterware.httpunit.GetMethodWebRequest) WebTable(com.meterware.httpunit.WebTable) GetMethodWebRequest(com.meterware.httpunit.GetMethodWebRequest) TextBlock(com.meterware.httpunit.TextBlock) URL(java.net.URL)

Example 97 with WebResponse

use of com.meterware.httpunit.WebResponse 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 98 with WebResponse

use of com.meterware.httpunit.WebResponse 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 99 with WebResponse

use of com.meterware.httpunit.WebResponse 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 100 with WebResponse

use of com.meterware.httpunit.WebResponse 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

WebResponse (com.meterware.httpunit.WebResponse)100 WebRequest (com.meterware.httpunit.WebRequest)95 GetMethodWebRequest (com.meterware.httpunit.GetMethodWebRequest)84 Test (org.junit.Test)76 WebConversation (com.meterware.httpunit.WebConversation)43 ServletUnitClient (com.meterware.servletunit.ServletUnitClient)41 PostMethodWebRequest (com.meterware.httpunit.PostMethodWebRequest)30 ByteArrayInputStream (java.io.ByteArrayInputStream)28 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)16 PutMethodWebRequest (com.meterware.httpunit.PutMethodWebRequest)15 TextBlock (com.meterware.httpunit.TextBlock)14 URL (java.net.URL)14 HttpServletRequest (javax.servlet.http.HttpServletRequest)14 HttpServletResponse (javax.servlet.http.HttpServletResponse)14 HttpSession (javax.servlet.http.HttpSession)9 WebForm (com.meterware.httpunit.WebForm)7 HeaderOnlyWebRequest (com.meterware.httpunit.HeaderOnlyWebRequest)5 OperateOnDeployment (org.jboss.arquillian.container.test.api.OperateOnDeployment)5 HttpException (com.meterware.httpunit.HttpException)4 HttpNotFoundException (com.meterware.httpunit.HttpNotFoundException)4