Author: oheger
Date: Sat Mar 2 20:16:26 2013
New Revision: 1451932
URL: http://svn.apache.org/r1451932
Log:
Trailing spaces and organized imports.
Modified:
commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/PropertyUtils.java
commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/PropertyUtilsBean.java
commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/PropertyUtilsTestCase.java
Modified:
commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/PropertyUtils.java
URL:
http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/PropertyUtils.java?rev=1451932&r1=1451931&r2=1451932&view=diff
==============================================================================
---
commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/PropertyUtils.java
(original)
+++
commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/PropertyUtils.java
Sat Mar 2 20:16:26 2013
@@ -108,7 +108,7 @@ public class PropertyUtils {
/**
* The debugging detail level for this component.
- *
+ *
* Note that this static variable will have unexpected side-effects if
* this class is deployed in a shared classloader within a container.
* However as it is actually completely ignored by this class due to its
@@ -146,7 +146,7 @@ public class PropertyUtils {
*
* <p>For more details see <code>PropertyUtilsBean</code>.</p>
*
- * @see PropertyUtilsBean#clearDescriptors
+ * @see PropertyUtilsBean#clearDescriptors
*/
public static void clearDescriptors() {
@@ -174,7 +174,7 @@ public class PropertyUtils {
* throws an exception
* @exception NoSuchMethodException if an accessor method for this
* propety cannot be found
- * @see PropertyUtilsBean#copyProperties
+ * @see PropertyUtilsBean#copyProperties
*/
public static void copyProperties(Object dest, Object orig)
throws IllegalAccessException, InvocationTargetException,
@@ -200,7 +200,7 @@ public class PropertyUtils {
* throws an exception
* @exception NoSuchMethodException if an accessor method for this
* propety cannot be found
- * @see PropertyUtilsBean#describe
+ * @see PropertyUtilsBean#describe
*/
public static Map describe(Object bean)
throws IllegalAccessException, InvocationTargetException,
@@ -232,7 +232,7 @@ public class PropertyUtils {
* throws an exception
* @exception NoSuchMethodException if an accessor method for this
* propety cannot be found
- * @see PropertyUtilsBean#getIndexedProperty(Object,String)
+ * @see PropertyUtilsBean#getIndexedProperty(Object,String)
*/
public static Object getIndexedProperty(Object bean, String name)
throws IllegalAccessException, InvocationTargetException,
@@ -264,7 +264,7 @@ public class PropertyUtils {
* throws an exception
* @exception NoSuchMethodException if an accessor method for this
* propety cannot be found
- * @see PropertyUtilsBean#getIndexedProperty(Object,String, int)
+ * @see PropertyUtilsBean#getIndexedProperty(Object,String, int)
*/
public static Object getIndexedProperty(Object bean,
String name, int index)
@@ -292,7 +292,7 @@ public class PropertyUtils {
* throws an exception
* @exception NoSuchMethodException if an accessor method for this
* propety cannot be found
- * @see PropertyUtilsBean#getMappedProperty(Object,String)
+ * @see PropertyUtilsBean#getMappedProperty(Object,String)
*/
public static Object getMappedProperty(Object bean, String name)
throws IllegalAccessException, InvocationTargetException,
@@ -320,7 +320,7 @@ public class PropertyUtils {
* throws an exception
* @exception NoSuchMethodException if an accessor method for this
* propety cannot be found
- * @see PropertyUtilsBean#getMappedProperty(Object,String, String)
+ * @see PropertyUtilsBean#getMappedProperty(Object,String, String)
*/
public static Object getMappedProperty(Object bean,
String name, String key)
@@ -382,7 +382,7 @@ public class PropertyUtils {
* <code>name</code> is null
* @exception NestedNullException if a nested reference to a
* property returns null
- * @exception InvocationTargetException
+ * @exception InvocationTargetException
* if the property accessor method throws an exception
* @exception NoSuchMethodException if an accessor method for this
* propety cannot be found
@@ -393,7 +393,7 @@ public class PropertyUtils {
NoSuchMethodException {
return PropertyUtilsBean.getInstance().getNestedProperty(bean, name);
-
+
}
@@ -609,7 +609,7 @@ public class PropertyUtils {
NoSuchMethodException {
return PropertyUtilsBean.getInstance().getSimpleProperty(bean, name);
-
+
}
Modified:
commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/PropertyUtilsBean.java
URL:
http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/PropertyUtilsBean.java?rev=1451932&r1=1451931&r2=1451932&view=diff
==============================================================================
---
commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/PropertyUtilsBean.java
(original)
+++
commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/PropertyUtilsBean.java
Sat Mar 2 20:16:26 2013
@@ -124,15 +124,15 @@ public class PropertyUtilsBean {
private WeakFastHashMap mappedDescriptorsCache = null;
private static final Class[] EMPTY_CLASS_PARAMETERS = new Class[0];
private static final Class[] LIST_CLASS_PARAMETER = new Class[]
{java.util.List.class};
-
+
/** An empty object array */
private static final Object[] EMPTY_OBJECT_ARRAY = new Object[0];
/** Log instance */
private final Log log = LogFactory.getLog(PropertyUtils.class);
-
+
// ---------------------------------------------------------- Constructors
-
+
/** Base constructor */
public PropertyUtilsBean() {
descriptorsCache = new WeakFastHashMap();
@@ -209,11 +209,11 @@ public class PropertyUtilsBean {
* <p>If the origin "bean" is actually a <code>Map</code>, it is assumed
* to contain String-valued <strong>simple</strong> property names as the
keys, pointing
* at the corresponding property values that will be set in the destination
- * bean.<strong>Note</strong> that this method is intended to perform
- * a "shallow copy" of the properties and so complex properties
+ * bean.<strong>Note</strong> that this method is intended to perform
+ * a "shallow copy" of the properties and so complex properties
* (for example, nested ones) will not be copied.</p>
- *
- * <p>Note, that this method will not copy a List to a List, or an
Object[]
+ *
+ * <p>Note, that this method will not copy a List to a List, or an Object[]
* to an Object[]. It's specifically for copying JavaBean properties. </p>
*
* @param dest Destination bean whose properties are modified
@@ -446,7 +446,7 @@ public class PropertyUtilsBean {
if (bean.getClass().isArray()) {
return Array.get(bean, index);
} else if (bean instanceof List) {
- return ((List)bean).get(index);
+ return ((List)bean).get(index);
}
}
if (name == null) {
@@ -721,7 +721,7 @@ public class PropertyUtilsBean {
* <code>name</code> is null
* @exception NestedNullException if a nested reference to a
* property returns null
- * @exception InvocationTargetException
+ * @exception InvocationTargetException
* if the property accessor method throws an exception
* @exception NoSuchMethodException if an accessor method for this
* propety cannot be found
@@ -781,24 +781,24 @@ public class PropertyUtilsBean {
* @param bean Map bean
* @param propertyName The property name
* @return the property value
- *
+ *
* @throws IllegalArgumentException when the propertyName is regarded as
* being invalid.
- *
+ *
* @throws IllegalAccessException just in case subclasses override this
* method to try to access real getter methods and find permission is
denied.
- *
+ *
* @throws InvocationTargetException just in case subclasses override this
* method to try to access real getter methods, and find it throws an
* exception when invoked.
- *
+ *
* @throws NoSuchMethodException just in case subclasses override this
* method to try to access real getter methods, and want to fail if
* no simple method is available.
* @since 1.8.0
*/
- protected Object getPropertyOfMapBean(Map bean, String propertyName)
- throws IllegalArgumentException, IllegalAccessException,
+ protected Object getPropertyOfMapBean(Map bean, String propertyName)
+ throws IllegalArgumentException, IllegalAccessException,
InvocationTargetException, NoSuchMethodException {
if (resolver.isMapped(propertyName)) {
@@ -908,10 +908,10 @@ public class PropertyUtilsBean {
if (name == null) {
return (null);
}
-
+
PropertyDescriptor[] descriptors = getPropertyDescriptors(bean);
if (descriptors != null) {
-
+
for (int i = 0; i < descriptors.length; i++) {
if (name.equals(descriptors[i].getName())) {
return (descriptors[i]);
@@ -941,7 +941,7 @@ public class PropertyUtilsBean {
mappedDescriptors.put(name, result);
}
}
-
+
return result;
}
@@ -1041,7 +1041,7 @@ public class PropertyUtilsBean {
if (parameterTypes.length == 1 &&
List.class.isAssignableFrom(parameterTypes[0])) {
writeMethod = methods[j];
- break;
+ break;
}
}
}
@@ -1309,7 +1309,7 @@ public class PropertyUtilsBean {
((DynaBean) bean).getDynaClass().getDynaProperty(name);
if (descriptor == null) {
throw new NoSuchMethodException("Unknown property '" +
- name + "' on dynaclass '" +
+ name + "' on dynaclass '" +
((DynaBean) bean).getDynaClass() + "'" );
}
return (((DynaBean) bean).get(name));
@@ -1395,7 +1395,7 @@ public class PropertyUtilsBean {
// Resolve nested references
while (resolver.hasNested(name)) {
String next = resolver.next(name);
- Object nestedBean = null;
+ Object nestedBean = null;
try {
nestedBean = getProperty(bean, next);
} catch (IllegalAccessException e) {
@@ -1486,7 +1486,7 @@ public class PropertyUtilsBean {
// Resolve nested references
while (resolver.hasNested(name)) {
String next = resolver.next(name);
- Object nestedBean = null;
+ Object nestedBean = null;
try {
nestedBean = getProperty(bean, next);
} catch (IllegalAccessException e) {
@@ -1643,7 +1643,7 @@ public class PropertyUtilsBean {
Array.set(bean, index, value);
return;
} else if (bean instanceof List) {
- ((List)bean).set(index, value);
+ ((List)bean).set(index, value);
return;
}
}
@@ -1684,7 +1684,7 @@ public class PropertyUtilsBean {
try {
if (log.isTraceEnabled()) {
String valueClassName =
- value == null ? "<null>"
+ value == null ? "<null>"
: value.getClass().getName();
log.trace("setSimpleProperty: Invoking method "
+ writeMethod +" with index=" + index
@@ -1768,12 +1768,12 @@ public class PropertyUtilsBean {
key = resolver.getKey(name);
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException
- ("Invalid mapped property '" + name +
+ ("Invalid mapped property '" + name +
"' on bean class '" + bean.getClass() + "'");
}
if (key == null) {
throw new IllegalArgumentException
- ("Invalid mapped property '" + name +
+ ("Invalid mapped property '" + name +
"' on bean class '" + bean.getClass() + "'");
}
@@ -1975,18 +1975,18 @@ public class PropertyUtilsBean {
* </ul>
* <p>
* The default behaviour of beanutils 1.7.1 or later is for assigning to
- * "a.b" to mean a.put(b, obj) always. However the behaviour of beanutils
+ * "a.b" to mean a.put(b, obj) always. However the behaviour of beanutils
* version 1.6.0, 1.6.1, 1.7.0 was for "a.b" to mean a.setB(obj) if such
* a method existed, and a.put(b, obj) otherwise. In version 1.5 it meant
* a.put(b, obj) always (ie the same as the behaviour in the current
version).
- * In versions prior to 1.5 it meant a.setB(obj) always. [yes, this is
+ * In versions prior to 1.5 it meant a.setB(obj) always. [yes, this is
* all <i>very</i> unfortunate]
* <p>
- * Users who would like to customise the meaning of "a.b" in method
+ * Users who would like to customise the meaning of "a.b" in method
* setNestedProperty when a is a Map can create a custom subclass of
- * this class and override this method to implement the behaviour of
+ * this class and override this method to implement the behaviour of
* their choice, such as restoring the pre-1.4 behaviour of this class
- * if they wish. When overriding this method, do not forget to deal
+ * if they wish. When overriding this method, do not forget to deal
* with MAPPED_DELIM and INDEXED_DELIM characters in the propertyName.
* <p>
* Note, however, that the recommended solution for objects that
@@ -1999,24 +1999,24 @@ public class PropertyUtilsBean {
* @param bean Map bean
* @param propertyName The property name
* @param value the property value
- *
+ *
* @throws IllegalArgumentException when the propertyName is regarded as
* being invalid.
- *
+ *
* @throws IllegalAccessException just in case subclasses override this
* method to try to access real setter methods and find permission is
denied.
- *
+ *
* @throws InvocationTargetException just in case subclasses override this
* method to try to access real setter methods, and find it throws an
* exception when invoked.
- *
+ *
* @throws NoSuchMethodException just in case subclasses override this
* method to try to access real setter methods, and want to fail if
* no simple method is available.
* @since 1.8.0
*/
protected void setPropertyOfMapBean(Map bean, String propertyName, Object
value)
- throws IllegalArgumentException, IllegalAccessException,
+ throws IllegalArgumentException, IllegalAccessException,
InvocationTargetException, NoSuchMethodException {
if (resolver.isMapped(propertyName)) {
@@ -2119,7 +2119,7 @@ public class PropertyUtilsBean {
((DynaBean) bean).getDynaClass().getDynaProperty(name);
if (descriptor == null) {
throw new NoSuchMethodException("Unknown property '" +
- name + "' on dynaclass '" +
+ name + "' on dynaclass '" +
((DynaBean) bean).getDynaClass() + "'" );
}
((DynaBean) bean).set(name, value);
@@ -2151,12 +2151,12 @@ public class PropertyUtilsBean {
invokeMethod(writeMethod, bean, values);
}
-
+
/** This just catches and wraps IllegalArgumentException. */
private Object invokeMethod(
- Method method,
- Object bean,
- Object[] values)
+ Method method,
+ Object bean,
+ Object[] values)
throws
IllegalAccessException,
InvocationTargetException {
@@ -2166,9 +2166,9 @@ public class PropertyUtilsBean {
}
try {
-
+
return method.invoke(bean, values);
-
+
} catch (NullPointerException cause) {
// JDK 1.3 and JDK 1.4 throw NullPointerException if an argument is
// null for a primitive value (JDK 1.5+ throw
IllegalArgumentException)
@@ -2196,7 +2196,7 @@ public class PropertyUtilsBean {
}
}
IllegalArgumentException e = new IllegalArgumentException(
- "Cannot invoke " + method.getDeclaringClass().getName() + "."
+ "Cannot invoke " + method.getDeclaringClass().getName() + "."
+ method.getName() + " on bean class '" + bean.getClass() +
"' - " + cause.getMessage()
// as per https://issues.apache.org/jira/browse/BEANUTILS-224
@@ -2233,7 +2233,7 @@ public class PropertyUtilsBean {
}
}
IllegalArgumentException e = new IllegalArgumentException(
- "Cannot invoke " + method.getDeclaringClass().getName() + "."
+ "Cannot invoke " + method.getDeclaringClass().getName() + "."
+ method.getName() + " on bean class '" + bean.getClass() +
"' - " + cause.getMessage()
// as per https://issues.apache.org/jira/browse/BEANUTILS-224
@@ -2245,7 +2245,7 @@ public class PropertyUtilsBean {
log.error("Method invocation failed", cause);
}
throw e;
-
+
}
}
}
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=1451932&r1=1451931&r2=1451932&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
Sat Mar 2 20:16:26 2013
@@ -5,15 +5,15 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- */
+ */
package org.apache.commons.beanutils;
@@ -28,14 +28,14 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
import org.apache.commons.beanutils.priv.PrivateBeanFactory;
import org.apache.commons.beanutils.priv.PrivateDirect;
import org.apache.commons.beanutils.priv.PublicSubBean;
-import junit.framework.TestCase;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
/**
* <p>Test Case for the PropertyUtils class. The majority of these tests use
@@ -285,7 +285,7 @@ public class PropertyUtilsTestCase exten
bean.getShortProperty());
assertEquals("stringProperty", "New String Property",
bean.getStringProperty());
-
+
// Indexed Properties
String dupProperty[] = bean.getDupProperty();
assertNotNull("dupProperty present", dupProperty);
@@ -1071,7 +1071,7 @@ public class PropertyUtilsTestCase exten
Map secondMap = new HashMap();
secondMap.put("SECOND-KEY-1", "SECOND-VALUE-1");
secondMap.put("SECOND-KEY-2", "SECOND-VALUE-2");
-
+
List mainList = new ArrayList();
mainList.add(firstMap);
mainList.add(secondMap);
@@ -1246,16 +1246,16 @@ public class PropertyUtilsTestCase exten
fail("Thew exception: " + e);
}
- try
+ try
{
assertEquals("Can't retrieved nested with mapped property",
"Mapped Value",
PropertyUtils.getNestedProperty(
bean,"mappedNested.value(Mapped Key)"));
- } catch (Exception e)
+ } catch (Exception e)
{
fail("Thew exception: " + e);
- }
+ }
}
@@ -1660,14 +1660,14 @@ public class PropertyUtilsTestCase exten
}
- /**
+ /**
* When a bean has a null property which is reference by the standard
access language,
* this should throw a NestedNullException.
*/
public void testThrowNestedNull() throws Exception {
NestedTestBean nestedBean = new NestedTestBean("base");
// don't init!
-
+
try {
NestedTestBean value = (NestedTestBean) PropertyUtils.getProperty(
nestedBean,
@@ -1824,7 +1824,7 @@ public class PropertyUtilsTestCase exten
bean.setFoo("foo-start");
bean.setBar("bar-start");
Object result = null;
-
+
// Get Foo
try {
result = PropertyUtils.getProperty(bean, "foo");
@@ -2235,7 +2235,7 @@ public class PropertyUtilsTestCase exten
fail("InvocationTargetException");
} catch (NoSuchMethodException e) {
// Correct result for this test
- assertEquals("Unknown property 'unknown' on class '" +
+ assertEquals("Unknown property 'unknown' on class '" +
bean.getClass() + "'", e.getMessage() );
}
@@ -2258,7 +2258,7 @@ public class PropertyUtilsTestCase exten
fail("InvocationTargetException");
} catch (NoSuchMethodException e) {
// Correct result for this test
- assertEquals("Property 'writeOnlyProperty' has no getter method in
class '" +
+ assertEquals("Property 'writeOnlyProperty' has no getter method in
class '" +
bean.getClass() + "'", e.getMessage() );
}
@@ -2321,7 +2321,7 @@ public class PropertyUtilsTestCase exten
} catch (Throwable t) {
fail("Property " + property +" isReadable Threw exception: " + t);
}
-
+
try {
property = "nestedDynaBean";
assertTrue("Property " + property +" isReadable expeced TRUE",
PropertyUtils.isReadable(bean, property));
@@ -2398,7 +2398,7 @@ public class PropertyUtilsTestCase exten
} catch (Throwable t) {
fail("Property " + property +" isWriteable Threw exception: " + t);
}
-
+
try {
property = "nestedDynaBean";
assertTrue("Property " + property +" isWriteable expeced TRUE",
PropertyUtils.isWriteable(bean, property));
@@ -2639,7 +2639,7 @@ public class PropertyUtilsTestCase exten
Map secondMap = new HashMap();
secondMap.put("SECOND-KEY-1", "SECOND-VALUE-1");
secondMap.put("SECOND-KEY-2", "SECOND-VALUE-2");
-
+
List mainList = new ArrayList();
mainList.add(firstMap);
mainList.add(secondMap);
@@ -3259,19 +3259,19 @@ public class PropertyUtilsTestCase exten
bean.setMappedObjects("nested.property", testBean);
assertEquals("Can retrieve directly (C)",
"This is a string",
- testBean.getStringProperty());
+ testBean.getStringProperty());
try {
PropertyUtils.setNestedProperty(bean,
"mappedObjects(nested.property).stringProperty",
"Updated String Value");
assertEquals("Check set via setNestedProperty (C)",
"Updated String Value",
- testBean.getStringProperty());
+ testBean.getStringProperty());
} catch (Exception e) {
fail("Thew exception: " + e);
}
// -------- PropertyUtils.setNestedProperty() --------
- bean.getNested().setMappedProperty("Mapped Key", "Nested Mapped
Value");
+ bean.getNested().setMappedProperty("Mapped Key", "Nested Mapped
Value");
try {
assertEquals("Can retrieve via getNestedProperty (D)",
"Nested Mapped Value",
@@ -3285,10 +3285,10 @@ public class PropertyUtilsTestCase exten
bean,"nested.mappedProperty(Mapped Key)"));
} catch (Exception e) {
fail("Thew exception: " + e);
- }
+ }
}
-
+
/**
* Corner cases on setNestedProperty invalid arguments.
*/
@@ -3812,7 +3812,7 @@ public class PropertyUtilsTestCase exten
fail("InvocationTargetException");
} catch (NoSuchMethodException e) {
// Correct result for this test
- assertEquals("Property 'readOnlyProperty' has no setter method in
class '" +
+ assertEquals("Property 'readOnlyProperty' has no setter method in
class '" +
bean.getClass() + "'", e.getMessage() );
}
@@ -3893,7 +3893,7 @@ public class PropertyUtilsTestCase exten
fail("InvocationTargetException");
} catch (NoSuchMethodException e) {
// Correct result for this test
- assertEquals("Unknown property 'unknown' on class '" +
+ assertEquals("Unknown property 'unknown' on class '" +
bean.getClass() + "'", e.getMessage() );
}
@@ -4086,133 +4086,133 @@ public class PropertyUtilsTestCase exten
NestedTestBean nestedBean = new NestedTestBean("base");
nestedBean.init();
nestedBean.getSimpleBeanProperty().init();
-
- NestedTestBean
-
+
+ NestedTestBean
+
// test first calling properties on indexed beans
-
+
value = (NestedTestBean) PropertyUtils.getProperty(
nestedBean,
"indexedProperty[0]");
assertEquals("Cannot get simple index(1)", "Bean@0", value.getName());
assertEquals("Bug in NestedTestBean", "NOT SET",
value.getTestString());
-
+
value = (NestedTestBean) PropertyUtils.getProperty(
nestedBean,
- "indexedProperty[1]");
+ "indexedProperty[1]");
assertEquals("Cannot get simple index(1)", "Bean@1", value.getName());
assertEquals("Bug in NestedTestBean", "NOT SET",
value.getTestString());
-
+
String
prop = (String) PropertyUtils.getProperty(
nestedBean,
"indexedProperty[0].testString");
assertEquals("Get property on indexes failed (1)", "NOT SET", prop);
-
+
prop = (String) PropertyUtils.getProperty(
nestedBean,
- "indexedProperty[1].testString");
- assertEquals("Get property on indexes failed (2)", "NOT SET", prop);
+ "indexedProperty[1].testString");
+ assertEquals("Get property on indexes failed (2)", "NOT SET", prop);
PropertyUtils.setProperty(
nestedBean,
"indexedProperty[0].testString",
"Test#1");
assertEquals(
- "Cannot set property on indexed bean (1)",
- "Test#1",
+ "Cannot set property on indexed bean (1)",
+ "Test#1",
nestedBean.getIndexedProperty(0).getTestString());
-
+
PropertyUtils.setProperty(
nestedBean,
"indexedProperty[1].testString",
- "Test#2");
+ "Test#2");
assertEquals(
- "Cannot set property on indexed bean (2)",
- "Test#2",
- nestedBean.getIndexedProperty(1).getTestString());
-
-
+ "Cannot set property on indexed bean (2)",
+ "Test#2",
+ nestedBean.getIndexedProperty(1).getTestString());
+
+
// test first calling indexed properties on a simple property
-
+
value = (NestedTestBean) PropertyUtils.getProperty(
nestedBean,
"simpleBeanProperty");
assertEquals("Cannot get simple bean", "Simple Property Bean",
value.getName());
assertEquals("Bug in NestedTestBean", "NOT SET",
value.getTestString());
-
+
value = (NestedTestBean) PropertyUtils.getProperty(
nestedBean,
"simpleBeanProperty.indexedProperty[3]");
assertEquals("Cannot get index property on property", "Bean@3",
value.getName());
assertEquals("Bug in NestedTestBean", "NOT SET",
value.getTestString());
-
+
PropertyUtils.setProperty(
nestedBean,
"simpleBeanProperty.indexedProperty[3].testString",
- "Test#3");
+ "Test#3");
assertEquals(
- "Cannot set property on indexed property on property",
- "Test#3",
-
nestedBean.getSimpleBeanProperty().getIndexedProperty(3).getTestString());
+ "Cannot set property on indexed property on property",
+ "Test#3",
+
nestedBean.getSimpleBeanProperty().getIndexedProperty(3).getTestString());
}
-
+
/** Text case for setting properties on inner classes */
public void testGetSetInnerBean() throws Exception {
BeanWithInnerBean bean = new BeanWithInnerBean();
-
+
PropertyUtils.setProperty(bean, "innerBean.fish(loiterTimer)", "5");
String out = (String) PropertyUtils.getProperty(bean.getInnerBean(),
"fish(loiterTimer)");
assertEquals(
- "(1) Inner class property set/get property failed.",
- "5",
- out);
-
+ "(1) Inner class property set/get property failed.",
+ "5",
+ out);
+
out = (String) PropertyUtils.getProperty(bean,
"innerBean.fish(loiterTimer)");
-
+
assertEquals(
- "(2) Inner class property set/get property failed.",
- "5",
- out);
+ "(2) Inner class property set/get property failed.",
+ "5",
+ out);
}
-
+
/** Text case for setting properties on parent */
public void testGetSetParentBean() throws Exception {
SonOfAlphaBean bean = new SonOfAlphaBean("Roger");
-
+
String out = (String) PropertyUtils.getProperty(bean, "name");
assertEquals(
- "(1) Get/Set On Parent.",
- "Roger",
- out);
-
+ "(1) Get/Set On Parent.",
+ "Roger",
+ out);
+
PropertyUtils.setProperty(bean, "name", "abcd");
assertEquals(
- "(2) Get/Set On Parent.",
- "abcd",
- bean.getName());
+ "(2) Get/Set On Parent.",
+ "abcd",
+ bean.getName());
}
-
+
public void testSetNoGetter() throws Exception
{
BetaBean bean = new BetaBean("Cedric");
-
+
// test standard no getter
bean.setNoGetterProperty("Sigma");
assertEquals("BetaBean test failed", "Sigma", bean.getSecret());
-
+
assertNotNull("Descriptor is null",
PropertyUtils.getPropertyDescriptor(bean, "noGetterProperty"));
-
+
BeanUtils.setProperty(bean, "noGetterProperty", "Omega");
assertEquals("Cannot set no-getter property", "Omega",
bean.getSecret());
-
+
// test mapped no getter descriptor
- MappedPropertyDescriptor descriptor
+ MappedPropertyDescriptor descriptor
= new MappedPropertyDescriptor("noGetterMappedProperty",
BetaBean.class);
-
+
assertNotNull("Map Descriptor is null",
PropertyUtils.getPropertyDescriptor(bean, "noGetterMappedProperty"));
-
+
PropertyUtils.setMappedProperty(bean, "noGetterMappedProperty",
"Epsilon", "Epsilon");
assertEquals("Cannot set mapped no-getter property", "MAP:Epsilon",
bean.getSecret());
}
@@ -4233,7 +4233,7 @@ public class PropertyUtilsTestCase exten
fail("setProperty(foo) threw " + t);
}
assertEquals("foo property", "foo-updated", bean.getFoo());
-
+
// Set Bar
try {
PropertyUtils.setProperty(bean, "bar", "bar-updated");
@@ -4242,7 +4242,7 @@ public class PropertyUtilsTestCase exten
}
assertEquals("bar property", "bar-updated", bean.getBar());
}
-
+
/**
* There is an issue in setNestedProperty/getNestedProperty when the
* target bean is a map and the name string requests mapped or indexed
@@ -4272,10 +4272,10 @@ public class PropertyUtilsTestCase exten
HashMap submap = new HashMap();
BetaBean betaBean1 = new BetaBean("test1");
BetaBean betaBean2 = new BetaBean("test2");
-
+
// map.put("submap", submap)
PropertyUtils.setNestedProperty(map, "submap", submap);
-
+
// map.get("submap").put("beta1", betaBean1)
PropertyUtils.setNestedProperty(map, "submap.beta1", betaBean1);
assertEquals("Unexpected keys in map", "submap", keysToString(map));
@@ -4290,8 +4290,8 @@ public class PropertyUtilsTestCase exten
// returned object is a Map or Array.
PropertyUtils.setNestedProperty(map, "submap(beta2)", betaBean2);
- // What, no exception? In that case, setNestedProperties has
- // probably just tried to do
+ // What, no exception? In that case, setNestedProperties has
+ // probably just tried to do
// map.set("submap(beta2)", betaBean2)
// which is almost certainly not what the used expected. This is
// what beanutils 1.5.0 to 1.7.1 did....
@@ -4313,9 +4313,9 @@ public class PropertyUtilsTestCase exten
// only effectively has "simple" properties, even when the
// returned object is a Map or Array.
Object o = PropertyUtils.getNestedProperty(map, "submap[3]");
-
- // What, no exception? In that case, getNestedProperties has
- // probably just tried to do
+
+ // What, no exception? In that case, getNestedProperties has
+ // probably just tried to do
// map.get("submap[3]")
// which is almost certainly not what the used expected. This is
// what beanutils 1.5.0 to 1.7.1 did....
@@ -4348,13 +4348,13 @@ public class PropertyUtilsTestCase exten
return buf.toString();
}
- /**
+ /**
* This tests to see that classes that implement Map always have their
* custom properties ignored.
* <p>
* Note that this behaviour has changed several times over past releases
* of beanutils, breaking backwards compatibility each time. Here's hoping
- * that the current 1.7.1 release is the last time this behaviour changes!
+ * that the current 1.7.1 release is the last time this behaviour changes!
*/
public void testMapExtensionDefault() throws Exception {
ExtendMapBean bean = new ExtendMapBean();
@@ -4362,38 +4362,38 @@ public class PropertyUtilsTestCase exten
// setting property direct should work, and not affect map
bean.setUnusuallyNamedProperty("bean value");
assertEquals("Set property direct failed", "bean value",
bean.getUnusuallyNamedProperty());
- assertNull("Get on unset map property failed",
+ assertNull("Get on unset map property failed",
PropertyUtils.getNestedProperty(bean,
"unusuallyNamedProperty"));
-
+
// setting simple property should call the setter method only, and not
// affect the map.
PropertyUtils.setSimpleProperty(bean, "unusuallyNamedProperty", "new
value");
assertEquals("Set property on map failed (1)", "new value",
bean.getUnusuallyNamedProperty());
- assertNull("Get on unset map property failed",
+ assertNull("Get on unset map property failed",
PropertyUtils.getNestedProperty(bean,
"unusuallyNamedProperty"));
// setting via setNestedProperty should affect the map only, and not
// call the setter method.
PropertyUtils.setProperty(bean, "unusuallyNamedProperty", "next
value");
assertEquals(
- "setNestedProperty on map not visible to getNestedProperty",
- "next value",
+ "setNestedProperty on map not visible to getNestedProperty",
+ "next value",
PropertyUtils.getNestedProperty(bean,
"unusuallyNamedProperty"));
assertEquals(
- "Set nested property on map unexpected affected simple property",
- "new value",
+ "Set nested property on map unexpected affected simple property",
+ "new value",
bean.getUnusuallyNamedProperty());
}
- /**
+ /**
* This tests to see that it is possible to subclass PropertyUtilsBean
* and change the behaviour of setNestedProperty/getNestedProperty when
- * dealing with objects that implement Map.
+ * dealing with objects that implement Map.
*/
public void testMapExtensionCustom() throws Exception {
PropsFirstPropertyUtilsBean utilsBean = new
PropsFirstPropertyUtilsBean();
ExtendMapBean bean = new ExtendMapBean();
-
+
// hardly worth testing this, really :-)
bean.setUnusuallyNamedProperty("bean value");
assertEquals("Set property direct failed", "bean value",
bean.getUnusuallyNamedProperty());
@@ -4406,16 +4406,16 @@ public class PropertyUtilsTestCase exten
// getNestedProperty with getter should obtain the simple property
utilsBean.setProperty(bean, "unusuallyNamedProperty", "next value");
assertEquals("Set property on map failed (2)", "next value",
bean.getUnusuallyNamedProperty());
- assertEquals("setNestedProperty on non-simple property failed",
+ assertEquals("setNestedProperty on non-simple property failed",
"next value",
utilsBean.getNestedProperty(bean, "unusuallyNamedProperty"));
// setting property without setter should update the map
// getting property without setter should fetch from the map
utilsBean.setProperty(bean, "mapProperty", "value1");
- assertEquals("setNestedProperty on non-simple property failed",
+ assertEquals("setNestedProperty on non-simple property failed",
"value1", utilsBean.getNestedProperty(bean, "mapProperty"));
-
+
HashMap myMap = new HashMap();
myMap.put("thebean", bean);
utilsBean.getNestedProperty(myMap, "thebean.mapitem");