Search in sources :

Example 1 with WebLink

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

the class LicensesReportTest method testReport.

/**
     * Test report
     *
     * @throws Exception if any
     */
public void testReport() throws Exception {
    generateReport("license", "licenses-plugin-config.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());
    // only 1 link in default report
    final WebLink[] links = response.getLinks();
    assertEquals(1, links.length);
    assertEquals("http://maven.apache.org/", links[0].getURLString());
}
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 2 with WebLink

use of com.meterware.httpunit.WebLink in project wildfly by wildfly.

the class SAMLIDPInitiatedTestCase method testAuthentication.

@Ignore("wait for PL > 2.6.0.CR2")
@Test
@OperateOnDeployment("identity-provider")
public void testAuthentication(@ArquillianResource URL url) throws Exception {
    WebConversation conversation = new WebConversation();
    HttpUnitOptions.setLoggingHttpHeaders(true);
    WebRequest request = new GetMethodWebRequest(url.toString());
    WebResponse response = conversation.getResponse(request);
    assertEquals(1, response.getForms().length);
    WebForm webForm = response.getForms()[0];
    webForm.setParameter("j_username", "tomcat");
    webForm.setParameter("j_password", "tomcat");
    webForm.getSubmitButtons()[0].click();
    response = conversation.getCurrentPage();
    LOGGER.debug("Response from IDP: " + response.getText());
    LOGGER.debug("SP1-URL: " + serviceProviderPostURL);
    LOGGER.debug("webURI: " + webURI);
    WebLink link = response.getLinkWithID("service-provider-1-id");
    assertNotNull("Cannot reach link with id: service-provider-1-id", link);
    response = link.click();
    assertTrue("Not properly redirected to sp-post1.war", response.getText().contains("Welcome to sp-post1.war"));
}
Also used : WebResponse(com.meterware.httpunit.WebResponse) WebConversation(com.meterware.httpunit.WebConversation) WebRequest(com.meterware.httpunit.WebRequest) GetMethodWebRequest(com.meterware.httpunit.GetMethodWebRequest) WebForm(com.meterware.httpunit.WebForm) GetMethodWebRequest(com.meterware.httpunit.GetMethodWebRequest) WebLink(com.meterware.httpunit.WebLink) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 3 with WebLink

use of com.meterware.httpunit.WebLink 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 4 with WebLink

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

Aggregations

GetMethodWebRequest (com.meterware.httpunit.GetMethodWebRequest)4 WebLink (com.meterware.httpunit.WebLink)4 WebRequest (com.meterware.httpunit.WebRequest)4 WebResponse (com.meterware.httpunit.WebResponse)4 TextBlock (com.meterware.httpunit.TextBlock)3 URL (java.net.URL)3 WebConversation (com.meterware.httpunit.WebConversation)1 WebForm (com.meterware.httpunit.WebForm)1 OperateOnDeployment (org.jboss.arquillian.container.test.api.OperateOnDeployment)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1