You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by oh...@apache.org on 2013/11/08 22:08:33 UTC
svn commit: r1540186 [5/6] - in /commons/proper/beanutils/trunk: ./
src/changes/ src/main/java/org/apache/commons/beanutils/
src/main/java/org/apache/commons/beanutils/converters/
src/main/java/org/apache/commons/beanutils/locale/ src/test/java/org/apa...
Modified: commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/DynaBeanMapDecoratorTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/DynaBeanMapDecoratorTestCase.java?rev=1540186&r1=1540185&r2=1540186&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/DynaBeanMapDecoratorTestCase.java (original)
+++ commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/DynaBeanMapDecoratorTestCase.java Fri Nov 8 21:08:30 2013
@@ -24,6 +24,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
+
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
@@ -33,6 +34,7 @@ import junit.framework.TestSuite;
*
* @version $Id$
*/
+@SuppressWarnings("deprecation")
public class DynaBeanMapDecoratorTestCase extends TestCase {
private static final DynaProperty stringProp = new DynaProperty("stringProp", String.class);
@@ -47,14 +49,14 @@ public class DynaBeanMapDecoratorTestCas
private static String stringVal = "somevalue";
private static Integer intVal = new Integer(5);
private static Date dateVal = new Date();
- private final Map mapVal = new HashMap();
+ private final Map<Object, Object> mapVal = new HashMap<Object, Object>();
private final Object[] values = new Object[] {stringVal, null, intVal, dateVal, mapVal};
private BasicDynaBean dynaBean;
- private Map decoratedMap;
- private Map modifiableMap;
- private static final Map emptyMap = new DynaBeanMapDecorator(new BasicDynaBean(new BasicDynaClass()));
+ private Map<Object, Object> decoratedMap;
+ private Map<Object, Object> modifiableMap;
+ private static final Map<Object, Object> emptyMap = new DynaBeanMapDecorator(new BasicDynaBean(new BasicDynaClass()));
// ---------------------------------------------------------- Constructors
@@ -163,18 +165,20 @@ public class DynaBeanMapDecoratorTestCas
* Test entrySet() method
*/
public void testEntrySet() {
- Set set = modifiableMap.entrySet();
+ Set<Map.Entry<Object, Object>> set = modifiableMap.entrySet();
// Check the Set can't be modified
- checkUnmodifiable("entrySet()", set);
+ Map<Object, Object> m = new HashMap<Object, Object>();
+ m.put("key", "value");
+ checkUnmodifiable("entrySet()", set, m.entrySet().iterator().next());
assertEquals("entrySet size", properties.length, set.size());
- Iterator iterator = set.iterator();
- List namesList = new ArrayList();
+ Iterator<Map.Entry<Object, Object>> iterator = set.iterator();
+ List<String> namesList = new ArrayList<String>();
int i = 0;
while (iterator.hasNext()) {
- Map.Entry entry = (Map.Entry)iterator.next();
+ Map.Entry<Object, Object> entry = iterator.next();
String name = (String)entry.getKey();
namesList.add(name);
Object expectValue = decoratedMap.get(name);
@@ -216,10 +220,10 @@ public class DynaBeanMapDecoratorTestCas
* Test keySet() method
*/
public void testKeySet() {
- Set set = modifiableMap.keySet();
+ Set<Object> set = modifiableMap.keySet();
// Check the Set can't be modified
- checkUnmodifiable("keySet()", set);
+ checkUnmodifiable("keySet()", set, "xyz");
assertEquals("keySet size", properties.length, set.size());
@@ -256,7 +260,7 @@ public class DynaBeanMapDecoratorTestCas
public void testPutAll() {
String newValue = "ABC";
- Map newMap = new HashMap();
+ Map<Object, Object> newMap = new HashMap<Object, Object>();
newMap.put(stringProp.getName(), newValue);
// Test read only
@@ -303,15 +307,15 @@ public class DynaBeanMapDecoratorTestCas
* Test values() method
*/
public void testValues() {
- Collection collection = modifiableMap.values();
+ Collection<Object> collection = modifiableMap.values();
// Check the Collection can't be modified
- checkUnmodifiable("values()", collection);
+ checkUnmodifiable("values()", collection, "xyz");
assertEquals("values size", values.length, collection.size());
// Collection should be ordered in same sequence as properties
- Iterator iterator = collection.iterator();
+ Iterator<Object> iterator = collection.iterator();
int i = 0;
while (iterator.hasNext()) {
assertEquals("values("+i+")", values[i], iterator.next());
@@ -322,20 +326,18 @@ public class DynaBeanMapDecoratorTestCas
/**
* Check that a Collection is not modifiable
*/
- private void checkUnmodifiable(String desc, Collection collection) {
- String testVal = "xyz";
-
+ private <E> void checkUnmodifiable(String desc, Collection<E> collection, E addElem) {
// Check can't add()
try {
- collection.add(testVal);
+ collection.add(addElem);
fail(desc + ".add()");
} catch(UnsupportedOperationException ignore) {
// expected result
}
// Check can't addAll()
- List list = new ArrayList(1);
- list.add(testVal);
+ List<E> list = new ArrayList<E>(1);
+ list.add(addElem);
try {
collection.addAll(list);
fail(desc + ".addAll()");
Modified: commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/DynaBeanUtilsTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/DynaBeanUtilsTestCase.java?rev=1540186&r1=1540185&r2=1540186&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/DynaBeanUtilsTestCase.java (original)
+++ commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/DynaBeanUtilsTestCase.java Fri Nov 8 21:08:30 2013
@@ -25,8 +25,8 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import junit.framework.TestCase;
import junit.framework.Test;
+import junit.framework.TestCase;
import junit.framework.TestSuite;
@@ -125,7 +125,7 @@ public class DynaBeanUtilsTestCase exten
int intIndexed[] = { 0, 10, 20, 30, 40 };
bean.set("intIndexed", intIndexed);
bean.set("intProperty", new Integer(123));
- List listIndexed = new ArrayList();
+ List<String> listIndexed = new ArrayList<String>();
listIndexed.add("String 0");
listIndexed.add("String 1");
listIndexed.add("String 2");
@@ -133,15 +133,15 @@ public class DynaBeanUtilsTestCase exten
listIndexed.add("String 4");
bean.set("listIndexed", listIndexed);
bean.set("longProperty", new Long(321));
- HashMap mapProperty = new HashMap();
+ HashMap<String, Object> mapProperty = new HashMap<String, Object>();
mapProperty.put("First Key", "First Value");
mapProperty.put("Second Key", "Second Value");
bean.set("mapProperty", mapProperty);
- HashMap mappedProperty = new HashMap();
+ HashMap<String, Object> mappedProperty = new HashMap<String, Object>();
mappedProperty.put("First Key", "First Value");
mappedProperty.put("Second Key", "Second Value");
bean.set("mappedProperty", mappedProperty);
- HashMap mappedIntProperty = new HashMap();
+ HashMap<String, Integer> mappedIntProperty = new HashMap<String, Integer>();
mappedIntProperty.put("One", new Integer(1));
mappedIntProperty.put("Two", new Integer(2));
bean.set("mappedIntProperty", mappedIntProperty);
@@ -344,7 +344,7 @@ public class DynaBeanUtilsTestCase exten
*/
public void testCopyPropertiesMap() {
- Map map = new HashMap();
+ Map<String, Object> map = new HashMap<String, Object>();
map.put("booleanProperty", "false");
map.put("byteProperty", "111");
map.put("doubleProperty", "333.0");
@@ -475,7 +475,7 @@ public class DynaBeanUtilsTestCase exten
*/
public void testDescribe() {
- Map map = null;
+ Map<String, Object> map = null;
try {
map = PropertyUtils.describe(bean);
} catch (Exception e) {
@@ -526,7 +526,7 @@ public class DynaBeanUtilsTestCase exten
try {
- HashMap map = new HashMap();
+ HashMap<String, Object> map = new HashMap<String, Object>();
// int intArray[] = new int[] { 123, 456, 789 };
String intArrayIn[] = new String[] { "123", "456", "789" };
map.put("intArray", intArrayIn);
@@ -698,7 +698,7 @@ public class DynaBeanUtilsTestCase exten
try {
- HashMap map = new HashMap();
+ HashMap<String, Object> map = new HashMap<String, Object>();
map.put("intIndexed[0]", "100");
map.put("intIndexed[2]", "120");
map.put("intIndexed[4]", "140");
@@ -758,7 +758,7 @@ public class DynaBeanUtilsTestCase exten
try {
- HashMap map = new HashMap();
+ HashMap<String, Object> map = new HashMap<String, Object>();
map.put("mappedProperty(First Key)", "New First Value");
map.put("mappedProperty(Third Key)", "New Third Value");
@@ -792,7 +792,7 @@ public class DynaBeanUtilsTestCase exten
try {
- HashMap map = new HashMap();
+ HashMap<String, Object> map = new HashMap<String, Object>();
map.put("nested.booleanProperty", "false");
// booleanSecond is left at true
map.put("nested.doubleProperty", "432.0");
@@ -845,7 +845,7 @@ public class DynaBeanUtilsTestCase exten
bean.set("nullProperty", "non-null value");
- HashMap map = new HashMap();
+ HashMap<String, Object> map = new HashMap<String, Object>();
map.put("booleanProperty", "false");
// booleanSecond is left at true
map.put("doubleProperty", "432.0");
@@ -1150,17 +1150,17 @@ public class DynaBeanUtilsTestCase exten
*/
public void testCopyPropertyNestedMappedMap() throws Exception {
- Map origMap = new HashMap();
+ Map<String, Object> origMap = new HashMap<String, Object>();
origMap.put("First Key", "First Value");
origMap.put("Second Key", "Second Value");
- Map changedMap = new HashMap();
+ Map<String, Object> changedMap = new HashMap<String, Object>();
changedMap.put("First Key", "First Value");
changedMap.put("Second Key", "Second Value");
// No conversion required
BeanUtils.copyProperty(bean, "nested.mapProperty(Second Key)",
"New Second Value");
- checkMap((Map) bean.get("mapProperty"), origMap);
+ checkMap((Map<?, ?>) bean.get("mapProperty"), origMap);
changedMap.put("Second Key", "New Second Value");
checkMap(((TestBean) bean.get("nested")).getMapProperty(), changedMap);
@@ -1214,10 +1214,10 @@ public class DynaBeanUtilsTestCase exten
// Ensure that the actual Map matches the expected Map
- protected void checkMap(Map actual, Map expected) {
+ protected void checkMap(Map<?, ?> actual, Map<?, ?> expected) {
assertNotNull("actual map not null", actual);
assertEquals("actual map size", expected.size(), actual.size());
- Iterator keys = expected.keySet().iterator();
+ Iterator<?> keys = expected.keySet().iterator();
while (keys.hasNext()) {
Object key = keys.next();
assertEquals("actual map value(" + key + ")",
Modified: commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/DynaPropertyUtilsTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/DynaPropertyUtilsTestCase.java?rev=1540186&r1=1540185&r2=1540186&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/DynaPropertyUtilsTestCase.java (original)
+++ commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/DynaPropertyUtilsTestCase.java Fri Nov 8 21:08:30 2013
@@ -25,8 +25,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import junit.framework.TestCase;
import junit.framework.Test;
+import junit.framework.TestCase;
import junit.framework.TestSuite;
@@ -118,7 +118,7 @@ public class DynaPropertyUtilsTestCase e
int intIndexed[] = { 0, 10, 20, 30, 40 };
bean.set("intIndexed", intIndexed);
bean.set("intProperty", new Integer(123));
- List listIndexed = new ArrayList();
+ List<String> listIndexed = new ArrayList<String>();
listIndexed.add("String 0");
listIndexed.add("String 1");
listIndexed.add("String 2");
@@ -126,19 +126,19 @@ public class DynaPropertyUtilsTestCase e
listIndexed.add("String 4");
bean.set("listIndexed", listIndexed);
bean.set("longProperty", new Long(321));
- HashMap mapProperty = new HashMap();
+ HashMap<String, Object> mapProperty = new HashMap<String, Object>();
mapProperty.put("First Key", "First Value");
mapProperty.put("Second Key", "Second Value");
bean.set("mapProperty", mapProperty);
- HashMap mappedObjects = new HashMap();
+ HashMap<String, Object> mappedObjects = new HashMap<String, Object>();
mappedObjects.put("First Key", "First Value");
mappedObjects.put("Second Key", "Second Value");
bean.set("mappedObjects", mappedObjects);
- HashMap mappedProperty = new HashMap();
+ HashMap<String, Object> mappedProperty = new HashMap<String, Object>();
mappedProperty.put("First Key", "First Value");
mappedProperty.put("Second Key", "Second Value");
bean.set("mappedProperty", mappedProperty);
- HashMap mappedIntProperty = new HashMap();
+ HashMap<String, Integer> mappedIntProperty = new HashMap<String, Integer>();
mappedIntProperty.put("One", new Integer(1));
mappedIntProperty.put("Two", new Integer(2));
bean.set("mappedIntProperty", mappedIntProperty);
@@ -188,7 +188,7 @@ public class DynaPropertyUtilsTestCase e
*/
public void testCopyPropertiesMap() {
- Map map = new HashMap();
+ Map<String, Object> map = new HashMap<String, Object>();
map.put("booleanProperty", Boolean.FALSE);
map.put("doubleProperty", new Double(333.0));
map.put("dupProperty", new String[] { "New 0", "New 1", "New 2" });
@@ -245,7 +245,7 @@ public class DynaPropertyUtilsTestCase e
*/
public void testDescribe() {
- Map map = null;
+ Map<String, Object> map = null;
try {
map = PropertyUtils.describe(bean);
} catch (Exception e) {
@@ -1278,9 +1278,8 @@ public class DynaPropertyUtilsTestCase e
*/
public void testGetSimpleIndexed() {
- Object value = null;
try {
- value = PropertyUtils.getSimpleProperty(bean,
+ PropertyUtils.getSimpleProperty(bean,
"intIndexed[0]");
fail("Should have thrown IllegalArgumentException");
} catch (IllegalAccessException e) {
@@ -1355,9 +1354,8 @@ public class DynaPropertyUtilsTestCase e
*/
public void testGetSimpleNested() {
- Object value = null;
try {
- value = PropertyUtils.getSimpleProperty(bean,
+ PropertyUtils.getSimpleProperty(bean,
"nested.stringProperty");
fail("Should have thrown IllegaArgumentException");
} catch (IllegalAccessException e) {
Modified: commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/DynaResultSetTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/DynaResultSetTestCase.java?rev=1540186&r1=1540185&r2=1540186&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/DynaResultSetTestCase.java (original)
+++ commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/DynaResultSetTestCase.java Fri Nov 8 21:08:30 2013
@@ -22,8 +22,8 @@ package org.apache.commons.beanutils;
import java.math.BigDecimal;
import java.util.Iterator;
-import junit.framework.TestCase;
import junit.framework.Test;
+import junit.framework.TestCase;
import junit.framework.TestSuite;
@@ -178,7 +178,7 @@ public class DynaResultSetTestCase exten
public void testIteratorCount() {
- Iterator rows = dynaClass.iterator();
+ Iterator<?> rows = dynaClass.iterator();
assertNotNull("iterator exists", rows);
int n = 0;
while (rows.hasNext()) {
@@ -196,7 +196,7 @@ public class DynaResultSetTestCase exten
public void testIteratorResults() {
// Grab the third row
- Iterator rows = dynaClass.iterator();
+ Iterator<DynaBean> rows = dynaClass.iterator();
rows.next();
rows.next();
DynaBean row = (DynaBean) rows.next();
@@ -255,7 +255,7 @@ public class DynaResultSetTestCase exten
}
// Grab the third row
- Iterator rows = dynaClass.iterator();
+ Iterator<DynaBean> rows = dynaClass.iterator();
rows.next();
rows.next();
DynaBean row = (DynaBean) rows.next();
Modified: commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/DynaRowSetTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/DynaRowSetTestCase.java?rev=1540186&r1=1540185&r2=1540186&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/DynaRowSetTestCase.java (original)
+++ commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/DynaRowSetTestCase.java Fri Nov 8 21:08:30 2013
@@ -181,7 +181,7 @@ public class DynaRowSetTestCase extends
public void testListCount() {
- List rows = dynaClass.getRows();
+ List<DynaBean> rows = dynaClass.getRows();
assertNotNull("list exists", rows);
assertEquals("list row count", 5, rows.size());
@@ -191,8 +191,8 @@ public class DynaRowSetTestCase extends
public void testListResults() {
// Grab the third row
- List rows = dynaClass.getRows();
- DynaBean row = (DynaBean) rows.get(2);
+ List<DynaBean> rows = dynaClass.getRows();
+ DynaBean row = rows.get(2);
// Invalid argument test
try {
@@ -247,8 +247,8 @@ public class DynaRowSetTestCase extends
}
// Grab the third row
- List rows = dynaClass.getRows();
- DynaBean row = (DynaBean) rows.get(2);
+ List<DynaBean> rows = dynaClass.getRows();
+ DynaBean row = rows.get(2);
// Invalid argument test
try {
@@ -295,7 +295,7 @@ public class DynaRowSetTestCase extends
// created one with low limit
RowSetDynaClass limitedDynaClass = new RowSetDynaClass(TestResultSet.createProxy(), 3);
- List rows = limitedDynaClass.getRows();
+ List<DynaBean> rows = limitedDynaClass.getRows();
assertNotNull("list exists", rows);
assertEquals("limited row count", 3, rows.size());
@@ -329,8 +329,8 @@ public class DynaRowSetTestCase extends
assertEquals("Timestamp ResultSet Value", CustomTimestamp.class, resultSet.getObject("timestampProperty").getClass());
RowSetDynaClass inconsistentDynaClass = new RowSetDynaClass(resultSet);
- DynaBean firstRow = (DynaBean)inconsistentDynaClass.getRows().get(0);
- Class expectedType = null;
+ DynaBean firstRow = inconsistentDynaClass.getRows().get(0);
+ Class<?> expectedType = null;
DynaProperty property = null;
// Test Date
Modified: commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/ExtendMapBean.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/ExtendMapBean.java?rev=1540186&r1=1540185&r2=1540186&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/ExtendMapBean.java (original)
+++ commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/ExtendMapBean.java Fri Nov 8 21:08:30 2013
@@ -26,7 +26,7 @@ import java.util.Hashtable;
* @version $Id$
*/
-public class ExtendMapBean extends Hashtable {
+public class ExtendMapBean extends Hashtable<Object, Object> {
private String dbName = "[UNSET]";
Modified: commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/IndexedPropertyTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/IndexedPropertyTestCase.java?rev=1540186&r1=1540185&r2=1540186&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/IndexedPropertyTestCase.java (original)
+++ commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/IndexedPropertyTestCase.java Fri Nov 8 21:08:30 2013
@@ -17,10 +17,10 @@
package org.apache.commons.beanutils;
-import java.util.List;
-import java.util.ArrayList;
import java.beans.IndexedPropertyDescriptor;
import java.beans.PropertyDescriptor;
+import java.util.ArrayList;
+import java.util.List;
import junit.framework.Test;
import junit.framework.TestCase;
@@ -52,9 +52,9 @@ public class IndexedPropertyTestCase ext
private PropertyUtilsBean propertyUtilsBean;
private String[] testArray;
private String[] newArray;
- private List testList;
- private List newList;
- private ArrayList arrayList;
+ private List<String> testList;
+ private List<Object> newList;
+ private ArrayList<Object> arrayList;
// ---------------------------------------------------------- Constructors
@@ -85,17 +85,17 @@ public class IndexedPropertyTestCase ext
testArray= new String[] {"array-0", "array-1", "array-2"};
newArray = new String[] {"newArray-0", "newArray-1", "newArray-2"};
- testList = new ArrayList();
+ testList = new ArrayList<String>();
testList.add("list-0");
testList.add("list-1");
testList.add("list-2");
- newList = new ArrayList();
+ newList = new ArrayList<Object>();
newList.add("newList-0");
newList.add("newList-1");
newList.add("newList-2");
- arrayList = new ArrayList();
+ arrayList = new ArrayList<Object>();
arrayList.add("arrayList-0");
arrayList.add("arrayList-1");
arrayList.add("arrayList-2");
@@ -511,7 +511,7 @@ public class IndexedPropertyTestCase ext
beanUtilsBean.setProperty(bean, "stringList", newList);
Object value = bean.getStringList();
assertEquals("Type is different", newList.getClass(), value.getClass());
- List list = (List)value;
+ List<?> list = (List<?>)value;
assertEquals("List size is different", newList.size(), list.size());
for (int i = 0; i < list.size(); i++) {
assertEquals("Element " + i + " is different", newList.get(i), list.get(i));
@@ -571,7 +571,7 @@ public class IndexedPropertyTestCase ext
beanUtilsBean.setProperty(bean, "arrayList", newList);
Object value = bean.getArrayList();
assertEquals("Type is different", newList.getClass(), value.getClass());
- List list = (List)value;
+ List<?> list = (List<?>)value;
assertEquals("List size is different", newList.size(), list.size());
for (int i = 0; i < list.size(); i++) {
assertEquals("Element " + i + " is different", newList.get(i), list.get(i));
Modified: commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/IndexedTestBean.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/IndexedTestBean.java?rev=1540186&r1=1540185&r2=1540186&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/IndexedTestBean.java (original)
+++ commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/IndexedTestBean.java Fri Nov 8 21:08:30 2013
@@ -17,8 +17,8 @@
package org.apache.commons.beanutils;
-import java.util.List;
import java.util.ArrayList;
+import java.util.List;
/**
* Indexed Properties Test bean for JUnit tests for the "beanutils" component.
@@ -28,8 +28,8 @@ import java.util.ArrayList;
public class IndexedTestBean {
private String[] stringArray;
- private List stringList;
- private ArrayList arrayList;
+ private List<String> stringList;
+ private ArrayList<Object> arrayList;
// ----------------------------------------------------------- Constructors
@@ -71,14 +71,14 @@ public class IndexedTestBean {
/**
* Getter for the java.util.List property.
*/
- public List getStringList() {
+ public List<String> getStringList() {
return stringList;
}
/**
* Setter for the java.util.List property.
*/
- public void setStringList(List stringList) {
+ public void setStringList(List<String> stringList) {
this.stringList = stringList;
}
@@ -86,7 +86,7 @@ public class IndexedTestBean {
* Indexed Getter for the java.util.List property.
*/
public String getStringList(int index) {
- return (String)stringList.get(index);
+ return stringList.get(index);
}
/**
@@ -99,14 +99,14 @@ public class IndexedTestBean {
/**
* Getter for the java.util.ArrayList property.
*/
- public ArrayList getArrayList() {
+ public ArrayList<Object> getArrayList() {
return arrayList;
}
/**
* Setter for the java.util.ArrayList property.
*/
- public void setArrayList(ArrayList arrayList) {
+ public void setArrayList(ArrayList<Object> arrayList) {
this.arrayList = arrayList;
}
Modified: commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/LazyDynaBeanTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/LazyDynaBeanTestCase.java?rev=1540186&r1=1540185&r2=1540186&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/LazyDynaBeanTestCase.java (original)
+++ commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/LazyDynaBeanTestCase.java Fri Nov 8 21:08:30 2013
@@ -16,13 +16,14 @@
*/
package org.apache.commons.beanutils;
-import java.util.HashMap;
-import java.util.TreeMap;
+import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.LinkedList;
-import java.lang.reflect.InvocationTargetException;
-import junit.framework.TestCase;
+import java.util.TreeMap;
+
import junit.framework.Test;
+import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
@@ -170,12 +171,12 @@ public class LazyDynaBeanTestCase extend
bean.set(testProperty, testKey, testInteger1);
assertEquals("Check Mapped Property exists", HashMap.class, bean.get(testProperty).getClass());
assertEquals("Check First Mapped Value is correct(a)", testInteger1, bean.get(testProperty, testKey));
- assertEquals("Check First Mapped Value is correct(b)", testInteger1, ((HashMap)bean.get(testProperty)).get(testKey));
+ assertEquals("Check First Mapped Value is correct(b)", testInteger1, ((HashMap<?, ?>)bean.get(testProperty)).get(testKey));
// Set the property again - should set the new value
bean.set(testProperty, testKey, testInteger2);
assertEquals("Check Second Mapped Value is correct(a)", testInteger2, bean.get(testProperty, testKey));
- assertEquals("Check Second Mapped Value is correct(b)", testInteger2, ((HashMap)bean.get(testProperty)).get(testKey));
+ assertEquals("Check Second Mapped Value is correct(b)", testInteger2, ((HashMap<?, ?>)bean.get(testProperty)).get(testKey));
}
/**
@@ -197,12 +198,12 @@ public class LazyDynaBeanTestCase extend
bean.set(testProperty, testKey, testInteger1);
assertEquals("Check Mapped Property exists", TreeMap.class, bean.get(testProperty).getClass());
assertEquals("Check First Mapped Value is correct(a)", testInteger1, bean.get(testProperty, testKey));
- assertEquals("Check First Mapped Value is correct(b)", testInteger1, ((TreeMap)bean.get(testProperty)).get(testKey));
+ assertEquals("Check First Mapped Value is correct(b)", testInteger1, ((TreeMap<?, ?>)bean.get(testProperty)).get(testKey));
// Set the property again - should set the new value
bean.set(testProperty, testKey, testInteger2);
assertEquals("Check Second Mapped Value is correct(a)", testInteger2, bean.get(testProperty, testKey));
- assertEquals("Check Second Mapped Value is correct(b)", testInteger2, ((TreeMap)bean.get(testProperty)).get(testKey));
+ assertEquals("Check Second Mapped Value is correct(b)", testInteger2, ((TreeMap<?, ?>)bean.get(testProperty)).get(testKey));
}
/**
@@ -290,13 +291,13 @@ public class LazyDynaBeanTestCase extend
assertNotNull("Check Indexed Property is not null", bean.get(testProperty));
assertEquals("Check Indexed Property is correct type", ArrayList.class, bean.get(testProperty).getClass());
assertEquals("Check First Indexed Value is correct", testInteger1, bean.get(testProperty, index));
- assertEquals("Check First Array length is correct", new Integer(index+1), new Integer(((ArrayList)bean.get(testProperty)).size()));
+ assertEquals("Check First Array length is correct", new Integer(index+1), new Integer(((ArrayList<?>)bean.get(testProperty)).size()));
// Set a second indexed value, should automatically grow the ArrayList and set appropriate indexed value
index = index + 2;
bean.set(testProperty, index, testString1);
assertEquals("Check Second Indexed Value is correct", testString1, bean.get(testProperty, index));
- assertEquals("Check Second Array length is correct", new Integer(index+1), new Integer(((ArrayList)bean.get(testProperty)).size()));
+ assertEquals("Check Second Array length is correct", new Integer(index+1), new Integer(((ArrayList<?>)bean.get(testProperty)).size()));
}
/**
@@ -320,13 +321,13 @@ public class LazyDynaBeanTestCase extend
bean.set(testProperty, index, testString1);
assertEquals("Check Property type is correct", LinkedList.class, bean.get(testProperty).getClass());
assertEquals("Check First Indexed Value is correct", testString1, bean.get(testProperty, index));
- assertEquals("Check First Array length is correct", new Integer(index+1), new Integer(((LinkedList)bean.get(testProperty)).size()));
+ assertEquals("Check First Array length is correct", new Integer(index+1), new Integer(((LinkedList<?>)bean.get(testProperty)).size()));
// Set a second indexed value, should automatically grow the LinkedList and set appropriate indexed value
index = index + 2;
bean.set(testProperty, index, testInteger1);
assertEquals("Check Second Indexed Value is correct", testInteger1, bean.get(testProperty, index));
- assertEquals("Check Second Array length is correct", new Integer(index+1), new Integer(((LinkedList)bean.get(testProperty)).size()));
+ assertEquals("Check Second Array length is correct", new Integer(index+1), new Integer(((LinkedList<?>)bean.get(testProperty)).size()));
}
/**
Modified: commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/LazyDynaListTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/LazyDynaListTestCase.java?rev=1540186&r1=1540185&r2=1540186&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/LazyDynaListTestCase.java (original)
+++ commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/LazyDynaListTestCase.java Fri Nov 8 21:08:30 2013
@@ -16,17 +16,18 @@
*/
package org.apache.commons.beanutils;
-import java.util.List;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.TreeMap;
-import java.util.ArrayList;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
-import junit.framework.TestCase;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
import junit.framework.Test;
+import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
@@ -43,8 +44,8 @@ public class LazyDynaListTestCase extend
new DynaProperty(BASIC_PROP1, String.class),
new DynaProperty(BASIC_PROP2, HashMap.class)};
- protected DynaClass treeMapDynaClass = new LazyDynaMap(new TreeMap());
- protected DynaClass hashMapDynaClass = new LazyDynaMap(new HashMap());
+ protected DynaClass treeMapDynaClass = new LazyDynaMap(new TreeMap<String, Object>());
+ protected DynaClass hashMapDynaClass = new LazyDynaMap(new HashMap<String, Object>());
protected DynaClass pojoDynaClass = new WrapDynaBean(new TestBean()).getDynaClass();
protected DynaClass basicDynaClass = new BasicDynaClass("test", BasicDynaBean.class, properties);
@@ -174,15 +175,16 @@ public class LazyDynaListTestCase extend
/**
* Test Collection
*/
- public void testCollection(LazyDynaList list, Class testClass, DynaClass testDynaClass, Object wrongBean) {
+ public void testCollection(LazyDynaList list, Class<?> testClass, DynaClass testDynaClass, Object wrongBean) {
// ----- Create Collection & Array of Maps -----
int size = 5;
- List testList = new ArrayList(size);
- TreeMap[] testArray = new TreeMap[size];
+ List<Object> testList = new ArrayList<Object>(size);
+ TreeMap<?, ?>[] testArray = new TreeMap[size];
for (int i = 0; i < size; i++) {
- testArray[i] = new TreeMap();
- testArray[i].put("prop"+i, "val"+i);
+ TreeMap<String, Object> map = new TreeMap<String, Object>();
+ map.put("prop"+i, "val"+i);
+ testArray[i] = map;
testList.add(testArray[i]);
}
@@ -192,7 +194,7 @@ public class LazyDynaListTestCase extend
assertEquals("1. check size", size, lazyList.size());
DynaBean[] dynaArray = lazyList.toDynaBeanArray();
- TreeMap[] mapArray = (TreeMap[])lazyList.toArray();
+ TreeMap<?, ?>[] mapArray = (TreeMap[])lazyList.toArray();
// Check values
assertEquals("2. check size", size, dynaArray.length);
@@ -226,13 +228,13 @@ public class LazyDynaListTestCase extend
*/
public void testNullType() {
LazyDynaList lazyList = new LazyDynaList();
- lazyList.add(new HashMap());
+ lazyList.add(new HashMap<String, Object>());
}
/**
* Test DynaBean Create
*/
- private void dynaBeanTest(LazyDynaList list, Class testClass, DynaClass testDynaClass, Object wrongBean) {
+ private void dynaBeanTest(LazyDynaList list, Class<?> testClass, DynaClass testDynaClass, Object wrongBean) {
// Test get(index) created correct DynaBean - Second
Object dynaBean = list.get(1);
@@ -276,7 +278,7 @@ public class LazyDynaListTestCase extend
}
// Create Collection
- List collection = new ArrayList();
+ List<Object> collection = new ArrayList<Object>();
try {
collection.add(testDynaClass.newInstance());
collection.add(testDynaClass.newInstance());
@@ -339,7 +341,7 @@ public class LazyDynaListTestCase extend
/**
* Test Map Create
*/
- private void mapTest(LazyDynaList list, Class testClass, Object wrongBean) {
+ private void mapTest(LazyDynaList list, Class<?> testClass, Object wrongBean) {
// Test get(index) created correct DynaBean - First
Object dynaBean = list.get(0);
@@ -355,7 +357,7 @@ public class LazyDynaListTestCase extend
Object array = list.toArray();
assertNotNull("5. Array Not Created", array);
assertEquals("6. Not Map[]", testClass, array.getClass().getComponentType());
- Map[] mapArray = (Map[])array;
+ Map<?, ?>[] mapArray = (Map[])array;
assertEquals("7. Array Size Wrong", 1, mapArray.length);
// Test get(index) created correct DynaBean - Third
@@ -388,7 +390,7 @@ public class LazyDynaListTestCase extend
/**
* Test Pojo Create
*/
- private void pojoTest(LazyDynaList list, Class testClass, Object wrongBean) {
+ private void pojoTest(LazyDynaList list, Class<?> testClass, Object wrongBean) {
// Test get(index) created correct DynaBean - First
Object dynaBean = list.get(0);
@@ -568,4 +570,51 @@ public class LazyDynaListTestCase extend
}
-}
\ No newline at end of file
+ /**
+ * Tests toArray() if the list contains DynaBean objects.
+ */
+ public void testToArrayDynaBeans() {
+ LazyDynaList list = new LazyDynaList(LazyDynaBean.class);
+ LazyDynaBean elem = new LazyDynaBean();
+ list.add(elem);
+ LazyDynaBean[] beans = new LazyDynaBean[1];
+ assertSame("Wrong array", beans, list.toArray(beans));
+ assertSame("Wrong element", elem, beans[0]);
+ }
+
+ /**
+ * Tests toArray() if the list contains maps.
+ */
+ public void testToArrayMapType() {
+ LazyDynaList list = new LazyDynaList(HashMap.class);
+ HashMap<String, Object> elem = new HashMap<String, Object>();
+ list.add(elem);
+ Map<?, ?>[] array = new Map[1];
+ assertSame("Wrong array", array, list.toArray(array));
+ assertEquals("Wrong element", elem, array[0]);
+ }
+
+ /**
+ * Tests toArray() for other bean elements.
+ */
+ public void testToArrayOtherType() {
+ LazyDynaList list = new LazyDynaList(TestBean.class);
+ TestBean elem = new TestBean();
+ list.add(elem);
+ TestBean[] array = new TestBean[1];
+ assertSame("Wrong array", array, list.toArray(array));
+ assertEquals("Wrong element", elem, array[0]);
+ }
+
+ /**
+ * Tests toArray() if the array's size does not fit the collection size.
+ */
+ public void testToArrayUnsufficientSize() {
+ LazyDynaList list = new LazyDynaList(LazyDynaBean.class);
+ LazyDynaBean elem = new LazyDynaBean();
+ list.add(elem);
+ LazyDynaBean[] array = (LazyDynaBean[]) list.toArray(new LazyDynaBean[0]);
+ assertEquals("Wrong array size", 1, array.length);
+ assertEquals("Wrong element", elem, array[0]);
+ }
+}
Modified: commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/LazyDynaMapTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/LazyDynaMapTestCase.java?rev=1540186&r1=1540185&r2=1540186&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/LazyDynaMapTestCase.java (original)
+++ commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/LazyDynaMapTestCase.java Fri Nov 8 21:08:30 2013
@@ -16,15 +16,16 @@
*/
package org.apache.commons.beanutils;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.TreeMap;
-import java.util.List;
+import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.LinkedList;
-import java.lang.reflect.InvocationTargetException;
-import junit.framework.TestCase;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
import junit.framework.Test;
+import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
@@ -160,12 +161,12 @@ public class LazyDynaMapTestCase extends
dynaMap.set(testProperty, testKey, testInteger1);
assertEquals("Check Mapped Property exists", HashMap.class, dynaMap.get(testProperty).getClass());
assertEquals("Check First Mapped Value is correct(a)", testInteger1, dynaMap.get(testProperty, testKey));
- assertEquals("Check First Mapped Value is correct(b)", testInteger1, ((HashMap)dynaMap.get(testProperty)).get(testKey));
+ assertEquals("Check First Mapped Value is correct(b)", testInteger1, ((HashMap<?, ?>)dynaMap.get(testProperty)).get(testKey));
// Set the property again - should set the new value
dynaMap.set(testProperty, testKey, testInteger2);
assertEquals("Check Second Mapped Value is correct(a)", testInteger2, dynaMap.get(testProperty, testKey));
- assertEquals("Check Second Mapped Value is correct(b)", testInteger2, ((HashMap)dynaMap.get(testProperty)).get(testKey));
+ assertEquals("Check Second Mapped Value is correct(b)", testInteger2, ((HashMap<?, ?>)dynaMap.get(testProperty)).get(testKey));
}
/**
@@ -187,12 +188,12 @@ public class LazyDynaMapTestCase extends
dynaMap.set(testProperty, testKey, testInteger1);
assertEquals("Check Mapped Property exists", TreeMap.class, dynaMap.get(testProperty).getClass());
assertEquals("Check First Mapped Value is correct(a)", testInteger1, dynaMap.get(testProperty, testKey));
- assertEquals("Check First Mapped Value is correct(b)", testInteger1, ((TreeMap)dynaMap.get(testProperty)).get(testKey));
+ assertEquals("Check First Mapped Value is correct(b)", testInteger1, ((TreeMap<?, ?>)dynaMap.get(testProperty)).get(testKey));
// Set the property again - should set the new value
dynaMap.set(testProperty, testKey, testInteger2);
assertEquals("Check Second Mapped Value is correct(a)", testInteger2, dynaMap.get(testProperty, testKey));
- assertEquals("Check Second Mapped Value is correct(b)", testInteger2, ((TreeMap)dynaMap.get(testProperty)).get(testKey));
+ assertEquals("Check Second Mapped Value is correct(b)", testInteger2, ((TreeMap<?, ?>)dynaMap.get(testProperty)).get(testKey));
}
/**
@@ -280,13 +281,13 @@ public class LazyDynaMapTestCase extends
assertNotNull("Check Indexed Property is not null", dynaMap.get(testProperty));
assertEquals("Check Indexed Property is correct type", ArrayList.class, dynaMap.get(testProperty).getClass());
assertEquals("Check First Indexed Value is correct", testInteger1, dynaMap.get(testProperty, index));
- assertEquals("Check First Array length is correct", new Integer(index+1), new Integer(((ArrayList)dynaMap.get(testProperty)).size()));
+ assertEquals("Check First Array length is correct", new Integer(index+1), new Integer(((ArrayList<?>)dynaMap.get(testProperty)).size()));
// Set a second indexed value, should automatically grow the ArrayList and set appropriate indexed value
index = index + 2;
dynaMap.set(testProperty, index, testString1);
assertEquals("Check Second Indexed Value is correct", testString1, dynaMap.get(testProperty, index));
- assertEquals("Check Second Array length is correct", new Integer(index+1), new Integer(((ArrayList)dynaMap.get(testProperty)).size()));
+ assertEquals("Check Second Array length is correct", new Integer(index+1), new Integer(((ArrayList<?>)dynaMap.get(testProperty)).size()));
}
/**
@@ -310,13 +311,13 @@ public class LazyDynaMapTestCase extends
dynaMap.set(testProperty, index, testString1);
assertEquals("Check Property type is correct", LinkedList.class, dynaMap.get(testProperty).getClass());
assertEquals("Check First Indexed Value is correct", testString1, dynaMap.get(testProperty, index));
- assertEquals("Check First Array length is correct", new Integer(index+1), new Integer(((LinkedList)dynaMap.get(testProperty)).size()));
+ assertEquals("Check First Array length is correct", new Integer(index+1), new Integer(((LinkedList<?>)dynaMap.get(testProperty)).size()));
// Set a second indexed value, should automatically grow the LinkedList and set appropriate indexed value
index = index + 2;
dynaMap.set(testProperty, index, testInteger1);
assertEquals("Check Second Indexed Value is correct", testInteger1, dynaMap.get(testProperty, index));
- assertEquals("Check Second Array length is correct", new Integer(index+1), new Integer(((LinkedList)dynaMap.get(testProperty)).size()));
+ assertEquals("Check Second Array length is correct", new Integer(index+1), new Integer(((LinkedList<?>)dynaMap.get(testProperty)).size()));
}
/**
@@ -495,16 +496,16 @@ public class LazyDynaMapTestCase extends
// Create LazyDynaMap using TreeMap
// containing some properties
- LazyDynaMap orig = new LazyDynaMap(new TreeMap());
+ LazyDynaMap orig = new LazyDynaMap(new TreeMap<String, Object>());
orig.set("indexProp", 0, "indexVal0");
orig.set("indexProp", 1, "indexVal1");
- assertEquals("Index prop size", 2, ((List)orig.get("indexProp")).size());
+ assertEquals("Index prop size", 2, ((List<?>)orig.get("indexProp")).size());
LazyDynaMap newOne = (LazyDynaMap)orig.newInstance();
- Map newMap = newOne.getMap();
+ Map<String, Object> newMap = newOne.getMap();
assertEquals("Check Map type", TreeMap.class, newMap.getClass());
- ArrayList indexProp = (ArrayList)newMap.get("indexProp");
+ ArrayList<?> indexProp = (ArrayList<?>)newMap.get("indexProp");
assertNotNull("Indexed Prop missing", indexProp);
assertEquals("Index prop size", 0, indexProp.size());
}
Modified: commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/MappedPropertyTestBean.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/MappedPropertyTestBean.java?rev=1540186&r1=1540185&r2=1540186&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/MappedPropertyTestBean.java (original)
+++ commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/MappedPropertyTestBean.java Fri Nov 8 21:08:30 2013
@@ -29,8 +29,8 @@ import java.util.Map;
public class MappedPropertyTestBean {
- private final Map map = new HashMap();
- private final Map myMap = new HashMap();
+ private final Map<Object, Object> map = new HashMap<Object, Object>();
+ private final Map<Object, Object> myMap = new HashMap<Object, Object>();
// -------------------------------------------------------------- Properties
@@ -78,7 +78,7 @@ public class MappedPropertyTestBean {
public String getInvalidGetter(String key, String other) {
return (String) map.get(key);
}
- public Map getMyMap() {
+ public Map<Object, Object> getMyMap() {
return myMap;
}
Modified: commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/MappedPropertyTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/MappedPropertyTestCase.java?rev=1540186&r1=1540185&r2=1540186&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/MappedPropertyTestCase.java (original)
+++ commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/MappedPropertyTestCase.java Fri Nov 8 21:08:30 2013
@@ -16,11 +16,9 @@
*/
package org.apache.commons.beanutils;
-import junit.framework.TestCase;
import junit.framework.Test;
+import junit.framework.TestCase;
import junit.framework.TestSuite;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
/**
* <p>Test Case for the <code>MappedPropertyDescriptor</code>.</p>
@@ -29,9 +27,6 @@ import org.apache.commons.logging.LogFac
*/
public class MappedPropertyTestCase extends TestCase {
- private static final Log log = LogFactory.getLog(MappedPropertyTestCase.class);
-
-
// ---------------------------------------------------------- Constructors
/**
@@ -80,7 +75,7 @@ public class MappedPropertyTestCase exte
*/
public void testFound() {
String property = "mapproperty";
- Class clazz = MappedPropertyTestBean.class;
+ Class<?> clazz = MappedPropertyTestBean.class;
try {
MappedPropertyDescriptor desc
= new MappedPropertyDescriptor(property, clazz);
@@ -96,7 +91,7 @@ public class MappedPropertyTestCase exte
*/
public void testBooleanMapped() {
String property = "mappedBoolean";
- Class clazz = MappedPropertyTestBean.class;
+ Class<?> clazz = MappedPropertyTestBean.class;
try {
MappedPropertyDescriptor desc
= new MappedPropertyDescriptor(property, clazz);
@@ -112,10 +107,9 @@ public class MappedPropertyTestCase exte
*/
public void testNotFound() {
String property = "xxxxxxx";
- Class clazz = MappedPropertyTestBean.class;
+ Class<?> clazz = MappedPropertyTestBean.class;
try {
- MappedPropertyDescriptor desc
- = new MappedPropertyDescriptor(property, clazz);
+ new MappedPropertyDescriptor(property, clazz);
fail("Property '" + property + "' found in " + clazz.getName());
} catch (Exception ex) {
// expected result
@@ -127,7 +121,7 @@ public class MappedPropertyTestCase exte
*/
public void testMappedGetterOnly() {
String property = "mappedGetterOnly";
- Class clazz = MappedPropertyTestBean.class;
+ Class<?> clazz = MappedPropertyTestBean.class;
try {
MappedPropertyDescriptor desc
= new MappedPropertyDescriptor(property, clazz);
@@ -143,7 +137,7 @@ public class MappedPropertyTestCase exte
*/
public void testMappedSetterOnly() {
String property = "mappedSetterOnly";
- Class clazz = MappedPropertyTestBean.class;
+ Class<?> clazz = MappedPropertyTestBean.class;
try {
MappedPropertyDescriptor desc
= new MappedPropertyDescriptor(property, clazz);
@@ -159,7 +153,7 @@ public class MappedPropertyTestCase exte
*/
public void testInvalidSetter() {
String property = "invalidSetter";
- Class clazz = MappedPropertyTestBean.class;
+ Class<?> clazz = MappedPropertyTestBean.class;
try {
MappedPropertyDescriptor desc
= new MappedPropertyDescriptor(property, clazz);
@@ -175,7 +169,7 @@ public class MappedPropertyTestCase exte
*/
public void testInvalidGetter() {
String property = "invalidGetter";
- Class clazz = MappedPropertyTestBean.class;
+ Class<?> clazz = MappedPropertyTestBean.class;
try {
MappedPropertyDescriptor desc
= new MappedPropertyDescriptor(property, clazz);
@@ -195,7 +189,7 @@ public class MappedPropertyTestCase exte
*/
public void testDifferentTypes() {
String property = "differentTypes";
- Class clazz = MappedPropertyTestBean.class;
+ Class<?> clazz = MappedPropertyTestBean.class;
try {
MappedPropertyDescriptor desc
= new MappedPropertyDescriptor(property, clazz);
@@ -207,12 +201,10 @@ public class MappedPropertyTestCase exte
}
/**
- * Test Mpa getter
+ * Test Map getter
*/
public void testMapGetter() {
MappedPropertyTestBean bean = new MappedPropertyTestBean();
- Class clazz = MappedPropertyTestBean.class;
- String property = "myMap";
try {
String testValue = "test value";
String testKey = "testKey";
@@ -229,7 +221,7 @@ public class MappedPropertyTestCase exte
*/
public void testAnyArgsProperty() {
String property = "anyMapped";
- Class clazz = MappedPropertyTestBean.class;
+ Class<?> clazz = MappedPropertyTestBean.class;
try {
MappedPropertyDescriptor desc
= new MappedPropertyDescriptor(property, clazz);
@@ -241,11 +233,11 @@ public class MappedPropertyTestCase exte
}
/**
- * Test property with two primitve args
+ * Test property with two primitive args
*/
public void testPrimitiveArgsProperty() {
String property = "mappedPrimitive";
- Class clazz = MappedPropertyTestBean.class;
+ Class<?> clazz = MappedPropertyTestBean.class;
try {
MappedPropertyDescriptor desc
= new MappedPropertyDescriptor(property, clazz);
@@ -261,10 +253,9 @@ public class MappedPropertyTestCase exte
*/
public void testProtected() {
String property = "protectedProperty";
- Class clazz = MappedPropertyTestBean.class;
+ Class<?> clazz = MappedPropertyTestBean.class;
try {
- MappedPropertyDescriptor desc
- = new MappedPropertyDescriptor(property, clazz);
+ new MappedPropertyDescriptor(property, clazz);
fail("Property '" + property + "' found in " + clazz.getName());
} catch (Exception ex) {
// expected result
@@ -277,7 +268,7 @@ public class MappedPropertyTestCase exte
*/
public void testPublicParentMethod() {
String property = "mapproperty";
- Class clazz = MappedPropertyChildBean.class;
+ Class<?> clazz = MappedPropertyChildBean.class;
try {
MappedPropertyDescriptor desc
= new MappedPropertyDescriptor(property, clazz);
@@ -293,10 +284,9 @@ public class MappedPropertyTestCase exte
*/
public void testProtectedParentMethod() {
String property = "protectedMapped";
- Class clazz = MappedPropertyChildBean.class;
+ Class<?> clazz = MappedPropertyChildBean.class;
try {
- MappedPropertyDescriptor desc
- = new MappedPropertyDescriptor(property, clazz);
+ new MappedPropertyDescriptor(property, clazz);
fail("Property '" + property + "' found in " + clazz.getName());
} catch (Exception ex) {
}
@@ -308,7 +298,7 @@ public class MappedPropertyTestCase exte
*/
public void testInterfaceMapped() {
String property = "mapproperty";
- Class clazz = MappedPropertyTestInterface.class;
+ Class<?> clazz = MappedPropertyTestInterface.class;
try {
MappedPropertyDescriptor desc
= new MappedPropertyDescriptor(property, clazz);
@@ -324,10 +314,9 @@ public class MappedPropertyTestCase exte
*/
public void testInterfaceNotFound() {
String property = "XXXXXX";
- Class clazz = MappedPropertyTestInterface.class;
+ Class<?> clazz = MappedPropertyTestInterface.class;
try {
- MappedPropertyDescriptor desc
- = new MappedPropertyDescriptor(property, clazz);
+ new MappedPropertyDescriptor(property, clazz);
fail("Property '" + property + "' found in " + clazz.getName());
} catch (Exception ex) {
}
@@ -338,7 +327,7 @@ public class MappedPropertyTestCase exte
*/
public void testChildInterfaceMapped() {
String property = "mapproperty";
- Class clazz = MappedPropertyChildInterface.class;
+ Class<?> clazz = MappedPropertyChildInterface.class;
try {
MappedPropertyDescriptor desc
= new MappedPropertyDescriptor(property, clazz);
Modified: commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/PropertyUtilsBenchCase.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/PropertyUtilsBenchCase.java?rev=1540186&r1=1540185&r2=1540186&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/PropertyUtilsBenchCase.java (original)
+++ commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/PropertyUtilsBenchCase.java Fri Nov 8 21:08:30 2013
@@ -20,10 +20,10 @@ package org.apache.commons.beanutils;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.Map;
-import junit.framework.TestCase;
+
import junit.framework.Test;
+import junit.framework.TestCase;
import junit.framework.TestSuite;
@@ -63,7 +63,7 @@ public class PropertyUtilsBenchCase exte
// Input objects that have identical sets of properties and values.
private BenchBean inBean = null;
private DynaBean inDyna = null;
- private Map inMap = null;
+ private Map<String, Object> inMap = null;
// Output objects that have identical sets of properties.
private BenchBean outBean = null;
@@ -104,7 +104,7 @@ public class PropertyUtilsBenchCase exte
// Create input instances
inBean = new BenchBean();
- inMap = new HashMap();
+ inMap = new HashMap<String, Object>();
inMap.put("booleanProperty", new Boolean(inBean.getBooleanProperty()));
inMap.put("byteProperty", new Byte(inBean.getByteProperty()));
inMap.put("doubleProperty", new Double(inBean.getDoubleProperty()));
@@ -114,19 +114,16 @@ public class PropertyUtilsBenchCase exte
inMap.put("shortProperty", new Short(inBean.getShortProperty()));
inMap.put("stringProperty", inBean.getStringProperty());
inDyna = dynaClass.newInstance();
- Iterator inKeys = inMap.keySet().iterator();
- while (inKeys.hasNext()) {
- String inKey = (String) inKeys.next();
- inDyna.set(inKey, inMap.get(inKey));
+ for (Map.Entry<String, Object> e : inMap.entrySet()) {
+ inDyna.set(e.getKey(), e.getValue());
}
// Create output instances
outBean = new BenchBean();
outDyna = dynaClass.newInstance();
- Iterator outKeys = inMap.keySet().iterator();
- while (outKeys.hasNext()) {
- String outKey = (String) outKeys.next();
- outDyna.set(outKey, inMap.get(outKey));
+ inDyna = dynaClass.newInstance();
+ for (Map.Entry<String, Object> e : inMap.entrySet()) {
+ outDyna.set(e.getKey(), e.getValue());
}
// Set up PropertyUtilsBean instance we will use
Modified: commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/PropertyUtilsTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/PropertyUtilsTestCase.java?rev=1540186&r1=1540185&r2=1540186&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/PropertyUtilsTestCase.java (original)
+++ commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/PropertyUtilsTestCase.java Fri Nov 8 21:08:30 2013
@@ -253,7 +253,7 @@ public class PropertyUtilsTestCase exten
*/
public void testCopyPropertiesMap() {
- Map map = new HashMap();
+ Map<String, Object> map = new HashMap<String, Object>();
map.put("booleanProperty", Boolean.FALSE);
map.put("doubleProperty", new Double(333.0));
map.put("dupProperty", new String[] { "New 0", "New 1", "New 2" });
@@ -308,7 +308,7 @@ public class PropertyUtilsTestCase exten
*/
public void testDescribe() {
- Map map = null;
+ Map<String, Object> map = null;
try {
map = PropertyUtils.describe(bean);
} catch (Exception e) {
@@ -1044,7 +1044,7 @@ public class PropertyUtilsTestCase exten
public void testGetIndexedList() {
String[] firstArray = new String[] {"FIRST-1", "FIRST-2", "FIRST-3"};
String[] secondArray = new String[] {"SECOND-1", "SECOND-2", "SECOND-3", "SECOND-4"};
- List mainList = new ArrayList();
+ List<Object> mainList = new ArrayList<Object>();
mainList.add(Arrays.asList(firstArray));
mainList.add(Arrays.asList(secondArray));
TestBean bean = new TestBean(mainList);
@@ -1065,14 +1065,14 @@ public class PropertyUtilsTestCase exten
* Test getting a value out of a mapped Map
*/
public void testGetIndexedMap() {
- Map firstMap = new HashMap();
+ Map<String, Object> firstMap = new HashMap<String, Object>();
firstMap.put("FIRST-KEY-1", "FIRST-VALUE-1");
firstMap.put("FIRST-KEY-2", "FIRST-VALUE-2");
- Map secondMap = new HashMap();
+ Map<String, Object> secondMap = new HashMap<String, Object>();
secondMap.put("SECOND-KEY-1", "SECOND-VALUE-1");
secondMap.put("SECOND-KEY-2", "SECOND-VALUE-2");
- List mainList = new ArrayList();
+ List<Object> mainList = new ArrayList<Object>();
mainList.add(firstMap);
mainList.add(secondMap);
TestBean bean = new TestBean(mainList);
@@ -1174,7 +1174,7 @@ public class PropertyUtilsTestCase exten
*/
public void testGetMappedList() {
TestBean bean = new TestBean();
- List list = new ArrayList();
+ List<Object> list = new ArrayList<Object>();
list.add("klm");
list.add("nop");
list.add("qrs");
@@ -1193,7 +1193,7 @@ public class PropertyUtilsTestCase exten
*/
public void testGetMappedMap() {
TestBean bean = new TestBean();
- Map map = new HashMap();
+ Map<String, Object> map = new HashMap<String, Object>();
map.put("sub-key-1", "sub-value-1");
map.put("sub-key-2", "sub-value-2");
map.put("sub-key-3", "sub-value-3");
@@ -1669,7 +1669,7 @@ public class PropertyUtilsTestCase exten
// don't init!
try {
- NestedTestBean value = (NestedTestBean) PropertyUtils.getProperty(
+ PropertyUtils.getProperty(
nestedBean,
"simpleBeanProperty.indexedProperty[0]");
fail("NestedNullException not thrown");
@@ -1704,7 +1704,7 @@ public class PropertyUtilsTestCase exten
*/
public void testGetPropertyType() {
- Class clazz = null;
+ Class<?> clazz = null;
int intArray[] = new int[0];
String stringArray[] = new String[0];
@@ -1906,9 +1906,8 @@ public class PropertyUtilsTestCase exten
assertTrue("Found foo descriptor", n >= 0);
Method reader = pd[n].getReadMethod();
assertNotNull("Found foo read method", reader);
- Object value = null;
try {
- value = reader.invoke(beanPrivate, new Class[0]);
+ reader.invoke(beanPrivate, (Object[]) new Class<?>[0]);
fail("Foo reader did throw IllegalAccessException");
} catch (IllegalAccessException e) {
// Expected result for this test
@@ -2043,9 +2042,8 @@ public class PropertyUtilsTestCase exten
*/
public void testGetSimpleIndexed() {
- Object value = null;
try {
- value = PropertyUtils.getSimpleProperty(bean,
+ PropertyUtils.getSimpleProperty(bean,
"intIndexed[0]");
fail("Should have thrown IllegalArgumentException");
} catch (IllegalAccessException e) {
@@ -2120,9 +2118,8 @@ public class PropertyUtilsTestCase exten
*/
public void testGetSimpleNested() {
- Object value = null;
try {
- value = PropertyUtils.getSimpleProperty(bean,
+ PropertyUtils.getSimpleProperty(bean,
"nested.stringProperty");
fail("Should have thrown IllegaArgumentException");
} catch (IllegalAccessException e) {
@@ -2616,45 +2613,45 @@ public class PropertyUtilsTestCase exten
public void testSetIndexedList() {
String[] firstArray = new String[] {"FIRST-1", "FIRST-2", "FIRST-3"};
String[] secondArray = new String[] {"SECOND-1", "SECOND-2", "SECOND-3", "SECOND-4"};
- List mainList = new ArrayList();
+ List<Object> mainList = new ArrayList<Object>();
mainList.add(Arrays.asList(firstArray));
mainList.add(Arrays.asList(secondArray));
TestBean bean = new TestBean(mainList);
- assertEquals("BEFORE", "SECOND-4", ((List)bean.getListIndexed().get(1)).get(3));
+ assertEquals("BEFORE", "SECOND-4", ((List<?>)bean.getListIndexed().get(1)).get(3));
try {
PropertyUtils.setProperty(bean, "listIndexed[1][3]", "SECOND-4-UPDATED");
} catch (Throwable t) {
fail("Threw " + t + "");
}
- assertEquals("AFTER", "SECOND-4-UPDATED", ((List)bean.getListIndexed().get(1)).get(3));
+ assertEquals("AFTER", "SECOND-4-UPDATED", ((List<?>)bean.getListIndexed().get(1)).get(3));
}
/**
* Test setting a value out of a mapped Map
*/
public void testSetIndexedMap() {
- Map firstMap = new HashMap();
+ Map<String, Object> firstMap = new HashMap<String, Object>();
firstMap.put("FIRST-KEY-1", "FIRST-VALUE-1");
firstMap.put("FIRST-KEY-2", "FIRST-VALUE-2");
- Map secondMap = new HashMap();
+ Map<String, Object> secondMap = new HashMap<String, Object>();
secondMap.put("SECOND-KEY-1", "SECOND-VALUE-1");
secondMap.put("SECOND-KEY-2", "SECOND-VALUE-2");
- List mainList = new ArrayList();
+ List<Object> mainList = new ArrayList<Object>();
mainList.add(firstMap);
mainList.add(secondMap);
TestBean bean = new TestBean(mainList);
- assertEquals("BEFORE", null, ((Map)bean.getListIndexed().get(0)).get("FIRST-NEW-KEY"));
- assertEquals("BEFORE", "SECOND-VALUE-1", ((Map)bean.getListIndexed().get(1)).get("SECOND-KEY-1"));
+ assertEquals("BEFORE", null, ((Map<?, ?>)bean.getListIndexed().get(0)).get("FIRST-NEW-KEY"));
+ assertEquals("BEFORE", "SECOND-VALUE-1", ((Map<?, ?>)bean.getListIndexed().get(1)).get("SECOND-KEY-1"));
try {
PropertyUtils.setProperty(bean, "listIndexed[0](FIRST-NEW-KEY)", "FIRST-NEW-VALUE");
PropertyUtils.setProperty(bean, "listIndexed[1](SECOND-KEY-1)", "SECOND-VALUE-1-UPDATED");
} catch (Throwable t) {
fail("Threw " + t + "");
}
- assertEquals("BEFORE", "FIRST-NEW-VALUE", ((Map)bean.getListIndexed().get(0)).get("FIRST-NEW-KEY"));
- assertEquals("AFTER", "SECOND-VALUE-1-UPDATED", ((Map)bean.getListIndexed().get(1)).get("SECOND-KEY-1"));
+ assertEquals("BEFORE", "FIRST-NEW-VALUE", ((Map<?, ?>)bean.getListIndexed().get(0)).get("FIRST-NEW-KEY"));
+ assertEquals("AFTER", "SECOND-VALUE-1-UPDATED", ((Map<?, ?>)bean.getListIndexed().get(1)).get("SECOND-KEY-1"));
}
@@ -3093,19 +3090,19 @@ public class PropertyUtilsTestCase exten
*/
public void testSetMappedList() {
TestBean bean = new TestBean();
- List list = new ArrayList();
+ List<Object> list = new ArrayList<Object>();
list.add("klm");
list.add("nop");
list.add("qrs");
bean.getMapProperty().put("mappedList", list);
- assertEquals("BEFORE", "klm", ((List)bean.getMapProperty().get("mappedList")).get(0));
+ assertEquals("BEFORE", "klm", ((List<?>)bean.getMapProperty().get("mappedList")).get(0));
try {
PropertyUtils.setProperty(bean, "mapProperty(mappedList)[0]", "KLM-UPDATED");
} catch (Throwable t) {
fail("Threw " + t + "");
}
- assertEquals("AFTER", "KLM-UPDATED", ((List)bean.getMapProperty().get("mappedList")).get(0));
+ assertEquals("AFTER", "KLM-UPDATED", ((List<?>)bean.getMapProperty().get("mappedList")).get(0));
}
/**
@@ -3113,19 +3110,19 @@ public class PropertyUtilsTestCase exten
*/
public void testSetMappedMap() {
TestBean bean = new TestBean();
- Map map = new HashMap();
+ Map<String, Object> map = new HashMap<String, Object>();
map.put("sub-key-1", "sub-value-1");
map.put("sub-key-2", "sub-value-2");
map.put("sub-key-3", "sub-value-3");
bean.getMapProperty().put("mappedMap", map);
- assertEquals("BEFORE", "sub-value-3", ((Map)bean.getMapProperty().get("mappedMap")).get("sub-key-3"));
+ assertEquals("BEFORE", "sub-value-3", ((Map<?, ?>)bean.getMapProperty().get("mappedMap")).get("sub-key-3"));
try {
PropertyUtils.setProperty(bean, "mapProperty(mappedMap)(sub-key-3)", "SUB-KEY-3-UPDATED");
} catch (Throwable t) {
fail("Threw " + t + "");
}
- assertEquals("AFTER", "SUB-KEY-3-UPDATED", ((Map)bean.getMapProperty().get("mappedMap")).get("sub-key-3"));
+ assertEquals("AFTER", "SUB-KEY-3-UPDATED", ((Map<?, ?>)bean.getMapProperty().get("mappedMap")).get("sub-key-3"));
}
/**
@@ -4011,7 +4008,7 @@ public class PropertyUtilsTestCase exten
Method reader = PropertyUtils.getReadMethod(pd[n]);
assertNotNull("Reader for " + properties[i],
reader);
- Class clazz = reader.getDeclaringClass();
+ Class<?> clazz = reader.getDeclaringClass();
assertNotNull("Declaring class for " + properties[i],
clazz);
assertEquals("Correct declaring class for " + properties[i],
@@ -4020,7 +4017,7 @@ public class PropertyUtilsTestCase exten
// Actually call the reader method we received
try {
- reader.invoke(bean, new Class[0]);
+ reader.invoke(bean, (Object[]) new Class<?>[0]);
} catch (Throwable t) {
fail("Call for " + properties[i] + ": " + t);
}
@@ -4070,7 +4067,7 @@ public class PropertyUtilsTestCase exten
Method writer = PropertyUtils.getWriteMethod(pd[n]);
assertNotNull("Writer for " + properties[i],
writer);
- Class clazz = writer.getDeclaringClass();
+ Class<?> clazz = writer.getDeclaringClass();
assertNotNull("Declaring class for " + properties[i],
clazz);
assertEquals("Correct declaring class for " + properties[i],
@@ -4208,9 +4205,6 @@ public class PropertyUtilsTestCase exten
assertEquals("Cannot set no-getter property", "Omega", bean.getSecret());
// test mapped no getter descriptor
- MappedPropertyDescriptor descriptor
- = new MappedPropertyDescriptor("noGetterMappedProperty", BetaBean.class);
-
assertNotNull("Map Descriptor is null", PropertyUtils.getPropertyDescriptor(bean, "noGetterMappedProperty"));
PropertyUtils.setMappedProperty(bean, "noGetterMappedProperty", "Epsilon", "Epsilon");
@@ -4268,8 +4262,8 @@ public class PropertyUtilsTestCase exten
* mistake.
*/
public void testNestedPropertyKeyOrIndexOnBeanImplementingMap() throws Exception {
- HashMap map = new HashMap();
- HashMap submap = new HashMap();
+ HashMap<String, Object> map = new HashMap<String, Object>();
+ HashMap<String, Object> submap = new HashMap<String, Object>();
BetaBean betaBean1 = new BetaBean("test1");
BetaBean betaBean2 = new BetaBean("test2");
@@ -4312,7 +4306,7 @@ public class PropertyUtilsTestCase exten
// However this isn't how javabeans property methods work. A map
// only effectively has "simple" properties, even when the
// returned object is a Map or Array.
- Object o = PropertyUtils.getNestedProperty(map, "submap[3]");
+ PropertyUtils.getNestedProperty(map, "submap[3]");
// What, no exception? In that case, getNestedProperties has
// probably just tried to do
@@ -4336,10 +4330,10 @@ public class PropertyUtilsTestCase exten
* <p>
* If there are no keys, an empty string is returned.
*/
- private String keysToString(Map map) {
+ private String keysToString(Map<?, ?> map) {
Object[] mapKeys = map.keySet().toArray();
java.util.Arrays.sort(mapKeys);
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
for(int i=0; i<mapKeys.length; ++i) {
if (i != 0)
buf.append(", ");
@@ -4416,7 +4410,7 @@ public class PropertyUtilsTestCase exten
assertEquals("setNestedProperty on non-simple property failed",
"value1", utilsBean.getNestedProperty(bean, "mapProperty"));
- HashMap myMap = new HashMap();
+ HashMap<String, Object> myMap = new HashMap<String, Object>();
myMap.put("thebean", bean);
utilsBean.getNestedProperty(myMap, "thebean.mapitem");
utilsBean.getNestedProperty(myMap, "thebean(mapitem)");
Modified: commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/PropsFirstPropertyUtilsBean.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/PropsFirstPropertyUtilsBean.java?rev=1540186&r1=1540185&r2=1540186&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/PropsFirstPropertyUtilsBean.java (original)
+++ commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/PropsFirstPropertyUtilsBean.java Fri Nov 8 21:08:30 2013
@@ -16,9 +16,9 @@
*/
package org.apache.commons.beanutils;
-import java.util.Map;
import java.beans.PropertyDescriptor;
import java.lang.reflect.InvocationTargetException;
+import java.util.Map;
/**
* A PropertyUtilsBean which customises the behaviour of the
@@ -40,7 +40,7 @@ public class PropsFirstPropertyUtilsBean
* be correctly handled.
*/
@Override
- protected Object getPropertyOfMapBean(Map bean, String propertyName)
+ protected Object getPropertyOfMapBean(Map<?, ?> bean, String propertyName)
throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
PropertyDescriptor descriptor = getPropertyDescriptor(bean, propertyName);
@@ -60,7 +60,7 @@ public class PropsFirstPropertyUtilsBean
* be correctly handled.
*/
@Override
- protected void setPropertyOfMapBean(Map bean, String propertyName, Object value)
+ protected void setPropertyOfMapBean(Map<String, Object> bean, String propertyName, Object value)
throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
PropertyDescriptor descriptor = getPropertyDescriptor(bean, propertyName);
if (descriptor == null) {
Modified: commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/TestBean.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/TestBean.java?rev=1540186&r1=1540185&r2=1540186&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/TestBean.java (original)
+++ commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/TestBean.java Fri Nov 8 21:08:30 2013
@@ -19,11 +19,11 @@
package org.apache.commons.beanutils;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.io.Serializable;
/**
@@ -93,7 +93,7 @@ public class TestBean implements Seriali
setStringProperty(stringProperty);
}
- public TestBean(List listIndexed) {
+ public TestBean(List<Object> listIndexed) {
this.listIndexed = listIndexed;
}
@@ -269,9 +269,9 @@ public class TestBean implements Seriali
/**
* A List property accessed as an indexed property.
*/
- private List listIndexed = new ArrayList();
+ private List<Object> listIndexed = new ArrayList<Object>();
- public List getListIndexed() {
+ public List<Object> getListIndexed() {
return (listIndexed);
}
@@ -293,22 +293,22 @@ public class TestBean implements Seriali
/**
* A mapped property with only a getter and setter for a Map.
*/
- private Map mapProperty = null;
+ private Map<String, Object> mapProperty = null;
- public Map getMapProperty() {
+ public Map<String, Object> getMapProperty() {
// Create the map the very first time
if (mapProperty == null) {
- mapProperty = new HashMap();
+ mapProperty = new HashMap<String, Object>();
mapProperty.put("First Key", "First Value");
mapProperty.put("Second Key", "Second Value");
}
return (mapProperty);
}
- public void setMapProperty(Map mapProperty) {
+ public void setMapProperty(Map<String, Object> mapProperty) {
// Create the map the very first time
if (mapProperty == null) {
- mapProperty = new HashMap();
+ mapProperty = new HashMap<String, Object>();
mapProperty.put("First Key", "First Value");
mapProperty.put("Second Key", "Second Value");
}
@@ -319,12 +319,12 @@ public class TestBean implements Seriali
/**
* A mapped property that has String keys and Object values.
*/
- private HashMap mappedObjects = null;
+ private HashMap<String, Object> mappedObjects = null;
public Object getMappedObjects(String key) {
// Create the map the very first time
if (mappedObjects == null) {
- mappedObjects = new HashMap();
+ mappedObjects = new HashMap<String, Object>();
mappedObjects.put("First Key", "First Value");
mappedObjects.put("Second Key", "Second Value");
}
@@ -334,7 +334,7 @@ public class TestBean implements Seriali
public void setMappedObjects(String key, Object value) {
// Create the map the very first time
if (mappedObjects == null) {
- mappedObjects = new HashMap();
+ mappedObjects = new HashMap<String, Object>();
mappedObjects.put("First Key", "First Value");
mappedObjects.put("Second Key", "Second Value");
}
@@ -345,22 +345,22 @@ public class TestBean implements Seriali
/**
* A mapped property that has String keys and String values.
*/
- private HashMap mappedProperty = null;
+ private HashMap<String, String> mappedProperty = null;
public String getMappedProperty(String key) {
// Create the map the very first time
if (mappedProperty == null) {
- mappedProperty = new HashMap();
+ mappedProperty = new HashMap<String, String>();
mappedProperty.put("First Key", "First Value");
mappedProperty.put("Second Key", "Second Value");
}
- return ((String) mappedProperty.get(key));
+ return (mappedProperty.get(key));
}
public void setMappedProperty(String key, String value) {
// Create the map the very first time
if (mappedProperty == null) {
- mappedProperty = new HashMap();
+ mappedProperty = new HashMap<String, String>();
mappedProperty.put("First Key", "First Value");
mappedProperty.put("Second Key", "Second Value");
}
@@ -371,21 +371,21 @@ public class TestBean implements Seriali
/**
* A mapped property that has String keys and int values.
*/
- private HashMap mappedIntProperty = null;
+ private HashMap<String, Integer> mappedIntProperty = null;
public int getMappedIntProperty(String key) {
// Create the map the very first time
if (mappedIntProperty == null) {
- mappedIntProperty = new HashMap();
- mappedIntProperty.put("One", new Integer(1));
- mappedIntProperty.put("Two", new Integer(2));
+ mappedIntProperty = new HashMap<String, Integer>();
+ mappedIntProperty.put("One", 1);
+ mappedIntProperty.put("Two", 2);
}
- Integer x = (Integer) mappedIntProperty.get(key);
+ Integer x = mappedIntProperty.get(key);
return ((x == null) ? 0 : x.intValue());
}
public void setMappedIntProperty(String key, int value) {
- mappedIntProperty.put(key, new Integer(value));
+ mappedIntProperty.put(key, value);
}
Modified: commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/TestResultSet.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/TestResultSet.java?rev=1540186&r1=1540185&r2=1540186&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/TestResultSet.java (original)
+++ commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/TestResultSet.java Fri Nov 8 21:08:30 2013
@@ -88,7 +88,7 @@ public class TestResultSet implements In
*/
public static ResultSet createProxy(InvocationHandler invocationHandler) {
ClassLoader classLoader = ResultSet.class.getClassLoader();
- Class[] interfaces = new Class[] { ResultSet.class };
+ Class<?>[] interfaces = new Class[] { ResultSet.class };
return (ResultSet)Proxy.newProxyInstance(classLoader, interfaces, invocationHandler);
}
@@ -472,12 +472,12 @@ public class TestResultSet implements In
}
- public Object getObject(int columnIndex, Map map) throws SQLException {
+ public Object getObject(int columnIndex, Map<?, ?> map) throws SQLException {
throw new UnsupportedOperationException();
}
- public Object getObject(String columnName, Map map) throws SQLException {
+ public Object getObject(String columnName, Map<?, ?> map) throws SQLException {
throw new UnsupportedOperationException();
}
Modified: commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/TestResultSetMetaData.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/TestResultSetMetaData.java?rev=1540186&r1=1540185&r2=1540186&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/TestResultSetMetaData.java (original)
+++ commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/TestResultSetMetaData.java Fri Nov 8 21:08:30 2013
@@ -77,7 +77,7 @@ public class TestResultSetMetaData imple
*/
public static ResultSetMetaData createProxy(InvocationHandler invocationHandler) {
ClassLoader classLoader = ResultSetMetaData.class.getClassLoader();
- Class[] interfaces = new Class[] { ResultSetMetaData.class };
+ Class<?>[] interfaces = new Class[] { ResultSetMetaData.class };
return (ResultSetMetaData)Proxy.newProxyInstance(classLoader, interfaces, invocationHandler);
}
Modified: commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/ThrowExceptionConverter.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/ThrowExceptionConverter.java?rev=1540186&r1=1540185&r2=1540186&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/ThrowExceptionConverter.java (original)
+++ commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/ThrowExceptionConverter.java Fri Nov 8 21:08:30 2013
@@ -30,7 +30,7 @@ package org.apache.commons.beanutils;
public class ThrowExceptionConverter implements Converter {
- public Object convert(Class type, Object value) {
+ public <T> T convert(Class<T> type, Object value) {
throw new PassTestException();
}
}
Modified: commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/WrapDynaBeanTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/WrapDynaBeanTestCase.java?rev=1540186&r1=1540185&r2=1540186&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/WrapDynaBeanTestCase.java (original)
+++ commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/WrapDynaBeanTestCase.java Fri Nov 8 21:08:30 2013
@@ -22,6 +22,7 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
+
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -101,7 +102,7 @@ public class WrapDynaBeanTestCase extend
// Invalid getter
try {
- Object result = bean.get("invalidProperty");
+ bean.get("invalidProperty");
fail("Invalid get should have thrown IllegalArgumentException");
} catch (IllegalArgumentException t) {
// Expected result
@@ -141,7 +142,7 @@ public class WrapDynaBeanTestCase extend
// Invalid getter
try {
- Object result = bean.get("invalidProperty", 0);
+ bean.get("invalidProperty", 0);
fail("Invalid get should have thrown IllegalArgumentException");
} catch (IllegalArgumentException t) {
// Expected result