Search in sources :

Example 31 with WebResponse

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

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

the class SAMLIDPInitiatedTestCase method testPostOriginalRequest.

@Test
@OperateOnDeployment("identity-provider")
public void testPostOriginalRequest(@ArquillianResource URL url) throws Exception {
    WebRequest request = new GetMethodWebRequest(url.toString());
    WebConversation conversation = new WebConversation();
    WebResponse response = conversation.getResponse(request);
    WebForm webForm = response.getForms()[0];
    webForm.setParameter("j_username", "tomcat");
    webForm.setParameter("j_password", "tomcat");
    webForm.getSubmitButtons()[0].click();
    request = new GetMethodWebRequest(url + "?SAML_VERSION=2.0&TARGET=" + this.serviceProviderPostURL + "/savedRequest/savedRequest.jsp");
    response = conversation.getResponse(request);
    assertTrue(response.getText().contains("Back to the original requested resource."));
}
Also used : WebResponse(com.meterware.httpunit.WebResponse) WebRequest(com.meterware.httpunit.WebRequest) GetMethodWebRequest(com.meterware.httpunit.GetMethodWebRequest) WebConversation(com.meterware.httpunit.WebConversation) WebForm(com.meterware.httpunit.WebForm) GetMethodWebRequest(com.meterware.httpunit.GetMethodWebRequest) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) Test(org.junit.Test)

Example 33 with WebResponse

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

the class TeamReportTest method testReport.

/**
     * Test report
     *
     * @throws Exception if any
     */
public void testReport() throws Exception {
    File pluginXmlFile = new File(getBasedir(), "src/test/resources/plugin-configs/" + "team-plugin-config.xml");
    AbstractProjectInfoReport mojo = createReportMojo("project-team", pluginXmlFile);
    setVariableValueToObject(mojo, "showAvatarImages", Boolean.TRUE);
    generateReport(mojo, pluginXmlFile);
    assertTrue("Test html generated", getGeneratedReport("team-list.html").exists());
    URL reportURL = getGeneratedReport("team-list.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.team.name"), getString("report.team.title"));
    assertEquals(expectedTitle, response.getTitle());
    assertTrue(response.getText().contains("gravatar"));
    // Test the texts
    TextBlock[] textBlocks = response.getTextBlocks();
    assertEquals(textBlocks.length, 7);
    assertEquals(getString("report.team.intro.title"), textBlocks[0].getText());
    assertEquals(getString("report.team.intro.description1"), textBlocks[1].getText());
    assertEquals(getString("report.team.intro.description2"), textBlocks[2].getText());
    assertEquals(getString("report.team.developers.title"), textBlocks[3].getText());
    assertEquals(getString("report.team.developers.intro"), textBlocks[4].getText());
    assertEquals(getString("report.team.contributors.title"), textBlocks[5].getText());
    assertEquals(getString("report.team.nocontributor"), textBlocks[6].getText());
}
Also used : WebResponse(com.meterware.httpunit.WebResponse) WebRequest(com.meterware.httpunit.WebRequest) GetMethodWebRequest(com.meterware.httpunit.GetMethodWebRequest) File(java.io.File) GetMethodWebRequest(com.meterware.httpunit.GetMethodWebRequest) TextBlock(com.meterware.httpunit.TextBlock) URL(java.net.URL)

Example 34 with WebResponse

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

the class SummaryReportTest method testReport.

/**
     * Test report
     *
     * @throws Exception if any
     */
public void testReport() throws Exception {
    generateReport("summary", "summary-plugin-config.xml");
    assertTrue("Test html generated", getGeneratedReport("project-summary.html").exists());
    URL reportURL = getGeneratedReport("project-summary.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.summary.name"), getString("report.summary.title"));
    assertEquals(expectedTitle, response.getTitle());
    // Test the texts
    TextBlock[] textBlocks = response.getTextBlocks();
    assertEquals(getString("report.summary.title"), textBlocks[0].getText());
    assertEquals(getString("report.summary.general.title"), textBlocks[1].getText());
    assertEquals(getString("report.summary.organization.title"), textBlocks[2].getText());
    assertEquals(getString("report.summary.noorganization"), textBlocks[3].getText());
    assertEquals(getString("report.summary.build.title"), textBlocks[4].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 35 with WebResponse

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

the class ScmReportTest method testReport.

/**
     * Test report
     *
     * @throws Exception if any
     */
public void testReport() throws Exception {
    generateReport("scm", "scm-plugin-config.xml");
    assertTrue("Test html generated", getGeneratedReport("source-repository.html").exists());
    URL reportURL = getGeneratedReport("source-repository.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.scm.name"), getString("report.scm.title"));
    assertEquals(expectedTitle, response.getTitle());
    // Test the texts
    TextBlock[] textBlocks = response.getTextBlocks();
    assertEquals(textBlocks.length, 6);
    assertEquals(getString("report.scm.overview.title"), textBlocks[0].getText());
    assertEquals(getString("report.scm.general.intro"), textBlocks[1].getText());
    assertEquals(getString("report.scm.webaccess.title"), textBlocks[2].getText());
    assertEquals(getString("report.scm.webaccess.nourl"), textBlocks[3].getText());
    assertEquals(getString("report.scm.accessbehindfirewall.title"), textBlocks[4].getText());
    assertEquals(getString("report.scm.accessbehindfirewall.general.intro"), textBlocks[5].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)

Aggregations

WebResponse (com.meterware.httpunit.WebResponse)121 WebRequest (com.meterware.httpunit.WebRequest)108 Test (org.junit.Test)93 GetMethodWebRequest (com.meterware.httpunit.GetMethodWebRequest)91 ServletUnitClient (com.meterware.servletunit.ServletUnitClient)56 WebConversation (com.meterware.httpunit.WebConversation)44 PostMethodWebRequest (com.meterware.httpunit.PostMethodWebRequest)42 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 Document (org.w3c.dom.Document)12 HttpSession (javax.servlet.http.HttpSession)9 WebLink (com.meterware.httpunit.WebLink)8 WebForm (com.meterware.httpunit.WebForm)7 HeaderOnlyWebRequest (com.meterware.httpunit.HeaderOnlyWebRequest)5 OperateOnDeployment (org.jboss.arquillian.container.test.api.OperateOnDeployment)5