Example usage for org.springframework.http HttpStatus INTERNAL_SERVER_ERROR

List of usage examples for org.springframework.http HttpStatus INTERNAL_SERVER_ERROR

Introduction

In this page you can find the example usage for org.springframework.http HttpStatus INTERNAL_SERVER_ERROR.

Prototype

HttpStatus INTERNAL_SERVER_ERROR

To view the source code for org.springframework.http HttpStatus INTERNAL_SERVER_ERROR.

Click Source Link

Document

500 Internal Server Error .

Usage

From source file:com.orange.ngsi.client.SubscribeContextRequestTest.java

@Test(expected = HttpServerErrorException.class)
public void subscribeContextRequestWith500() throws Exception {

    mockServer.expect(requestTo(baseUrl + "/ngsi10/subscribeContext")).andExpect(method(HttpMethod.POST))
            .andRespond(withStatus(HttpStatus.INTERNAL_SERVER_ERROR));

    ngsiClient.subscribeContext(baseUrl, null, createSubscribeContextTemperature()).get();
}

From source file:com.orange.ngsi.client.UpdateContextSubscriptionTest.java

@Test(expected = HttpServerErrorException.class)
public void subscribeContextRequestWith500() throws Exception {

    mockServer.expect(requestTo(baseUrl + "/ngsi10/updateContextSubscription"))
            .andExpect(method(HttpMethod.POST)).andRespond(withStatus(HttpStatus.INTERNAL_SERVER_ERROR));

    ngsiClient.updateContextSubscription(baseUrl, null, createUpdateContextSubscriptionTemperature()).get();
}

From source file:com.orange.ngsi.client.RegisterContextRequestTest.java

@Test(expected = HttpServerErrorException.class)
public void registerContextRequestWith500() throws Exception {

    mockServer.expect(requestTo(baseUrl + "/ngsi9/registerContext")).andExpect(method(HttpMethod.POST))
            .andRespond(withStatus(HttpStatus.INTERNAL_SERVER_ERROR));

    ngsiClient.registerContext(baseUrl, null, createRegisterContextTemperature()).get();
}

From source file:at.ac.tuwien.dsg.cloud.utilities.gateway.registry.UserController.java

@RequestMapping(method = RequestMethod.PUT, value = REST_USER_PATH_VARIABLE)
public ResponseEntity<String> register(@PathVariable String user) {

    RequestEntity<KongUserCreateDto> request = RequestEntity
            .post(URI.create(this.kongUris.getKongConsumersUri())).contentType(MediaType.APPLICATION_JSON)
            .body(KongUserCreateDto.build(user));

    ResponseEntity<KongUser> resp = restUtilities.simpleRestExchange(request, KongUser.class);

    if (resp == null || resp.getStatusCode() != HttpStatus.CREATED) {
        return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
    }/*from   w  w  w .ja v  a 2s  . co  m*/

    KongUser kongUser = resp.getBody();
    kongUser.setKey(kongService.createKeyForUser(kongUser.getUserName()));

    if (kongUser.getKey() == null) {
        return new ResponseEntity<>("User was created but key generation failed!",
                HttpStatus.FAILED_DEPENDENCY);
    }

    this.kongUsers.getUsers().add(kongUser);
    return new ResponseEntity(kongUser.getKey().getKey(), HttpStatus.OK);
}

From source file:com.orange.ngsi.client.UnsubscribeContextRequestTest.java

@Test(expected = HttpServerErrorException.class)
public void unsubscribeContextRequestWith500() throws Exception {

    this.mockServer.expect(requestTo(baseUrl + "/ngsi10/unsubscribeContext")).andExpect(method(HttpMethod.POST))
            .andRespond(withStatus(HttpStatus.INTERNAL_SERVER_ERROR));

    ngsiClient.unsubscribeContext(baseUrl, null, subscriptionID).get();
}

From source file:org.esbtools.gateway.resync.controller.ResyncGateway.java

@ExceptionHandler(ResyncFailedException.class)
private ResponseEntity<ResyncResponse> resyncFailedExceptionHandler(ResyncFailedException e) {
    ResyncResponse resyncResponse = new ResyncResponse(ResyncResponse.Status.Error, e.getMessage());
    return new ResponseEntity<>(resyncResponse, HttpStatus.INTERNAL_SERVER_ERROR);
}

From source file:dk.nsi.haiba.lprimporter.status.StatusReporter.java

