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());
}
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"));
}
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());
}
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());
}
Aggregations