Example usage for org.apache.commons.httpclient HttpStatus SC_INTERNAL_SERVER_ERROR

List of usage examples for org.apache.commons.httpclient HttpStatus SC_INTERNAL_SERVER_ERROR

Introduction

In this page you can find the example usage for org.apache.commons.httpclient HttpStatus SC_INTERNAL_SERVER_ERROR.

Prototype

int SC_INTERNAL_SERVER_ERROR

To view the source code for org.apache.commons.httpclient HttpStatus SC_INTERNAL_SERVER_ERROR.

Click Source Link

Document

<tt>500 Server Error</tt> (HTTP/1.0 - RFC 1945)

Usage

From source file:org.wso2.mdm.integration.operation.OracleOperationManagement.java

@Test(dependsOnMethods = {
        "testInstallApps" }, description = "Test get operations for device with wrong Device ID")
public void testGetDeviceOperationsWithWrongDeviceID() throws Exception {
    MDMResponse response = client.get(Constants.OperationManagement.GET_DEVICE_OPERATIONS_ENDPOINT
            + Constants.NUMBER_NOT_EQUAL_TO_DEVICE_ID);
    Assert.assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, response.getStatus());
}

From source file:org.wso2.mdm.integration.policy.AndroidPolicyManagement.java

@Test(description = "Test add policy with erroneous payload.")
public void testAddPolicyWithErroneousPayload() throws Exception {
    MDMResponse response = client.post(Constants.PolicyManagement.ADD_POLICY_ENDPOINT,
            PayloadGenerator/*from www. j a va 2s. com*/
                    .getJsonPayload(Constants.PolicyManagement.ANDROID_POLICY_ERRONEOUS_PAYLOAD_FILE_NAME,
                            Constants.HTTP_METHOD_POST)
                    .toString());
    Assert.assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, response.getStatus());
}

From source file:org.wso2.mdm.integration.policy.AndroidPolicyManagement.java

@Test(description = "Test update policy with erroneous payload.", dependsOnMethods = { "testAddPolicy" })
public void testUpdatePolicyWithErroneousPayload() throws Exception {
    MDMResponse response = client.put(Constants.PolicyManagement.UPDATE_ANDROID_POLICY_ENDPOINT,
            PayloadGenerator//from   w  w  w.  j  av a2  s  .c om
                    .getJsonPayload(Constants.PolicyManagement.ANDROID_POLICY_ERRONEOUS_PAYLOAD_FILE_NAME,
                            Constants.HTTP_METHOD_POST)
                    .toString());
    Assert.assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, response.getStatus());
}

From source file:org.wso2.mdm.integration.policy.AndroidPolicyManagement.java

@Test(description = "Test remove policy without a policies.", dependsOnMethods = { "testRemovePolicy" })
public void testRemovePolicyWithoutPolicies() throws Exception {

    MDMResponse response = client.post(Constants.PolicyManagement.REMOVE_POLICY_ENDPOINT,
            Constants.PolicyManagement.REMOVE_ANDROID_POLICY_PAYLOAD_FILE_NAME);
    Assert.assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, response.getStatus());
}

From source file:org.wso2.mdm.integration.policy.WindowsPolicyManagement.java

@Test(description = "Test policy priorities with erroneous payload.", dependsOnMethods = {
        "testGetAllPolicies" })
public void testPolicyPrioritiesWithErroneousPayload() throws Exception {
    MDMResponse response = client.put(Constants.PolicyManagement.POLICY_PRIORITIES_ENDPOINT,
            Constants.PolicyManagement.POLICY_ERRONEOUS_PAYLOAD_FILE_NAME);
    Assert.assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, response.getStatus());
}

From source file:org.xwiki.test.escaping.framework.AbstractEscapingTest.java

/**
 * Download a page from the server and return its content. Throws a {@link RuntimeException} on connection problems
 * etc./* w w w .  j av  a  2s  . c om*/
 * 
 * @param url URL of the page
 * @return content of the page
 */
