diff --git a/org.springframework.beans/.classpath b/org.springframework.beans/.classpath
index 4636741915..29117f917c 100644
--- a/org.springframework.beans/.classpath
+++ b/org.springframework.beans/.classpath
@@ -11,7 +11,6 @@
-
diff --git a/org.springframework.beans/ivy.xml b/org.springframework.beans/ivy.xml
index f3c41e0271..d26d757c53 100644
--- a/org.springframework.beans/ivy.xml
+++ b/org.springframework.beans/ivy.xml
@@ -26,7 +26,6 @@
-
diff --git a/org.springframework.beans/src/test/java/org/springframework/beans/BeanUtilsTests.java b/org.springframework.beans/src/test/java/org/springframework/beans/BeanUtilsTests.java
index c682d03a71..8089c82996 100644
--- a/org.springframework.beans/src/test/java/org/springframework/beans/BeanUtilsTests.java
+++ b/org.springframework.beans/src/test/java/org/springframework/beans/BeanUtilsTests.java
@@ -30,6 +30,8 @@ import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceEditor;
+import test.beans.DerivedTestBean;
+
/**
* Unit tests for {@link BeanUtils}.
*
diff --git a/org.springframework.beans/src/test/java/org/springframework/beans/BeanWrapperEnumTests.java b/org.springframework.beans/src/test/java/org/springframework/beans/BeanWrapperEnumTests.java
index 75a063658a..43182fe69a 100644
--- a/org.springframework.beans/src/test/java/org/springframework/beans/BeanWrapperEnumTests.java
+++ b/org.springframework.beans/src/test/java/org/springframework/beans/BeanWrapperEnumTests.java
@@ -20,6 +20,9 @@ import static org.junit.Assert.*;
import org.junit.Test;
+import test.beans.CustomEnum;
+import test.beans.GenericBean;
+
/**
* @author Juergen Hoeller
* @author Chris Beams
diff --git a/org.springframework.beans/src/test/java/org/springframework/beans/BeanWrapperGenericsTests.java b/org.springframework.beans/src/test/java/org/springframework/beans/BeanWrapperGenericsTests.java
index 4091e87313..cbbdef1a34 100644
--- a/org.springframework.beans/src/test/java/org/springframework/beans/BeanWrapperGenericsTests.java
+++ b/org.springframework.beans/src/test/java/org/springframework/beans/BeanWrapperGenericsTests.java
@@ -38,6 +38,8 @@ import org.springframework.beans.propertyeditors.StringTrimmerEditor;
import org.springframework.core.io.Resource;
import org.springframework.core.io.UrlResource;
+import test.beans.GenericBean;
+
/**
* @author Juergen Hoeller
* @author Chris Beams
diff --git a/org.springframework.beans/src/test/java/org/springframework/beans/BeanWrapperTests.java b/org.springframework.beans/src/test/java/org/springframework/beans/BeanWrapperTests.java
index 74d7b4eaa3..cd3e4c181d 100644
--- a/org.springframework.beans/src/test/java/org/springframework/beans/BeanWrapperTests.java
+++ b/org.springframework.beans/src/test/java/org/springframework/beans/BeanWrapperTests.java
@@ -16,6 +16,8 @@
package org.springframework.beans;
+import static org.junit.Assert.*;
+
import java.beans.PropertyEditorSupport;
import java.math.BigDecimal;
import java.math.BigInteger;
@@ -34,11 +36,11 @@ import java.util.SortedMap;
import java.util.SortedSet;
import java.util.TreeMap;
import java.util.TreeSet;
+import java.util.Map.Entry;
-import junit.framework.TestCase;
import org.apache.commons.logging.LogFactory;
-import org.hibernate.FlushMode;
-
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowire;
import org.springframework.beans.propertyeditors.CustomNumberEditor;
import org.springframework.beans.propertyeditors.StringArrayPropertyEditor;
import org.springframework.beans.propertyeditors.StringTrimmerEditor;
@@ -46,14 +48,18 @@ import org.springframework.beans.support.DerivedFromProtectedBaseBean;
import org.springframework.util.StopWatch;
import org.springframework.util.StringUtils;
+import test.beans.BooleanTestBean;
+
/**
* @author Rod Johnson
* @author Juergen Hoeller
* @author Alef Arendsen
* @author Arjen Poutsma
+ * @author Chris Beams
*/
-public class BeanWrapperTests extends TestCase {
+public final class BeanWrapperTests {
+ @Test
public void testIsReadablePropertyNotReadable() {
NoRead nr = new NoRead();
BeanWrapper bw = new BeanWrapperImpl(nr);
@@ -63,12 +69,14 @@ public class BeanWrapperTests extends TestCase {
/**
* Shouldn't throw an exception: should just return false
*/
+ @Test
public void testIsReadablePropertyNoSuchProperty() {
NoRead nr = new NoRead();
BeanWrapper bw = new BeanWrapperImpl(nr);
assertFalse(bw.isReadableProperty("xxxxx"));
}
+ @Test
public void testIsReadablePropertyNull() {
NoRead nr = new NoRead();
BeanWrapper bw = new BeanWrapperImpl(nr);
@@ -81,6 +89,7 @@ public class BeanWrapperTests extends TestCase {
}
}
+ @Test
public void testIsWritablePropertyNull() {
NoRead nr = new NoRead();
BeanWrapper bw = new BeanWrapperImpl(nr);
@@ -93,6 +102,7 @@ public class BeanWrapperTests extends TestCase {
}
}
+ @Test
public void testReadableAndWritableForIndexedProperties() {
BeanWrapper bw = new BeanWrapperImpl(IndexedTestBean.class);
@@ -137,6 +147,7 @@ public class BeanWrapperTests extends TestCase {
assertFalse(bw.isWritableProperty("array[key1]"));
}
+ @Test
public void testTypeDeterminationForIndexedProperty() {
BeanWrapper bw = new BeanWrapperImpl(IndexedTestBean.class);
assertEquals(null, bw.getPropertyType("map[key0]"));
@@ -150,6 +161,7 @@ public class BeanWrapperTests extends TestCase {
assertEquals(String.class, bw.getPropertyType("map[key0]"));
}
+ @Test
public void testGetterThrowsException() {
GetterBean gb = new GetterBean();
BeanWrapper bw = new BeanWrapperImpl(gb);
@@ -157,6 +169,7 @@ public class BeanWrapperTests extends TestCase {
assertTrue("Set name to tom", gb.getName().equals("tom"));
}
+ @Test
public void testEmptyPropertyValuesSet() {
TestBean t = new TestBean();
int age = 50;
@@ -177,6 +190,7 @@ public class BeanWrapperTests extends TestCase {
}
}
+ @Test
public void testAllValid() {
TestBean t = new TestBean();
String newName = "tony";
@@ -199,6 +213,7 @@ public class BeanWrapperTests extends TestCase {
}
}
+ @Test
public void testBeanWrapperUpdates() {
TestBean t = new TestBean();
int newAge = 33;
@@ -215,6 +230,7 @@ public class BeanWrapperTests extends TestCase {
}
}
+ @Test
public void testValidNullUpdate() {
TestBean t = new TestBean();
t.setName("Frank"); // we need to change it back
@@ -229,6 +245,7 @@ public class BeanWrapperTests extends TestCase {
assertTrue("spouse is now null", t.getSpouse() == null);
}
+ @Test
public void testIgnoringIndexedProperty() {
MutablePropertyValues values = new MutablePropertyValues();
values.addPropertyValue("toBeIgnored[0]", new Integer(42));
@@ -236,6 +253,7 @@ public class BeanWrapperTests extends TestCase {
bw.setPropertyValues(values, true);
}
+ @Test
public void testConvertPrimitiveToString() {
MutablePropertyValues values = new MutablePropertyValues();
values.addPropertyValue("name", new Integer(42));
@@ -245,6 +263,7 @@ public class BeanWrapperTests extends TestCase {
assertEquals("42", tb.getName());
}
+ @Test
public void testConvertClassToString() {
MutablePropertyValues values = new MutablePropertyValues();
values.addPropertyValue("name", Integer.class);
@@ -259,6 +278,7 @@ public class BeanWrapperTests extends TestCase {
assertEquals(Integer.class.toString(), tb.getName());
}
+ @Test
public void testBooleanObject() {
BooleanTestBean tb = new BooleanTestBean();
BeanWrapper bw = new BeanWrapperImpl(tb);
@@ -273,6 +293,7 @@ public class BeanWrapperTests extends TestCase {
}
+ @Test
public void testNumberObjects() {
NumberTestBean tb = new NumberTestBean();
BeanWrapper bw = new BeanWrapperImpl(tb);
@@ -306,6 +327,7 @@ public class BeanWrapperTests extends TestCase {
assertTrue("Correct bigDecimal value", new BigDecimal("4.0").equals(tb.getBigDecimal()));
}
+ @Test
public void testNumberCoercion() {
NumberTestBean tb = new NumberTestBean();
BeanWrapper bw = new BeanWrapperImpl(tb);
@@ -339,18 +361,19 @@ public class BeanWrapperTests extends TestCase {
assertTrue("Correct bigDecimal value", new BigDecimal("4.0").equals(tb.getBigDecimal()));
}
+ @Test
public void testEnumByFieldName() {
EnumTester et = new EnumTester();
BeanWrapper bw = new BeanWrapperImpl(et);
- bw.setPropertyValue("flushMode", "MANUAL");
- assertEquals(FlushMode.MANUAL, et.getFlushMode());
+ bw.setPropertyValue("autowire", "BY_NAME");
+ assertEquals(Autowire.BY_NAME, et.getAutowire());
- bw.setPropertyValue("flushMode", " AUTO ");
- assertEquals(FlushMode.AUTO, et.getFlushMode());
+ bw.setPropertyValue("autowire", " BY_TYPE ");
+ assertEquals(Autowire.BY_TYPE, et.getAutowire());
try {
- bw.setPropertyValue("flushMode", "EVER");
+ bw.setPropertyValue("autowire", "NHERITED");
fail("Should have thrown TypeMismatchException");
}
catch (TypeMismatchException ex) {
@@ -358,6 +381,7 @@ public class BeanWrapperTests extends TestCase {
}
}
+ @Test
public void testPropertiesProperty() throws Exception {
PropsTester pt = new PropsTester();
BeanWrapper bw = new BeanWrapperImpl(pt);
@@ -375,6 +399,7 @@ public class BeanWrapperTests extends TestCase {
assertTrue("Freedom==slavery", freedomVal.equals("slavery"));
}
+ @Test
public void testStringArrayProperty() throws Exception {
PropsTester pt = new PropsTester();
BeanWrapper bw = new BeanWrapperImpl(pt);
@@ -384,7 +409,7 @@ public class BeanWrapperTests extends TestCase {
assertTrue("correct values", pt.stringArray[0].equals("foo") && pt.stringArray[1].equals("fi") &&
pt.stringArray[2].equals("fi") && pt.stringArray[3].equals("fum"));
- List list = new ArrayList();
+ List list = new ArrayList();
list.add("foo");
list.add("fi");
list.add("fi");
@@ -394,13 +419,13 @@ public class BeanWrapperTests extends TestCase {
assertTrue("correct values", pt.stringArray[0].equals("foo") && pt.stringArray[1].equals("fi") &&
pt.stringArray[2].equals("fi") && pt.stringArray[3].equals("fum"));
- Set set = new HashSet();
+ Set set = new HashSet();
set.add("foo");
set.add("fi");
set.add("fum");
bw.setPropertyValue("stringArray", set);
assertTrue("stringArray length = 3", pt.stringArray.length == 3);
- List result = Arrays.asList(pt.stringArray);
+ List result = Arrays.asList(pt.stringArray);
assertTrue("correct values", result.contains("foo") && result.contains("fi") && result.contains("fum"));
bw.setPropertyValue("stringArray", "one");
@@ -411,6 +436,7 @@ public class BeanWrapperTests extends TestCase {
assertTrue("stringArray is null", pt.stringArray == null);
}
+ @Test
public void testStringArrayPropertyWithCustomStringEditor() throws Exception {
PropsTester pt = new PropsTester();
BeanWrapper bw = new BeanWrapperImpl(pt);
@@ -425,7 +451,7 @@ public class BeanWrapperTests extends TestCase {
assertTrue("correct values", pt.stringArray[0].equals("foo") && pt.stringArray[1].equals("fi") &&
pt.stringArray[2].equals("fi") && pt.stringArray[3].equals("fum"));
- List list = new ArrayList();
+ List list = new ArrayList();
list.add("4foo");
list.add("7fi");
list.add("6fi");
@@ -435,13 +461,13 @@ public class BeanWrapperTests extends TestCase {
assertTrue("correct values", pt.stringArray[0].equals("foo") && pt.stringArray[1].equals("fi") &&
pt.stringArray[2].equals("fi") && pt.stringArray[3].equals("fum"));
- Set set = new HashSet();
+ Set set = new HashSet();
set.add("4foo");
set.add("7fi");
set.add("6fum");
bw.setPropertyValue("stringArray", set);
assertTrue("stringArray length = 3", pt.stringArray.length == 3);
- List result = Arrays.asList(pt.stringArray);
+ List result = Arrays.asList(pt.stringArray);
assertTrue("correct values", result.contains("foo") && result.contains("fi") && result.contains("fum"));
bw.setPropertyValue("stringArray", "8one");
@@ -449,6 +475,7 @@ public class BeanWrapperTests extends TestCase {
assertTrue("correct values", pt.stringArray[0].equals("one"));
}
+ @Test
public void testStringArrayPropertyWithStringSplitting() throws Exception {
PropsTester pt = new PropsTester();
BeanWrapperImpl bw = new BeanWrapperImpl(pt);
@@ -458,6 +485,7 @@ public class BeanWrapperTests extends TestCase {
assertTrue("correct values", pt.stringArray[0].equals("a1") && pt.stringArray[1].equals("b2"));
}
+ @Test
public void testStringArrayPropertyWithCustomStringDelimiter() throws Exception {
PropsTester pt = new PropsTester();
BeanWrapper bw = new BeanWrapperImpl(pt);
@@ -467,6 +495,7 @@ public class BeanWrapperTests extends TestCase {
assertTrue("correct values", pt.stringArray[0].equals("a1") && pt.stringArray[1].equals("b2"));
}
+ @Test
public void testStringPropertyWithCustomEditor() throws Exception {
TestBean tb = new TestBean();
BeanWrapper bw = new BeanWrapperImpl(tb);
@@ -488,6 +517,7 @@ public class BeanWrapperTests extends TestCase {
assertEquals("", tb.getName());
}
+ @Test
public void testIntArrayProperty() {
PropsTester pt = new PropsTester();
BeanWrapper bw = new BeanWrapperImpl(pt);
@@ -502,7 +532,7 @@ public class BeanWrapperTests extends TestCase {
assertTrue("correct values", pt.intArray[0] == 4 && pt.intArray[1] == 5 &&
pt.intArray[2] == 2 && pt.intArray[3] == 3);
- List list = new ArrayList();
+ List