DataBinder uses a default limit of 256 for array/collection auto-growing (SPR-7842)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
* Copyright 2002-2011 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,10 +19,11 @@ package org.springframework.beans;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* @author Keith Donald
|
||||
* @author Juergen Hoeller
|
||||
@@ -117,6 +118,19 @@ public class BeanWrapperAutoGrowingTests {
|
||||
assertNotNull(wrapper.getPropertyValue("list[3]"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPropertyValueAutoGrowListFailsAgainstLimit() {
|
||||
wrapper.setAutoGrowCollectionLimit(2);
|
||||
try {
|
||||
assertNotNull(wrapper.getPropertyValue("list[4]"));
|
||||
fail("Should have thrown InvalidPropertyException");
|
||||
}
|
||||
catch (InvalidPropertyException ex) {
|
||||
// expected
|
||||
assertTrue(ex.getRootCause() instanceof IndexOutOfBoundsException);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPropertyValueAutoGrowMultiDimensionalList() {
|
||||
assertNotNull(wrapper.getPropertyValue("multiList[0][0]"));
|
||||
@@ -135,6 +149,12 @@ public class BeanWrapperAutoGrowingTests {
|
||||
assertTrue(bean.getMap().get("A") instanceof Bean);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setNestedPropertyValueAutoGrowMap() {
|
||||
wrapper.setPropertyValue("map[A].nested", new Bean());
|
||||
assertTrue(bean.getMap().get("A").getNested() instanceof Bean);
|
||||
}
|
||||
|
||||
|
||||
public static class Bean {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user