Search in sources :

Example 1 with HttpAnyMethod

use of org.apache.sling.commons.testing.integration.HttpAnyMethod in project sling by apache.

the class SlingWebDavServletTest method testServiceRunning.

public void testServiceRunning() throws IOException {
    final String url = getHandlerUrl(HANDLER_1);
    final HttpAnyMethod propfind = new HttpAnyMethod("PROPFIND", url);
    int status = httpClient.executeMethod(propfind);
    assertEquals("PROPFIND " + url + " must return status 207", 207, status);
    final String content = propfind.getResponseBodyAsString();
    assertContains(content, HANDLER);
}
Also used : HttpAnyMethod(org.apache.sling.commons.testing.integration.HttpAnyMethod)

Example 2 with HttpAnyMethod

use of org.apache.sling.commons.testing.integration.HttpAnyMethod in project sling by apache.

the class WebDavDoubleSlashTest method assertPropfindStatus.

/** Do a PROPFIND on /dav, adding worskpace name after that as required by the Jackrabbit WebDAV modules */
private void assertPropfindStatus(final int expecetdStatus, final String workspace, final String path) throws IOException {
    final String webdavRoot = "/dav";
    final String url = HttpTest.HTTP_BASE_URL + webdavRoot + "/" + workspace + path;
    final HttpAnyMethod propfind = new HttpAnyMethod("PROPFIND", url);
    final int status = H.getHttpClient().executeMethod(propfind);
    if (expecetdStatus != status) {
        // print the response body in case of a test failure to help debugging
        fail("Status code " + expecetdStatus + " expected, got " + status + ".\n" + "Response body:\n" + propfind.getResponseBodyAsString());
    } else {
        // never fails, but there will be no assertion otherwise
        assertEquals("Status code", expecetdStatus, status);
    }
}
Also used : HttpAnyMethod(org.apache.sling.commons.testing.integration.HttpAnyMethod)

Example 3 with HttpAnyMethod

use of org.apache.sling.commons.testing.integration.HttpAnyMethod in project sling by apache.

the class WebdavOptionsTest method doTestOnPath.

/** OPTIONS request at given path must return a WWW-Authenticate header */
private void doTestOnPath(String path) throws Exception {
    final HttpClient noCredentialsClient = new HttpClient();
    final HttpAnyMethod opt = new HttpAnyMethod("OPTIONS", HTTP_BASE_URL + path);
    final int status = noCredentialsClient.executeMethod(opt);
    assertEquals("Expecting matching status on OPTIONS request at " + path, 401, status);
    final Header h = opt.getResponseHeader(WWW_Authenticate);
    assertNotNull("Expecting " + WWW_Authenticate + " header in response at " + path, h);
}
Also used : Header(org.apache.commons.httpclient.Header) HttpClient(org.apache.commons.httpclient.HttpClient) HttpAnyMethod(org.apache.sling.commons.testing.integration.HttpAnyMethod)

Example 4 with HttpAnyMethod

use of org.apache.sling.commons.testing.integration.HttpAnyMethod in project sling by apache.

the class SlingWebDavServletTest method checkHandler.

//
/**
     * @param handlerName
     * @param identifier The expected handler identifier to be returned as a property.
     * @throws IOException
     */
private void checkHandler(String handlerName, String identifier) throws IOException {
    final HttpAnyMethod propfind = new HttpAnyMethod("PROPFIND", handlerName);
    int status = httpClient.executeMethod(propfind);
    assertEquals("PROPFIND " + handlerName + " must return status 207", 207, status);
    final String content = propfind.getResponseBodyAsString();
    assertContains(content, identifier);
}
Also used : HttpAnyMethod(org.apache.sling.commons.testing.integration.HttpAnyMethod)

Aggregations

HttpAnyMethod (org.apache.sling.commons.testing.integration.HttpAnyMethod)4 Header (org.apache.commons.httpclient.Header)1 HttpClient (org.apache.commons.httpclient.HttpClient)1