@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 testAutoGrowBeyondDefaultLimit() { TestBean testBean = new TestBean(); DataBinder binder = new DataBinder(testBean, "testBean"); MutablePropertyValues mpvs = new MutablePropertyValues(); mpvs.add("friends[256]", ""); try { binder.bind(mpvs); fail("Should have thrown InvalidPropertyException"); } catch (InvalidPropertyException ex) { // expected assertTrue(ex.getRootCause() instanceof IndexOutOfBoundsException); } }
@Test public void testAutoGrowBeyondCustomLimit() { TestBean testBean = new TestBean(); DataBinder binder = new DataBinder(testBean, "testBean"); binder.setAutoGrowCollectionLimit(10); MutablePropertyValues mpvs = new MutablePropertyValues(); mpvs.add("friends[16]", ""); try { binder.bind(mpvs); fail("Should have thrown InvalidPropertyException"); } catch (InvalidPropertyException ex) { // expected assertTrue(ex.getRootCause() instanceof IndexOutOfBoundsException); } }