use of com.blade.mvc.http.Response in project blade by biezhi.
the class BaseTestCase method mockHttpResponse.
protected Response mockHttpResponse(int code) {
Response response = mock(Response.class);
when(response.statusCode()).thenReturn(code);
return response;
}
use of com.blade.mvc.http.Response in project blade by biezhi.
the class HttpResponseTest method testUnauthorized.
@Test
public void testUnauthorized() {
Response mockResponse = mockHttpResponse(200);
Response response = new HttpResponse(mockResponse);
response.unauthorized();
assertEquals(401, response.statusCode());
}
use of com.blade.mvc.http.Response in project blade by biezhi.
the class HttpResponseTest method testHeader.
@Test
public void testHeader() {
Response mockResponse = mockHttpResponse(200);
when(mockResponse.headers()).thenReturn(Collections.singletonMap("Server", "Nginx"));
Response response = new HttpResponse(mockResponse);
assertEquals(1, response.headers().size());
assertEquals("Nginx", response.headers().get("Server"));
}
use of com.blade.mvc.http.Response in project blade by biezhi.
the class HttpResponseTest method testNotFound.
@Test
public void testNotFound() {
Response mockResponse = mockHttpResponse(200);
Response response = new HttpResponse(mockResponse);
response.notFound();
assertEquals(404, response.statusCode());
}
use of com.blade.mvc.http.Response in project blade by biezhi.
the class HttpResponseTest method testContentType.
@Test
public void testContentType() {
Response mockResponse = mockHttpResponse(200);
Response response = new HttpResponse(mockResponse);
response.contentType(Const.CONTENT_TYPE_HTML);
assertEquals(Const.CONTENT_TYPE_HTML, response.contentType());
response.contentType("hello.world");
assertEquals("hello.world", response.contentType());
}
Aggregations