You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ibatis.apache.org by cb...@apache.org on 2008/07/16 08:46:40 UTC

svn commit: r677173 - in /ibatis/trunk/java/mapper/mapper2: src/com/ibatis/common/beans/ComplexBeanProbe.java test/com/ibatis/common/beans/ComplexBeanProbeTest.java

Author: cbegin
Date: Tue Jul 15 23:46:39 2008
New Revision: 677173

URL: http://svn.apache.org/viewvc?rev=677173&view=rev
Log:
iBATIS 511

Added:
    ibatis/trunk/java/mapper/mapper2/test/com/ibatis/common/beans/ComplexBeanProbeTest.java
Modified:
    ibatis/trunk/java/mapper/mapper2/src/com/ibatis/common/beans/ComplexBeanProbe.java

Modified: ibatis/trunk/java/mapper/mapper2/src/com/ibatis/common/beans/ComplexBeanProbe.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/src/com/ibatis/common/beans/ComplexBeanProbe.java?rev=677173&r1=677172&r2=677173&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/src/com/ibatis/common/beans/ComplexBeanProbe.java (original)
+++ ibatis/trunk/java/mapper/mapper2/src/com/ibatis/common/beans/ComplexBeanProbe.java Tue Jul 15 23:46:39 2008
@@ -15,12 +15,11 @@
  */
 package com.ibatis.common.beans;
 
-import com.ibatis.sqlmap.engine.mapping.result.ResultObjectFactoryUtil;
-
-import java.lang.reflect.Method;
 import java.util.Map;
 import java.util.StringTokenizer;
 
+import com.ibatis.sqlmap.engine.mapping.result.ResultObjectFactoryUtil;
+
 /**
  * StaticBeanProbe provides methods that allow simple, reflective access to
  * JavaBeans style properties.  Methods are provided for all simple types as
@@ -364,9 +363,9 @@
       throw e;
     } catch (Throwable t) {
       if (object == null) {
-        throw new ProbeException("Could not set property '" + name + "' for null reference.  Cause: " + t.toString(), t);
+        throw new ProbeException("Could not set property '" + name + "' to value '"+value+"' for null reference.  Cause: " + t.toString(), t);
       } else {
-        throw new ProbeException("Could not set property '" + name + "' for " + object.getClass().getName() + ".  Cause: " + t.toString(), t);
+        throw new ProbeException("Could not set property '" + name + "' to value '"+value+"' for " + object.getClass().getName() + ".  Cause: " + t.toString(), t);
       }
     }
   }

Added: ibatis/trunk/java/mapper/mapper2/test/com/ibatis/common/beans/ComplexBeanProbeTest.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/test/com/ibatis/common/beans/ComplexBeanProbeTest.java?rev=677173&view=auto
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/test/com/ibatis/common/beans/ComplexBeanProbeTest.java (added)
+++ ibatis/trunk/java/mapper/mapper2/test/com/ibatis/common/beans/ComplexBeanProbeTest.java Tue Jul 15 23:46:39 2008
@@ -0,0 +1,41 @@
+package com.ibatis.common.beans;
+
+import junit.framework.TestCase;
+
+public class ComplexBeanProbeTest extends TestCase {
+
+	public void testSetObject() {
+		Test myTest = new Test();
+		Probe probe = ProbeFactory.getProbe(myTest);
+		probe.setObject(myTest, "myInt", Integer.valueOf(1));
+		assertEquals(1, myTest.getMyInt());
+		probe.setObject(myTest, "myInt", Integer.valueOf(2));
+		assertEquals(2, myTest.getMyInt());
+		try {
+			probe.setObject(myTest, "myInt", null);
+			fail();
+		} catch (RuntimeException e) {
+			assertTrue(e.getMessage().contains("'myInt' to value 'null'"));
+		}
+		try {
+			probe.setObject(myTest, "myInt", Float.valueOf(1.2f));
+			fail();
+		} catch (RuntimeException e) {
+      assertTrue(e.getMessage().contains("'myInt' to value '1.2'"));
+		}
+	}
+
+	public class Test {
+
+		int	myInt;
+
+		public int getMyInt() {
+			return myInt;
+		}
+
+		public void setMyInt(int myInt) {
+			this.myInt = myInt;
+		}
+	}
+
+}