use of com.meterware.httpunit.WebResponse in project v7files by thiloplanz.
the class MiltonServletTest method testCOPYFolder.
public void testCOPYFolder() throws IOException, SAXException {
ServletUnitClient sc = sr.newClient();
sc.setAuthentication("V7Files", "admin", "admin");
{
WebRequest request = new MkColWebRequest("http://test/myServlet/1");
WebResponse resp = sc.getResponse(request);
assertEquals(HttpServletResponse.SC_CREATED, resp.getResponseCode());
}
{
WebRequest request = new PutMethodWebRequest("http://test/myServlet/1/test.txt", new ByteArrayInputStream("testPUT".getBytes()), "text/plain");
WebResponse resp = sc.getResponse(request);
assertEquals(HttpServletResponse.SC_CREATED, resp.getResponseCode());
}
{
WebRequest request = new CopyWebRequest("http://test/myServlet/1", "/myServlet/2");
WebResponse resp = sc.getResponse(request);
assertEquals(HttpServletResponse.SC_CREATED, resp.getResponseCode());
}
assertExists(sc, "http://test/myServlet/2/test.txt");
}
use of com.meterware.httpunit.WebResponse 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.WebResponse 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.WebResponse 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.WebResponse 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."));
}
Aggregations