SPR-6785 - Improve message error when the MarshallingView modelKey attribute is not valid

This commit is contained in:
Arjen Poutsma
2010-02-01 15:25:29 +00:00
parent 1dbb64580c
commit 208c2d9c8b
2 changed files with 26 additions and 0 deletions

View File

@@ -71,6 +71,29 @@ public class MarshallingViewTests {
verify(marshallerMock);
}
@Test
public void renderInvalidModelKey() throws Exception {
Object toBeMarshalled = new Object();
String modelKey = "key";
view.setModelKey("invalidKey");
Map model = new HashMap();
model.put(modelKey, toBeMarshalled);
MockHttpServletRequest request = new MockHttpServletRequest();
MockHttpServletResponse response = new MockHttpServletResponse();
replay(marshallerMock);
try {
view.render(model, request, response);
fail("ServletException expected");
}
catch (ServletException ex) {
// expected
}
assertEquals("Invalid content length", 0, response.getContentLength());
verify(marshallerMock);
}
@Test
public void renderModelKeyUnsupported() throws Exception {
Object toBeMarshalled = new Object();