use of com.meterware.servletunit.ServletUnitClient 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.servletunit.ServletUnitClient 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.servletunit.ServletUnitClient in project cxf by apache.
the class CXFServletTest method testGetUnformatServiceList.
@Test
public void testGetUnformatServiceList() throws Exception {
ServletUnitClient client = newClient();
client.setExceptionsThrownOnErrorStatus(false);
WebResponse res = client.getResponse(CONTEXT_URL + "/services?formatted=false");
assertTrue(res.getText().contains("http://localhost/mycontext/services/greeter3"));
assertTrue(res.getText().contains("http://localhost/mycontext/services/greeter2"));
assertTrue(res.getText().contains("http://localhost/mycontext/services/greeter"));
}
use of com.meterware.servletunit.ServletUnitClient in project cxf by apache.
the class CXFServletTest method testGetServiceList.
@Test
public void testGetServiceList() throws Exception {
ServletUnitClient client = newClient();
client.setExceptionsThrownOnErrorStatus(false);
WebResponse res = client.getResponse(CONTEXT_URL + "/services");
WebLink[] links = res.getLinks();
assertEquals("Wrong number of service links", 6, links.length);
Set<String> links2 = new HashSet<>();
for (WebLink l : links) {
links2.add(l.getURLString());
}
assertTrue(links2.contains(CONTEXT_URL + "/services/greeter?wsdl"));
assertTrue(links2.contains(CONTEXT_URL + "/services/greeter2?wsdl"));
assertTrue(links2.contains("http://cxf.apache.org/MyGreeter?wsdl"));
assertEquals("text/html", res.getContentType());
res = client.getResponse(CONTEXT_URL + "/services/");
links = res.getLinks();
links2.clear();
for (WebLink l : links) {
links2.add(l.getURLString());
}
assertEquals("Wrong number of service links", 6, links.length);
assertTrue(links2.contains(CONTEXT_URL + "/services/greeter?wsdl"));
assertTrue(links2.contains(CONTEXT_URL + "/services/greeter2?wsdl"));
assertTrue(links2.contains("http://cxf.apache.org/MyGreeter?wsdl"));
assertEquals("text/html", res.getContentType());
// Ensure that the Bus is available for people doing an Endpoint.publish() or similar.
assertNotNull(BusFactory.getDefaultBus(false));
}
use of com.meterware.servletunit.ServletUnitClient in project cxf by apache.
the class CXFServletTest method testInvalidServiceUrl.
@Test
public void testInvalidServiceUrl() throws Exception {
ServletUnitClient client = newClient();
client.setExceptionsThrownOnErrorStatus(false);
WebResponse res = client.getResponse(CONTEXT_URL + "/services/NoSuchService");
assertEquals(404, res.getResponseCode());
assertEquals("text/html", res.getContentType());
}
Aggregations