use of com.meterware.httpunit.WebRequest in project v7files by thiloplanz.
the class MiltonServletTest method testCOPYFile.
public void testCOPYFile() throws IOException, SAXException {
ServletUnitClient sc = sr.newClient();
sc.setAuthentication("V7Files", "admin", "admin");
prepareMockData("test.v7files.files", new BasicBSONObject("_id", new ObjectId()).append("filename", "a.txt").append("parent", "webdav").append("in", "abcd".getBytes()));
{
WebRequest request = new CopyWebRequest("http://test/myServlet/a.txt", "/myServlet/b.txt");
WebResponse resp = sc.getResponse(request);
assertEquals(HttpServletResponse.SC_CREATED, resp.getResponseCode());
}
assertGET(sc, "http://test/myServlet/a.txt", "abcd");
assertGET(sc, "http://test/myServlet/b.txt", "abcd");
}
use of com.meterware.httpunit.WebRequest in project v7files by thiloplanz.
the class MiltonServletTest method assertGET.
private void assertGET(ServletUnitClient sc, String url, String contents) throws IOException, SAXException {
WebRequest request = new GetMethodWebRequest(url);
WebResponse resp = sc.getResponse(request);
assertEquals(contents, resp.getText());
assertEquals(HttpServletResponse.SC_OK, resp.getResponseCode());
}
use of com.meterware.httpunit.WebRequest in project wildfly by wildfly.
the class RestoreOriginalRequestTestCase method testRedirectOriginalRequest.
@Test
@OperateOnDeployment("service-provider-1")
public void testRedirectOriginalRequest(@ArquillianResource URL serviceProvider1) throws Exception {
WebRequest request = new GetMethodWebRequest(formatUrl(serviceProvider1) + "/savedRequest/savedRequest.html");
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();
response = conversation.getCurrentPage();
assertTrue(response.getText().contains("Back to the original requested resource."));
}
use of com.meterware.httpunit.WebRequest in project wildfly by wildfly.
the class RestoreOriginalRequestTestCase method testPostOriginalRequestWithParams.
@Test
@OperateOnDeployment("service-provider-2")
public void testPostOriginalRequestWithParams(@ArquillianResource URL serviceProvider2) throws Exception {
WebRequest request = new GetMethodWebRequest(formatUrl(serviceProvider2) + "/savedRequest/savedRequest.jsp");
request.setParameter("SAVED_PARAM", "Param was saved.");
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();
response = conversation.getCurrentPage();
assertTrue(response.getText().contains("Param was saved."));
}
use of com.meterware.httpunit.WebRequest in project geode by apache.
the class TestSessionsBase method testSessionExpiration1.
/**
* Test setting the session expiration
*/
@Test
public void testSessionExpiration1() throws Exception {
// TestSessions only live for a second
sessionManager.setMaxInactiveInterval(1);
String key = "value_testSessionExpiration1";
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);
// Sleep a while
Thread.sleep(2000);
// The attribute should not be accessible now...
req.setParameter("cmd", QueryCommand.GET.name());
req.setParameter("param", key);
response = wc.getResponse(req);
assertEquals("", response.getText());
}
Aggregations