protected static URLContent getUrlContent(String url) {
    GetMethod get = new GetMethod(url);
    get.setFollowRedirects(true);
    if (isLoggedIn()) {
        get.setDoAuthentication(true);
        get.addRequestHeader("Authorization",
                "Basic " + new String(Base64.encodeBase64("Admin:admin".getBytes())));
    }

    try {
        int statusCode = AbstractEscapingTest.getClient().executeMethod(get);
        switch (statusCode) {
        case HttpStatus.SC_OK:
            // everything is fine
            break;
        case HttpStatus.SC_UNAUTHORIZED:
            // do not fail on 401 (unauthorized), used in some tests
            System.out.println("WARNING, Ignoring status 401 (unauthorized) for URL: " + url);
            break;
        case HttpStatus.SC_CONFLICT:
            // do not fail on 409 (conflict), used in some templates
            System.out.println("WARNING, Ignoring status 409 (conflict) for URL: " + url);
            break;
        case HttpStatus.SC_NOT_FOUND:
            // ignore 404 (the page is still rendered)
            break;
        case HttpStatus.SC_INTERNAL_SERVER_ERROR:
            // ignore 500 (internal server error), which is used by the standard exception.vm error display
            break;
        default:
            throw new RuntimeException("HTTP GET request returned status " + statusCode + " ("
                    + get.getStatusText() + ") for URL: " + url);
        }

        return new URLContent(get.getResponseHeader("Content-Type").getValue(), get.getResponseBody());
    } catch (IOException exception) {
        throw new RuntimeException("Error retrieving URL: " + url, exception);
    } finally {
        get.releaseConnection();
    }
}

From source file:org.zaproxy.zap.extension.pscanrules.ApplicationErrorScanner.java

/**
 * Perform the passive scanning of application errors inside the response
 * content//from   w w w.ja va 2s.c  o  m
 *
 * @param msg the message that need to be checked
 * @param id the id of the session
 * @param source the source code of the response
 */
@Override
public void scanHttpResponseReceive(HttpMessage msg, int id, Source source) {

    // First check if it's an INTERNAL SERVER ERROR
    int status = msg.getResponseHeader().getStatusCode();
    if (status == HttpStatus.SC_INTERNAL_SERVER_ERROR) {
        // We found it!
        // The AS raise an Internal Error
        // so a possible disclosure can be found
        raiseAlert(msg, id, EVIDENCE_INTERNAL_SERVER_ERROR);

    } else if (status != HttpStatus.SC_NOT_FOUND) {
        String evidence = matcher.findInContent(msg.getResponseBody().toString());
        if (evidence != null) {
            // We found it!
            // There exists a positive match of an
            // application error occurrence
            raiseAlert(msg, id, evidence);
        }
    }
}

From source file:pl.nask.hsn2.connector.CuckooRESTConnector.java

public final void deleteTaskData(long cuckooTaskId) {
    try (CuckooConnection connection = connect(cuckooURL + DELETE_TASK + cuckooTaskId)) {
        int status = connection.getResultStatusCode();
        switch (status) {
        case HttpStatus.SC_OK:
            LOGGER.info("Cuckoo: task data deleted: " + cuckooTaskId);
            break;
        case HttpStatus.SC_NOT_FOUND:
            LOGGER.warn("Cuckoo: error deleting task data, task not found: " + cuckooTaskId);
            break;
        case HttpStatus.SC_INTERNAL_SERVER_ERROR:
            LOGGER.warn("Cuckoo: error deleting task data, could not delete task data: " + cuckooTaskId);
            break;
        default://from   w w  w . jav a2s .c om
            LOGGER.warn("Cuckoo: error deleting task data (unknown status code: " + status + "), task: "
                    + cuckooTaskId);
        }
    } catch (CuckooException e) {
        LOGGER.warn("Cuckoo: error deleting task data: " + e.getMessage() + ", task: " + cuckooTaskId, e);
    } catch (IOException e) {
        LOGGER.warn("Error closing connection while deleting task data for task: " + cuckooTaskId, e);
    }
}