use of com.blade.mvc.http.HttpResponse 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.HttpResponse 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.HttpResponse 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.HttpResponse 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());
}
use of com.blade.mvc.http.HttpResponse 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"));
}
Aggregations