use of com.blade.mvc.http.Response in project blade by biezhi.
the class HttpResponseTest method testCookie.
@Test
public void testCookie() {
Response mockResponse = mockHttpResponse(200);
when(mockResponse.cookies()).thenReturn(Collections.singletonMap("c1", "value1"));
Response response = new HttpResponse(mockResponse);
assertEquals(1, response.cookies().size());
assertEquals("value1", response.cookies().get("c1"));
}
use of com.blade.mvc.http.Response in project blade by biezhi.
the class HttpResponseTest method testHeaders.
@Test
public void testHeaders() {
Response mockResponse = mockHttpResponse(200);
when(mockResponse.headers()).thenReturn(new HashMap<>());
Response response = new HttpResponse(mockResponse);
assertEquals(0, response.headers().size());
response.header("a", "123");
assertEquals(1, response.headers().size());
}
use of com.blade.mvc.http.Response in project blade by biezhi.
the class HttpResponseTest method testStatus.
@Test
public void testStatus() {
Response mockResponse = mockHttpResponse(666);
assertEquals(666, mockResponse.statusCode());
}
use of com.blade.mvc.http.Response in project blade by biezhi.
the class HttpResponseTest method testBadRequest.
@Test
public void testBadRequest() {
Response mockResponse = mockHttpResponse(200);
Response response = new HttpResponse(mockResponse);
response.badRequest();
assertEquals(400, response.statusCode());
}
use of com.blade.mvc.http.Response in project blade by biezhi.
the class ExceptionHandlerTest method before.
@Before
public void before() {
request = mock(Request.class);
when(request.header("Accept")).thenReturn("text/html");
response = mock(Response.class);
WebContext.init(Blade.me(), "/");
WebContext.set(new WebContext(request, response, null));
}
Aggregations