@RequestMapping(value = "/status")
public ResponseEntity<String> reportStatus() {

    String manual = request.getParameter("manual");
    if (manual == null || manual.trim().length() == 0) {
        // no value set, use default set in the import executor
        manual = "" + importExecutor.isManualOverride();
    } else {/*from w  ww  .  ja  v  a 2  s .c o m*/
        // manual flag is set on the request
        if (manual.equalsIgnoreCase("true")) {
            // flag is true, start the importer in a new thread
            importExecutor.setManualOverride(true);
            Runnable importer = new Runnable() {
                public void run() {
                    importExecutor.doProcess(true);
                }
            };
            importer.run();
        } else {
            importExecutor.setManualOverride(false);
        }
    }

    HttpHeaders headers = new HttpHeaders();
    String body = "OK";
    HttpStatus status = HttpStatus.INTERNAL_SERVER_ERROR;
    body = "OK";

    try {
        if (!statusRepo.isHAIBADBAlive()) {
            body = "HAIBA Database is _NOT_ running correctly";
        } else if (!statusRepo.isLPRDBAlive()) {
            body = "LPR Database is _NOT_ running correctly";
        } else if (statusRepo.isOverdue()) {
            // last run information is applied to body later
            body = "Is overdue";
        } else {
            status = HttpStatus.OK;
        }
    } catch (Exception e) {
        body = e.getMessage();
    }

    body += "</br>";
    body = addLastRunInformation(body);

    body += "</br>------------------</br>";

    String url = request.getRequestURL().toString();
    body += "<a href=\"" + url + "?manual=true\">Manual start importer</a>";
    body += "</br>";
    body += "<a href=\"" + url + "?manual=false\">Scheduled start importer</a>";
    body += "</br>";
    if (manual.equalsIgnoreCase("true")) {
        body += "status: MANUAL";
    } else {
        // default
        body += "status: SCHEDULED - " + cron;
    }

    headers.setContentType(MediaType.TEXT_HTML);

    return new ResponseEntity<String>(body, headers, status);
}

From source file:com.ge.predix.acs.commons.web.RestApiExceptionTest.java

@Test
public void testRestApiExceptionWithMessageExceptionBooleans() {
    RuntimeException runtimeException = new RuntimeException();
    RestApiException apiException = new RestApiException("message", runtimeException, true, true);

    Assert.assertEquals(apiException.getCause(), runtimeException);
    Assert.assertEquals(apiException.getMessage(), "message");
    Assert.assertEquals(apiException.getAppErrorCode(), "FAILURE");
    Assert.assertEquals(apiException.getHttpStatusCode(), HttpStatus.INTERNAL_SERVER_ERROR);
}

From source file:io.spring.initializr.actuate.stat.ProjectGenerationStatPublisherTests.java

@Test
public void recoverFromError() {
    ProjectRequest request = createProjectRequest();

    this.mockServer.expect(requestTo("http://example.com/elastic/initializr/request"))
            .andExpect(method(HttpMethod.POST)).andRespond(withStatus(HttpStatus.INTERNAL_SERVER_ERROR));

    this.mockServer.expect(requestTo("http://example.com/elastic/initializr/request"))
            .andExpect(method(HttpMethod.POST)).andRespond(withStatus(HttpStatus.INTERNAL_SERVER_ERROR));

    this.mockServer.expect(requestTo("http://example.com/elastic/initializr/request"))
            .andExpect(method(HttpMethod.POST))
            .andRespond(withStatus(HttpStatus.CREATED).body(mockResponse(UUID.randomUUID().toString(), true))
                    .contentType(MediaType.APPLICATION_JSON));

    this.statPublisher.handleEvent(new ProjectGeneratedEvent(request));
    this.mockServer.verify();
}

From source file:net.maritimecloud.identityregistry.controllers.CertificateController.java

@RequestMapping(value = "/api/certificates/ocsp", method = RequestMethod.POST, consumes = "application/ocsp-request", produces = "application/ocsp-response")
@ResponseBody/*w  ww.  j a va 2  s . c o m*/
public ResponseEntity<?> postOCSP(@RequestBody byte[] input) {
    byte[] byteResponse;
    try {
        byteResponse = handleOCSP(input);
    } catch (IOException e) {
        log.error("Failed to update OCSP", e);
        return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
    }
    return new ResponseEntity<>(byteResponse, HttpStatus.OK);
}