Search in sources :

Example 16 with HttpStatus

use of cn.taketoday.http.HttpStatus in project today-infrastructure by TAKETODAY.

the class RelativeRedirectFilterTests method doFilterSendRedirectWhenCustomSendRedirectHttpStatusThenLocationAnd301.

@Test
public void doFilterSendRedirectWhenCustomSendRedirectHttpStatusThenLocationAnd301() throws Exception {
    String location = "/foo";
    HttpStatus status = HttpStatus.MOVED_PERMANENTLY;
    this.filter.setRedirectStatus(status);
    sendRedirect(location);
    InOrder inOrder = Mockito.inOrder(this.response);
    inOrder.verify(this.response).setStatus(status.value());
    inOrder.verify(this.response).setHeader(HttpHeaders.LOCATION, location);
}
Also used : InOrder(org.mockito.InOrder) HttpStatus(cn.taketoday.http.HttpStatus) Test(org.junit.jupiter.api.Test)

Example 17 with HttpStatus

use of cn.taketoday.http.HttpStatus in project today-framework by TAKETODAY.

the class ResponseStatusException method getMessage.

@Override
public String getMessage() {
    HttpStatus code = HttpStatus.resolve(getRawStatusCode());
    String msg = (code != null ? code : getRawStatusCode()) + (this.reason != null ? " \"" + this.reason + "\"" : "");
    return ExceptionUtils.buildMessage(msg, getCause());
}
Also used : HttpStatus(cn.taketoday.http.HttpStatus)

Aggregations

HttpStatus (cn.taketoday.http.HttpStatus)17 Test (org.junit.jupiter.api.Test)8 Mono (reactor.core.publisher.Mono)5 ClientResponse (cn.taketoday.web.reactive.function.client.ClientResponse)4 URI (java.net.URI)4 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)4 TypeReference (cn.taketoday.core.TypeReference)3 DataBuffer (cn.taketoday.core.io.buffer.DataBuffer)3 DataBufferUtils (cn.taketoday.core.io.buffer.DataBufferUtils)3 HttpHeaders (cn.taketoday.http.HttpHeaders)3 MediaType (cn.taketoday.http.MediaType)3 ResponseEntity (cn.taketoday.http.ResponseEntity)3 BodyExtractors (cn.taketoday.web.reactive.function.BodyExtractors)3 Collections (java.util.Collections)3 Map (java.util.Map)3 StepVerifier (reactor.test.StepVerifier)3 DataBufferFactory (cn.taketoday.core.io.buffer.DataBufferFactory)2 DefaultDataBufferFactory (cn.taketoday.core.io.buffer.DefaultDataBufferFactory)2 NettyDataBufferFactory (cn.taketoday.core.io.buffer.NettyDataBufferFactory)2 AbstractDataBufferAllocatingTests (cn.taketoday.core.testfixture.io.buffer.AbstractDataBufferAllocatingTests)2