SPR-7047 - XML MarshallingView assumes non-null value for object to be marshalled.
This commit is contained in:
parent
8c8eca7e05
commit
9cecaa769e
|
|
@ -132,7 +132,7 @@ public class MarshallingView extends AbstractView {
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
for (Object o : model.values()) {
|
for (Object o : model.values()) {
|
||||||
if (this.marshaller.supports(o.getClass())) {
|
if (o != null && this.marshaller.supports(o.getClass())) {
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -94,6 +94,27 @@ public class MarshallingViewTests {
|
||||||
verify(marshallerMock);
|
verify(marshallerMock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void renderNullModelValue() throws Exception {
|
||||||
|
String modelKey = "key";
|
||||||
|
Map model = new HashMap();
|
||||||
|
model.put(modelKey, null);
|
||||||
|
|
||||||
|
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
|
@Test
|
||||||
public void renderModelKeyUnsupported() throws Exception {
|
public void renderModelKeyUnsupported() throws Exception {
|
||||||
Object toBeMarshalled = new Object();
|
Object toBeMarshalled = new Object();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue