use of com.meterware.httpunit.WebRequest in project maven-plugins by apache.
the class DependencyConvergenceReportTest method testReport.
/**
* Test report
*
* @throws Exception if any
*/
public void testReport() throws Exception {
generateReport("dependency-convergence", "dependency-convergence-plugin-config.xml");
assertTrue("Test html generated", getGeneratedReport("dependency-convergence.html").exists());
URL reportURL = getGeneratedReport("dependency-convergence.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.dependency-convergence.name"), getString("report.dependency-convergence.reactor.title"));
assertEquals(expectedTitle, response.getTitle());
// Test the texts
TextBlock[] textBlocks = response.getTextBlocks();
assertEquals(getString("report.dependency-convergence.reactor.name"), textBlocks[0].getText());
}
use of com.meterware.httpunit.WebRequest 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.WebRequest in project maven-plugins by apache.
the class MailingListsReportTest method testReport.
/**
* Test report
*
* @throws Exception if any
*/
public void testReport() throws Exception {
generateReport("mailing-list", "mailing-lists-plugin-config.xml");
assertTrue("Test html generated", getGeneratedReport("mail-lists.html").exists());
URL reportURL = getGeneratedReport("mail-lists.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.mailing-lists.name"), getString("report.mailing-lists.title"));
assertEquals(expectedTitle, response.getTitle());
// Test the texts
TextBlock[] textBlocks = response.getTextBlocks();
assertEquals(getString("report.mailing-lists.title"), textBlocks[0].getText());
assertEquals(getString("report.mailing-lists.intro"), textBlocks[1].getText());
}
use of com.meterware.httpunit.WebRequest in project geode by apache.
the class TestSessionsTomcat8Base method testSessionPersists1.
/**
* Check that our session persists. The values we pass in as query params are used to set
* attributes on the session.
*/
@Test
public void testSessionPersists1() throws Exception {
String key = "value_testSessionPersists1";
String value = "Foo";
WebConversation wc = new WebConversation();
WebRequest req = new GetMethodWebRequest(String.format("http://localhost:%d/test", port));
req.setParameter("cmd", QueryCommand.SET.name());
req.setParameter("param", key);
req.setParameter("value", value);
WebResponse response = wc.getResponse(req);
String sessionId = response.getNewCookieValue("JSESSIONID");
assertNotNull("No apparent session cookie", sessionId);
// The request retains the cookie from the prior response...
req.setParameter("cmd", QueryCommand.GET.name());
req.setParameter("param", key);
req.removeParameter("value");
response = wc.getResponse(req);
assertEquals(value, response.getText());
}
use of com.meterware.httpunit.WebRequest in project geode by apache.
the class TestSessionsTomcat8Base method testBasicRegion.
/**
* Test that a session attribute gets set into the region too.
*/
@Test
public void testBasicRegion() throws Exception {
String key = "value_testBasicRegion";
String value = "Foo";
WebConversation wc = new WebConversation();
WebRequest req = new GetMethodWebRequest(String.format("http://localhost:%d/test", port));
// Set an attribute
req.setParameter("cmd", QueryCommand.SET.name());
req.setParameter("param", key);
req.setParameter("value", value);
WebResponse response = wc.getResponse(req);
String sessionId = response.getNewCookieValue("JSESSIONID");
assertEquals(value, region.get(sessionId).getAttribute(key));
}
Aggregations