use of ninja.Result in project ninja by ninjaframework.
the class NinjaServletContextTest method testContentTypeWithNullEncodingGetsConvertedProperlyUponFinalize.
@Test
public void testContentTypeWithNullEncodingGetsConvertedProperlyUponFinalize() {
// init the context
context.init(servletContext, httpServletRequest, httpServletResponse);
// this must be Content-Type: application/json; encoding=utf-8
Result result = Results.json();
// force a characterset that is not there. Stupid but tests that its working.
result.charset(null);
context.finalizeHeaders(result);
// make sure utf-8 is used under all circumstances:
verify(httpServletResponse).setCharacterEncoding(NinjaConstant.UTF_8);
}
use of ninja.Result in project ninja by ninjaframework.
the class NinjaServletContextTest method testContentTypeGetsConvertedProperlyUponFinalize.
@Test
public void testContentTypeGetsConvertedProperlyUponFinalize() {
// init the context
context.init(servletContext, httpServletRequest, httpServletResponse);
// this must be Content-Type: application/json; encoding=utf-8
Result result = Results.json();
context.finalizeHeaders(result);
verify(httpServletResponse).setCharacterEncoding(result.getCharset());
verify(httpServletResponse).setContentType(result.getContentType());
}
Aggregations