From 07e9f1775be0b0fbf2e617f9964501b8af5a2aa2 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Sun, 20 Jun 2010 19:11:36 +0000 Subject: [PATCH] added test for invalid binding to ClassLoader --- .../validation/DataBinderTests.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/org.springframework.context/src/test/java/org/springframework/validation/DataBinderTests.java b/org.springframework.context/src/test/java/org/springframework/validation/DataBinderTests.java index c6b662fe8e..210944e24e 100644 --- a/org.springframework.context/src/test/java/org/springframework/validation/DataBinderTests.java +++ b/org.springframework.context/src/test/java/org/springframework/validation/DataBinderTests.java @@ -225,6 +225,22 @@ public class DataBinderTests extends TestCase { } } + public void testBindingWithSystemFieldError() throws Exception { + TestBean rod = new TestBean(); + DataBinder binder = new DataBinder(rod, "person"); + MutablePropertyValues pvs = new MutablePropertyValues(); + pvs.add("class.classLoader.URLs[0]", "http://myserver"); + binder.setIgnoreUnknownFields(false); + + try { + binder.bind(pvs); + fail("Should have thrown NotWritablePropertyException"); + } + catch (NotWritablePropertyException ex) { + assertTrue(ex.getMessage().contains("classLoader")); + } + } + public void testBindingWithErrorsAndCustomEditors() throws Exception { TestBean rod = new TestBean(); DataBinder binder = new DataBinder(rod, "person");