You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2023/02/18 13:53:21 UTC
[commons-beanutils] 03/05: Normalize formatting
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-beanutils.git
commit 9cd5a53a59c1636b5e78d4eef960e6b460340711
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Feb 15 14:21:34 2023 -0500
Normalize formatting
---
.../beanutils2/BaseDynaBeanMapDecorator.java | 136 +-
.../apache/commons/beanutils2/AbstractChild.java | 6 +-
.../apache/commons/beanutils2/AbstractParent.java | 3 +-
.../commons/beanutils2/BasicDynaBeanTestCase.java | 259 +--
.../commons/beanutils2/BeanComparatorTestCase.java | 107 +-
.../beanutils2/BeanIntrospectionDataTestCase.java | 20 +-
.../apache/commons/beanutils2/BeanMapTestCase.java | 186 +--
.../BeanPropertyValueChangeConsumerTestCase.java | 5 +-
.../BeanPropertyValueEqualsPredicateTestCase.java | 48 +-
.../BeanToPropertyValueTransformerTestCase.java | 46 +-
.../commons/beanutils2/BeanUtilsBean2TestCase.java | 8 +-
.../commons/beanutils2/BeanUtilsBeanTestCase.java | 459 ++----
.../commons/beanutils2/BeanUtilsBenchCase.java | 55 +-
.../commons/beanutils2/BeanWithInnerBean.java | 27 +-
.../commons/beanutils2/BeanificationTestCase.java | 87 +-
.../org/apache/commons/beanutils2/BenchBean.java | 2 -
.../beanutils2/ConstructorUtilsTestCase.java | 90 +-
.../commons/beanutils2/ConvertUtilsTestCase.java | 157 +-
.../beanutils2/DynaBeanMapDecoratorTestCase.java | 77 +-
.../commons/beanutils2/DynaBeanUtilsTestCase.java | 460 ++----
.../commons/beanutils2/DynaPropertyTestCase.java | 1 +
.../beanutils2/DynaPropertyUtilsTestCase.java | 906 +++--------
.../apache/commons/beanutils2/ExtendMapBean.java | 9 +-
.../beanutils2/FluentIntrospectionTestBean.java | 3 +-
.../FluentPropertyBeanIntrospectorTestCase.java | 26 +-
.../beanutils2/IndexedPropertyTestCase.java | 137 +-
.../apache/commons/beanutils2/IndexedTestBean.java | 2 -
.../commons/beanutils2/LazyDynaBeanTestCase.java | 88 +-
.../commons/beanutils2/LazyDynaClassTestCase.java | 10 +-
.../commons/beanutils2/LazyDynaListTestCase.java | 111 +-
.../commons/beanutils2/LazyDynaMapTestCase.java | 98 +-
.../beanutils2/MappedPropertyChildBean.java | 2 +-
.../beanutils2/MappedPropertyChildInterface.java | 3 +-
.../commons/beanutils2/MappedPropertyTestBean.java | 10 +-
.../commons/beanutils2/MappedPropertyTestCase.java | 57 +-
.../commons/beanutils2/MethodUtilsTestCase.java | 273 +---
.../apache/commons/beanutils2/NestedTestBean.java | 5 -
.../commons/beanutils2/PropertyUtilsBenchCase.java | 45 +-
.../commons/beanutils2/PropertyUtilsTestCase.java | 1717 ++++++--------------
.../beanutils2/PropsFirstPropertyUtilsBean.java | 21 +-
...SuppressPropertiesBeanIntrospectorTestCase.java | 27 +-
.../org/apache/commons/beanutils2/TestBean.java | 100 +-
.../beanutils2/TestBeanPackageSubclass.java | 3 +-
.../commons/beanutils2/TestBeanPublicSubclass.java | 3 +-
.../beanutils2/ThrowExceptionConverter.java | 6 +-
.../commons/beanutils2/WrapDynaBeanTestCase.java | 68 +-
.../commons/beanutils2/bugs/Jira157TestCase.java | 21 +-
.../commons/beanutils2/bugs/Jira18TestCase.java | 41 +-
.../commons/beanutils2/bugs/Jira273TestCase.java | 21 +-
.../commons/beanutils2/bugs/Jira298TestCase.java | 4 +-
.../commons/beanutils2/bugs/Jira345TestCase.java | 18 +-
.../commons/beanutils2/bugs/Jira347TestCase.java | 68 +-
.../commons/beanutils2/bugs/Jira349TestCase.java | 6 +-
.../commons/beanutils2/bugs/Jira357TestCase.java | 15 +-
.../commons/beanutils2/bugs/Jira359TestCase.java | 13 +-
.../commons/beanutils2/bugs/Jira381TestCase.java | 18 +-
.../commons/beanutils2/bugs/Jira411TestCase.java | 3 +-
.../commons/beanutils2/bugs/Jira422TestCase.java | 6 +-
.../commons/beanutils2/bugs/Jira454TestCase.java | 3 +-
.../commons/beanutils2/bugs/Jira456TestCase.java | 12 +-
.../commons/beanutils2/bugs/Jira458TestCase.java | 5 +-
.../commons/beanutils2/bugs/Jira463TestCase.java | 6 +-
.../commons/beanutils2/bugs/Jira465TestCase.java | 6 +-
.../commons/beanutils2/bugs/Jira492TestCase.java | 6 +-
.../commons/beanutils2/bugs/Jira509TestCase.java | 11 +-
.../commons/beanutils2/bugs/Jira61TestCase.java | 165 +-
.../commons/beanutils2/bugs/Jira87TestCase.java | 6 +-
.../commons/beanutils2/bugs/Jira92TestCase.java | 5 +-
.../beanutils2/bugs/other/Jira18BeanFactory.java | 10 +-
.../beanutils2/bugs/other/Jira273BeanFactory.java | 10 +-
.../beanutils2/bugs/other/Jira298BeanFactory.java | 3 +
.../bugs/other/Jira492IndexedListsSupport.java | 4 +
.../beanutils2/bugs/other/Jira61BeanFactory.java | 6 +-
.../beanutils2/bugs/other/Jira87BeanFactory.java | 1 +
.../converters/ArrayConverterTestCase.java | 70 +-
.../converters/BaseLocaleConverterTestCase.java | 48 +-
.../converters/BigDecimalConverterTestCase.java | 70 +-
.../converters/BigIntegerConverterTestCase.java | 57 +-
.../converters/BooleanConverterTestCase.java | 28 +-
.../converters/ByteConverterTestCase.java | 73 +-
.../converters/CalendarConverterTestCase.java | 7 +-
.../converters/CharacterConverterTestCase.java | 21 +-
.../converters/ClassConverterTestCase.java | 16 +-
.../beanutils2/converters/ClassReloader.java | 33 +-
.../converters/ClassReloaderTestCase.java | 1 -
.../converters/DateConverterTestBase.java | 105 +-
.../converters/DateConverterTestCase.java | 5 +
.../converters/DoubleConverterTestCase.java | 79 +-
.../converters/DurationConverterTestCase.java | 38 +-
.../converters/EnumConverterTestCase.java | 40 +-
.../converters/FileConverterTestCase.java | 31 +-
.../converters/FloatConverterTestCase.java | 79 +-
.../converters/IntegerConverterTestCase.java | 63 +-
.../converters/LocalDateConverterTestCase.java | 5 +
.../converters/LocalDateTimeConverterTestCase.java | 5 +
.../converters/LocalTimeConverterTestCase.java | 36 +-
.../converters/LongConverterTestCase.java | 66 +-
.../beanutils2/converters/MemoryTestCase.java | 139 +-
.../converters/MonthDayConverterTestCase.java | 38 +-
.../converters/NumberConverterTestBase.java | 70 +-
.../OffsetDateTimeConverterTestCase.java | 7 +-
.../converters/OffsetTimeConverterTestCase.java | 36 +-
.../converters/PathConverterTestCase.java | 30 +-
.../converters/PeriodConverterTestCase.java | 38 +-
.../converters/ShortConverterTestCase.java | 63 +-
.../converters/URIConverterTestCase.java | 51 +-
.../converters/URLConverterTestCase.java | 16 +-
.../converters/UUIDConverterTestCase.java | 36 +-
.../converters/YearConverterTestCase.java | 38 +-
.../converters/YearMonthConverterTestCase.java | 38 +-
.../converters/ZoneIdConverterTestCase.java | 38 +-
.../converters/ZoneOffsetConverterTestCase.java | 38 +-
.../converters/ZonedDateTimeConverterTestCase.java | 5 +
.../expression/DefaultResolverTestCase.java | 38 +-
.../beanutils2/locale/LocaleBeanUtilsTestCase.java | 6 +-
.../locale/LocaleBeanificationTestCase.java | 108 +-
.../locale/LocaleConvertUtilsTestCase.java | 308 ++--
.../memoryleaktests/MemoryLeakTestCase.java | 106 +-
.../memoryleaktests/pojotests/CustomInteger.java | 13 +-
.../commons/beanutils2/priv/PackageBean.java | 19 +-
.../commons/beanutils2/priv/PrivateBean.java | 10 +-
.../beanutils2/priv/PrivateBeanSubclass.java | 7 +-
.../commons/beanutils2/priv/PrivateDirect.java | 2 -
.../commons/beanutils2/priv/PrivateIndirect.java | 2 -
.../commons/beanutils2/priv/PublicSubBean.java | 19 +-
.../beanutils2/sql/DynaResultSetTestCase.java | 81 +-
.../commons/beanutils2/sql/DynaRowSetTestCase.java | 111 +-
.../commons/beanutils2/sql/TestResultSet.java | 197 +--
.../beanutils2/sql/TestResultSetMetaData.java | 58 +-
.../sql/converters/SqlDateConverterTestCase.java | 9 +-
.../sql/converters/SqlTimeConverterTestCase.java | 7 +-
.../converters/SqlTimestampConverterTestCase.java | 5 +
132 files changed, 3111 insertions(+), 6114 deletions(-)
diff --git a/src/main/java/org/apache/commons/beanutils2/BaseDynaBeanMapDecorator.java b/src/main/java/org/apache/commons/beanutils2/BaseDynaBeanMapDecorator.java
index 9074ecb6..28794e50 100644
--- a/src/main/java/org/apache/commons/beanutils2/BaseDynaBeanMapDecorator.java
+++ b/src/main/java/org/apache/commons/beanutils2/BaseDynaBeanMapDecorator.java
@@ -25,25 +25,23 @@ import java.util.Map;
import java.util.Set;
/**
- * <p>A base class for decorators providing {@code Map} behavior on
- * {@link DynaBean}s.</p>
+ * <p>
+ * A base class for decorators providing {@code Map} behavior on {@link DynaBean}s.
+ * </p>
*
- * <p>The motivation for this implementation is to provide access to {@link DynaBean}
- * properties in technologies that are unaware of BeanUtils and {@link DynaBean}s -
- * such as the expression languages of JSTL and JSF.</p>
+ * <p>
+ * The motivation for this implementation is to provide access to {@link DynaBean} properties in technologies that are unaware of BeanUtils and
+ * {@link DynaBean}s - such as the expression languages of JSTL and JSF.
+ * </p>
*
- * <p>This rather technical base class implements the methods of the
- * {@code Map} interface on top of a {@code DynaBean}. It was introduced
- * to handle generic parameters in a meaningful way without breaking
- * backwards compatibility of the 1.x {@code DynaBeanMapDecorator} class: A
- * map wrapping a {@code DynaBean} should be of type {@code Map<String, Object>}.
- * However, when using these generic parameters in {@code DynaBeanMapDecorator}
- * this would be an incompatible change (as method signatures would have to
- * be adapted). To solve this problem, this generic base class is added
- * which allows specifying the key type as parameter. This makes it easy to
- * have a new subclass using the correct generic parameters while
- * {@code DynaBeanMapDecorator} could still remain with compatible
- * parameters.</p>
+ * <p>
+ * This rather technical base class implements the methods of the {@code Map} interface on top of a {@code DynaBean}. It was introduced to handle generic
+ * parameters in a meaningful way without breaking backwards compatibility of the 1.x {@code DynaBeanMapDecorator} class: A map wrapping a {@code DynaBean}
+ * should be of type {@code Map<String, Object>}. However, when using these generic parameters in {@code DynaBeanMapDecorator} this would be an incompatible
+ * change (as method signatures would have to be adapted). To solve this problem, this generic base class is added which allows specifying the key type as
+ * parameter. This makes it easy to have a new subclass using the correct generic parameters while {@code DynaBeanMapDecorator} could still remain with
+ * compatible parameters.
+ * </p>
*
* @param <K> the type of the keys in the decorated map
* @since 1.9.0
@@ -54,11 +52,8 @@ public abstract class BaseDynaBeanMapDecorator<K> implements Map<K, Object> {
private final boolean readOnly;
private transient Set<K> keySet;
-
-
/**
- * Constructs a read only Map for the specified
- * {@link DynaBean}.
+ * Constructs a read only Map for the specified {@link DynaBean}.
*
* @param dynaBean The dyna bean being decorated
* @throws IllegalArgumentException if the {@link DynaBean} is null.
@@ -71,8 +66,7 @@ public abstract class BaseDynaBeanMapDecorator<K> implements Map<K, Object> {
* Constructs a Map for the specified {@link DynaBean}.
*
* @param dynaBean The dyna bean being decorated
- * @param readOnly {@code true} if the Map is read only
- * otherwise {@code false}
+ * @param readOnly {@code true} if the Map is read only otherwise {@code false}
* @throws IllegalArgumentException if the {@link DynaBean} is null.
*/
public BaseDynaBeanMapDecorator(final DynaBean dynaBean, final boolean readOnly) {
@@ -83,22 +77,15 @@ public abstract class BaseDynaBeanMapDecorator<K> implements Map<K, Object> {
this.readOnly = readOnly;
}
-
-
-
-
/**
* Indicate whether the Map is read only.
*
- * @return {@code true} if the Map is read only,
- * otherwise {@code false}.
+ * @return {@code true} if the Map is read only, otherwise {@code false}.
*/
public boolean isReadOnly() {
return readOnly;
}
-
-
/**
* clear() operation is not supported.
*
@@ -110,12 +97,10 @@ public abstract class BaseDynaBeanMapDecorator<K> implements Map<K, Object> {
}
/**
- * Indicate whether the {@link DynaBean} contains a specified
- * value for one (or more) of its properties.
+ * Indicate whether the {@link DynaBean} contains a specified value for one (or more) of its properties.
*
* @param key The {@link DynaBean}'s property name
- * @return {@code true} if one of the {@link DynaBean}'s
- * properties contains a specified value.
+ * @return {@code true} if one of the {@link DynaBean}'s properties contains a specified value.
*/
@Override
public boolean containsKey(final Object key) {
@@ -125,13 +110,10 @@ public abstract class BaseDynaBeanMapDecorator<K> implements Map<K, Object> {
}
/**
- * Indicates whether the decorated {@link DynaBean} contains
- * a specified value.
+ * Indicates whether the decorated {@link DynaBean} contains a specified value.
*
* @param value The value to check for.
- * @return {@code true} if one of the {@link DynaBean}'s
- * properties contains the specified value, otherwise
- * {@code false}.
+ * @return {@code true} if one of the {@link DynaBean}'s properties contains the specified value, otherwise {@code false}.
*/
@Override
public boolean containsValue(final Object value) {
@@ -151,14 +133,15 @@ public abstract class BaseDynaBeanMapDecorator<K> implements Map<K, Object> {
}
/**
- * <p>Returns the Set of the property/value mappings
- * in the decorated {@link DynaBean}.</p>
+ * <p>
+ * Returns the Set of the property/value mappings in the decorated {@link DynaBean}.
+ * </p>
*
- * <p>Each element in the Set is a {@code Map.Entry}
- * type.</p>
+ * <p>
+ * Each element in the Set is a {@code Map.Entry} type.
+ * </p>
*
- * @return An unmodifiable set of the DynaBean
- * property name/value pairs
+ * @return An unmodifiable set of the DynaBean property name/value pairs
*/
@Override
public Set<Map.Entry<K, Object>> entrySet() {
@@ -173,8 +156,7 @@ public abstract class BaseDynaBeanMapDecorator<K> implements Map<K, Object> {
}
/**
- * Gets the value for the specified key from
- * the decorated {@link DynaBean}.
+ * Gets the value for the specified key from the decorated {@link DynaBean}.
*
* @param key The {@link DynaBean}'s property name
* @return The value for the specified property.
@@ -185,11 +167,9 @@ public abstract class BaseDynaBeanMapDecorator<K> implements Map<K, Object> {
}
/**
- * Indicate whether the decorated {@link DynaBean} has
- * any properties.
+ * Indicate whether the decorated {@link DynaBean} has any properties.
*
- * @return {@code true} if the {@link DynaBean} has
- * no properties, otherwise {@code false}.
+ * @return {@code true} if the {@link DynaBean} has no properties, otherwise {@code false}.
*/
@Override
public boolean isEmpty() {
@@ -197,15 +177,16 @@ public abstract class BaseDynaBeanMapDecorator<K> implements Map<K, Object> {
}
/**
- * <p>Returns the Set of the property
- * names in the decorated {@link DynaBean}.</p>
+ * <p>
+ * Returns the Set of the property names in the decorated {@link DynaBean}.
+ * </p>
*
- * <p><b>N.B.</b>For {@link DynaBean}s whose associated {@link DynaClass}
- * is a {@link MutableDynaClass} a new Set is created every
- * time, otherwise the Set is created only once and cached.</p>
+ * <p>
+ * <b>N.B.</b>For {@link DynaBean}s whose associated {@link DynaClass} is a {@link MutableDynaClass} a new Set is created every time, otherwise the Set is
+ * created only once and cached.
+ * </p>
*
- * @return An unmodifiable set of the {@link DynaBean}s
- * property names.
+ * @return An unmodifiable set of the {@link DynaBean}s property names.
*/
@Override
public Set<K> keySet() {
@@ -232,14 +213,12 @@ public abstract class BaseDynaBeanMapDecorator<K> implements Map<K, Object> {
}
/**
- * Puts the value for the specified property in
- * the decorated {@link DynaBean}.
+ * Puts the value for the specified property in the decorated {@link DynaBean}.
*
- * @param key The {@link DynaBean}'s property name
+ * @param key The {@link DynaBean}'s property name
* @param value The value for the specified property.
* @return The previous property's value.
- * @throws UnsupportedOperationException if
- * {@code isReadOnly()} is true.
+ * @throws UnsupportedOperationException if {@code isReadOnly()} is true.
*/
@Override
public Object put(final K key, final Object value) {
@@ -256,8 +235,7 @@ public abstract class BaseDynaBeanMapDecorator<K> implements Map<K, Object> {
* Copy the contents of a Map to the decorated {@link DynaBean}.
*
* @param map The Map of values to copy.
- * @throws UnsupportedOperationException if
- * {@code isReadOnly()} is true.
+ * @throws UnsupportedOperationException if {@code isReadOnly()} is true.
*/
@Override
public void putAll(final Map<? extends K, ? extends Object> map) {
@@ -280,8 +258,8 @@ public abstract class BaseDynaBeanMapDecorator<K> implements Map<K, Object> {
}
/**
- * Returns the number properties in the decorated
- * {@link DynaBean}.
+ * Returns the number properties in the decorated {@link DynaBean}.
+ *
* @return The number of properties.
*/
@Override
@@ -290,8 +268,7 @@ public abstract class BaseDynaBeanMapDecorator<K> implements Map<K, Object> {
}
/**
- * Returns the set of property values in the
- * decorated {@link DynaBean}.
+ * Returns the set of property values in the decorated {@link DynaBean}.
*
* @return Unmodifiable collection of values.
*/
@@ -307,11 +284,8 @@ public abstract class BaseDynaBeanMapDecorator<K> implements Map<K, Object> {
return Collections.unmodifiableList(values);
}
-
-
/**
- * Provide access to the underlying {@link DynaBean}
- * this Map decorates.
+ * Provide access to the underlying {@link DynaBean} this Map decorates.
*
* @return the decorated {@link DynaBean}.
*/
@@ -327,11 +301,8 @@ public abstract class BaseDynaBeanMapDecorator<K> implements Map<K, Object> {
*/
protected abstract K convertKey(String propertyName);
-
-
/**
- * Convenience method to retrieve the {@link DynaProperty}s
- * for this {@link DynaClass}.
+ * Convenience method to retrieve the {@link DynaProperty}s for this {@link DynaClass}.
*
* @return The an array of the {@link DynaProperty}s.
*/
@@ -340,8 +311,7 @@ public abstract class BaseDynaBeanMapDecorator<K> implements Map<K, Object> {
}
/**
- * Convenience method to convert an Object
- * to a String.
+ * Convenience method to convert an Object to a String.
*
* @param obj The Object to convert
* @return String representation of the object
@@ -368,10 +338,8 @@ public abstract class BaseDynaBeanMapDecorator<K> implements Map<K, Object> {
if (!(o instanceof Map.Entry)) {
return false;
}
- final Map.Entry<?, ?> e = (Map.Entry<?, ?>)o;
- return key.equals(e.getKey()) &&
- (value == null ? e.getValue() == null
- : value.equals(e.getValue()));
+ final Map.Entry<?, ?> e = (Map.Entry<?, ?>) o;
+ return key.equals(e.getKey()) && (value == null ? e.getValue() == null : value.equals(e.getValue()));
}
@Override
diff --git a/src/test/java/org/apache/commons/beanutils2/AbstractChild.java b/src/test/java/org/apache/commons/beanutils2/AbstractChild.java
index b7b9fc42..b9bbc528 100644
--- a/src/test/java/org/apache/commons/beanutils2/AbstractChild.java
+++ b/src/test/java/org/apache/commons/beanutils2/AbstractChild.java
@@ -23,14 +23,12 @@ public class AbstractChild implements Child {
private String name;
- protected void setName(final String name)
- {
+ protected void setName(final String name) {
this.name = name;
}
@Override
- public String getName()
- {
+ public String getName() {
return name;
}
diff --git a/src/test/java/org/apache/commons/beanutils2/AbstractParent.java b/src/test/java/org/apache/commons/beanutils2/AbstractParent.java
index 984d3642..d7fc4f1a 100644
--- a/src/test/java/org/apache/commons/beanutils2/AbstractParent.java
+++ b/src/test/java/org/apache/commons/beanutils2/AbstractParent.java
@@ -23,8 +23,7 @@ public abstract class AbstractParent {
private Child child;
- public Child getChild()
- {
+ public Child getChild() {
return child;
}
diff --git a/src/test/java/org/apache/commons/beanutils2/BasicDynaBeanTestCase.java b/src/test/java/org/apache/commons/beanutils2/BasicDynaBeanTestCase.java
index 40e8dd02..af2832e0 100644
--- a/src/test/java/org/apache/commons/beanutils2/BasicDynaBeanTestCase.java
+++ b/src/test/java/org/apache/commons/beanutils2/BasicDynaBeanTestCase.java
@@ -31,46 +31,27 @@ import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
- * <p>Test Case for the {@code BasicDynaBean} implementation class.
- * These tests were based on the ones in {@code PropertyUtilsTestCase}
- * because the two classes provide similar levels of functionality.</p>
+ * <p>
+ * Test Case for the {@code BasicDynaBean} implementation class. These tests were based on the ones in {@code PropertyUtilsTestCase} because the two classes
+ * provide similar levels of functionality.
+ * </p>
*
*/
public class BasicDynaBeanTestCase extends TestCase {
-
-
/**
* The basic test bean for each test.
*/
protected DynaBean bean = null;
/**
- * The set of property names we expect to have returned when calling
- * {@code getDynaProperties()}. You should update this list
- * when new properties are added to TestBean.
+ * The set of property names we expect to have returned when calling {@code getDynaProperties()}. You should update this list when new properties are added
+ * to TestBean.
*/
- protected final static String[] properties = {
- "booleanProperty",
- "booleanSecond",
- "doubleProperty",
- "floatProperty",
- "intArray",
- "intIndexed",
- "intProperty",
- "listIndexed",
- "longProperty",
- "mappedProperty",
- "mappedIntProperty",
- "nullProperty",
- "shortProperty",
- "stringArray",
- "stringIndexed",
- "stringProperty",
- };
-
-
+ protected final static String[] properties = { "booleanProperty", "booleanSecond", "doubleProperty", "floatProperty", "intArray", "intIndexed",
+ "intProperty", "listIndexed", "longProperty", "mappedProperty", "mappedIntProperty", "nullProperty", "shortProperty", "stringArray",
+ "stringIndexed", "stringProperty", };
/**
* Constructs a new instance of this test case.
@@ -83,8 +64,6 @@ public class BasicDynaBeanTestCase extends TestCase {
}
-
-
/**
* Sets up instance variables required by this test case.
*/
@@ -123,11 +102,9 @@ public class BasicDynaBeanTestCase extends TestCase {
bean.set("mappedIntProperty", mappedIntProperty);
// Property "nullProperty" is not initialized, so it should return null
bean.set("shortProperty", Short.valueOf((short) 987));
- final String[] stringArray =
- { "String 0", "String 1", "String 2", "String 3", "String 4" };
+ final String[] stringArray = { "String 0", "String 1", "String 2", "String 3", "String 4" };
bean.set("stringArray", stringArray);
- final String[] stringIndexed =
- { "String 0", "String 1", "String 2", "String 3", "String 4" };
+ final String[] stringIndexed = { "String 0", "String 1", "String 2", "String 3", "String 4" };
bean.set("stringIndexed", stringIndexed);
bean.set("stringProperty", "This is a string");
@@ -152,18 +129,14 @@ public class BasicDynaBeanTestCase extends TestCase {
}
-
-
/**
* Corner cases on getDynaProperty invalid arguments.
*/
public void testGetDescriptorArguments() {
try {
- final DynaProperty descriptor =
- bean.getDynaClass().getDynaProperty("unknown");
- assertNull("Unknown property descriptor should be null",
- descriptor);
+ final DynaProperty descriptor = bean.getDynaClass().getDynaProperty("unknown");
+ assertNull("Unknown property descriptor should be null", descriptor);
} catch (final Throwable t) {
fail("Threw " + t + " instead of returning null");
}
@@ -225,8 +198,7 @@ public class BasicDynaBeanTestCase extends TestCase {
}
/**
- * Positive getDynaProperty on property {@code booleanSecond}
- * that uses an "is" method as the getter.
+ * Positive getDynaProperty on property {@code booleanSecond} that uses an "is" method as the getter.
*/
public void testGetDescriptorSecond() {
@@ -253,8 +225,7 @@ public class BasicDynaBeanTestCase extends TestCase {
}
/**
- * Positive test for getDynaProperties(). Each property name
- * listed in {@code properties} should be returned exactly once.
+ * Positive test for getDynaProperties(). Each property name listed in {@code properties} should be returned exactly once.
*/
public void testGetDescriptors() {
@@ -307,10 +278,8 @@ public class BasicDynaBeanTestCase extends TestCase {
try {
value = bean.get("intArray", i);
assertNotNull("intArray returned value " + i, value);
- assertTrue("intArray returned Integer " + i,
- value instanceof Integer);
- assertEquals("intArray returned correct " + i, i * 10,
- ((Integer) value).intValue());
+ assertTrue("intArray returned Integer " + i, value instanceof Integer);
+ assertEquals("intArray returned correct " + i, i * 10, ((Integer) value).intValue());
} catch (final Throwable t) {
fail("intArray " + i + " threw " + t);
}
@@ -318,10 +287,8 @@ public class BasicDynaBeanTestCase extends TestCase {
try {
value = bean.get("intIndexed", i);
assertNotNull("intIndexed returned value " + i, value);
- assertTrue("intIndexed returned Integer " + i,
- value instanceof Integer);
- assertEquals("intIndexed returned correct " + i, i * 10,
- ((Integer) value).intValue());
+ assertTrue("intIndexed returned Integer " + i, value instanceof Integer);
+ assertEquals("intIndexed returned correct " + i, i * 10, ((Integer) value).intValue());
} catch (final Throwable t) {
fail("intIndexed " + i + " threw " + t);
}
@@ -329,10 +296,8 @@ public class BasicDynaBeanTestCase extends TestCase {
try {
value = bean.get("listIndexed", i);
assertNotNull("listIndexed returned value " + i, value);
- assertTrue("list returned String " + i,
- value instanceof String);
- assertEquals("listIndexed returned correct " + i,
- "String " + i, (String) value);
+ assertTrue("list returned String " + i, value instanceof String);
+ assertEquals("listIndexed returned correct " + i, "String " + i, (String) value);
} catch (final Throwable t) {
fail("listIndexed " + i + " threw " + t);
}
@@ -340,10 +305,8 @@ public class BasicDynaBeanTestCase extends TestCase {
try {
value = bean.get("stringArray", i);
assertNotNull("stringArray returned value " + i, value);
- assertTrue("stringArray returned String " + i,
- value instanceof String);
- assertEquals("stringArray returned correct " + i,
- "String " + i, (String) value);
+ assertTrue("stringArray returned String " + i, value instanceof String);
+ assertEquals("stringArray returned correct " + i, "String " + i, (String) value);
} catch (final Throwable t) {
fail("stringArray " + i + " threw " + t);
}
@@ -351,10 +314,8 @@ public class BasicDynaBeanTestCase extends TestCase {
try {
value = bean.get("stringIndexed", i);
assertNotNull("stringIndexed returned value " + i, value);
- assertTrue("stringIndexed returned String " + i,
- value instanceof String);
- assertEquals("stringIndexed returned correct " + i,
- "String " + i, (String) value);
+ assertTrue("stringIndexed returned String " + i, value instanceof String);
+ assertEquals("stringIndexed returned correct " + i, "String " + i, (String) value);
} catch (final Throwable t) {
fail("stringIndexed " + i + " threw " + t);
}
@@ -432,8 +393,7 @@ public class BasicDynaBeanTestCase extends TestCase {
final Object value = bean.get("booleanProperty");
assertNotNull("Got a value", value);
assertTrue("Got correct type", value instanceof Boolean);
- assertTrue("Got correct value",
- (Boolean) value);
+ assertTrue("Got correct value", (Boolean) value);
} catch (final Throwable e) {
fail("Exception: " + e);
}
@@ -449,9 +409,7 @@ public class BasicDynaBeanTestCase extends TestCase {
final Object value = bean.get("doubleProperty");
assertNotNull("Got a value", value);
assertTrue("Got correct type", value instanceof Double);
- assertEquals("Got correct value",
- ((Double) value).doubleValue(),
- 321.0, 0.005);
+ assertEquals("Got correct value", ((Double) value).doubleValue(), 321.0, 0.005);
} catch (final Throwable t) {
fail("Exception: " + t);
}
@@ -467,10 +425,7 @@ public class BasicDynaBeanTestCase extends TestCase {
final Object value = bean.get("floatProperty");
assertNotNull("Got a value", value);
assertTrue("Got correct type", value instanceof Float);
- assertEquals("Got correct value",
- ((Float) value).floatValue(),
- (float) 123.0,
- (float) 0.005);
+ assertEquals("Got correct value", ((Float) value).floatValue(), (float) 123.0, (float) 0.005);
} catch (final Throwable t) {
fail("Exception: " + t);
}
@@ -486,9 +441,7 @@ public class BasicDynaBeanTestCase extends TestCase {
final Object value = bean.get("intProperty");
assertNotNull("Got a value", value);
assertTrue("Got correct type", value instanceof Integer);
- assertEquals("Got correct value",
- ((Integer) value).intValue(),
- 123);
+ assertEquals("Got correct value", ((Integer) value).intValue(), 123);
} catch (final Throwable t) {
fail("Exception: " + t);
}
@@ -504,9 +457,7 @@ public class BasicDynaBeanTestCase extends TestCase {
final Object value = bean.get("longProperty");
assertNotNull("Got a value", value);
assertTrue("Got correct type", value instanceof Long);
- assertEquals("Got correct value",
- ((Long) value).longValue(),
- 321);
+ assertEquals("Got correct value", ((Long) value).longValue(), 321);
} catch (final Throwable t) {
fail("Exception: " + t);
}
@@ -522,9 +473,7 @@ public class BasicDynaBeanTestCase extends TestCase {
final Object value = bean.get("shortProperty");
assertNotNull("Got a value", value);
assertTrue("Got correct type", value instanceof Short);
- assertEquals("Got correct value",
- ((Short) value).shortValue(),
- (short) 987);
+ assertEquals("Got correct value", ((Short) value).shortValue(), (short) 987);
} catch (final Throwable t) {
fail("Exception: " + t);
}
@@ -540,9 +489,7 @@ public class BasicDynaBeanTestCase extends TestCase {
final Object value = bean.get("stringProperty");
assertNotNull("Got a value", value);
assertTrue("Got correct type", value instanceof String);
- assertEquals("Got correct value",
- (String) value,
- "This is a string");
+ assertEquals("Got correct value", (String) value, "This is a string");
} catch (final Throwable t) {
fail("Exception: " + t);
}
@@ -555,15 +502,13 @@ public class BasicDynaBeanTestCase extends TestCase {
public void testMappedContains() {
try {
- assertTrue("Can see first key",
- bean.contains("mappedProperty", "First Key"));
+ assertTrue("Can see first key", bean.contains("mappedProperty", "First Key"));
} catch (final Throwable t) {
fail("Exception: " + t);
}
try {
- assertTrue("Can not see unknown key",
- !bean.contains("mappedProperty", "Unknown Key"));
+ assertTrue("Can not see unknown key", !bean.contains("mappedProperty", "Unknown Key"));
} catch (final Throwable t) {
fail("Exception: " + t);
}
@@ -576,21 +521,17 @@ public class BasicDynaBeanTestCase extends TestCase {
public void testMappedRemove() {
try {
- assertTrue("Can see first key",
- bean.contains("mappedProperty", "First Key"));
+ assertTrue("Can see first key", bean.contains("mappedProperty", "First Key"));
bean.remove("mappedProperty", "First Key");
- assertTrue("Can not see first key",
- !bean.contains("mappedProperty", "First Key"));
+ assertTrue("Can not see first key", !bean.contains("mappedProperty", "First Key"));
} catch (final Throwable t) {
fail("Exception: " + t);
}
try {
- assertTrue("Can not see unknown key",
- !bean.contains("mappedProperty", "Unknown Key"));
+ assertTrue("Can not see unknown key", !bean.contains("mappedProperty", "Unknown Key"));
bean.remove("mappedProperty", "Unknown Key");
- assertTrue("Can not see unknown key",
- !bean.contains("mappedProperty", "Unknown Key"));
+ assertTrue("Can not see unknown key", !bean.contains("mappedProperty", "Unknown Key"));
} catch (final Throwable t) {
fail("Exception: " + t);
}
@@ -616,8 +557,7 @@ public class BasicDynaBeanTestCase extends TestCase {
// Deserialize the test bean
try {
bean = null;
- final ByteArrayInputStream bais =
- new ByteArrayInputStream(baos.toByteArray());
+ final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
final ObjectInputStream ois = new ObjectInputStream(bais);
bean = (DynaBean) ois.readObject();
bais.close();
@@ -697,10 +637,8 @@ public class BasicDynaBeanTestCase extends TestCase {
bean.set("intArray", 0, Integer.valueOf(1));
value = bean.get("intArray", 0);
assertNotNull("Returned new value 0", value);
- assertTrue("Returned Integer new value 0",
- value instanceof Integer);
- assertEquals("Returned correct new value 0", 1,
- ((Integer) value).intValue());
+ assertTrue("Returned Integer new value 0", value instanceof Integer);
+ assertEquals("Returned correct new value 0", 1, ((Integer) value).intValue());
} catch (final Throwable t) {
fail("Threw " + t);
}
@@ -709,10 +647,8 @@ public class BasicDynaBeanTestCase extends TestCase {
bean.set("intIndexed", 1, Integer.valueOf(11));
value = bean.get("intIndexed", 1);
assertNotNull("Returned new value 1", value);
- assertTrue("Returned Integer new value 1",
- value instanceof Integer);
- assertEquals("Returned correct new value 1", 11,
- ((Integer) value).intValue());
+ assertTrue("Returned Integer new value 1", value instanceof Integer);
+ assertEquals("Returned correct new value 1", 11, ((Integer) value).intValue());
} catch (final Throwable t) {
fail("Threw " + t);
}
@@ -721,10 +657,8 @@ public class BasicDynaBeanTestCase extends TestCase {
bean.set("listIndexed", 2, "New Value 2");
value = bean.get("listIndexed", 2);
assertNotNull("Returned new value 2", value);
- assertTrue("Returned String new value 2",
- value instanceof String);
- assertEquals("Returned correct new value 2", "New Value 2",
- (String) value);
+ assertTrue("Returned String new value 2", value instanceof String);
+ assertEquals("Returned correct new value 2", "New Value 2", (String) value);
} catch (final Throwable t) {
fail("Threw " + t);
}
@@ -733,10 +667,8 @@ public class BasicDynaBeanTestCase extends TestCase {
bean.set("stringArray", 3, "New Value 3");
value = bean.get("stringArray", 3);
assertNotNull("Returned new value 3", value);
- assertTrue("Returned String new value 3",
- value instanceof String);
- assertEquals("Returned correct new value 3", "New Value 3",
- (String) value);
+ assertTrue("Returned String new value 3", value instanceof String);
+ assertEquals("Returned correct new value 3", "New Value 3", (String) value);
} catch (final Throwable t) {
fail("Threw " + t);
}
@@ -745,10 +677,8 @@ public class BasicDynaBeanTestCase extends TestCase {
bean.set("stringIndexed", 4, "New Value 4");
value = bean.get("stringIndexed", 4);
assertNotNull("Returned new value 4", value);
- assertTrue("Returned String new value 4",
- value instanceof String);
- assertEquals("Returned correct new value 4", "New Value 4",
- (String) value);
+ assertTrue("Returned String new value 4", value instanceof String);
+ assertEquals("Returned correct new value 4", "New Value 4", (String) value);
} catch (final Throwable t) {
fail("Threw " + t);
}
@@ -762,18 +692,14 @@ public class BasicDynaBeanTestCase extends TestCase {
try {
bean.set("mappedProperty", "First Key", "New First Value");
- assertEquals("Can replace old value",
- "New First Value",
- (String) bean.get("mappedProperty", "First Key"));
+ assertEquals("Can replace old value", "New First Value", (String) bean.get("mappedProperty", "First Key"));
} catch (final Throwable t) {
fail("Finding fourth value threw " + t);
}
try {
bean.set("mappedProperty", "Fourth Key", "Fourth Value");
- assertEquals("Can set new value",
- "Fourth Value",
- (String) bean.get("mappedProperty", "Fourth Key"));
+ assertEquals("Can set new value", "Fourth Value", (String) bean.get("mappedProperty", "Fourth Key"));
} catch (final Throwable t) {
fail("Finding fourth value threw " + t);
}
@@ -786,13 +712,10 @@ public class BasicDynaBeanTestCase extends TestCase {
public void testSetSimpleBoolean() {
try {
- final boolean oldValue =
- ((Boolean) bean.get("booleanProperty")).booleanValue();
+ final boolean oldValue = ((Boolean) bean.get("booleanProperty")).booleanValue();
final boolean newValue = !oldValue;
bean.set("booleanProperty", Boolean.valueOf(newValue));
- assertTrue("Matched new value",
- newValue ==
- ((Boolean) bean.get("booleanProperty")).booleanValue());
+ assertTrue("Matched new value", newValue == ((Boolean) bean.get("booleanProperty")).booleanValue());
} catch (final Throwable e) {
fail("Exception: " + e);
}
@@ -805,14 +728,10 @@ public class BasicDynaBeanTestCase extends TestCase {
public void testSetSimpleDouble() {
try {
- final double oldValue =
- ((Double) bean.get("doubleProperty")).doubleValue();
+ final double oldValue = ((Double) bean.get("doubleProperty")).doubleValue();
final double newValue = oldValue + 1.0;
bean.set("doubleProperty", Double.valueOf(newValue));
- assertEquals("Matched new value",
- newValue,
- ((Double) bean.get("doubleProperty")).doubleValue(),
- 0.005);
+ assertEquals("Matched new value", newValue, ((Double) bean.get("doubleProperty")).doubleValue(), 0.005);
} catch (final Throwable e) {
fail("Exception: " + e);
}
@@ -825,14 +744,10 @@ public class BasicDynaBeanTestCase extends TestCase {
public void testSetSimpleFloat() {
try {
- final float oldValue =
- ((Float) bean.get("floatProperty")).floatValue();
+ final float oldValue = ((Float) bean.get("floatProperty")).floatValue();
final float newValue = oldValue + (float) 1.0;
bean.set("floatProperty", Float.valueOf(newValue));
- assertEquals("Matched new value",
- newValue,
- ((Float) bean.get("floatProperty")).floatValue(),
- (float) 0.005);
+ assertEquals("Matched new value", newValue, ((Float) bean.get("floatProperty")).floatValue(), (float) 0.005);
} catch (final Throwable e) {
fail("Exception: " + e);
}
@@ -845,13 +760,10 @@ public class BasicDynaBeanTestCase extends TestCase {
public void testSetSimpleInt() {
try {
- final int oldValue =
- ((Integer) bean.get("intProperty")).intValue();
+ final int oldValue = ((Integer) bean.get("intProperty")).intValue();
final int newValue = oldValue + 1;
bean.set("intProperty", Integer.valueOf(newValue));
- assertEquals("Matched new value",
- newValue,
- ((Integer) bean.get("intProperty")).intValue());
+ assertEquals("Matched new value", newValue, ((Integer) bean.get("intProperty")).intValue());
} catch (final Throwable e) {
fail("Exception: " + e);
}
@@ -864,13 +776,10 @@ public class BasicDynaBeanTestCase extends TestCase {
public void testSetSimpleLong() {
try {
- final long oldValue =
- ((Long) bean.get("longProperty")).longValue();
+ final long oldValue = ((Long) bean.get("longProperty")).longValue();
final long newValue = oldValue + 1;
bean.set("longProperty", Long.valueOf(newValue));
- assertEquals("Matched new value",
- newValue,
- ((Long) bean.get("longProperty")).longValue());
+ assertEquals("Matched new value", newValue, ((Long) bean.get("longProperty")).longValue());
} catch (final Throwable e) {
fail("Exception: " + e);
}
@@ -883,13 +792,10 @@ public class BasicDynaBeanTestCase extends TestCase {
public void testSetSimpleShort() {
try {
- final short oldValue =
- ((Short) bean.get("shortProperty")).shortValue();
+ final short oldValue = ((Short) bean.get("shortProperty")).shortValue();
final short newValue = (short) (oldValue + 1);
bean.set("shortProperty", Short.valueOf(newValue));
- assertEquals("Matched new value",
- newValue,
- ((Short) bean.get("shortProperty")).shortValue());
+ assertEquals("Matched new value", newValue, ((Short) bean.get("shortProperty")).shortValue());
} catch (final Throwable e) {
fail("Exception: " + e);
}
@@ -905,46 +811,28 @@ public class BasicDynaBeanTestCase extends TestCase {
final String oldValue = (String) bean.get("stringProperty");
final String newValue = oldValue + " Extra Value";
bean.set("stringProperty", newValue);
- assertEquals("Matched new value",
- newValue,
- (String) bean.get("stringProperty"));
+ assertEquals("Matched new value", newValue, (String) bean.get("stringProperty"));
} catch (final Throwable e) {
fail("Exception: " + e);
}
}
-
-
/**
- * Create and return a {@code DynaClass} instance for our test
- * {@code DynaBean}.
+ * Create and return a {@code DynaClass} instance for our test {@code DynaBean}.
*/
protected DynaClass createDynaClass() {
final int[] intArray = {};
final String[] stringArray = {};
- final DynaClass dynaClass = new BasicDynaClass
- ("TestDynaClass", null,
- new DynaProperty[]{
- new DynaProperty("booleanProperty", Boolean.TYPE),
- new DynaProperty("booleanSecond", Boolean.TYPE),
- new DynaProperty("doubleProperty", Double.TYPE),
- new DynaProperty("floatProperty", Float.TYPE),
- new DynaProperty("intArray", intArray.getClass()),
- new DynaProperty("intIndexed", intArray.getClass()),
- new DynaProperty("intProperty", Integer.TYPE),
- new DynaProperty("listIndexed", List.class),
- new DynaProperty("longProperty", Long.TYPE),
- new DynaProperty("mappedProperty", Map.class),
- new DynaProperty("mappedIntProperty", Map.class),
- new DynaProperty("nullProperty", String.class),
- new DynaProperty("shortProperty", Short.TYPE),
- new DynaProperty("stringArray", stringArray.getClass()),
- new DynaProperty("stringIndexed", stringArray.getClass()),
- new DynaProperty("stringProperty", String.class),
- });
+ final DynaClass dynaClass = new BasicDynaClass("TestDynaClass", null, new DynaProperty[] { new DynaProperty("booleanProperty", Boolean.TYPE),
+ new DynaProperty("booleanSecond", Boolean.TYPE), new DynaProperty("doubleProperty", Double.TYPE), new DynaProperty("floatProperty", Float.TYPE),
+ new DynaProperty("intArray", intArray.getClass()), new DynaProperty("intIndexed", intArray.getClass()),
+ new DynaProperty("intProperty", Integer.TYPE), new DynaProperty("listIndexed", List.class), new DynaProperty("longProperty", Long.TYPE),
+ new DynaProperty("mappedProperty", Map.class), new DynaProperty("mappedIntProperty", Map.class), new DynaProperty("nullProperty", String.class),
+ new DynaProperty("shortProperty", Short.TYPE), new DynaProperty("stringArray", stringArray.getClass()),
+ new DynaProperty("stringIndexed", stringArray.getClass()), new DynaProperty("stringProperty", String.class), });
return dynaClass;
}
@@ -958,8 +846,7 @@ public class BasicDynaBeanTestCase extends TestCase {
protected void testGetDescriptorBase(final String name, final Class<?> type) {
try {
- final DynaProperty descriptor =
- bean.getDynaClass().getDynaProperty(name);
+ final DynaProperty descriptor = bean.getDynaClass().getDynaProperty(name);
assertNotNull("Got descriptor", descriptor);
assertEquals("Got correct type", type, descriptor.getType());
} catch (final Throwable t) {
diff --git a/src/test/java/org/apache/commons/beanutils2/BeanComparatorTestCase.java b/src/test/java/org/apache/commons/beanutils2/BeanComparatorTestCase.java
index edf702d8..e3e2a6ce 100644
--- a/src/test/java/org/apache/commons/beanutils2/BeanComparatorTestCase.java
+++ b/src/test/java/org/apache/commons/beanutils2/BeanComparatorTestCase.java
@@ -17,19 +17,15 @@
package org.apache.commons.beanutils2;
-
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
-
/**
- * Test Case for the BeanComparator class.
+ * Test Case for the BeanComparator class.
*/
public class BeanComparatorTestCase extends TestCase {
-
-
/**
* The test beans for each test.
*/
@@ -37,8 +33,6 @@ public class BeanComparatorTestCase extends TestCase {
protected AlphaBean alphaBean1 = null;
protected AlphaBean alphaBean2 = null;
-
-
/**
* Constructs a new instance of this test case.
*
@@ -48,8 +42,6 @@ public class BeanComparatorTestCase extends TestCase {
super(name);
}
-
-
/**
* Sets up instance variables required by this test case.
*/
@@ -60,7 +52,6 @@ public class BeanComparatorTestCase extends TestCase {
alphaBean2 = new AlphaBean("alphaBean2");
}
-
/**
* Returns the tests included in this test suite.
*/
@@ -78,112 +69,97 @@ public class BeanComparatorTestCase extends TestCase {
alphaBean2 = null;
}
-
-
/**
- * Tests comparing two beans via their name using the default Comparator
+ * Tests comparing two beans via their name using the default Comparator
*/
public void testSimpleCompare() {
- final BeanComparator<AlphaBean, String> beanComparator = new BeanComparator<>(
- "name");
+ final BeanComparator<AlphaBean, String> beanComparator = new BeanComparator<>("name");
final int result = beanComparator.compare(alphaBean1, alphaBean2);
- assertTrue("Comparator did not sort properly. Result:" + result,
- result == -1);
+ assertTrue("Comparator did not sort properly. Result:" + result, result == -1);
}
/**
- * Tests comparing two beans via their name using the default Comparator, but the inverse
+ * Tests comparing two beans via their name using the default Comparator, but the inverse
*/
public void testSimpleCompareInverse() {
- final BeanComparator<AlphaBean, String> beanComparator = new BeanComparator<>(
- "name");
+ final BeanComparator<AlphaBean, String> beanComparator = new BeanComparator<>("name");
final int result = beanComparator.compare(alphaBean2, alphaBean1);
- assertTrue("Comparator did not sort properly. Result:" + result,
- result == 1);
+ assertTrue("Comparator did not sort properly. Result:" + result, result == 1);
}
/**
- * Tests comparing two beans via their name using the default Comparator where they have the same value.
+ * Tests comparing two beans via their name using the default Comparator where they have the same value.
*/
public void testCompareIdentical() {
alphaBean1 = new AlphaBean("alphabean");
alphaBean2 = new AlphaBean("alphabean");
- final BeanComparator<AlphaBean, String> beanComparator = new BeanComparator<>(
- "name");
+ final BeanComparator<AlphaBean, String> beanComparator = new BeanComparator<>("name");
final int result = beanComparator.compare(alphaBean1, alphaBean2);
- assertTrue("Comparator did not sort properly. Result:" + result,
- result == 0);
+ assertTrue("Comparator did not sort properly. Result:" + result, result == 0);
}
/**
- * Tests comparing one bean against itself.
+ * Tests comparing one bean against itself.
*/
public void testCompareBeanAgainstSelf() {
- final BeanComparator<AlphaBean, String> beanComparator = new BeanComparator<>(
- "name");
+ final BeanComparator<AlphaBean, String> beanComparator = new BeanComparator<>("name");
final int result = beanComparator.compare(alphaBean1, alphaBean1);
- assertTrue("Comparator did not sort properly. Result:" + result,
- result == 0);
+ assertTrue("Comparator did not sort properly. Result:" + result, result == 0);
}
/**
- * Tests comparing two beans via their name using the default Comparator, but with one of the beans
- * being null.
+ * Tests comparing two beans via their name using the default Comparator, but with one of the beans being null.
*/
public void testCompareWithNulls() {
try {
- final BeanComparator<AlphaBean, String> beanComparator = new BeanComparator<>("name");
- beanComparator.compare(alphaBean2, null);
+ final BeanComparator<AlphaBean, String> beanComparator = new BeanComparator<>("name");
+ beanComparator.compare(alphaBean2, null);
- fail("Should not be able to compare a null value.");
- }
- catch (final Exception e) {
+ fail("Should not be able to compare a null value.");
+ } catch (final Exception e) {
// expected result
}
}
/**
- * Tests comparing two beans who don't have a property
+ * Tests comparing two beans who don't have a property
*/
public void testCompareOnMissingProperty() {
try {
- final BeanComparator<AlphaBean, String> beanComparator = new BeanComparator<>("bogusName");
- beanComparator.compare(alphaBean2, alphaBean1);
- fail("should not be able to compare");
+ final BeanComparator<AlphaBean, String> beanComparator = new BeanComparator<>("bogusName");
+ beanComparator.compare(alphaBean2, alphaBean1);
+ fail("should not be able to compare");
-
- }
- catch (final Exception e) {
- assertTrue("Wrong exception was thrown: " + e, e.toString().contains("Unknown property"));
+ } catch (final Exception e) {
+ assertTrue("Wrong exception was thrown: " + e, e.toString().contains("Unknown property"));
}
}
/**
- * Tests comparing two beans on a boolean property, which is not possible.
+ * Tests comparing two beans on a boolean property, which is not possible.
*/
public void testCompareOnBooleanProperty() {
try {
- final TestBean testBeanA = new TestBean();
- final TestBean testBeanB = new TestBean();
+ final TestBean testBeanA = new TestBean();
+ final TestBean testBeanB = new TestBean();
- testBeanA.setBooleanProperty(true);
- testBeanB.setBooleanProperty(false);
+ testBeanA.setBooleanProperty(true);
+ testBeanB.setBooleanProperty(false);
- final BeanComparator<TestBean, String> beanComparator = new BeanComparator<>("booleanProperty");
- beanComparator.compare(testBeanA, testBeanB);
+ final BeanComparator<TestBean, String> beanComparator = new BeanComparator<>("booleanProperty");
+ beanComparator.compare(testBeanA, testBeanB);
- // **** java.lang.Boolean implements Comparable from JDK 1.5 onwards
- // so this test no longer fails
- // fail("BeanComparator should throw an exception when comparing two booleans.");
+ // **** java.lang.Boolean implements Comparable from JDK 1.5 onwards
+ // so this test no longer fails
+ // fail("BeanComparator should throw an exception when comparing two booleans.");
- }
- catch (final ClassCastException cce){
- // Expected result
+ } catch (final ClassCastException cce) {
+ // Expected result
}
}
/**
- * Tests comparing two beans on a boolean property, then changing the property and testing/
+ * Tests comparing two beans on a boolean property, then changing the property and testing/
*/
public void testSetProperty() {
final TestBean testBeanA = new TestBean();
@@ -192,12 +168,10 @@ public class BeanComparatorTestCase extends TestCase {
testBeanA.setDoubleProperty(5.5);
testBeanB.setDoubleProperty(1.0);
- final BeanComparator<TestBean, String> beanComparator = new BeanComparator<>(
- "doubleProperty");
+ final BeanComparator<TestBean, String> beanComparator = new BeanComparator<>("doubleProperty");
int result = beanComparator.compare(testBeanA, testBeanB);
- assertTrue("Comparator did not sort properly. Result:" + result,
- result == 1);
+ assertTrue("Comparator did not sort properly. Result:" + result, result == 1);
testBeanA.setStringProperty("string 1");
testBeanB.setStringProperty("string 2");
@@ -206,7 +180,6 @@ public class BeanComparatorTestCase extends TestCase {
result = beanComparator.compare(testBeanA, testBeanB);
- assertTrue("Comparator did not sort properly. Result:" + result,
- result == -1);
+ assertTrue("Comparator did not sort properly. Result:" + result, result == -1);
}
}
diff --git a/src/test/java/org/apache/commons/beanutils2/BeanIntrospectionDataTestCase.java b/src/test/java/org/apache/commons/beanutils2/BeanIntrospectionDataTestCase.java
index e3746f54..6ef6af1c 100644
--- a/src/test/java/org/apache/commons/beanutils2/BeanIntrospectionDataTestCase.java
+++ b/src/test/java/org/apache/commons/beanutils2/BeanIntrospectionDataTestCase.java
@@ -72,36 +72,30 @@ public class BeanIntrospectionDataTestCase extends TestCase {
final BeanIntrospectionData data = setUpData();
final PropertyDescriptor pd = fetchTestDescriptor(data);
assertNotNull("No write method", pd.getWriteMethod());
- assertEquals("Wrong write method", pd.getWriteMethod(),
- data.getWriteMethod(BEAN_CLASS, pd));
+ assertEquals("Wrong write method", pd.getWriteMethod(), data.getWriteMethod(BEAN_CLASS, pd));
}
/**
- * Tests whether a write method can be queried that is currently not available in the
- * property descriptor.
+ * Tests whether a write method can be queried that is currently not available in the property descriptor.
*/
public void testGetWriteMethodUndefined() throws Exception {
final BeanIntrospectionData data = setUpData();
final PropertyDescriptor pd = fetchTestDescriptor(data);
final Method writeMethod = pd.getWriteMethod();
pd.setWriteMethod(null);
- assertEquals("Wrong write method", writeMethod,
- data.getWriteMethod(BEAN_CLASS, pd));
+ assertEquals("Wrong write method", writeMethod, data.getWriteMethod(BEAN_CLASS, pd));
assertEquals("Method not set in descriptor", writeMethod, pd.getWriteMethod());
}
/**
- * Tests getWriteMethod() if the method cannot be resolved. (This is a corner case
- * which should normally not happen in practice.)
+ * Tests getWriteMethod() if the method cannot be resolved. (This is a corner case which should normally not happen in practice.)
*/
public void testGetWriteMethodNonExisting() throws Exception {
- final PropertyDescriptor pd = new PropertyDescriptor(TEST_PROP,
- BEAN_CLASS.getMethod("getFluentGetProperty"), BEAN_CLASS.getMethod(
- "setFluentGetProperty", String.class));
+ final PropertyDescriptor pd = new PropertyDescriptor(TEST_PROP, BEAN_CLASS.getMethod("getFluentGetProperty"),
+ BEAN_CLASS.getMethod("setFluentGetProperty", String.class));
final Map<String, String> methods = new HashMap<>();
methods.put(TEST_PROP, "hashCode");
- final BeanIntrospectionData data = new BeanIntrospectionData(
- new PropertyDescriptor[] { pd }, methods);
+ final BeanIntrospectionData data = new BeanIntrospectionData(new PropertyDescriptor[] { pd }, methods);
pd.setWriteMethod(null);
assertNull("Got a write method", data.getWriteMethod(BEAN_CLASS, pd));
}
diff --git a/src/test/java/org/apache/commons/beanutils2/BeanMapTestCase.java b/src/test/java/org/apache/commons/beanutils2/BeanMapTestCase.java
index da3d7c82..36e7ef2d 100644
--- a/src/test/java/org/apache/commons/beanutils2/BeanMapTestCase.java
+++ b/src/test/java/org/apache/commons/beanutils2/BeanMapTestCase.java
@@ -47,24 +47,14 @@ public class BeanMapTestCase extends AbstractTestMap {
return BulkTest.makeSuite(BeanMapTestCase.class);
}
-/*
- note to self. The getter and setter methods were generated by copying the
- field declarations and using the following regular expression search and
- replace:
-
- From:
- private \(.*\) some\(.*\);
- To:
- public \1 getSome\2Value() {
- return some\2;
- }
- public void setSome\2Value(\1 value) {
- some\2 = value;
- }
-
- Also note: The sample keys and mappings were generated manually.
-*/
-
+ /*
+ * note to self. The getter and setter methods were generated by copying the field declarations and using the following regular expression search and
+ * replace:
+ *
+ * From: private \(.*\) some\(.*\); To: public \1 getSome\2Value() { return some\2; } public void setSome\2Value(\1 value) { some\2 = value; }
+ *
+ * Also note: The sample keys and mappings were generated manually.
+ */
public static class BeanWithProperties implements Serializable {
private int someInt;
@@ -81,6 +71,7 @@ public class BeanMapTestCase extends AbstractTestMap {
public int getSomeIntValue() {
return someInt;
}
+
public void setSomeIntValue(final int value) {
someInt = value;
}
@@ -88,6 +79,7 @@ public class BeanMapTestCase extends AbstractTestMap {
public long getSomeLongValue() {
return someLong;
}
+
public void setSomeLongValue(final long value) {
someLong = value;
}
@@ -95,6 +87,7 @@ public class BeanMapTestCase extends AbstractTestMap {
public double getSomeDoubleValue() {
return someDouble;
}
+
public void setSomeDoubleValue(final double value) {
someDouble = value;
}
@@ -102,6 +95,7 @@ public class BeanMapTestCase extends AbstractTestMap {
public float getSomeFloatValue() {
return someFloat;
}
+
public void setSomeFloatValue(final float value) {
someFloat = value;
}
@@ -109,6 +103,7 @@ public class BeanMapTestCase extends AbstractTestMap {
public short getSomeShortValue() {
return someShort;
}
+
public void setSomeShortValue(final short value) {
someShort = value;
}
@@ -116,6 +111,7 @@ public class BeanMapTestCase extends AbstractTestMap {
public byte getSomeByteValue() {
return someByte;
}
+
public void setSomeByteValue(final byte value) {
someByte = value;
}
@@ -123,6 +119,7 @@ public class BeanMapTestCase extends AbstractTestMap {
public char getSomeCharValue() {
return someChar;
}
+
public void setSomeCharValue(final char value) {
someChar = value;
}
@@ -130,6 +127,7 @@ public class BeanMapTestCase extends AbstractTestMap {
public String getSomeStringValue() {
return someString;
}
+
public void setSomeStringValue(final String value) {
someString = value;
}
@@ -137,6 +135,7 @@ public class BeanMapTestCase extends AbstractTestMap {
public Integer getSomeIntegerValue() {
return someInteger;
}
+
public void setSomeIntegerValue(final Integer value) {
someInteger = value;
}
@@ -144,6 +143,7 @@ public class BeanMapTestCase extends AbstractTestMap {
public Object getSomeObjectValue() {
return someObject;
}
+
public void setSomeObjectValue(final Object value) {
someObject = value;
}
@@ -151,9 +151,11 @@ public class BeanMapTestCase extends AbstractTestMap {
public static class BeanThrowingExceptions extends BeanWithProperties {
private static final long serialVersionUID = 1L;
+
public void setValueThrowingException(final String value) {
throw new TestException();
}
+
public String getValueThrowingException() {
throw new TestException();
}
@@ -166,76 +168,42 @@ public class BeanMapTestCase extends AbstractTestMap {
private static final long serialVersionUID = 1L;
}
- // note to self. The Sample keys were generated by copying the field
+ // note to self. The Sample keys were generated by copying the field
// declarations and using the following regular expression search and replace:
//
// From:
- // private \(.*\) some\(.*\);
+ // private \(.*\) some\(.*\);
// To:
- // "some\2Value",
+ // "some\2Value",
//
// Then, I manually added the "class" key, which is a property that exists for
// all beans (and all objects for that matter.
@Override
public Object[] getSampleKeys() {
- final Object[] keys = {
- "someIntValue",
- "someLongValue",
- "someDoubleValue",
- "someFloatValue",
- "someShortValue",
- "someByteValue",
- "someCharValue",
- "someIntegerValue",
- "someStringValue",
- "someObjectValue",
- "class",
- };
+ final Object[] keys = { "someIntValue", "someLongValue", "someDoubleValue", "someFloatValue", "someShortValue", "someByteValue", "someCharValue",
+ "someIntegerValue", "someStringValue", "someObjectValue", "class", };
return keys;
}
/**
- * An object value that will be stored in the bean map as a value. Need
- * to save this externally so that we can make sure the object instances
- * are equivalent since getSampleValues() would otherwise construct a new
- * and different Object each time.
+ * An object value that will be stored in the bean map as a value. Need to save this externally so that we can make sure the object instances are equivalent
+ * since getSampleValues() would otherwise construct a new and different Object each time.
**/
private final Object objectInFullMap = new Object();
// note to self: the sample values were created manually
@Override
public Object[] getSampleValues() {
- final Object[] values = {
- Integer.valueOf(1234),
- Long.valueOf(1298341928234L),
- Double.valueOf(123423.34),
- Float.valueOf(1213332.12f),
- Short.valueOf((short)134),
- Byte.valueOf((byte)10),
- Character.valueOf('a'),
- Integer.valueOf(1432),
- "SomeStringValue",
- objectInFullMap,
- BeanWithProperties.class,
- };
+ final Object[] values = { Integer.valueOf(1234), Long.valueOf(1298341928234L), Double.valueOf(123423.34), Float.valueOf(1213332.12f),
+ Short.valueOf((short) 134), Byte.valueOf((byte) 10), Character.valueOf('a'), Integer.valueOf(1432), "SomeStringValue", objectInFullMap,
+ BeanWithProperties.class, };
return values;
}
@Override
public Object[] getNewSampleValues() {
- final Object[] values = {
- Integer.valueOf(223),
- Long.valueOf(23341928234L),
- Double.valueOf(23423.34),
- Float.valueOf(213332.12f),
- Short.valueOf((short)234),
- Byte.valueOf((byte)20),
- Character.valueOf('b'),
- Integer.valueOf(232),
- "SomeNewStringValue",
- new Object(),
- null,
- };
+ final Object[] values = { Integer.valueOf(223), Long.valueOf(23341928234L), Double.valueOf(23423.34), Float.valueOf(213332.12f),
+ Short.valueOf((short) 234), Byte.valueOf((byte) 20), Character.valueOf('b'), Integer.valueOf(232), "SomeNewStringValue", new Object(), null, };
return values;
}
@@ -249,9 +217,8 @@ public class BeanMapTestCase extends AbstractTestMap {
}
/**
- * The mappings in a BeanMap are fixed on the properties the underlying
- * bean has. Adding and removing mappings is not possible, thus this
- * method is overridden to return false.
+ * The mappings in a BeanMap are fixed on the properties the underlying bean has. Adding and removing mappings is not possible, thus this method is
+ * overridden to return false.
*/
@Override
public boolean isPutAddSupported() {
@@ -259,9 +226,8 @@ public class BeanMapTestCase extends AbstractTestMap {
}
/**
- * The mappings in a BeanMap are fixed on the properties the underlying
- * bean has. Adding and removing mappings is not possible, thus this
- * method is overridden to return false.
+ * The mappings in a BeanMap are fixed on the properties the underlying bean has. Adding and removing mappings is not possible, thus this method is
+ * overridden to return false.
*/
@Override
public boolean isRemoveSupported() {
@@ -277,8 +243,8 @@ public class BeanMapTestCase extends AbstractTestMap {
bean.setSomeLongValue(1298341928234L);
bean.setSomeDoubleValue(123423.34);
bean.setSomeFloatValue(1213332.12f);
- bean.setSomeShortValue((short)134);
- bean.setSomeByteValue((byte)10);
+ bean.setSomeShortValue((short) 134);
+ bean.setSomeByteValue((byte) 10);
bean.setSomeCharValue('a');
bean.setSomeIntegerValue(Integer.valueOf(1432));
bean.setSomeStringValue("SomeStringValue");
@@ -294,37 +260,27 @@ public class BeanMapTestCase extends AbstractTestMap {
@Override
public String[] ignoredTests() {
// Ignore the serialization tests on collection views.
- return new String[] {
- "TestBeanMap.bulkTestMapEntrySet.testCanonicalEmptyCollectionExists",
- "TestBeanMap.bulkTestMapEntrySet.testCanonicalFullCollectionExists",
- "TestBeanMap.bulkTestMapKeySet.testCanonicalEmptyCollectionExists",
- "TestBeanMap.bulkTestMapKeySet.testCanonicalFullCollectionExists",
- "TestBeanMap.bulkTestMapValues.testCanonicalEmptyCollectionExists",
- "TestBeanMap.bulkTestMapValues.testCanonicalFullCollectionExists",
- "TestBeanMap.bulkTestMapEntrySet.testSimpleSerialization",
- "TestBeanMap.bulkTestMapKeySet.testSimpleSerialization",
- "TestBeanMap.bulkTestMapEntrySet.testSerializeDeserializeThenCompare",
- "TestBeanMap.bulkTestMapKeySet.testSerializeDeserializeThenCompare"
- };
+ return new String[] { "TestBeanMap.bulkTestMapEntrySet.testCanonicalEmptyCollectionExists",
+ "TestBeanMap.bulkTestMapEntrySet.testCanonicalFullCollectionExists", "TestBeanMap.bulkTestMapKeySet.testCanonicalEmptyCollectionExists",
+ "TestBeanMap.bulkTestMapKeySet.testCanonicalFullCollectionExists", "TestBeanMap.bulkTestMapValues.testCanonicalEmptyCollectionExists",
+ "TestBeanMap.bulkTestMapValues.testCanonicalFullCollectionExists", "TestBeanMap.bulkTestMapEntrySet.testSimpleSerialization",
+ "TestBeanMap.bulkTestMapKeySet.testSimpleSerialization", "TestBeanMap.bulkTestMapEntrySet.testSerializeDeserializeThenCompare",
+ "TestBeanMap.bulkTestMapKeySet.testSerializeDeserializeThenCompare" };
}
/**
- * Need to override this method because the "clear()" method on the bean
- * map just returns the bean properties to their default states. It does
- * not actually remove the mappings as per the map contract. The default
- * testClear() methods checks that the clear method throws an
- * UnsupportedOperationException since this class is not add/remove
- * modifiable. In our case though, we do not always throw that exception.
+ * Need to override this method because the "clear()" method on the bean map just returns the bean properties to their default states. It does not actually
+ * remove the mappings as per the map contract. The default testClear() methods checks that the clear method throws an UnsupportedOperationException since
+ * this class is not add/remove modifiable. In our case though, we do not always throw that exception.
*/
@Override
public void testMapClear() {
- //TODO: make sure a call to BeanMap.clear returns the bean to its
- //default initialization values.
+ // TODO: make sure a call to BeanMap.clear returns the bean to its
+ // default initialization values.
}
/**
- * Need to override this method because the "put()" method on the bean
- * doesn't work for this type of Map.
+ * Need to override this method because the "put()" method on the bean doesn't work for this type of Map.
*/
@Override
public void testMapPut() {
@@ -332,26 +288,24 @@ public class BeanMapTestCase extends AbstractTestMap {
}
public void testBeanMapClone() {
- final BeanMap map = (BeanMap)makeFullMap();
+ final BeanMap map = (BeanMap) makeFullMap();
try {
- final BeanMap map2 = (BeanMap)map.clone();
+ final BeanMap map2 = (BeanMap) map.clone();
// make sure containsKey is working to verify the bean was cloned
// ok, and the read methods were properly initialized
final Object[] keys = getSampleKeys();
for (final Object key : keys) {
- assertTrue("Cloned BeanMap should contain the same keys",
- map2.containsKey(key));
+ assertTrue("Cloned BeanMap should contain the same keys", map2.containsKey(key));
}
} catch (final CloneNotSupportedException exception) {
- fail("BeanMap.clone() should not throw a " +
- "CloneNotSupportedException when clone should succeed.");
+ fail("BeanMap.clone() should not throw a " + "CloneNotSupportedException when clone should succeed.");
}
}
public void testBeanMapPutAllWriteable() {
- final BeanMap map1 = (BeanMap)makeFullMap();
- final BeanMap map2 = (BeanMap)makeFullMap();
+ final BeanMap map1 = (BeanMap) makeFullMap();
+ final BeanMap map2 = (BeanMap) makeFullMap();
map2.put("someIntValue", Integer.valueOf(0));
map1.putAllWriteable(map2);
assertEquals(map1.get("someIntValue"), Integer.valueOf(0));
@@ -370,18 +324,18 @@ public class BeanMapTestCase extends AbstractTestMap {
}
/**
- * Test the default transformers using the getTypeTransformer() method
+ * Test the default transformers using the getTypeTransformer() method
*/
public void testGetTypeTransformerMethod() {
final BeanMap beanMap = new BeanMap();
- assertEquals("Boolean.TYPE", Boolean.TRUE, beanMap.getTypeTransformer(Boolean.TYPE).apply("true"));
- assertEquals("Character.TYPE", Character.valueOf('B'), beanMap.getTypeTransformer(Character.TYPE).apply("BCD"));
- assertEquals("Byte.TYPE", Byte.valueOf((byte)1), beanMap.getTypeTransformer(Byte.TYPE).apply("1"));
- assertEquals("Short.TYPE", Short.valueOf((short)2), beanMap.getTypeTransformer(Short.TYPE).apply("2"));
- assertEquals("Integer.TYPE", Integer.valueOf(3), beanMap.getTypeTransformer(Integer.TYPE).apply("3"));
- assertEquals("Long.TYPE", Long.valueOf(4), beanMap.getTypeTransformer(Long.TYPE).apply("4"));
- assertEquals("Float.TYPE", Float.valueOf("5"), beanMap.getTypeTransformer(Float.TYPE).apply("5"));
- assertEquals("Double.TYPE", Double.valueOf("6"), beanMap.getTypeTransformer(Double.TYPE).apply("6"));
+ assertEquals("Boolean.TYPE", Boolean.TRUE, beanMap.getTypeTransformer(Boolean.TYPE).apply("true"));
+ assertEquals("Character.TYPE", Character.valueOf('B'), beanMap.getTypeTransformer(Character.TYPE).apply("BCD"));
+ assertEquals("Byte.TYPE", Byte.valueOf((byte) 1), beanMap.getTypeTransformer(Byte.TYPE).apply("1"));
+ assertEquals("Short.TYPE", Short.valueOf((short) 2), beanMap.getTypeTransformer(Short.TYPE).apply("2"));
+ assertEquals("Integer.TYPE", Integer.valueOf(3), beanMap.getTypeTransformer(Integer.TYPE).apply("3"));
+ assertEquals("Long.TYPE", Long.valueOf(4), beanMap.getTypeTransformer(Long.TYPE).apply("4"));
+ assertEquals("Float.TYPE", Float.valueOf("5"), beanMap.getTypeTransformer(Float.TYPE).apply("5"));
+ assertEquals("Double.TYPE", Double.valueOf("6"), beanMap.getTypeTransformer(Double.TYPE).apply("6"));
}
/**
@@ -403,7 +357,7 @@ public class BeanMapTestCase extends AbstractTestMap {
} catch (final CloneNotSupportedException e) {
Throwable cause = null;
try {
- cause = (Throwable)PropertyUtils.getProperty(e, "cause");
+ cause = (Throwable) PropertyUtils.getProperty(e, "cause");
} catch (final Exception e2) {
fail("Non-public bean - retrieving the cause threw " + e2);
}
@@ -419,7 +373,7 @@ public class BeanMapTestCase extends AbstractTestMap {
} catch (final CloneNotSupportedException e) {
Throwable cause = null;
try {
- cause = (Throwable)PropertyUtils.getProperty(e, "cause");
+ cause = (Throwable) PropertyUtils.getProperty(e, "cause");
} catch (final Exception e2) {
fail("Setter Exception - retrieving the cause threw " + e2);
}
@@ -446,7 +400,7 @@ public class BeanMapTestCase extends AbstractTestMap {
} catch (final UnsupportedOperationException e) {
Throwable cause = null;
try {
- cause = (Throwable)PropertyUtils.getProperty(e, "cause");
+ cause = (Throwable) PropertyUtils.getProperty(e, "cause");
} catch (final Exception e2) {
fail("Retrieving the cause threw " + e2);
}
@@ -473,8 +427,8 @@ public class BeanMapTestCase extends AbstractTestMap {
Throwable cause1 = null;
Throwable cause2 = null;
try {
- cause1 = (Throwable)PropertyUtils.getProperty(e, "cause");
- cause2 = (Throwable)PropertyUtils.getProperty(e, "cause.cause");
+ cause1 = (Throwable) PropertyUtils.getProperty(e, "cause");
+ cause2 = (Throwable) PropertyUtils.getProperty(e, "cause.cause");
} catch (final Exception e2) {
fail("Setter exception - retrieving the cause threw " + e2);
}
diff --git a/src/test/java/org/apache/commons/beanutils2/BeanPropertyValueChangeConsumerTestCase.java b/src/test/java/org/apache/commons/beanutils2/BeanPropertyValueChangeConsumerTestCase.java
index 4fd3658b..5c3a1709 100644
--- a/src/test/java/org/apache/commons/beanutils2/BeanPropertyValueChangeConsumerTestCase.java
+++ b/src/test/java/org/apache/commons/beanutils2/BeanPropertyValueChangeConsumerTestCase.java
@@ -19,7 +19,6 @@ package org.apache.commons.beanutils2;
import junit.framework.TestCase;
-
/**
* Test cases for {@code BeanPropertyValueChangeClosure}.
*
@@ -270,8 +269,8 @@ public class BeanPropertyValueChangeConsumerTestCase extends TestCase {
final TestBean testBean = new TestBean();
// create a consumer that will attempt to set a property on the null bean in the path
- final BeanPropertyValueChangeConsumer<TestBean, Object> consumer = new BeanPropertyValueChangeConsumer<>(
- "anotherNested.stringProperty", "Should ignore exception", true);
+ final BeanPropertyValueChangeConsumer<TestBean, Object> consumer = new BeanPropertyValueChangeConsumer<>("anotherNested.stringProperty",
+ "Should ignore exception", true);
try {
consumer.accept(testBean);
diff --git a/src/test/java/org/apache/commons/beanutils2/BeanPropertyValueEqualsPredicateTestCase.java b/src/test/java/org/apache/commons/beanutils2/BeanPropertyValueEqualsPredicateTestCase.java
index 20420d7b..e33fa77c 100644
--- a/src/test/java/org/apache/commons/beanutils2/BeanPropertyValueEqualsPredicateTestCase.java
+++ b/src/test/java/org/apache/commons/beanutils2/BeanPropertyValueEqualsPredicateTestCase.java
@@ -44,8 +44,7 @@ public class BeanPropertyValueEqualsPredicateTestCase extends TestCase {
* Test evaluate with simple String property.
*/
public void testEvaluateWithSimpleStringProperty() {
- final BeanPropertyValueEqualsPredicate<TestBean, String> predicate =
- new BeanPropertyValueEqualsPredicate<>("stringProperty","foo");
+ final BeanPropertyValueEqualsPredicate<TestBean, String> predicate = new BeanPropertyValueEqualsPredicate<>("stringProperty", "foo");
assertTrue(predicate.test(new TestBean("foo")));
assertTrue(!predicate.test(new TestBean("bar")));
}
@@ -54,8 +53,7 @@ public class BeanPropertyValueEqualsPredicateTestCase extends TestCase {
* Test evaluate with simple String property and null values.
*/
public void testEvaluateWithSimpleStringPropertyWithNullValues() {
- final BeanPropertyValueEqualsPredicate<TestBean, String> predicate =
- new BeanPropertyValueEqualsPredicate<>("stringProperty",null);
+ final BeanPropertyValueEqualsPredicate<TestBean, String> predicate = new BeanPropertyValueEqualsPredicate<>("stringProperty", null);
assertTrue(predicate.test(new TestBean((String) null)));
assertTrue(!predicate.test(new TestBean("bar")));
}
@@ -64,8 +62,7 @@ public class BeanPropertyValueEqualsPredicateTestCase extends TestCase {
* Test evaluate with nested property.
*/
public void testEvaluateWithNestedProperty() {
- final BeanPropertyValueEqualsPredicate<TestBean, String> predicate =
- new BeanPropertyValueEqualsPredicate<>("anotherNested.stringProperty","match");
+ final BeanPropertyValueEqualsPredicate<TestBean, String> predicate = new BeanPropertyValueEqualsPredicate<>("anotherNested.stringProperty", "match");
final TestBean testBean = new TestBean();
final TestBean nestedBean = new TestBean("match");
testBean.setAnotherNested(nestedBean);
@@ -78,8 +75,7 @@ public class BeanPropertyValueEqualsPredicateTestCase extends TestCase {
* Test evaluate with null in property path and ignore=false.
*/
public void testEvaluateWithNullInPath() {
- final BeanPropertyValueEqualsPredicate<TestBean, String> predicate =
- new BeanPropertyValueEqualsPredicate<>("anotherNested.stringProperty","foo");
+ final BeanPropertyValueEqualsPredicate<TestBean, String> predicate = new BeanPropertyValueEqualsPredicate<>("anotherNested.stringProperty", "foo");
try {
// try to evaluate the predicate
predicate.test(new TestBean());
@@ -93,8 +89,8 @@ public class BeanPropertyValueEqualsPredicateTestCase extends TestCase {
* Test evaluate with null in property path and ignore=true.
*/
public void testEvaluateWithNullInPathAndIgnoreTrue() {
- final BeanPropertyValueEqualsPredicate<TestBean, String> predicate =
- new BeanPropertyValueEqualsPredicate<>("anotherNested.stringProperty","foo", true);
+ final BeanPropertyValueEqualsPredicate<TestBean, String> predicate = new BeanPropertyValueEqualsPredicate<>("anotherNested.stringProperty", "foo",
+ true);
try {
assertTrue(!predicate.test(new TestBean()));
} catch (final IllegalArgumentException e) {
@@ -106,8 +102,7 @@ public class BeanPropertyValueEqualsPredicateTestCase extends TestCase {
* Test evaluate with int property.
*/
public void testEvaluateWithIntProperty() {
- final BeanPropertyValueEqualsPredicate<TestBean, Integer> predicate =
- new BeanPropertyValueEqualsPredicate<>("intProperty",expectedIntegerValue);
+ final BeanPropertyValueEqualsPredicate<TestBean, Integer> predicate = new BeanPropertyValueEqualsPredicate<>("intProperty", expectedIntegerValue);
assertTrue(predicate.test(new TestBean(expectedIntegerValue.intValue())));
assertTrue(!predicate.test(new TestBean(expectedIntegerValue.intValue() - 1)));
}
@@ -116,8 +111,7 @@ public class BeanPropertyValueEqualsPredicateTestCase extends TestCase {
* Test evaluate with float property.
*/
public void testEvaluateWithFloatProperty() {
- final BeanPropertyValueEqualsPredicate<TestBean, Float> predicate =
- new BeanPropertyValueEqualsPredicate<>("floatProperty",expectedFloatValue);
+ final BeanPropertyValueEqualsPredicate<TestBean, Float> predicate = new BeanPropertyValueEqualsPredicate<>("floatProperty", expectedFloatValue);
assertTrue(predicate.test(new TestBean(expectedFloatValue.floatValue())));
assertTrue(!predicate.test(new TestBean(expectedFloatValue.floatValue() - 1)));
}
@@ -126,8 +120,7 @@ public class BeanPropertyValueEqualsPredicateTestCase extends TestCase {
* Test evaluate with double property.
*/
public void testEvaluateWithDoubleProperty() {
- final BeanPropertyValueEqualsPredicate<TestBean, Double> predicate =
- new BeanPropertyValueEqualsPredicate<>("doubleProperty",expectedDoubleValue);
+ final BeanPropertyValueEqualsPredicate<TestBean, Double> predicate = new BeanPropertyValueEqualsPredicate<>("doubleProperty", expectedDoubleValue);
assertTrue(predicate.test(new TestBean(expectedDoubleValue.doubleValue())));
assertTrue(!predicate.test(new TestBean(expectedDoubleValue.doubleValue() - 1)));
}
@@ -136,8 +129,7 @@ public class BeanPropertyValueEqualsPredicateTestCase extends TestCase {
* Test evaluate with boolean property.
*/
public void testEvaluateWithBooleanProperty() {
- final BeanPropertyValueEqualsPredicate<TestBean, Boolean> predicate =
- new BeanPropertyValueEqualsPredicate<>("booleanProperty",expectedBooleanValue);
+ final BeanPropertyValueEqualsPredicate<TestBean, Boolean> predicate = new BeanPropertyValueEqualsPredicate<>("booleanProperty", expectedBooleanValue);
assertTrue(predicate.test(new TestBean(expectedBooleanValue.booleanValue())));
assertTrue(!predicate.test(new TestBean(!expectedBooleanValue.booleanValue())));
}
@@ -146,8 +138,7 @@ public class BeanPropertyValueEqualsPredicateTestCase extends TestCase {
* Test evaluate with byte property.
*/
public void testEvaluateWithByteProperty() {
- final BeanPropertyValueEqualsPredicate<TestBean, Byte> predicate =
- new BeanPropertyValueEqualsPredicate<>("byteProperty",expectedByteValue);
+ final BeanPropertyValueEqualsPredicate<TestBean, Byte> predicate = new BeanPropertyValueEqualsPredicate<>("byteProperty", expectedByteValue);
final TestBean testBean = new TestBean();
testBean.setByteProperty(expectedByteValue.byteValue());
assertTrue(predicate.test(testBean));
@@ -160,8 +151,7 @@ public class BeanPropertyValueEqualsPredicateTestCase extends TestCase {
*/
public void testEvaluateWithMappedProperty() {
// try a key that is in the map
- BeanPropertyValueEqualsPredicate<TestBean, String> predicate =
- new BeanPropertyValueEqualsPredicate<>("mappedProperty(test-key)", "match");
+ BeanPropertyValueEqualsPredicate<TestBean, String> predicate = new BeanPropertyValueEqualsPredicate<>("mappedProperty(test-key)", "match");
final TestBean testBean = new TestBean();
testBean.setMappedProperty("test-key", "match");
assertTrue(predicate.test(testBean));
@@ -178,8 +168,7 @@ public class BeanPropertyValueEqualsPredicateTestCase extends TestCase {
*/
public void testEvaluateWithIndexedProperty() {
// try a valid index
- BeanPropertyValueEqualsPredicate<TestBean, Object> predicate =
- new BeanPropertyValueEqualsPredicate<>("intIndexed[0]",expectedIntegerValue);
+ BeanPropertyValueEqualsPredicate<TestBean, Object> predicate = new BeanPropertyValueEqualsPredicate<>("intIndexed[0]", expectedIntegerValue);
final TestBean testBean = new TestBean();
testBean.setIntIndexed(0, expectedIntegerValue.intValue());
assertTrue(predicate.test(testBean));
@@ -200,8 +189,7 @@ public class BeanPropertyValueEqualsPredicateTestCase extends TestCase {
* Test evaluate with primitive property and null value.
*/
public void testEvaluateWithPrimitiveAndNull() {
- BeanPropertyValueEqualsPredicate<TestBean, Object> predicate =
- new BeanPropertyValueEqualsPredicate<>("intProperty",null);
+ BeanPropertyValueEqualsPredicate<TestBean, Object> predicate = new BeanPropertyValueEqualsPredicate<>("intProperty", null);
assertTrue(!predicate.test(new TestBean(0)));
predicate = new BeanPropertyValueEqualsPredicate<>("booleanProperty", null);
@@ -215,8 +203,8 @@ public class BeanPropertyValueEqualsPredicateTestCase extends TestCase {
* Test evaluate with nested mapped property.
*/
public void testEvaluateWithNestedMappedProperty() {
- final BeanPropertyValueEqualsPredicate<TestBean, String> predicate =
- new BeanPropertyValueEqualsPredicate<>("anotherNested.mappedProperty(test-key)","match");
+ final BeanPropertyValueEqualsPredicate<TestBean, String> predicate = new BeanPropertyValueEqualsPredicate<>("anotherNested.mappedProperty(test-key)",
+ "match");
final TestBean testBean = new TestBean();
final TestBean nestedBean = new TestBean();
nestedBean.setMappedProperty("test-key", "match");
@@ -242,8 +230,8 @@ public class BeanPropertyValueEqualsPredicateTestCase extends TestCase {
*/
public void testEvaluateWithReadOnlyProperty() {
final TestBean testBean = new TestBean();
- final BeanPropertyValueEqualsPredicate<TestBean, String> predicate =
- new BeanPropertyValueEqualsPredicate<>("readOnlyProperty",testBean.getReadOnlyProperty());
+ final BeanPropertyValueEqualsPredicate<TestBean, String> predicate = new BeanPropertyValueEqualsPredicate<>("readOnlyProperty",
+ testBean.getReadOnlyProperty());
assertTrue(predicate.test(new TestBean()));
}
diff --git a/src/test/java/org/apache/commons/beanutils2/BeanToPropertyValueTransformerTestCase.java b/src/test/java/org/apache/commons/beanutils2/BeanToPropertyValueTransformerTestCase.java
index 85dc8923..aecd7448 100644
--- a/src/test/java/org/apache/commons/beanutils2/BeanToPropertyValueTransformerTestCase.java
+++ b/src/test/java/org/apache/commons/beanutils2/BeanToPropertyValueTransformerTestCase.java
@@ -19,7 +19,6 @@ package org.apache.commons.beanutils2;
import junit.framework.TestCase;
-
/**
* Test cases for {@code BeanToPropertyValueTransformer}.
*
@@ -46,8 +45,7 @@ public class BeanToPropertyValueTransformerTestCase extends TestCase {
* Test transform with simple String property.
*/
public void testTransformWithSimpleStringProperty() {
- final BeanToPropertyValueTransformer<TestBean, String> transformer =
- new BeanToPropertyValueTransformer<>("stringProperty");
+ final BeanToPropertyValueTransformer<TestBean, String> transformer = new BeanToPropertyValueTransformer<>("stringProperty");
final TestBean testBean = new TestBean("foo");
assertEquals("foo", transformer.apply(testBean));
}
@@ -57,8 +55,7 @@ public class BeanToPropertyValueTransformerTestCase extends TestCase {
*
*/
public void testTransformWithSimpleStringPropertyAndNullValue() {
- final BeanToPropertyValueTransformer<TestBean, String> transformer =
- new BeanToPropertyValueTransformer<>("stringProperty");
+ final BeanToPropertyValueTransformer<TestBean, String> transformer = new BeanToPropertyValueTransformer<>("stringProperty");
final TestBean testBean = new TestBean((String) null);
assertNull(transformer.apply(testBean));
}
@@ -67,8 +64,7 @@ public class BeanToPropertyValueTransformerTestCase extends TestCase {
* Test transform with simple int property.
*/
public void testTransformWithSimpleIntProperty() {
- final BeanToPropertyValueTransformer<TestBean, Integer> transformer =
- new BeanToPropertyValueTransformer<>("intProperty");
+ final BeanToPropertyValueTransformer<TestBean, Integer> transformer = new BeanToPropertyValueTransformer<>("intProperty");
final TestBean testBean = new TestBean(expectedIntegerValue.intValue());
assertEquals(expectedIntegerValue, transformer.apply(testBean));
}
@@ -77,8 +73,7 @@ public class BeanToPropertyValueTransformerTestCase extends TestCase {
* Test transform with simple long property.
*/
public void testTransformWithSimpleLongProperty() {
- final BeanToPropertyValueTransformer<TestBean, Long> transformer =
- new BeanToPropertyValueTransformer<>("longProperty");
+ final BeanToPropertyValueTransformer<TestBean, Long> transformer = new BeanToPropertyValueTransformer<>("longProperty");
final TestBean testBean = new TestBean();
testBean.setLongProperty(expectedLongValue.longValue());
assertEquals(expectedLongValue, transformer.apply(testBean));
@@ -88,8 +83,7 @@ public class BeanToPropertyValueTransformerTestCase extends TestCase {
* Test transform with simple float property.
*/
public void testTransformWithSimpleFloatProperty() {
- final BeanToPropertyValueTransformer<TestBean, Float> transformer =
- new BeanToPropertyValueTransformer<>("floatProperty");
+ final BeanToPropertyValueTransformer<TestBean, Float> transformer = new BeanToPropertyValueTransformer<>("floatProperty");
final TestBean testBean = new TestBean(expectedFloatValue.floatValue());
assertEquals(expectedFloatValue, transformer.apply(testBean));
}
@@ -98,8 +92,7 @@ public class BeanToPropertyValueTransformerTestCase extends TestCase {
* Test transform with simple double property.
*/
public void testTransformWithSimpleDoubleProperty() {
- final BeanToPropertyValueTransformer<TestBean, Double> transformer =
- new BeanToPropertyValueTransformer<>("doubleProperty");
+ final BeanToPropertyValueTransformer<TestBean, Double> transformer = new BeanToPropertyValueTransformer<>("doubleProperty");
final TestBean testBean = new TestBean(expectedDoubleValue.doubleValue());
assertEquals(expectedDoubleValue, transformer.apply(testBean));
}
@@ -108,8 +101,7 @@ public class BeanToPropertyValueTransformerTestCase extends TestCase {
* Test transform with simple byte property.
*/
public void testTransformWithSimpleByteProperty() {
- final BeanToPropertyValueTransformer<TestBean, Byte> transformer =
- new BeanToPropertyValueTransformer<>("byteProperty");
+ final BeanToPropertyValueTransformer<TestBean, Byte> transformer = new BeanToPropertyValueTransformer<>("byteProperty");
final TestBean testBean = new TestBean();
testBean.setByteProperty(expectedByteValue.byteValue());
assertEquals(expectedByteValue, transformer.apply(testBean));
@@ -119,8 +111,7 @@ public class BeanToPropertyValueTransformerTestCase extends TestCase {
* Test transform with simple boolean property.
*/
public void testTransformWithSimpleBooleanProperty() {
- final BeanToPropertyValueTransformer<TestBean, Boolean> transformer =
- new BeanToPropertyValueTransformer<>("booleanProperty");
+ final BeanToPropertyValueTransformer<TestBean, Boolean> transformer = new BeanToPropertyValueTransformer<>("booleanProperty");
final TestBean testBean = new TestBean(expectedBooleanValue.booleanValue());
assertEquals(expectedBooleanValue, transformer.apply(testBean));
}
@@ -140,8 +131,7 @@ public class BeanToPropertyValueTransformerTestCase extends TestCase {
* Test transform with read only property.
*/
public void testTransformWithReadOnlyProperty() {
- final BeanToPropertyValueTransformer<TestBean, String> transformer =
- new BeanToPropertyValueTransformer<>("readOnlyProperty");
+ final BeanToPropertyValueTransformer<TestBean, String> transformer = new BeanToPropertyValueTransformer<>("readOnlyProperty");
final TestBean testBean = new TestBean();
assertEquals(testBean.getReadOnlyProperty(), transformer.apply(testBean));
}
@@ -161,8 +151,7 @@ public class BeanToPropertyValueTransformerTestCase extends TestCase {
* Test transform with nested property.
*/
public void testTransformWithNestedProperty() {
- final BeanToPropertyValueTransformer<TestBean, String> transformer =
- new BeanToPropertyValueTransformer<>("anotherNested.stringProperty");
+ final BeanToPropertyValueTransformer<TestBean, String> transformer = new BeanToPropertyValueTransformer<>("anotherNested.stringProperty");
final TestBean testBean = new TestBean();
final TestBean nestedBean = new TestBean("foo");
testBean.setAnotherNested(nestedBean);
@@ -173,8 +162,7 @@ public class BeanToPropertyValueTransformerTestCase extends TestCase {
* Test transform with mapped property.
*/
public void testTransformWithMappedProperty() {
- BeanToPropertyValueTransformer<TestBean, String> transformer =
- new BeanToPropertyValueTransformer<>("mappedProperty(test-key)");
+ BeanToPropertyValueTransformer<TestBean, String> transformer = new BeanToPropertyValueTransformer<>("mappedProperty(test-key)");
final TestBean testBean = new TestBean();
// try a valid key
@@ -190,8 +178,7 @@ public class BeanToPropertyValueTransformerTestCase extends TestCase {
* Test transform with indexed property.
*/
public void testTransformWithIndexedProperty() {
- BeanToPropertyValueTransformer<TestBean, Integer> transformer =
- new BeanToPropertyValueTransformer<>("intIndexed[0]");
+ BeanToPropertyValueTransformer<TestBean, Integer> transformer = new BeanToPropertyValueTransformer<>("intIndexed[0]");
final TestBean testBean = new TestBean();
testBean.setIntIndexed(0, expectedIntegerValue.intValue());
assertEquals(expectedIntegerValue, transformer.apply(testBean));
@@ -211,8 +198,7 @@ public class BeanToPropertyValueTransformerTestCase extends TestCase {
* Test transform with nested indexed property.
*/
public void testTransformWithNestedIndexedProperty() {
- final BeanToPropertyValueTransformer<TestBean, Integer> transformer =
- new BeanToPropertyValueTransformer<>("anotherNested.intIndexed[0]");
+ final BeanToPropertyValueTransformer<TestBean, Integer> transformer = new BeanToPropertyValueTransformer<>("anotherNested.intIndexed[0]");
final TestBean testBean = new TestBean();
final TestBean nestedBean = new TestBean();
nestedBean.setIntIndexed(0, expectedIntegerValue.intValue());
@@ -224,8 +210,7 @@ public class BeanToPropertyValueTransformerTestCase extends TestCase {
* Test transform with null in property path.
*/
public void testTransformWithNullInPath() {
- final BeanToPropertyValueTransformer<TestBean, String> transformer =
- new BeanToPropertyValueTransformer<>("anotherNested.stringProperty");
+ final BeanToPropertyValueTransformer<TestBean, String> transformer = new BeanToPropertyValueTransformer<>("anotherNested.stringProperty");
try {
transformer.apply(new TestBean());
@@ -239,8 +224,7 @@ public class BeanToPropertyValueTransformerTestCase extends TestCase {
* Test transform with null in property path and ignore = true.
*/
public void testTransformWithNullInPathAndIgnoreTrue() {
- final BeanToPropertyValueTransformer<TestBean, String> transformer =
- new BeanToPropertyValueTransformer<>("anotherNested.stringProperty",true);
+ final BeanToPropertyValueTransformer<TestBean, String> transformer = new BeanToPropertyValueTransformer<>("anotherNested.stringProperty", true);
assertEquals(null, transformer.apply(new TestBean()));
}
}
diff --git a/src/test/java/org/apache/commons/beanutils2/BeanUtilsBean2TestCase.java b/src/test/java/org/apache/commons/beanutils2/BeanUtilsBean2TestCase.java
index cb4baa51..69bdff7d 100644
--- a/src/test/java/org/apache/commons/beanutils2/BeanUtilsBean2TestCase.java
+++ b/src/test/java/org/apache/commons/beanutils2/BeanUtilsBean2TestCase.java
@@ -79,7 +79,7 @@ public class BeanUtilsBean2TestCase extends BeanUtilsBeanTestCase {
public void testCopyPropertyConvertToStringArray() {
try {
bean.setStringArray(null);
- BeanUtils.copyProperty(bean, "stringArray", new java.util.Date[] {testUtilDate});
+ BeanUtils.copyProperty(bean, "stringArray", new java.util.Date[] { testUtilDate });
} catch (final Throwable t) {
fail("Threw " + t);
}
@@ -109,7 +109,7 @@ public class BeanUtilsBean2TestCase extends BeanUtilsBeanTestCase {
public void testGetArrayPropertyDate() {
String[] value = null;
try {
- bean.setDateArrayProperty(new java.util.Date[] {testUtilDate});
+ bean.setDateArrayProperty(new java.util.Date[] { testUtilDate });
value = BeanUtils.getArrayProperty(bean, "dateArrayProperty");
} catch (final Throwable t) {
fail("Threw " + t);
@@ -125,7 +125,7 @@ public class BeanUtilsBean2TestCase extends BeanUtilsBeanTestCase {
public void testGetIndexedPropertyDate() {
String value = null;
try {
- bean.setDateArrayProperty(new java.util.Date[] {testUtilDate});
+ bean.setDateArrayProperty(new java.util.Date[] { testUtilDate });
value = BeanUtils.getIndexedProperty(bean, "dateArrayProperty[0]");
} catch (final Throwable t) {
fail("Threw " + t);
@@ -168,7 +168,7 @@ public class BeanUtilsBean2TestCase extends BeanUtilsBeanTestCase {
public void testSetPropertyConvertToStringArray() {
try {
bean.setStringArray(null);
- BeanUtils.setProperty(bean, "stringArray", new java.util.Date[] {testUtilDate});
+ BeanUtils.setProperty(bean, "stringArray", new java.util.Date[] { testUtilDate });
} catch (final Throwable t) {
fail("Threw " + t);
}
diff --git a/src/test/java/org/apache/commons/beanutils2/BeanUtilsBeanTestCase.java b/src/test/java/org/apache/commons/beanutils2/BeanUtilsBeanTestCase.java
index b128f6a1..24ac73d6 100644
--- a/src/test/java/org/apache/commons/beanutils2/BeanUtilsBeanTestCase.java
+++ b/src/test/java/org/apache/commons/beanutils2/BeanUtilsBeanTestCase.java
@@ -33,27 +33,24 @@ import junit.framework.TestSuite;
/**
* <p>
- * Test Case for the BeanUtils class. The majority of these tests use
- * instances of the TestBean class, so be sure to update the tests if you
- * change the characteristics of that class.
+ * Test Case for the BeanUtils class. The majority of these tests use instances of the TestBean class, so be sure to update the tests if you change the
+ * characteristics of that class.
* </p>
*
* <p>
- * Template for this stolen from Craigs PropertyUtilsTestCase
+ * Template for this stolen from Craigs PropertyUtilsTestCase
* </p>
*
* <p>
- * Note that the tests are dependant upon the static aspects
- * (such as array sizes...) of the TestBean.java class, so ensure
- * than all changes to TestBean are reflected here.
+ * Note that the tests are dependant upon the static aspects (such as array sizes...) of the TestBean.java class, so ensure than all changes to TestBean are
+ * reflected here.
* </p>
*
* <p>
- * So far, this test case has tests for the following methods of the
- * {@code BeanUtils} class:
+ * So far, this test case has tests for the following methods of the {@code BeanUtils} class:
* </p>
* <ul>
- * <li>getArrayProperty(Object bean, String name)</li>
+ * <li>getArrayProperty(Object bean, String name)</li>
* </ul>
*
*/
@@ -67,28 +64,14 @@ public class BeanUtilsBeanTestCase extends TestCase {
/**
* The set of properties that should be described.
*/
- protected String[] describes =
- { "booleanProperty",
- "booleanSecond",
- "byteProperty",
- "doubleProperty",
- "dupProperty",
- "floatProperty",
- "intArray",
- // "intIndexed",
- "longProperty",
- "listIndexed",
- "longProperty",
- // "mappedProperty",
- // "mappedIntProperty",
- "nested",
- "nullProperty",
- "readOnlyProperty",
- "shortProperty",
- "stringArray",
- // "stringIndexed",
- "stringProperty"
- };
+ protected String[] describes = { "booleanProperty", "booleanSecond", "byteProperty", "doubleProperty", "dupProperty", "floatProperty", "intArray",
+ // "intIndexed",
+ "longProperty", "listIndexed", "longProperty",
+ // "mappedProperty",
+ // "mappedIntProperty",
+ "nested", "nullProperty", "readOnlyProperty", "shortProperty", "stringArray",
+ // "stringIndexed",
+ "stringProperty" };
/** Test Calendar value */
protected java.util.Calendar testCalendar;
@@ -129,8 +112,7 @@ public class BeanUtilsBeanTestCase extends TestCase {
dateConverter.setPattern("dd.MM.yyyy");
ConvertUtils.register(dateConverter, java.util.Date.class);
- final ArrayConverter dateArrayConverter =
- new ArrayConverter(java.util.Date[].class, dateConverter, 0);
+ final ArrayConverter dateArrayConverter = new ArrayConverter(java.util.Date[].class, dateConverter, 0);
ConvertUtils.register(dateArrayConverter, java.util.Date[].class);
testCalendar = Calendar.getInstance();
@@ -171,8 +153,7 @@ public class BeanUtilsBeanTestCase extends TestCase {
orig.set("booleanProperty", Boolean.FALSE);
orig.set("byteProperty", Byte.valueOf((byte) 111));
orig.set("doubleProperty", Double.valueOf(333.33));
- orig.set("dupProperty",
- new String[] { "New 0", "New 1", "New 2" });
+ orig.set("dupProperty", new String[] { "New 0", "New 1", "New 2" });
orig.set("intArray", new int[] { 100, 200, 300 });
orig.set("intProperty", Integer.valueOf(333));
orig.set("longProperty", Long.valueOf(3333));
@@ -188,28 +169,13 @@ public class BeanUtilsBeanTestCase extends TestCase {
}
// Validate the results for scalar properties
- assertEquals("Copied boolean property",
- false,
- bean.getBooleanProperty());
- assertEquals("Copied byte property",
- (byte) 111,
- bean.getByteProperty());
- assertEquals("Copied double property",
- 333.33,
- bean.getDoubleProperty(),
- 0.005);
- assertEquals("Copied int property",
- 333,
- bean.getIntProperty());
- assertEquals("Copied long property",
- 3333,
- bean.getLongProperty());
- assertEquals("Copied short property",
- (short) 33,
- bean.getShortProperty());
- assertEquals("Copied string property",
- "Custom string",
- bean.getStringProperty());
+ assertEquals("Copied boolean property", false, bean.getBooleanProperty());
+ assertEquals("Copied byte property", (byte) 111, bean.getByteProperty());
+ assertEquals("Copied double property", 333.33, bean.getDoubleProperty(), 0.005);
+ assertEquals("Copied int property", 333, bean.getIntProperty());
+ assertEquals("Copied long property", 3333, bean.getLongProperty());
+ assertEquals("Copied short property", (short) 33, bean.getShortProperty());
+ assertEquals("Copied string property", "Custom string", bean.getStringProperty());
// Validate the results for array properties
final String[] dupProperty = bean.getDupProperty();
@@ -256,22 +222,14 @@ public class BeanUtilsBeanTestCase extends TestCase {
}
// Scalar properties
- assertEquals("booleanProperty", false,
- bean.getBooleanProperty());
- assertEquals("byteProperty", (byte) 111,
- bean.getByteProperty());
- assertEquals("doubleProperty", 333.0,
- bean.getDoubleProperty(), 0.005);
- assertEquals("floatProperty", (float) 222.0,
- bean.getFloatProperty(), (float) 0.005);
- assertEquals("longProperty", 111,
- bean.getIntProperty());
- assertEquals("longProperty", 444,
- bean.getLongProperty());
- assertEquals("shortProperty", (short) 555,
- bean.getShortProperty());
- assertEquals("stringProperty", "New String Property",
- bean.getStringProperty());
+ assertEquals("booleanProperty", false, bean.getBooleanProperty());
+ assertEquals("byteProperty", (byte) 111, bean.getByteProperty());
+ assertEquals("doubleProperty", 333.0, bean.getDoubleProperty(), 0.005);
+ assertEquals("floatProperty", (float) 222.0, bean.getFloatProperty(), (float) 0.005);
+ assertEquals("longProperty", 111, bean.getIntProperty());
+ assertEquals("longProperty", 444, bean.getLongProperty());
+ assertEquals("shortProperty", (short) 555, bean.getShortProperty());
+ assertEquals("stringProperty", "New String Property", bean.getStringProperty());
// Indexed Properties
final String[] dupProperty = bean.getDupProperty();
@@ -315,28 +273,13 @@ public class BeanUtilsBeanTestCase extends TestCase {
}
// Validate the results for scalar properties
- assertEquals("Copied boolean property",
- false,
- bean.getBooleanProperty());
- assertEquals("Copied byte property",
- (byte) 111,
- bean.getByteProperty());
- assertEquals("Copied double property",
- 333.33,
- bean.getDoubleProperty(),
- 0.005);
- assertEquals("Copied int property",
- 333,
- bean.getIntProperty());
- assertEquals("Copied long property",
- 3333,
- bean.getLongProperty());
- assertEquals("Copied short property",
- (short) 33,
- bean.getShortProperty());
- assertEquals("Copied string property",
- "Custom string",
- bean.getStringProperty());
+ assertEquals("Copied boolean property", false, bean.getBooleanProperty());
+ assertEquals("Copied byte property", (byte) 111, bean.getByteProperty());
+ assertEquals("Copied double property", 333.33, bean.getDoubleProperty(), 0.005);
+ assertEquals("Copied int property", 333, bean.getIntProperty());
+ assertEquals("Copied long property", 3333, bean.getLongProperty());
+ assertEquals("Copied short property", (short) 33, bean.getShortProperty());
+ assertEquals("Copied string property", "Custom string", bean.getStringProperty());
// Validate the results for array properties
final String[] dupProperty = bean.getDupProperty();
@@ -373,56 +316,36 @@ public class BeanUtilsBeanTestCase extends TestCase {
// Verify existence of all the properties that should be present
for (final String describe : describes) {
- assertTrue("Property '" + describe + "' is present",
- map.containsKey(describe));
+ assertTrue("Property '" + describe + "' is present", map.containsKey(describe));
}
- assertTrue("Property 'writeOnlyProperty' is not present",
- !map.containsKey("writeOnlyProperty"));
+ assertTrue("Property 'writeOnlyProperty' is not present", !map.containsKey("writeOnlyProperty"));
// Verify the values of scalar properties
- assertEquals("Value of 'booleanProperty'",
- "true",
- map.get("booleanProperty"));
- assertEquals("Value of 'byteProperty'",
- "121",
- map.get("byteProperty"));
- assertEquals("Value of 'doubleProperty'",
- "321.0",
- map.get("doubleProperty"));
- assertEquals("Value of 'floatProperty'",
- "123.0",
- map.get("floatProperty"));
- assertEquals("Value of 'intProperty'",
- "123",
- map.get("intProperty"));
- assertEquals("Value of 'longProperty'",
- "321",
- map.get("longProperty"));
- assertEquals("Value of 'shortProperty'",
- "987",
- map.get("shortProperty"));
- assertEquals("Value of 'stringProperty'",
- "This is a string",
- map.get("stringProperty"));
+ assertEquals("Value of 'booleanProperty'", "true", map.get("booleanProperty"));
+ assertEquals("Value of 'byteProperty'", "121", map.get("byteProperty"));
+ assertEquals("Value of 'doubleProperty'", "321.0", map.get("doubleProperty"));
+ assertEquals("Value of 'floatProperty'", "123.0", map.get("floatProperty"));
+ assertEquals("Value of 'intProperty'", "123", map.get("intProperty"));
+ assertEquals("Value of 'longProperty'", "321", map.get("longProperty"));
+ assertEquals("Value of 'shortProperty'", "987", map.get("shortProperty"));
+ assertEquals("Value of 'stringProperty'", "This is a string", map.get("stringProperty"));
}
/**
- * tests the string and int arrays of TestBean
+ * tests the string and int arrays of TestBean
*/
public void testGetArrayProperty() {
try {
String[] arr = BeanUtils.getArrayProperty(bean, "stringArray");
final String[] comp = bean.getStringArray();
- assertTrue("String array length = " + comp.length,
- comp.length == arr.length);
+ assertTrue("String array length = " + comp.length, comp.length == arr.length);
arr = BeanUtils.getArrayProperty(bean, "intArray");
final int[] iarr = bean.getIntArray();
- assertTrue("String array length = " + iarr.length,
- iarr.length == arr.length);
+ assertTrue("String array length = " + iarr.length, iarr.length == arr.length);
// Test property which isn't array or collection
arr = BeanUtils.getArrayProperty(bean, "shortProperty");
@@ -452,7 +375,7 @@ public class BeanUtilsBeanTestCase extends TestCase {
public void testGetArrayPropertyDate() {
String[] value = null;
try {
- bean.setDateArrayProperty(new java.util.Date[] {testUtilDate});
+ bean.setDateArrayProperty(new java.util.Date[] { testUtilDate });
value = BeanUtils.getArrayProperty(bean, "dateArrayProperty");
} catch (final Throwable t) {
fail("Threw " + t);
@@ -462,7 +385,7 @@ public class BeanUtilsBeanTestCase extends TestCase {
}
/**
- * tests getting an indexed property
+ * tests getting an indexed property
*/
public void testGetIndexedProperty1() {
try {
@@ -488,7 +411,7 @@ public class BeanUtilsBeanTestCase extends TestCase {
public void testGetIndexedPropertyDate() {
String value = null;
try {
- bean.setDateArrayProperty(new java.util.Date[] {testUtilDate});
+ bean.setDateArrayProperty(new java.util.Date[] { testUtilDate });
value = BeanUtils.getIndexedProperty(bean, "dateArrayProperty[0]");
} catch (final Throwable t) {
fail("Threw " + t);
@@ -497,7 +420,7 @@ public class BeanUtilsBeanTestCase extends TestCase {
}
/**
- * tests getting an indexed property
+ * tests getting an indexed property
*/
public void testGetIndexedProperty2() {
try {
@@ -521,14 +444,13 @@ public class BeanUtilsBeanTestCase extends TestCase {
}
/**
- * tests getting a nested property
+ * tests getting a nested property
*/
public void testGetNestedProperty() {
try {
final String val = BeanUtils.getNestedProperty(bean, "nested.stringProperty");
final String comp = bean.getNested().getStringProperty();
- assertTrue("nested.StringProperty == " + comp,
- val.equals(comp));
+ assertTrue("nested.StringProperty == " + comp, val.equals(comp));
} catch (final IllegalAccessException e) {
fail("IllegalAccessException");
} catch (final InvocationTargetException e) {
@@ -539,15 +461,14 @@ public class BeanUtilsBeanTestCase extends TestCase {
}
/**
- * tests getting a 'whatever' property
+ * tests getting a 'whatever' property
*/
public void testGetGeneralProperty() {
try {
final String val = BeanUtils.getProperty(bean, "nested.intIndexed[2]");
final String comp = String.valueOf(bean.getIntIndexed(2));
- assertTrue("nested.intIndexed[2] == " + comp,
- val.equals(comp));
+ assertTrue("nested.intIndexed[2] == " + comp, val.equals(comp));
} catch (final IllegalAccessException e) {
fail("IllegalAccessException");
} catch (final InvocationTargetException e) {
@@ -558,15 +479,14 @@ public class BeanUtilsBeanTestCase extends TestCase {
}
/**
- * tests getting a 'whatever' property
+ * tests getting a 'whatever' property
*/
public void testGetSimpleProperty() {
try {
final String val = BeanUtils.getSimpleProperty(bean, "shortProperty");
final String comp = String.valueOf(bean.getShortProperty());
- assertTrue("shortProperty == " + comp,
- val.equals(comp));
+ assertTrue("shortProperty == " + comp, val.equals(comp));
} catch (final IllegalAccessException e) {
fail("IllegalAccessException");
} catch (final InvocationTargetException e) {
@@ -604,16 +524,11 @@ public class BeanUtilsBeanTestCase extends TestCase {
BeanUtils.populate(bean, map);
- assertEquals("intIndexed[0] is 100",
- 100, bean.getIntIndexed(0));
- assertEquals("intIndexed[1] is 10",
- 10, bean.getIntIndexed(1));
- assertEquals("intIndexed[2] is 120",
- 120, bean.getIntIndexed(2));
- assertEquals("intIndexed[3] is 30",
- 30, bean.getIntIndexed(3));
- assertEquals("intIndexed[4] is 140",
- 140, bean.getIntIndexed(4));
+ assertEquals("intIndexed[0] is 100", 100, bean.getIntIndexed(0));
+ assertEquals("intIndexed[1] is 10", 10, bean.getIntIndexed(1));
+ assertEquals("intIndexed[2] is 120", 120, bean.getIntIndexed(2));
+ assertEquals("intIndexed[3] is 30", 30, bean.getIntIndexed(3));
+ assertEquals("intIndexed[4] is 140", 140, bean.getIntIndexed(4));
map.clear();
map.put("stringIndexed[1]", "New String 1");
@@ -621,16 +536,11 @@ public class BeanUtilsBeanTestCase extends TestCase {
BeanUtils.populate(bean, map);
- assertEquals("stringIndexed[0] is \"String 0\"",
- "String 0", bean.getStringIndexed(0));
- assertEquals("stringIndexed[1] is \"New String 1\"",
- "New String 1", bean.getStringIndexed(1));
- assertEquals("stringIndexed[2] is \"String 2\"",
- "String 2", bean.getStringIndexed(2));
- assertEquals("stringIndexed[3] is \"New String 3\"",
- "New String 3", bean.getStringIndexed(3));
- assertEquals("stringIndexed[4] is \"String 4\"",
- "String 4", bean.getStringIndexed(4));
+ assertEquals("stringIndexed[0] is \"String 0\"", "String 0", bean.getStringIndexed(0));
+ assertEquals("stringIndexed[1] is \"New String 1\"", "New String 1", bean.getStringIndexed(1));
+ assertEquals("stringIndexed[2] is \"String 2\"", "String 2", bean.getStringIndexed(2));
+ assertEquals("stringIndexed[3] is \"New String 3\"", "New String 3", bean.getStringIndexed(3));
+ assertEquals("stringIndexed[4] is \"String 4\"", "String 4", bean.getStringIndexed(4));
} catch (final IllegalAccessException e) {
fail("IllegalAccessException");
@@ -657,8 +567,7 @@ public class BeanUtilsBeanTestCase extends TestCase {
intArray = bean.getIntArray();
assertNotNull("intArray is present", intArray);
- assertEquals("intArray length",
- 3, intArray.length);
+ assertEquals("intArray length", 3, intArray.length);
assertEquals("intArray[0]", 123, intArray[0]);
assertEquals("intArray[1]", 456, intArray[1]);
assertEquals("intArray[2]", 789, intArray[2]);
@@ -689,17 +598,10 @@ public class BeanUtilsBeanTestCase extends TestCase {
BeanUtils.populate(bean, map);
- assertEquals("mappedProperty(First Key)",
- "New First Value",
- bean.getMappedProperty("First Key"));
- assertEquals("mappedProperty(Second Key)",
- "Second Value",
- bean.getMappedProperty("Second Key"));
- assertEquals("mappedProperty(Third Key)",
- "New Third Value",
- bean.getMappedProperty("Third Key"));
- assertNull("mappedProperty(Fourth Key",
- bean.getMappedProperty("Fourth Key"));
+ assertEquals("mappedProperty(First Key)", "New First Value", bean.getMappedProperty("First Key"));
+ assertEquals("mappedProperty(Second Key)", "Second Value", bean.getMappedProperty("Second Key"));
+ assertEquals("mappedProperty(Third Key)", "New Third Value", bean.getMappedProperty("Third Key"));
+ assertNull("mappedProperty(Fourth Key", bean.getMappedProperty("Fourth Key"));
} catch (final IllegalAccessException e) {
fail("IllegalAccessException");
@@ -729,30 +631,15 @@ public class BeanUtilsBeanTestCase extends TestCase {
BeanUtils.populate(bean, map);
- assertTrue("booleanProperty is false",
- !bean.getNested().getBooleanProperty());
- assertTrue("booleanSecond is true",
- bean.getNested().isBooleanSecond());
- assertEquals("doubleProperty is 432.0",
- 432.0,
- bean.getNested().getDoubleProperty(),
- 0.005);
- assertEquals("floatProperty is 123.0",
- (float) 123.0,
- bean.getNested().getFloatProperty(),
- (float) 0.005);
- assertEquals("intProperty is 543",
- 543, bean.getNested().getIntProperty());
- assertEquals("longProperty is 321",
- 321, bean.getNested().getLongProperty());
- assertEquals("shortProperty is 654",
- (short) 654, bean.getNested().getShortProperty());
- assertEquals("stringProperty is \"This is a string\"",
- "This is a string",
- bean.getNested().getStringProperty());
- assertEquals("writeOnlyProperty is \"New writeOnlyProperty value\"",
- "New writeOnlyProperty value",
- bean.getNested().getWriteOnlyPropertyValue());
+ assertTrue("booleanProperty is false", !bean.getNested().getBooleanProperty());
+ assertTrue("booleanSecond is true", bean.getNested().isBooleanSecond());
+ assertEquals("doubleProperty is 432.0", 432.0, bean.getNested().getDoubleProperty(), 0.005);
+ assertEquals("floatProperty is 123.0", (float) 123.0, bean.getNested().getFloatProperty(), (float) 0.005);
+ assertEquals("intProperty is 543", 543, bean.getNested().getIntProperty());
+ assertEquals("longProperty is 321", 321, bean.getNested().getLongProperty());
+ assertEquals("shortProperty is 654", (short) 654, bean.getNested().getShortProperty());
+ assertEquals("stringProperty is \"This is a string\"", "This is a string", bean.getNested().getStringProperty());
+ assertEquals("writeOnlyProperty is \"New writeOnlyProperty value\"", "New writeOnlyProperty value", bean.getNested().getWriteOnlyPropertyValue());
} catch (final IllegalAccessException e) {
fail("IllegalAccessException");
@@ -789,30 +676,16 @@ public class BeanUtilsBeanTestCase extends TestCase {
assertTrue("booleanProperty is false", !bean.getBooleanProperty());
assertTrue("booleanSecond is true", bean.isBooleanSecond());
- assertEquals("byteProperty is 111",
- (byte) 111, bean.getByteProperty());
- assertEquals("doubleProperty is 432.0",
- 432.0, bean.getDoubleProperty(),
- 0.005);
- assertEquals("floatProperty is 123.0",
- (float) 123.0, bean.getFloatProperty(),
- (float) 0.005);
- assertEquals("intProperty is 543",
- 543, bean.getIntProperty());
- assertEquals("longProperty is 0",
- 0, bean.getLongProperty());
- assertNull("nullProperty is null",
- bean.getNullProperty());
- assertEquals("shortProperty is 654",
- (short) 654, bean.getShortProperty());
- assertEquals("stringProperty is \"This is a string\"",
- "This is a string", bean.getStringProperty());
- assertEquals("writeOnlyProperty is \"New writeOnlyProperty value\"",
- "New writeOnlyProperty value",
- bean.getWriteOnlyPropertyValue());
- assertEquals("readOnlyProperty is \"Read Only String Property\"",
- "Read Only String Property",
- bean.getReadOnlyProperty());
+ assertEquals("byteProperty is 111", (byte) 111, bean.getByteProperty());
+ assertEquals("doubleProperty is 432.0", 432.0, bean.getDoubleProperty(), 0.005);
+ assertEquals("floatProperty is 123.0", (float) 123.0, bean.getFloatProperty(), (float) 0.005);
+ assertEquals("intProperty is 543", 543, bean.getIntProperty());
+ assertEquals("longProperty is 0", 0, bean.getLongProperty());
+ assertNull("nullProperty is null", bean.getNullProperty());
+ assertEquals("shortProperty is 654", (short) 654, bean.getShortProperty());
+ assertEquals("stringProperty is \"This is a string\"", "This is a string", bean.getStringProperty());
+ assertEquals("writeOnlyProperty is \"New writeOnlyProperty value\"", "New writeOnlyProperty value", bean.getWriteOnlyPropertyValue());
+ assertEquals("readOnlyProperty is \"Read Only String Property\"", "Read Only String Property", bean.getReadOnlyProperty());
} catch (final IllegalAccessException e) {
fail("IllegalAccessException");
@@ -835,10 +708,8 @@ public class BeanUtilsBeanTestCase extends TestCase {
BeanUtils.setProperty(bean, "stringArray", null);
newValue = PropertyUtils.getSimpleProperty(bean, "stringArray");
assertNotNull("stringArray is not null", newValue);
- assertTrue("stringArray of correct type",
- newValue instanceof String[]);
- assertEquals("stringArray length",
- 1, ((String[]) newValue).length);
+ assertTrue("stringArray of correct type", newValue instanceof String[]);
+ assertEquals("stringArray length", 1, ((String[]) newValue).length);
PropertyUtils.setProperty(bean, "stringArray", oldValue);
// Indexed value into array
@@ -846,18 +717,14 @@ public class BeanUtilsBeanTestCase extends TestCase {
BeanUtils.setProperty(bean, "stringArray[2]", null);
newValue = PropertyUtils.getSimpleProperty(bean, "stringArray");
assertNotNull("stringArray is not null", newValue);
- assertTrue("stringArray of correct type",
- newValue instanceof String[]);
- assertEquals("stringArray length",
- 5, ((String[]) newValue).length);
- assertTrue("stringArray[2] is null",
- ((String[]) newValue)[2] == null);
+ assertTrue("stringArray of correct type", newValue instanceof String[]);
+ assertEquals("stringArray length", 5, ((String[]) newValue).length);
+ assertTrue("stringArray[2] is null", ((String[]) newValue)[2] == null);
PropertyUtils.setProperty(bean, "stringArray", oldValue);
// Value into scalar
BeanUtils.setProperty(bean, "stringProperty", null);
- assertTrue("stringProperty is now null",
- BeanUtils.getProperty(bean, "stringProperty") == null);
+ assertTrue("stringProperty is now null", BeanUtils.getProperty(bean, "stringProperty") == null);
}
@@ -866,9 +733,9 @@ public class BeanUtilsBeanTestCase extends TestCase {
*/
public void testSetPropertyOnPrimitiveWrappers() throws Exception {
- BeanUtils.setProperty(bean,"intProperty", Integer.valueOf(1));
- assertEquals(1,bean.getIntProperty());
- BeanUtils.setProperty(bean,"stringProperty", Integer.valueOf(1));
+ BeanUtils.setProperty(bean, "intProperty", Integer.valueOf(1));
+ assertEquals(1, bean.getIntProperty());
+ BeanUtils.setProperty(bean, "stringProperty", Integer.valueOf(1));
assertEquals(1, Integer.parseInt(bean.getStringProperty()));
}
@@ -880,12 +747,10 @@ public class BeanUtilsBeanTestCase extends TestCase {
BeanUtils.setProperty(bean, "byteProperty", Byte.valueOf((byte) 123));
assertEquals((byte) 123, bean.getByteProperty());
-/*
- BeanUtils.setProperty(bean, "byteProperty", new Double((double) 123));
- assertEquals((byte) 123, bean.getByteProperty());
- BeanUtils.setProperty(bean, "byteProperty", new Float((float) 123));
- assertEquals((byte) 123, bean.getByteProperty());
-*/
+ /*
+ * BeanUtils.setProperty(bean, "byteProperty", new Double((double) 123)); assertEquals((byte) 123, bean.getByteProperty()); BeanUtils.setProperty(bean,
+ * "byteProperty", new Float((float) 123)); assertEquals((byte) 123, bean.getByteProperty());
+ */
BeanUtils.setProperty(bean, "byteProperty", Integer.valueOf(123));
assertEquals((byte) 123, bean.getByteProperty());
BeanUtils.setProperty(bean, "byteProperty", Long.valueOf(123));
@@ -937,7 +802,7 @@ public class BeanUtilsBeanTestCase extends TestCase {
public void testSetPropertyConvertToStringArray() {
try {
bean.setStringArray(null);
- BeanUtils.setProperty(bean, "stringArray", new java.util.Date[] {testUtilDate});
+ BeanUtils.setProperty(bean, "stringArray", new java.util.Date[] { testUtilDate });
} catch (final Throwable t) {
fail("Threw " + t);
}
@@ -1005,12 +870,10 @@ public class BeanUtilsBeanTestCase extends TestCase {
BeanUtils.setProperty(bean, "longProperty", Byte.valueOf((byte) 123));
assertEquals(123, bean.getIntProperty());
-/*
- BeanUtils.setProperty(bean, "longProperty", new Double((double) 123));
- assertEquals((int) 123, bean.getIntProperty());
- BeanUtils.setProperty(bean, "longProperty", new Float((float) 123));
- assertEquals((int) 123, bean.getIntProperty());
-*/
+ /*
+ * BeanUtils.setProperty(bean, "longProperty", new Double((double) 123)); assertEquals((int) 123, bean.getIntProperty()); BeanUtils.setProperty(bean,
+ * "longProperty", new Float((float) 123)); assertEquals((int) 123, bean.getIntProperty());
+ */
BeanUtils.setProperty(bean, "longProperty", Integer.valueOf(123));
assertEquals(123, bean.getIntProperty());
BeanUtils.setProperty(bean, "longProperty", Long.valueOf(123));
@@ -1027,12 +890,10 @@ public class BeanUtilsBeanTestCase extends TestCase {
BeanUtils.setProperty(bean, "longProperty", Byte.valueOf((byte) 123));
assertEquals(123, bean.getLongProperty());
-/*
- BeanUtils.setProperty(bean, "longProperty", new Double((double) 123));
- assertEquals((long) 123, bean.getLongProperty());
- BeanUtils.setProperty(bean, "longProperty", new Float((float) 123));
- assertEquals((long) 123, bean.getLongProperty());
-*/
+ /*
+ * BeanUtils.setProperty(bean, "longProperty", new Double((double) 123)); assertEquals((long) 123, bean.getLongProperty()); BeanUtils.setProperty(bean,
+ * "longProperty", new Float((float) 123)); assertEquals((long) 123, bean.getLongProperty());
+ */
BeanUtils.setProperty(bean, "longProperty", Integer.valueOf(123));
assertEquals(123, bean.getLongProperty());
BeanUtils.setProperty(bean, "longProperty", Long.valueOf(123));
@@ -1060,12 +921,10 @@ public class BeanUtilsBeanTestCase extends TestCase {
BeanUtils.setProperty(bean, "shortProperty", Byte.valueOf((byte) 123));
assertEquals((short) 123, bean.getShortProperty());
-/*
- BeanUtils.setProperty(bean, "shortProperty", new Double((double) 123));
- assertEquals((short) 123, bean.getShortProperty());
- BeanUtils.setProperty(bean, "shortProperty", new Float((float) 123));
- assertEquals((short) 123, bean.getShortProperty());
-*/
+ /*
+ * BeanUtils.setProperty(bean, "shortProperty", new Double((double) 123)); assertEquals((short) 123, bean.getShortProperty());
+ * BeanUtils.setProperty(bean, "shortProperty", new Float((float) 123)); assertEquals((short) 123, bean.getShortProperty());
+ */
BeanUtils.setProperty(bean, "shortProperty", Integer.valueOf(123));
assertEquals((short) 123, bean.getShortProperty());
BeanUtils.setProperty(bean, "shortProperty", Long.valueOf(123));
@@ -1080,14 +939,14 @@ public class BeanUtilsBeanTestCase extends TestCase {
*/
public void testSetPropertyStringToArray() throws Exception {
BeanUtils.setProperty(bean, "stringArray", "ABC,DEF,GHI");
- final String[] strArray = bean.getStringArray();
+ final String[] strArray = bean.getStringArray();
assertEquals("length", 3, strArray.length);
assertEquals("value[0]", "ABC", strArray[0]);
assertEquals("value[1]", "DEF", strArray[1]);
assertEquals("value[2]", "GHI", strArray[2]);
BeanUtils.setProperty(bean, "intArray", "0, 10, 20, 30, 40");
- final int[] intArray = bean.getIntArray();
+ final int[] intArray = bean.getIntArray();
assertEquals("length", 5, intArray.length);
assertEquals("value[0]", 0, intArray[0]);
assertEquals("value[1]", 10, intArray[1]);
@@ -1158,7 +1017,7 @@ public class BeanUtilsBeanTestCase extends TestCase {
public void testCopyPropertyConvertToStringArray() {
try {
bean.setStringArray(null);
- BeanUtils.copyProperty(bean, "stringArray", new java.util.Date[] {testUtilDate});
+ BeanUtils.copyProperty(bean, "stringArray", new java.util.Date[] { testUtilDate });
} catch (final Throwable t) {
fail("Threw " + t);
}
@@ -1280,8 +1139,7 @@ public class BeanUtilsBeanTestCase extends TestCase {
}
/**
- * Test copying a property using a nested indexed array expression,
- * with and without conversions.
+ * Test copying a property using a nested indexed array expression, with and without conversions.
*/
public void testCopyPropertyNestedIndexedArray() throws Exception {
@@ -1329,8 +1187,7 @@ public class BeanUtilsBeanTestCase extends TestCase {
changedMap.put("Second Key", "Second Value");
// No conversion required
- BeanUtils.copyProperty(bean, "nested.mapProperty(Second Key)",
- "New Second Value");
+ BeanUtils.copyProperty(bean, "nested.mapProperty(Second Key)", "New Second Value");
checkMap(bean.getMapProperty(), origMap);
changedMap.put("Second Key", "New Second Value");
checkMap(bean.getNested().getMapProperty(), changedMap);
@@ -1338,8 +1195,7 @@ public class BeanUtilsBeanTestCase extends TestCase {
}
/**
- * Test copying a property using a nested simple expression, with and
- * without conversions.
+ * Test copying a property using a nested simple expression, with and without conversions.
*/
public void testCopyPropertyNestedSimple() throws Exception {
@@ -1384,8 +1240,7 @@ public class BeanUtilsBeanTestCase extends TestCase {
}
/**
- * Test copying a new value to a write-only property, with and without
- * conversions.
+ * Test copying a new value to a write-only property, with and without conversions.
*/
public void testCopyPropertyWriteOnly() throws Exception {
@@ -1402,8 +1257,7 @@ public class BeanUtilsBeanTestCase extends TestCase {
}
/**
- * Test setting a new value to a write-only property, with and without
- * conversions.
+ * Test setting a new value to a write-only property, with and without conversions.
*/
public void testSetPropertyWriteOnly() throws Exception {
@@ -1430,23 +1284,19 @@ public class BeanUtilsBeanTestCase extends TestCase {
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 {
BeanUtils.setProperty(bean, "mapProperty(mappedMap)(sub-key-3)", "SUB-KEY-3-UPDATED");
} catch (final 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"));
}
/** Tests that separate instances can register separate instances */
public void testSeparateInstances() throws Exception {
- final BeanUtilsBean utilsOne = new BeanUtilsBean(
- new ConvertUtilsBean(),
- new PropertyUtilsBean());
- final BeanUtilsBean utilsTwo = new BeanUtilsBean(
- new ConvertUtilsBean(),
- new PropertyUtilsBean());
+ final BeanUtilsBean utilsOne = new BeanUtilsBean(new ConvertUtilsBean(), new PropertyUtilsBean());
+ final BeanUtilsBean utilsTwo = new BeanUtilsBean(new ConvertUtilsBean(), new PropertyUtilsBean());
final TestBean bean = new TestBean();
@@ -1468,7 +1318,8 @@ public class BeanUtilsBeanTestCase extends TestCase {
utilsOne.setProperty(bean, "booleanProperty", "true");
fail("Registered conversion not used.");
- } catch (final PassTestException e) { /* Do nothing */ }
+ } catch (final PassTestException e) {
+ /* Do nothing */ }
// make sure that this conversion has no been registered in the other instance
try {
@@ -1483,23 +1334,15 @@ public class BeanUtilsBeanTestCase extends TestCase {
}
public void testArrayPropertyConversion() throws Exception {
- final BeanUtilsBean beanUtils = new BeanUtilsBean(
- new ConvertUtilsBean(),
- new PropertyUtilsBean());
+ final BeanUtilsBean beanUtils = new BeanUtilsBean(new ConvertUtilsBean(), new PropertyUtilsBean());
final TestBean bean = new TestBean();
- final String [] results = beanUtils.getArrayProperty(bean, "intArray");
+ final String[] results = beanUtils.getArrayProperty(bean, "intArray");
final int[] values = bean.getIntArray();
- assertEquals(
- "Converted array size not equal to property array size.",
- results.length,
- values.length);
- for (int i=0, size=values.length ; i<size; i++) {
- assertEquals(
- "Value " + i + " incorrectly converted ",
- values[i] + "",
- results[i]);
+ assertEquals("Converted array size not equal to property array size.", results.length, values.length);
+ for (int i = 0, size = values.length; i < size; i++) {
+ assertEquals("Value " + i + " incorrectly converted ", values[i] + "", results[i]);
}
}
@@ -1508,8 +1351,7 @@ public class BeanUtilsBeanTestCase extends TestCase {
assertNotNull("actual array not null", actual);
assertEquals("actual array length", expected.length, actual.length);
for (int i = 0; i < actual.length; i++) {
- assertEquals("actual array value[" + i + "]",
- expected[i], actual[i]);
+ assertEquals("actual array value[" + i + "]", expected[i], actual[i]);
}
}
@@ -1518,8 +1360,7 @@ public class BeanUtilsBeanTestCase extends TestCase {
assertNotNull("actual map not null", actual);
assertEquals("actual map size", expected.size(), actual.size());
for (final Object key : expected.keySet()) {
- assertEquals("actual map value(" + key + ")",
- expected.get(key), actual.get(key));
+ assertEquals("actual map value(" + key + ")", expected.get(key), actual.get(key));
}
}
@@ -1528,10 +1369,7 @@ public class BeanUtilsBeanTestCase extends TestCase {
BeanUtils.setProperty(bean, "mapproperty(this.that.the-other)", "some.dotty.value");
- assertEquals(
- "Mapped property set correctly",
- "some.dotty.value",
- bean.getMapproperty("this.that.the-other"));
+ assertEquals("Mapped property set correctly", "some.dotty.value", bean.getMapproperty("this.that.the-other"));
}
/**
@@ -1542,7 +1380,7 @@ public class BeanUtilsBeanTestCase extends TestCase {
return;
}
final String parentMsg = "PARENT-THROWABLE";
- final String causeMsg = "THROWABLE-CAUSE";
+ final String causeMsg = "THROWABLE-CAUSE";
try {
initCauseAndThrowException(parentMsg, causeMsg);
} catch (final Throwable thrownParent) {
@@ -1553,8 +1391,7 @@ public class BeanUtilsBeanTestCase extends TestCase {
assertNotNull("Cause Null", thrownCause);
assertEquals("Cause", causeMsg, thrownCause.getMessage());
} catch (final Throwable testError) {
- fail("If you're running JDK 1.3 then don't worry this should fail," +
- " if not then needs checking out: " + testError);
+ fail("If you're running JDK 1.3 then don't worry this should fail," + " if not then needs checking out: " + testError);
}
}
}
@@ -1563,7 +1400,7 @@ public class BeanUtilsBeanTestCase extends TestCase {
* Use reflection to get the cause
*/
private Throwable getCause(final Throwable t) throws Throwable {
- return (Throwable)PropertyUtils.getProperty(t, "cause");
+ return (Throwable) PropertyUtils.getProperty(t, "cause");
}
/**
@@ -1591,7 +1428,7 @@ public class BeanUtilsBeanTestCase extends TestCase {
*/
public static boolean isPre14JVM() {
final String version = System.getProperty("java.specification.version");
- final StringTokenizer tokenizer = new StringTokenizer(version,".");
+ final StringTokenizer tokenizer = new StringTokenizer(version, ".");
if (tokenizer.nextToken().equals("1")) {
final String minorVersion = tokenizer.nextToken();
if (minorVersion.equals("0")) {
diff --git a/src/test/java/org/apache/commons/beanutils2/BeanUtilsBenchCase.java b/src/test/java/org/apache/commons/beanutils2/BeanUtilsBenchCase.java
index 1d80bb84..497a41d5 100644
--- a/src/test/java/org/apache/commons/beanutils2/BeanUtilsBenchCase.java
+++ b/src/test/java/org/apache/commons/beanutils2/BeanUtilsBenchCase.java
@@ -49,7 +49,7 @@ public class BeanUtilsBenchCase extends TestCase {
// Input objects that have identical sets of properties and values.
private BenchBean inBean = null;
private DynaBean inDyna = null;
- private Map<String, Object> inMap = null; // Map of Objects requiring no conversion
+ private Map<String, Object> inMap = null; // Map of Objects requiring no conversion
private Map<String, String> inStrs = null; // Map of Strings requiring conversion
// Output objects that have identical sets of properties.
@@ -72,18 +72,11 @@ public class BeanUtilsBenchCase extends TestCase {
}
// Set up DynaClass for our DynaBean instances
- dynaClass = new BasicDynaClass
- ("BenchDynaClass", null,
- new DynaProperty[]{
- new DynaProperty("booleanProperty", Boolean.TYPE),
- new DynaProperty("byteProperty", Byte.TYPE),
- new DynaProperty("doubleProperty", Double.TYPE),
- new DynaProperty("floatProperty", Float.TYPE),
- new DynaProperty("intProperty", Integer.TYPE),
- new DynaProperty("longProperty", Long.TYPE),
- new DynaProperty("shortProperty", Short.TYPE),
- new DynaProperty("stringProperty", String.class),
- });
+ dynaClass = new BasicDynaClass("BenchDynaClass", null,
+ new DynaProperty[] { new DynaProperty("booleanProperty", Boolean.TYPE), new DynaProperty("byteProperty", Byte.TYPE),
+ new DynaProperty("doubleProperty", Double.TYPE), new DynaProperty("floatProperty", Float.TYPE),
+ new DynaProperty("intProperty", Integer.TYPE), new DynaProperty("longProperty", Long.TYPE),
+ new DynaProperty("shortProperty", Short.TYPE), new DynaProperty("stringProperty", String.class), });
// Create input instances
inBean = new BenchBean();
@@ -157,8 +150,7 @@ public class BeanUtilsBenchCase extends TestCase {
bu.copyProperties(outBean, inBean);
}
stopMillis = System.currentTimeMillis();
- System.err.println("BU.copyProperties(bean,bean), count=" + counter +
- ", time=" + (stopMillis - startMillis));
+ System.err.println("BU.copyProperties(bean,bean), count=" + counter + ", time=" + (stopMillis - startMillis));
// Bean->Dyna
for (long i = 0; i < counter; i++) {
@@ -169,8 +161,7 @@ public class BeanUtilsBenchCase extends TestCase {
bu.copyProperties(outDyna, inBean);
}
stopMillis = System.currentTimeMillis();
- System.err.println("BU.copyProperties(dyna,bean), count=" + counter +
- ", time=" + (stopMillis - startMillis));
+ System.err.println("BU.copyProperties(dyna,bean), count=" + counter + ", time=" + (stopMillis - startMillis));
}
@@ -189,8 +180,7 @@ public class BeanUtilsBenchCase extends TestCase {
bu.copyProperties(outBean, inDyna);
}
stopMillis = System.currentTimeMillis();
- System.err.println("BU.copyProperties(bean,dyna), count=" + counter +
- ", time=" + (stopMillis - startMillis));
+ System.err.println("BU.copyProperties(bean,dyna), count=" + counter + ", time=" + (stopMillis - startMillis));
// Dyna->Dyna
for (long i = 0; i < counter; i++) {
@@ -201,8 +191,7 @@ public class BeanUtilsBenchCase extends TestCase {
bu.copyProperties(outDyna, inDyna);
}
stopMillis = System.currentTimeMillis();
- System.err.println("BU.copyProperties(dyna,dyna), count=" + counter +
- ", time=" + (stopMillis - startMillis));
+ System.err.println("BU.copyProperties(dyna,dyna), count=" + counter + ", time=" + (stopMillis - startMillis));
}
@@ -221,8 +210,7 @@ public class BeanUtilsBenchCase extends TestCase {
bu.copyProperties(outBean, inMap);
}
stopMillis = System.currentTimeMillis();
- System.err.println("BU.copyProperties(bean, map), count=" + counter +
- ", time=" + (stopMillis - startMillis));
+ System.err.println("BU.copyProperties(bean, map), count=" + counter + ", time=" + (stopMillis - startMillis));
// Map->Dyna
for (long i = 0; i < counter; i++) {
@@ -233,8 +221,7 @@ public class BeanUtilsBenchCase extends TestCase {
bu.copyProperties(outDyna, inMap);
}
stopMillis = System.currentTimeMillis();
- System.err.println("BU.copyProperties(dyna, map), count=" + counter +
- ", time=" + (stopMillis - startMillis));
+ System.err.println("BU.copyProperties(dyna, map), count=" + counter + ", time=" + (stopMillis - startMillis));
}
@@ -253,8 +240,7 @@ public class BeanUtilsBenchCase extends TestCase {
bu.copyProperties(outBean, inStrs);
}
stopMillis = System.currentTimeMillis();
- System.err.println("BU.copyProperties(bean,strs), count=" + counter +
- ", time=" + (stopMillis - startMillis));
+ System.err.println("BU.copyProperties(bean,strs), count=" + counter + ", time=" + (stopMillis - startMillis));
// Strs->Dyna
for (long i = 0; i < counter; i++) {
@@ -265,8 +251,7 @@ public class BeanUtilsBenchCase extends TestCase {
bu.copyProperties(outDyna, inStrs);
}
stopMillis = System.currentTimeMillis();
- System.err.println("BU.copyProperties(dyna,strs), count=" + counter +
- ", time=" + (stopMillis - startMillis));
+ System.err.println("BU.copyProperties(dyna,strs), count=" + counter + ", time=" + (stopMillis - startMillis));
}
@@ -285,8 +270,7 @@ public class BeanUtilsBenchCase extends TestCase {
bu.populate(outBean, inMap);
}
stop = System.currentTimeMillis();
- System.err.println("BU.populate(bean, map), count=" + counter +
- ", time=" + (stop - startMillis));
+ System.err.println("BU.populate(bean, map), count=" + counter + ", time=" + (stop - startMillis));
// Map->Dyna
for (long i = 0; i < counter; i++) {
@@ -297,8 +281,7 @@ public class BeanUtilsBenchCase extends TestCase {
bu.populate(outDyna, inMap);
}
stop = System.currentTimeMillis();
- System.err.println("BU.populate(dyna, map), count=" + counter +
- ", time=" + (stop - startMillis));
+ System.err.println("BU.populate(dyna, map), count=" + counter + ", time=" + (stop - startMillis));
}
@@ -318,8 +301,7 @@ public class BeanUtilsBenchCase extends TestCase {
bu.populate(outBean, inStrs);
}
stop = System.currentTimeMillis();
- System.err.println("BU.populate(bean,strs), count=" + counter +
- ", time=" + (stop - startMillis));
+ System.err.println("BU.populate(bean,strs), count=" + counter + ", time=" + (stop - startMillis));
// Strs->Dyna
for (long i = 0; i < counter; i++) {
@@ -330,8 +312,7 @@ public class BeanUtilsBenchCase extends TestCase {
bu.populate(outDyna, inStrs);
}
stop = System.currentTimeMillis();
- System.err.println("BU.populate(dyna,strs), count=" + counter +
- ", time=" + (stop - startMillis));
+ System.err.println("BU.populate(dyna,strs), count=" + counter + ", time=" + (stop - startMillis));
}
diff --git a/src/test/java/org/apache/commons/beanutils2/BeanWithInnerBean.java b/src/test/java/org/apache/commons/beanutils2/BeanWithInnerBean.java
index 5e9d1af7..e4607ebf 100644
--- a/src/test/java/org/apache/commons/beanutils2/BeanWithInnerBean.java
+++ b/src/test/java/org/apache/commons/beanutils2/BeanWithInnerBean.java
@@ -24,21 +24,24 @@ import java.util.Properties;
*
*/
public class BeanWithInnerBean {
- private final InnerBean innerBean = new InnerBean();
+ private final InnerBean innerBean = new InnerBean();
- public BeanWithInnerBean() {}
- public InnerBean getInnerBean(){
- return innerBean;
+ public BeanWithInnerBean() {
}
- public class InnerBean {
- private final Properties fish = new Properties();
-
- public String getFish(final String key){
- return fish.getProperty(key);
+ public InnerBean getInnerBean() {
+ return innerBean;
}
- public void setFish(final String key, final String value){
- fish.setProperty(key, value);
+
+ public class InnerBean {
+ private final Properties fish = new Properties();
+
+ public String getFish(final String key) {
+ return fish.getProperty(key);
+ }
+
+ public void setFish(final String key, final String value) {
+ fish.setProperty(key, value);
+ }
}
- }
}
diff --git a/src/test/java/org/apache/commons/beanutils2/BeanificationTestCase.java b/src/test/java/org/apache/commons/beanutils2/BeanificationTestCase.java
index 2a19fb0b..284daa00 100644
--- a/src/test/java/org/apache/commons/beanutils2/BeanificationTestCase.java
+++ b/src/test/java/org/apache/commons/beanutils2/BeanificationTestCase.java
@@ -74,8 +74,9 @@ public class BeanificationTestCase extends TestCase {
public void testMemoryTestMethodology() throws Exception {
// test methodology
// many thanks to Juozas Baliuka for suggesting this method
- ClassLoader loader = new ClassLoader(this.getClass().getClassLoader()) {};
- final WeakReference<ClassLoader> reference = new WeakReference<>(loader);
+ ClassLoader loader = new ClassLoader(this.getClass().getClassLoader()) {
+ };
+ final WeakReference<ClassLoader> reference = new WeakReference<>(loader);
@SuppressWarnings("unused")
Class<?> myClass = loader.loadClass("org.apache.commons.beanutils2.BetaBean");
@@ -87,19 +88,18 @@ public class BeanificationTestCase extends TestCase {
int iterations = 0;
int bytz = 2;
- while(true) {
+ while (true) {
System.gc();
- if(iterations++ > MAX_GC_ITERATIONS){
+ if (iterations++ > MAX_GC_ITERATIONS) {
fail("Max iterations reached before resource released.");
}
- if( reference.get() == null ) {
+ if (reference.get() == null) {
break;
}
// create garbage:
@SuppressWarnings("unused")
- final
- byte[] b = new byte[bytz];
+ final byte[] b = new byte[bytz];
bytz = bytz * 2;
}
}
@@ -120,7 +120,7 @@ public class BeanificationTestCase extends TestCase {
Integer test = new Integer(1);
final WeakReference<Integer> testReference = new WeakReference<>(test, queue);
- //Map map = new ReferenceMap(ReferenceMap.WEAK, ReferenceMap.HARD, true);
+ // Map map = new ReferenceMap(ReferenceMap.WEAK, ReferenceMap.HARD, true);
final Map<Object, Object> map = new WeakHashMap<>();
map.put(loader, test);
@@ -134,23 +134,20 @@ public class BeanificationTestCase extends TestCase {
int iterations = 0;
int bytz = 2;
- while(true) {
+ while (true) {
System.gc();
- if(iterations++ > MAX_GC_ITERATIONS){
+ if (iterations++ > MAX_GC_ITERATIONS) {
fail("Max iterations reached before resource released.");
}
map.isEmpty();
- if(
- loaderReference.get() == null &&
- testReference.get() == null) {
+ if (loaderReference.get() == null && testReference.get() == null) {
break;
}
// create garbage:
@SuppressWarnings("unused")
- final
- byte[] b = new byte[bytz];
+ final byte[] b = new byte[bytz];
bytz = bytz * 2;
}
}
@@ -164,7 +161,7 @@ public class BeanificationTestCase extends TestCase {
// many thanks to Juozas Baliuka for suggesting this methodology
TestClassLoader loader = new TestClassLoader();
- final WeakReference<ClassLoader> loaderReference = new WeakReference<>(loader);
+ final WeakReference<ClassLoader> loaderReference = new WeakReference<>(loader);
BeanUtilsBean.getInstance();
class GetBeanUtilsBeanThread extends Thread {
@@ -173,7 +170,8 @@ public class BeanificationTestCase extends TestCase {
ConvertUtilsBean convertUtils;
PropertyUtilsBean propertyUtils;
- GetBeanUtilsBeanThread() {}
+ GetBeanUtilsBeanThread() {
+ }
@Override
public void run() {
@@ -192,15 +190,14 @@ public class BeanificationTestCase extends TestCase {
GetBeanUtilsBeanThread thread = new GetBeanUtilsBeanThread();
@SuppressWarnings("unused")
- final
- WeakReference<Thread> threadWeakReference = new WeakReference<>(thread);
+ final WeakReference<Thread> threadWeakReference = new WeakReference<>(thread);
thread.setContextClassLoader(loader);
thread.start();
thread.join();
final WeakReference<BeanUtilsBean> beanUtilsReference = new WeakReference<>(thread.beanUtils);
- final WeakReference<PropertyUtilsBean> propertyUtilsReference = new WeakReference<>(thread.propertyUtils);
+ final WeakReference<PropertyUtilsBean> propertyUtilsReference = new WeakReference<>(thread.propertyUtils);
final WeakReference<ConvertUtilsBean> convertUtilsReference = new WeakReference<>(thread.convertUtils);
assertNotNull("Weak reference released early (1)", loaderReference.get());
@@ -215,32 +212,27 @@ public class BeanificationTestCase extends TestCase {
int iterations = 0;
int bytz = 2;
- while(true) {
+ while (true) {
BeanUtilsBean.getInstance();
System.gc();
- if(iterations++ > MAX_GC_ITERATIONS){
+ if (iterations++ > MAX_GC_ITERATIONS) {
fail("Max iterations reached before resource released.");
}
- if(
- loaderReference.get() == null &&
- beanUtilsReference.get() == null &&
- propertyUtilsReference.get() == null &&
- convertUtilsReference.get() == null) {
+ if (loaderReference.get() == null && beanUtilsReference.get() == null && propertyUtilsReference.get() == null
+ && convertUtilsReference.get() == null) {
break;
}
// create garbage:
@SuppressWarnings("unused")
- final
- byte[] b = new byte[bytz];
+ final byte[] b = new byte[bytz];
bytz = bytz * 2;
}
}
/**
- * Tests whether difference instances are loaded by different
- * context classloaders.
+ * Tests whether difference instances are loaded by different context classloaders.
*/
public void testGetByContextClassLoader() throws Exception {
@@ -276,21 +268,13 @@ public class BeanificationTestCase extends TestCase {
thread.join();
assertEquals("Signal not set by test thread", 2, signal.getSignal());
- assertTrue(
- "Different BeanUtilsBean instances per context classloader",
- BeanUtilsBean.getInstance() != signal.getBean());
- assertTrue(
- "Different ConvertUtilsBean instances per context classloader",
- ConvertUtilsBean.getInstance() != signal.getConvertUtils());
- assertTrue(
- "Different PropertyUtilsBean instances per context classloader",
- PropertyUtilsBean.getInstance() != signal.getPropertyUtils());
+ assertTrue("Different BeanUtilsBean instances per context classloader", BeanUtilsBean.getInstance() != signal.getBean());
+ assertTrue("Different ConvertUtilsBean instances per context classloader", ConvertUtilsBean.getInstance() != signal.getConvertUtils());
+ assertTrue("Different PropertyUtilsBean instances per context classloader", PropertyUtilsBean.getInstance() != signal.getPropertyUtils());
}
-
/**
- * Tests whether difference instances are loaded by different
- * context classloaders.
+ * Tests whether difference instances are loaded by different context classloaders.
*/
public void testContextClassLoaderLocal() throws Exception {
@@ -351,12 +335,7 @@ public class BeanificationTestCase extends TestCase {
public void run() {
try {
signal.setSignal(3);
- ConvertUtils.register(new Converter<Integer>() {
- @Override
- public Integer convert(final Class<Integer> type, final Object value) {
- return ConvertUtils.primitiveToWrapper(type).cast(new Integer(9));
- }
- }, Integer.TYPE);
+ ConvertUtils.register((type, value) -> ConvertUtils.primitiveToWrapper(type).cast(new Integer(9)), Integer.TYPE);
BeanUtils.setProperty(bean, "int", new Integer(1));
} catch (final Exception e) {
e.printStackTrace();
@@ -374,12 +353,7 @@ public class BeanificationTestCase extends TestCase {
BeanUtils.setProperty(bean, "int", new Integer(1));
assertEquals("Wrong property value (1)", 1, bean.getInt());
- ConvertUtils.register(new Converter<Integer>() {
- @Override
- public Integer convert(final Class<Integer> type, final Object value) {
- return ConvertUtils.primitiveToWrapper(type).cast(new Integer(5));
- }
- }, Integer.TYPE);
+ ConvertUtils.register((type, value) -> ConvertUtils.primitiveToWrapper(type).cast(new Integer(5)), Integer.TYPE);
BeanUtils.setProperty(bean, "int", new Integer(1));
assertEquals("Wrong property value(2)", 5, bean.getInt());
@@ -443,7 +417,7 @@ public class BeanificationTestCase extends TestCase {
assertEquals("Second thread gets value it set", beanTwo, signal.getBean());
}
- /** Tests whether the unset method works*/
+ /** Tests whether the unset method works */
public void testContextClassLoaderUnset() throws Exception {
final BeanUtilsBean beanOne = new BeanUtilsBean();
final ContextClassLoaderLocal<BeanUtilsBean> ccll = new ContextClassLoaderLocal<>();
@@ -519,4 +493,3 @@ public class BeanificationTestCase extends TestCase {
}
}
}
-
diff --git a/src/test/java/org/apache/commons/beanutils2/BenchBean.java b/src/test/java/org/apache/commons/beanutils2/BenchBean.java
index fc4ff3a4..4c55cbd2 100644
--- a/src/test/java/org/apache/commons/beanutils2/BenchBean.java
+++ b/src/test/java/org/apache/commons/beanutils2/BenchBean.java
@@ -24,8 +24,6 @@ package org.apache.commons.beanutils2;
public class BenchBean {
-
-
/**
* A boolean property.
*/
diff --git a/src/test/java/org/apache/commons/beanutils2/ConstructorUtilsTestCase.java b/src/test/java/org/apache/commons/beanutils2/ConstructorUtilsTestCase.java
index 18f8a9fb..c91cda61 100644
--- a/src/test/java/org/apache/commons/beanutils2/ConstructorUtilsTestCase.java
+++ b/src/test/java/org/apache/commons/beanutils2/ConstructorUtilsTestCase.java
@@ -25,13 +25,13 @@ import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
- * <p> Test case for {@code ConstructorUtils} </p>
+ * <p>
+ * Test case for {@code ConstructorUtils}
+ * </p>
*
*/
public class ConstructorUtilsTestCase extends TestCase {
-
-
/**
* Constructs a new instance of this test case.
*
@@ -41,8 +41,6 @@ public class ConstructorUtilsTestCase extends TestCase {
super(name);
}
-
-
/**
* Sets up instance variables required by this test case.
*/
@@ -66,20 +64,18 @@ public class ConstructorUtilsTestCase extends TestCase {
super.tearDown();
}
-
-
public void testInvokeConstructor() throws Exception {
{
- final Object obj = ConstructorUtils.invokeConstructor(TestBean.class,"TEST");
+ final Object obj = ConstructorUtils.invokeConstructor(TestBean.class, "TEST");
assertNotNull(obj);
assertTrue(obj instanceof TestBean);
- assertEquals("TEST",((TestBean)obj).getStringProperty());
+ assertEquals("TEST", ((TestBean) obj).getStringProperty());
}
{
- final Object obj = ConstructorUtils.invokeConstructor(TestBean.class,Float.valueOf(17.3f));
+ final Object obj = ConstructorUtils.invokeConstructor(TestBean.class, Float.valueOf(17.3f));
assertNotNull(obj);
assertTrue(obj instanceof TestBean);
- assertEquals(17.3f,((TestBean)obj).getFloatProperty(),0.0f);
+ assertEquals(17.3f, ((TestBean) obj).getFloatProperty(), 0.0f);
}
}
@@ -91,54 +87,54 @@ public class ConstructorUtilsTestCase extends TestCase {
public void testInvokeConstructorWithArgArray() throws Exception {
final Object[] args = { Float.valueOf(17.3f), "TEST" };
- final Object obj = ConstructorUtils.invokeConstructor(TestBean.class,args);
+ final Object obj = ConstructorUtils.invokeConstructor(TestBean.class, args);
assertNotNull(obj);
assertTrue(obj instanceof TestBean);
- assertEquals(17.3f,((TestBean)obj).getFloatProperty(),0.0f);
- assertEquals("TEST",((TestBean)obj).getStringProperty());
+ assertEquals(17.3f, ((TestBean) obj).getFloatProperty(), 0.0f);
+ assertEquals("TEST", ((TestBean) obj).getStringProperty());
}
public void testInvokeConstructorWithTypeArray() throws Exception {
{
final Object[] args = { Boolean.TRUE, "TEST" };
final Class<?>[] types = { Boolean.TYPE, String.class };
- final Object obj = ConstructorUtils.invokeConstructor(TestBean.class,args,types);
+ final Object obj = ConstructorUtils.invokeConstructor(TestBean.class, args, types);
assertNotNull(obj);
assertTrue(obj instanceof TestBean);
- assertEquals(true,((TestBean)obj).getBooleanProperty());
- assertEquals("TEST",((TestBean)obj).getStringProperty());
+ assertEquals(true, ((TestBean) obj).getBooleanProperty());
+ assertEquals("TEST", ((TestBean) obj).getStringProperty());
}
{
final Object[] args = { Boolean.TRUE, "TEST" };
final Class<?>[] types = { Boolean.class, String.class };
- final Object obj = ConstructorUtils.invokeConstructor(TestBean.class,args,types);
+ final Object obj = ConstructorUtils.invokeConstructor(TestBean.class, args, types);
assertNotNull(obj);
assertTrue(obj instanceof TestBean);
- assertEquals(true,((TestBean)obj).isBooleanSecond());
- assertEquals("TEST",((TestBean)obj).getStringProperty());
+ assertEquals(true, ((TestBean) obj).isBooleanSecond());
+ assertEquals("TEST", ((TestBean) obj).getStringProperty());
}
}
public void testInvokeExactConstructor() throws Exception {
{
- final Object obj = ConstructorUtils.invokeExactConstructor(TestBean.class,"TEST");
+ final Object obj = ConstructorUtils.invokeExactConstructor(TestBean.class, "TEST");
assertNotNull(obj);
assertTrue(obj instanceof TestBean);
- assertEquals("TEST",((TestBean)obj).getStringProperty());
+ assertEquals("TEST", ((TestBean) obj).getStringProperty());
}
{
try {
- ConstructorUtils.invokeExactConstructor(TestBean.class,Float.valueOf(17.3f));
+ ConstructorUtils.invokeExactConstructor(TestBean.class, Float.valueOf(17.3f));
fail("Expected NoSuchMethodException");
- } catch(final NoSuchMethodException e) {
+ } catch (final NoSuchMethodException e) {
// expected
}
}
{
- final Object obj = ConstructorUtils.invokeExactConstructor(TestBean.class,Boolean.TRUE);
+ final Object obj = ConstructorUtils.invokeExactConstructor(TestBean.class, Boolean.TRUE);
assertNotNull(obj);
assertTrue(obj instanceof TestBean);
- assertEquals(true,((TestBean)obj).isBooleanSecond());
+ assertEquals(true, ((TestBean) obj).isBooleanSecond());
}
}
@@ -152,19 +148,19 @@ public class ConstructorUtilsTestCase extends TestCase {
{
final Object[] args = { Float.valueOf(17.3f), "TEST" };
try {
- ConstructorUtils.invokeExactConstructor(TestBean.class,args);
+ ConstructorUtils.invokeExactConstructor(TestBean.class, args);
fail("Expected NoSuchMethodException");
- } catch(final NoSuchMethodException e) {
+ } catch (final NoSuchMethodException e) {
// expected
}
}
{
final Object[] args = { Boolean.TRUE, "TEST" };
- final Object obj = ConstructorUtils.invokeExactConstructor(TestBean.class,args);
+ final Object obj = ConstructorUtils.invokeExactConstructor(TestBean.class, args);
assertNotNull(obj);
assertTrue(obj instanceof TestBean);
- assertEquals(true,((TestBean)obj).isBooleanSecond());
- assertEquals("TEST",((TestBean)obj).getStringProperty());
+ assertEquals(true, ((TestBean) obj).isBooleanSecond());
+ assertEquals("TEST", ((TestBean) obj).getStringProperty());
}
}
@@ -172,37 +168,37 @@ public class ConstructorUtilsTestCase extends TestCase {
{
final Object[] args = { Boolean.TRUE, "TEST" };
final Class<?>[] types = { Boolean.TYPE, String.class };
- final Object obj = ConstructorUtils.invokeExactConstructor(TestBean.class,args,types);
+ final Object obj = ConstructorUtils.invokeExactConstructor(TestBean.class, args, types);
assertNotNull(obj);
assertTrue(obj instanceof TestBean);
- assertEquals(true,((TestBean)obj).getBooleanProperty());
- assertEquals("TEST",((TestBean)obj).getStringProperty());
+ assertEquals(true, ((TestBean) obj).getBooleanProperty());
+ assertEquals("TEST", ((TestBean) obj).getStringProperty());
}
{
final Object[] args = { Boolean.TRUE, "TEST" };
final Class<?>[] types = { Boolean.class, String.class };
- final Object obj = ConstructorUtils.invokeExactConstructor(TestBean.class,args,types);
+ final Object obj = ConstructorUtils.invokeExactConstructor(TestBean.class, args, types);
assertNotNull(obj);
assertTrue(obj instanceof TestBean);
- assertEquals(true,((TestBean)obj).isBooleanSecond());
- assertEquals("TEST",((TestBean)obj).getStringProperty());
+ assertEquals(true, ((TestBean) obj).isBooleanSecond());
+ assertEquals("TEST", ((TestBean) obj).getStringProperty());
}
{
final Object[] args = { Float.valueOf(17.3f), "TEST" };
final Class<?>[] types = { Float.TYPE, String.class };
- final Object obj = ConstructorUtils.invokeExactConstructor(TestBean.class,args,types);
+ final Object obj = ConstructorUtils.invokeExactConstructor(TestBean.class, args, types);
assertNotNull(obj);
assertTrue(obj instanceof TestBean);
- assertEquals(17.3f,((TestBean)obj).getFloatProperty(),0.0f);
- assertEquals("TEST",((TestBean)obj).getStringProperty());
+ assertEquals(17.3f, ((TestBean) obj).getFloatProperty(), 0.0f);
+ assertEquals("TEST", ((TestBean) obj).getStringProperty());
}
{
final Object[] args = { Float.valueOf(17.3f), "TEST" };
final Class<?>[] types = { Float.class, String.class };
try {
- ConstructorUtils.invokeExactConstructor(TestBean.class,args,types);
+ ConstructorUtils.invokeExactConstructor(TestBean.class, args, types);
fail("Expected NoSuchMethodException");
- } catch(final NoSuchMethodException e) {
+ } catch (final NoSuchMethodException e) {
// expected
}
}
@@ -210,17 +206,17 @@ public class ConstructorUtilsTestCase extends TestCase {
public void testGetAccessibleConstructor() throws Exception {
{
- final Constructor<?> ctor = ConstructorUtils.getAccessibleConstructor(TestBean.class,String.class);
+ final Constructor<?> ctor = ConstructorUtils.getAccessibleConstructor(TestBean.class, String.class);
assertNotNull(ctor);
assertTrue(Modifier.isPublic(ctor.getModifiers()));
}
{
- final Constructor<?> ctor = ConstructorUtils.getAccessibleConstructor(TestBean.class,Integer.class);
+ final Constructor<?> ctor = ConstructorUtils.getAccessibleConstructor(TestBean.class, Integer.class);
assertNotNull(ctor);
assertTrue(Modifier.isPublic(ctor.getModifiers()));
}
{
- final Constructor<?> ctor = ConstructorUtils.getAccessibleConstructor(TestBean.class,Integer.TYPE);
+ final Constructor<?> ctor = ConstructorUtils.getAccessibleConstructor(TestBean.class, Integer.TYPE);
assertNull(ctor);
}
}
@@ -228,13 +224,13 @@ public class ConstructorUtilsTestCase extends TestCase {
public void testGetAccessibleConstructorWithTypeArray() throws Exception {
{
final Class<?>[] types = { Boolean.TYPE, String.class };
- final Constructor<?> ctor = ConstructorUtils.getAccessibleConstructor(TestBean.class,types);
+ final Constructor<?> ctor = ConstructorUtils.getAccessibleConstructor(TestBean.class, types);
assertNotNull(ctor);
assertTrue(Modifier.isPublic(ctor.getModifiers()));
}
{
final Class<?>[] types = { Boolean.TYPE, Boolean.TYPE, String.class };
- final Constructor<?> ctor = ConstructorUtils.getAccessibleConstructor(TestBean.class,types);
+ final Constructor<?> ctor = ConstructorUtils.getAccessibleConstructor(TestBean.class, types);
assertNull(ctor);
}
}
diff --git a/src/test/java/org/apache/commons/beanutils2/ConvertUtilsTestCase.java b/src/test/java/org/apache/commons/beanutils2/ConvertUtilsTestCase.java
index fa03d7c8..8f9f0c7d 100644
--- a/src/test/java/org/apache/commons/beanutils2/ConvertUtilsTestCase.java
+++ b/src/test/java/org/apache/commons/beanutils2/ConvertUtilsTestCase.java
@@ -32,17 +32,13 @@ import junit.framework.TestSuite;
/**
* <p>
- * Test Case for the ConvertUtils class.
+ * Test Case for the ConvertUtils class.
* </p>
*
*/
public class ConvertUtilsTestCase extends TestCase {
-
-
-
-
/**
* Constructs a new instance of this test case.
*
@@ -52,8 +48,6 @@ public class ConvertUtilsTestCase extends TestCase {
super(name);
}
-
-
/**
* Sets up instance variables required by this test case.
*/
@@ -79,8 +73,6 @@ public class ConvertUtilsTestCase extends TestCase {
// No action required
}
-
-
/**
* Negative String to primitive integer array tests.
*/
@@ -107,8 +99,7 @@ public class ConvertUtilsTestCase extends TestCase {
}
/**
- * Negative scalar conversion tests. These rely on the standard
- * default value conversions in ConvertUtils.
+ * Negative scalar conversion tests. These rely on the standard default value conversions in ConvertUtils.
*/
public void testNegativeScalar() {
@@ -131,8 +122,7 @@ public class ConvertUtilsTestCase extends TestCase {
assertEquals(((Byte) value).byteValue(), (byte) 0);
try {
- value = ConvertUtils.convert
- ("org.apache.commons.beanutils2.Undefined", Class.class);
+ value = ConvertUtils.convert("org.apache.commons.beanutils2.Undefined", Class.class);
fail("Should have thrown conversion exception");
} catch (final ConversionException e) {
// Expected result
@@ -140,8 +130,7 @@ public class ConvertUtilsTestCase extends TestCase {
value = ConvertUtils.convert("foo", Double.TYPE);
assertTrue(value instanceof Double);
- assertEquals(((Double) value).doubleValue(), 0.0,
- 0.005);
+ assertEquals(((Double) value).doubleValue(), 0.0, 0.005);
value = ConvertUtils.convert("foo", Double.class);
assertTrue(value instanceof Double);
@@ -149,13 +138,11 @@ public class ConvertUtilsTestCase extends TestCase {
value = ConvertUtils.convert("foo", Float.TYPE);
assertTrue(value instanceof Float);
- assertEquals(((Float) value).floatValue(), (float) 0.0,
- (float) 0.005);
+ assertEquals(((Float) value).floatValue(), (float) 0.0, (float) 0.005);
value = ConvertUtils.convert("foo", Float.class);
assertTrue(value instanceof Float);
- assertEquals(((Float) value).floatValue(), (float) 0.0,
- (float) 0.005);
+ assertEquals(((Float) value).floatValue(), (float) 0.0, (float) 0.005);
value = ConvertUtils.convert("foo", Integer.TYPE);
assertTrue(value instanceof Integer);
@@ -208,19 +195,13 @@ public class ConvertUtilsTestCase extends TestCase {
final String[] stringArray1 = { "abc" };
final String[] stringArray2 = { "abc", "def" };
- assertEquals("intArray0", null,
- ConvertUtils.convert(intArray0));
- assertEquals("intArray1", "123",
- ConvertUtils.convert(intArray1));
- assertEquals("intArray2", "123",
- ConvertUtils.convert(intArray2));
+ assertEquals("intArray0", null, ConvertUtils.convert(intArray0));
+ assertEquals("intArray1", "123", ConvertUtils.convert(intArray1));
+ assertEquals("intArray2", "123", ConvertUtils.convert(intArray2));
- assertEquals("stringArray0", null,
- ConvertUtils.convert(stringArray0));
- assertEquals("stringArray1", "abc",
- ConvertUtils.convert(stringArray1));
- assertEquals("stringArray2", "abc",
- ConvertUtils.convert(stringArray2));
+ assertEquals("stringArray0", null, ConvertUtils.convert(stringArray0));
+ assertEquals("stringArray1", "abc", ConvertUtils.convert(stringArray1));
+ assertEquals("stringArray2", "abc", ConvertUtils.convert(stringArray2));
}
@@ -229,28 +210,17 @@ public class ConvertUtilsTestCase extends TestCase {
*/
public void testObjectToStringScalar() {
- assertEquals("Boolean->String", "false",
- ConvertUtils.convert(Boolean.FALSE));
- assertEquals("Boolean->String", "true",
- ConvertUtils.convert(Boolean.TRUE));
- assertEquals("Byte->String", "123",
- ConvertUtils.convert(Byte.valueOf((byte) 123)));
- assertEquals("Character->String", "a",
- ConvertUtils.convert(Character.valueOf('a')));
- assertEquals("Double->String", "123.0",
- ConvertUtils.convert(Double.valueOf(123.0)));
- assertEquals("Float->String", "123.0",
- ConvertUtils.convert(Float.valueOf((float) 123.0)));
- assertEquals("Integer->String", "123",
- ConvertUtils.convert(Integer.valueOf(123)));
- assertEquals("Long->String", "123",
- ConvertUtils.convert(Long.valueOf(123)));
- assertEquals("Short->String", "123",
- ConvertUtils.convert(Short.valueOf((short) 123)));
- assertEquals("String->String", "abc",
- ConvertUtils.convert("abc"));
- assertEquals("String->String null", null,
- ConvertUtils.convert(null));
+ assertEquals("Boolean->String", "false", ConvertUtils.convert(Boolean.FALSE));
+ assertEquals("Boolean->String", "true", ConvertUtils.convert(Boolean.TRUE));
+ assertEquals("Byte->String", "123", ConvertUtils.convert(Byte.valueOf((byte) 123)));
+ assertEquals("Character->String", "a", ConvertUtils.convert(Character.valueOf('a')));
+ assertEquals("Double->String", "123.0", ConvertUtils.convert(Double.valueOf(123.0)));
+ assertEquals("Float->String", "123.0", ConvertUtils.convert(Float.valueOf((float) 123.0)));
+ assertEquals("Integer->String", "123", ConvertUtils.convert(Integer.valueOf(123)));
+ assertEquals("Long->String", "123", ConvertUtils.convert(Long.valueOf(123)));
+ assertEquals("Short->String", "123", ConvertUtils.convert(Short.valueOf((short) 123)));
+ assertEquals("String->String", "abc", ConvertUtils.convert("abc"));
+ assertEquals("String->String null", null, ConvertUtils.convert(null));
}
@@ -414,13 +384,11 @@ public class ConvertUtilsTestCase extends TestCase {
value = ConvertUtils.convert("123.456", Float.TYPE);
assertTrue(value instanceof Float);
- assertEquals(((Float) value).floatValue(), (float) 123.456,
- (float) 0.005);
+ assertEquals(((Float) value).floatValue(), (float) 123.456, (float) 0.005);
value = ConvertUtils.convert("123.456", Float.class);
assertTrue(value instanceof Float);
- assertEquals(((Float) value).floatValue(), (float) 123.456,
- (float) 0.005);
+ assertEquals(((Float) value).floatValue(), (float) 123.456, (float) 0.005);
value = ConvertUtils.convert("123", Integer.TYPE);
assertTrue(value instanceof Integer);
@@ -497,23 +465,17 @@ public class ConvertUtilsTestCase extends TestCase {
value = ConvertUtils.convert("{'abc'}", stringArray.getClass());
checkStringArray(value, stringArray1);
- value = ConvertUtils.convert("abc 'de,f'",
- stringArray.getClass());
+ value = ConvertUtils.convert("abc 'de,f'", stringArray.getClass());
checkStringArray(value, stringArray2);
- value = ConvertUtils.convert("{abc, 'de,f'}",
- stringArray.getClass());
+ value = ConvertUtils.convert("{abc, 'de,f'}", stringArray.getClass());
checkStringArray(value, stringArray2);
- value = ConvertUtils.convert("\"abc\",\"de,f\"",
- stringArray.getClass());
+ value = ConvertUtils.convert("\"abc\",\"de,f\"", stringArray.getClass());
checkStringArray(value, stringArray2);
- value = ConvertUtils.convert("{\"abc\" 'de,f'}",
- stringArray.getClass());
+ value = ConvertUtils.convert("{\"abc\" 'de,f'}", stringArray.getClass());
checkStringArray(value, stringArray2);
- value = ConvertUtils.convert("'abc' 'de,f'",
- stringArray.getClass());
+ value = ConvertUtils.convert("'abc' 'de,f'", stringArray.getClass());
checkStringArray(value, stringArray2);
- value = ConvertUtils.convert("{'abc', \"de,f\"}",
- stringArray.getClass());
+ value = ConvertUtils.convert("{'abc', \"de,f\"}", stringArray.getClass());
checkStringArray(value, stringArray2);
}
@@ -523,20 +485,13 @@ public class ConvertUtilsTestCase extends TestCase {
final ConvertUtilsBean utilsTwo = new ConvertUtilsBean();
// make sure that the test work ok before anything's changed
- Object
- value = utilsOne.convert("true", Boolean.TYPE);
+ Object value = utilsOne.convert("true", Boolean.TYPE);
assertTrue(value instanceof Boolean);
- assertEquals(
- "Standard conversion failed (1)",
- ((Boolean) value).booleanValue(),
- true);
+ assertEquals("Standard conversion failed (1)", ((Boolean) value).booleanValue(), true);
value = utilsTwo.convert("true", Boolean.TYPE);
assertTrue(value instanceof Boolean);
- assertEquals(
- "Standard conversion failed (2)",
- ((Boolean) value).booleanValue(),
- true);
+ assertEquals("Standard conversion failed (2)", ((Boolean) value).booleanValue(), true);
// now register a test
@@ -546,16 +501,14 @@ public class ConvertUtilsTestCase extends TestCase {
utilsOne.convert("true", Boolean.TYPE);
fail("Register converter failed.");
- } catch (final PassTestException e) { /* This shows that the registration has worked */ }
+ } catch (final PassTestException e) {
+ /* This shows that the registration has worked */ }
try {
// nothing should have changed
value = utilsTwo.convert("true", Boolean.TYPE);
assertTrue(value instanceof Boolean);
- assertEquals(
- "Standard conversion failed (3)",
- ((Boolean) value).booleanValue(),
- true);
+ assertEquals("Standard conversion failed (3)", ((Boolean) value).booleanValue(), true);
} catch (final PassTestException e) {
// This is a failure since utilsTwo should still have
@@ -571,25 +524,18 @@ public class ConvertUtilsTestCase extends TestCase {
value = utilsTwo.convert("true", Boolean.TYPE);
assertTrue(value instanceof Boolean);
- assertEquals(
- "Standard conversion failed (4)",
- ((Boolean) value).booleanValue(),
- true);
+ assertEquals("Standard conversion failed (4)", ((Boolean) value).booleanValue(), true);
}
public void testDeregisteringSingleConverter() throws Exception {
// make sure that the test work ok before anything's changed
- final Object
- value = ConvertUtils.convert("true", Boolean.TYPE);
+ final Object value = ConvertUtils.convert("true", Boolean.TYPE);
assertTrue(value instanceof Boolean);
- assertEquals(
- "Standard conversion failed (1)",
- ((Boolean) value).booleanValue(),
- true);
+ assertEquals("Standard conversion failed (1)", ((Boolean) value).booleanValue(), true);
// we'll test deregister
ConvertUtils.deregister(Boolean.TYPE);
- assertNull("Converter should be null",ConvertUtils.lookup(Boolean.TYPE));
+ assertNull("Converter should be null", ConvertUtils.lookup(Boolean.TYPE));
}
@@ -637,22 +583,17 @@ public class ConvertUtilsTestCase extends TestCase {
public void testConvertUnsupportedTargetType() {
final ConvertUtilsBean utils = new ConvertUtilsBean();
final Object value = "A test value";
- assertSame("Got different object", value,
- utils.convert(value, getClass()));
+ assertSame("Got different object", value, utils.convert(value, getClass()));
}
-
-
private void checkIntegerArray(final Object value, final int[] intArray) {
assertNotNull("Returned value is not null", value);
- assertEquals("Returned value is int[]",
- intArray.getClass(), value.getClass());
+ assertEquals("Returned value is int[]", intArray.getClass(), value.getClass());
final int[] results = (int[]) value;
assertEquals("Returned array length", intArray.length, results.length);
for (int i = 0; i < intArray.length; i++) {
- assertEquals("Returned array value " + i,
- intArray[i], results[i]);
+ assertEquals("Returned array value " + i, intArray[i], results[i]);
}
}
@@ -660,17 +601,13 @@ public class ConvertUtilsTestCase extends TestCase {
private void checkStringArray(final Object value, final String[] stringArray) {
assertNotNull("Returned value is not null", value);
- assertEquals("Returned value is String[]",
- stringArray.getClass(), value.getClass());
+ assertEquals("Returned value is String[]", stringArray.getClass(), value.getClass());
final String[] results = (String[]) value;
- assertEquals("Returned array length",
- stringArray.length, results.length);
+ assertEquals("Returned array length", stringArray.length, results.length);
for (int i = 0; i < stringArray.length; i++) {
- assertEquals("Returned array value " + i,
- stringArray[i], results[i]);
+ assertEquals("Returned array value " + i, stringArray[i], results[i]);
}
}
}
-
diff --git a/src/test/java/org/apache/commons/beanutils2/DynaBeanMapDecoratorTestCase.java b/src/test/java/org/apache/commons/beanutils2/DynaBeanMapDecoratorTestCase.java
index 999c9f48..771d2708 100644
--- a/src/test/java/org/apache/commons/beanutils2/DynaBeanMapDecoratorTestCase.java
+++ b/src/test/java/org/apache/commons/beanutils2/DynaBeanMapDecoratorTestCase.java
@@ -31,35 +31,34 @@ import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
- * <p>Test Case for the {@code DynaBeanMapDecorator} implementation class.</p>
+ * <p>
+ * Test Case for the {@code DynaBeanMapDecorator} implementation class.
+ * </p>
*
*/
@SuppressWarnings("deprecation")
public class DynaBeanMapDecoratorTestCase extends TestCase {
private static final DynaProperty stringProp = new DynaProperty("stringProp", String.class);
- private static final DynaProperty nullProp = new DynaProperty("nullProp", String.class);
- private static final DynaProperty intProp = new DynaProperty("intProp", Integer.class);
- private static final DynaProperty dateProp = new DynaProperty("dateProp", Date.class);
- private static final DynaProperty mapProp = new DynaProperty("mapProp", Map.class);
- private static final DynaProperty[] properties = {
- stringProp, nullProp, intProp, dateProp, mapProp};
+ private static final DynaProperty nullProp = new DynaProperty("nullProp", String.class);
+ private static final DynaProperty intProp = new DynaProperty("intProp", Integer.class);
+ private static final DynaProperty dateProp = new DynaProperty("dateProp", Date.class);
+ private static final DynaProperty mapProp = new DynaProperty("mapProp", Map.class);
+ private static final DynaProperty[] properties = { stringProp, nullProp, intProp, dateProp, mapProp };
private static final DynaClass dynaClass = new BasicDynaClass("testDynaClass", BasicDynaBean.class, properties);
- private static final String stringVal = "somevalue";
- private static final Integer intVal = Integer.valueOf(5);
- private static final Date dateVal = new Date();
- private final Map<Object, Object> mapVal = new HashMap<>();
+ private static final String stringVal = "somevalue";
+ private static final Integer intVal = Integer.valueOf(5);
+ private static final Date dateVal = new Date();
+ private final Map<Object, Object> mapVal = new HashMap<>();
- private final Object[] values = {stringVal, null, intVal, dateVal, mapVal};
+ private final Object[] values = { stringVal, null, intVal, dateVal, mapVal };
private BasicDynaBean dynaBean;
private Map<String, Object> decoratedMap;
private Map<String, Object> modifiableMap;
private static final Map<String, Object> emptyMap = new DynaBeanPropertyMapDecorator(new BasicDynaBean(new BasicDynaClass()));
-
-
/**
* Constructs a new instance of this test case.
*
@@ -69,8 +68,6 @@ public class DynaBeanMapDecoratorTestCase extends TestCase {
super(name);
}
-
-
/**
* Run thus Test
*/
@@ -102,7 +99,7 @@ public class DynaBeanMapDecoratorTestCase extends TestCase {
}
// Create decorated Maps
- decoratedMap = new DynaBeanPropertyMapDecorator(dynaBean);
+ decoratedMap = new DynaBeanPropertyMapDecorator(dynaBean);
modifiableMap = new DynaBeanPropertyMapDecorator(dynaBean, false);
}
@@ -117,14 +114,12 @@ public class DynaBeanMapDecoratorTestCase extends TestCase {
modifiableMap = null;
}
-
-
/**
* Test isReadOnly() method
*/
public void testIsReadOnly() {
- assertTrue("decoratedMap true", ((DynaBeanPropertyMapDecorator)decoratedMap).isReadOnly());
- assertFalse("modifiableMap false", ((DynaBeanPropertyMapDecorator)modifiableMap).isReadOnly());
+ assertTrue("decoratedMap true", ((DynaBeanPropertyMapDecorator) decoratedMap).isReadOnly());
+ assertFalse("modifiableMap false", ((DynaBeanPropertyMapDecorator) modifiableMap).isReadOnly());
}
/**
@@ -134,13 +129,13 @@ public class DynaBeanMapDecoratorTestCase extends TestCase {
try {
decoratedMap.clear();
fail("decoratedMap.clear()");
- } catch(final UnsupportedOperationException ignore) {
+ } catch (final UnsupportedOperationException ignore) {
// expected result
}
try {
modifiableMap.clear();
fail("modifiableMap.clear()");
- } catch(final UnsupportedOperationException ignore) {
+ } catch (final UnsupportedOperationException ignore) {
// expected result
}
}
@@ -149,7 +144,7 @@ public class DynaBeanMapDecoratorTestCase extends TestCase {
* Test containsKey() method
*/
public void testContainsKey() {
- assertTrue("decoratedMap true", decoratedMap.containsKey(stringProp.getName()));
+ assertTrue("decoratedMap true", decoratedMap.containsKey(stringProp.getName()));
assertFalse("decoratedMap false", decoratedMap.containsKey("xyz"));
}
@@ -157,7 +152,7 @@ public class DynaBeanMapDecoratorTestCase extends TestCase {
* Test containsValue() method
*/
public void testContainsValue() {
- assertTrue("decoratedMap true", decoratedMap.containsValue(stringVal));
+ assertTrue("decoratedMap true", decoratedMap.containsValue(stringVal));
assertFalse("decoratedMap false", decoratedMap.containsValue("xyz"));
}
@@ -177,10 +172,10 @@ public class DynaBeanMapDecoratorTestCase extends TestCase {
final List<String> namesList = new ArrayList<>();
int i = 0;
for (final Entry<String, Object> entry : set) {
- final String name = entry.getKey();
+ final String name = entry.getKey();
namesList.add(name);
final Object expectValue = decoratedMap.get(name);
- assertEquals("entrySet("+i+") val", expectValue, entry.getValue());
+ assertEquals("entrySet(" + i + ") val", expectValue, entry.getValue());
i++;
}
for (int j = 0; j < properties.length; j++) {
@@ -201,7 +196,7 @@ public class DynaBeanMapDecoratorTestCase extends TestCase {
try {
decoratedMap.get("xyz");
fail("decoratedMap invalid");
- } catch(final IllegalArgumentException ignore) {
+ } catch (final IllegalArgumentException ignore) {
// expected result
}
}
@@ -210,7 +205,7 @@ public class DynaBeanMapDecoratorTestCase extends TestCase {
* Test isEmpty() method
*/
public void testIsEmpty() {
- assertTrue("Empty", emptyMap.isEmpty());
+ assertTrue("Empty", emptyMap.isEmpty());
assertFalse("Not Empty", decoratedMap.isEmpty());
}
@@ -242,7 +237,7 @@ public class DynaBeanMapDecoratorTestCase extends TestCase {
try {
decoratedMap.put(stringProp.getName(), newValue);
fail("Not read only");
- } catch(final UnsupportedOperationException ignore) {
+ } catch (final UnsupportedOperationException ignore) {
// expected result
}
@@ -265,14 +260,14 @@ public class DynaBeanMapDecoratorTestCase extends TestCase {
try {
decoratedMap.putAll(newMap);
fail("Not read only");
- } catch(final UnsupportedOperationException ignore) {
+ } catch (final UnsupportedOperationException ignore) {
// expected result
}
// Test Writable
assertEquals("before putAll", stringVal, dynaBean.get(stringProp.getName()));
modifiableMap.putAll(newMap);
- assertEquals("after putAll", newValue, dynaBean.get(stringProp.getName()));
+ assertEquals("after putAll", newValue, dynaBean.get(stringProp.getName()));
}
/**
@@ -282,13 +277,13 @@ public class DynaBeanMapDecoratorTestCase extends TestCase {
try {
decoratedMap.remove(stringProp.getName());
fail("decoratedMap.remove()");
- } catch(final UnsupportedOperationException ignore) {
+ } catch (final UnsupportedOperationException ignore) {
// expected result
}
try {
modifiableMap.remove(stringProp.getName());
fail("modifiableMap.remove()");
- } catch(final UnsupportedOperationException ignore) {
+ } catch (final UnsupportedOperationException ignore) {
// expected result
}
}
@@ -316,7 +311,7 @@ public class DynaBeanMapDecoratorTestCase extends TestCase {
final Iterator<Object> iterator = collection.iterator();
int i = 0;
while (iterator.hasNext()) {
- assertEquals("values("+i+")", values[i], iterator.next());
+ assertEquals("values(" + i + ")", values[i], iterator.next());
i++;
}
}
@@ -329,7 +324,7 @@ public class DynaBeanMapDecoratorTestCase extends TestCase {
try {
collection.add(addElem);
fail(desc + ".add()");
- } catch(final UnsupportedOperationException ignore) {
+ } catch (final UnsupportedOperationException ignore) {
// expected result
}
@@ -339,7 +334,7 @@ public class DynaBeanMapDecoratorTestCase extends TestCase {
try {
collection.addAll(list);
fail(desc + ".addAll()");
- } catch(final UnsupportedOperationException ignore) {
+ } catch (final UnsupportedOperationException ignore) {
// expected result
}
@@ -347,7 +342,7 @@ public class DynaBeanMapDecoratorTestCase extends TestCase {
try {
collection.clear();
fail(desc + ".clear()");
- } catch(final UnsupportedOperationException ignore) {
+ } catch (final UnsupportedOperationException ignore) {
// expected result
}
@@ -355,7 +350,7 @@ public class DynaBeanMapDecoratorTestCase extends TestCase {
try {
collection.remove("abc");
fail(desc + ".remove()");
- } catch(final UnsupportedOperationException ignore) {
+ } catch (final UnsupportedOperationException ignore) {
// expected result
}
@@ -363,7 +358,7 @@ public class DynaBeanMapDecoratorTestCase extends TestCase {
try {
collection.removeAll(list);
fail(desc + ".removeAll()");
- } catch(final UnsupportedOperationException ignore) {
+ } catch (final UnsupportedOperationException ignore) {
// expected result
}
@@ -371,7 +366,7 @@ public class DynaBeanMapDecoratorTestCase extends TestCase {
try {
collection.retainAll(list);
fail(desc + ".retainAll()");
- } catch(final UnsupportedOperationException ignore) {
+ } catch (final UnsupportedOperationException ignore) {
// expected result
}
}
diff --git a/src/test/java/org/apache/commons/beanutils2/DynaBeanUtilsTestCase.java b/src/test/java/org/apache/commons/beanutils2/DynaBeanUtilsTestCase.java
index d92d9c81..e0a913ee 100644
--- a/src/test/java/org/apache/commons/beanutils2/DynaBeanUtilsTestCase.java
+++ b/src/test/java/org/apache/commons/beanutils2/DynaBeanUtilsTestCase.java
@@ -34,8 +34,6 @@ import junit.framework.TestSuite;
public class DynaBeanUtilsTestCase extends TestCase {
-
-
/**
* The basic test bean for each test.
*/
@@ -49,31 +47,10 @@ public class DynaBeanUtilsTestCase extends TestCase {
/**
* The set of properties that should be described.
*/
- protected String[] describes =
- { "booleanProperty",
- "booleanSecond",
- "byteProperty",
- "doubleProperty",
- "dupProperty",
- "floatProperty",
- "intArray",
- "intIndexed",
- "intProperty",
- "listIndexed",
- "longProperty",
- "mapProperty",
- "mappedProperty",
- "mappedIntProperty",
- "nested",
- "nullProperty",
- // "readOnlyProperty",
- "shortProperty",
- "stringArray",
- "stringIndexed",
- "stringProperty"
- };
-
-
+ protected String[] describes = { "booleanProperty", "booleanSecond", "byteProperty", "doubleProperty", "dupProperty", "floatProperty", "intArray",
+ "intIndexed", "intProperty", "listIndexed", "longProperty", "mapProperty", "mappedProperty", "mappedIntProperty", "nested", "nullProperty",
+ // "readOnlyProperty",
+ "shortProperty", "stringArray", "stringIndexed", "stringProperty" };
/**
* Constructs a new instance of this test case.
@@ -86,8 +63,6 @@ public class DynaBeanUtilsTestCase extends TestCase {
}
-
-
/**
* Sets up instance variables required by this test case.
*/
@@ -106,7 +81,7 @@ public class DynaBeanUtilsTestCase extends TestCase {
bean.set("byteProperty", Byte.valueOf((byte) 121));
bean.set("doubleProperty", Double.valueOf(321.0));
bean.set("floatProperty", Float.valueOf((float) 123.0));
- final String[] dupProperty = { "Dup 0", "Dup 1", "Dup 2", "Dup 3", "Dup 4"};
+ final String[] dupProperty = { "Dup 0", "Dup 1", "Dup 2", "Dup 3", "Dup 4" };
bean.set("dupProperty", dupProperty);
final int[] intArray = { 0, 10, 20, 30, 40 };
bean.set("intArray", intArray);
@@ -137,11 +112,9 @@ public class DynaBeanUtilsTestCase extends TestCase {
bean.set("nested", nested);
// Property "nullProperty" is not initialized, so it should return null
bean.set("shortProperty", Short.valueOf((short) 987));
- final String[] stringArray =
- { "String 0", "String 1", "String 2", "String 3", "String 4" };
+ final String[] stringArray = { "String 0", "String 1", "String 2", "String 3", "String 4" };
bean.set("stringArray", stringArray);
- final String[] stringIndexed =
- { "String 0", "String 1", "String 2", "String 3", "String 4" };
+ final String[] stringIndexed = { "String 0", "String 1", "String 2", "String 3", "String 4" };
bean.set("stringIndexed", stringIndexed);
bean.set("stringProperty", "This is a string");
@@ -167,8 +140,6 @@ public class DynaBeanUtilsTestCase extends TestCase {
}
-
-
/**
* Test the cloneBean() method from a DynaBean.
*/
@@ -183,7 +154,7 @@ public class DynaBeanUtilsTestCase extends TestCase {
fail("newInstance(): " + e);
}
orig.set("booleanProperty", Boolean.FALSE);
- orig.set("byteProperty", Byte.valueOf((byte)111));
+ orig.set("byteProperty", Byte.valueOf((byte) 111));
orig.set("doubleProperty", Double.valueOf(333.33));
orig.set("dupProperty", new String[] { "New 0", "New 1", "New 2" });
orig.set("intArray", new int[] { 100, 200, 300 });
@@ -202,28 +173,13 @@ public class DynaBeanUtilsTestCase extends TestCase {
}
// Validate the results for scalar properties
- assertEquals("Cloned boolean property",
- false,
- ((Boolean) clonedBean.get("booleanProperty")).booleanValue());
- assertEquals("Cloned byte property",
- (byte) 111,
- ((Byte) clonedBean.get("byteProperty")).byteValue());
- assertEquals("Cloned double property",
- 333.33,
- ((Double) clonedBean.get("doubleProperty")).doubleValue(),
- 0.005);
- assertEquals("Cloned int property",
- 333,
- ((Integer) clonedBean.get("intProperty")).intValue());
- assertEquals("Cloned long property",
- 3333,
- ((Long) clonedBean.get("longProperty")).longValue());
- assertEquals("Cloned short property",
- (short) 33,
- ((Short) clonedBean.get("shortProperty")).shortValue());
- assertEquals("Cloned string property",
- "Custom string",
- (String) clonedBean.get("stringProperty"));
+ assertEquals("Cloned boolean property", false, ((Boolean) clonedBean.get("booleanProperty")).booleanValue());
+ assertEquals("Cloned byte property", (byte) 111, ((Byte) clonedBean.get("byteProperty")).byteValue());
+ assertEquals("Cloned double property", 333.33, ((Double) clonedBean.get("doubleProperty")).doubleValue(), 0.005);
+ assertEquals("Cloned int property", 333, ((Integer) clonedBean.get("intProperty")).intValue());
+ assertEquals("Cloned long property", 3333, ((Long) clonedBean.get("longProperty")).longValue());
+ assertEquals("Cloned short property", (short) 33, ((Short) clonedBean.get("shortProperty")).shortValue());
+ assertEquals("Cloned string property", "Custom string", (String) clonedBean.get("stringProperty"));
// Validate the results for array properties
final String[] dupProperty = (String[]) clonedBean.get("dupProperty");
@@ -260,7 +216,7 @@ public class DynaBeanUtilsTestCase extends TestCase {
fail("newInstance(): " + e);
}
orig.set("booleanProperty", Boolean.FALSE);
- orig.set("byteProperty", Byte.valueOf((byte)111));
+ orig.set("byteProperty", Byte.valueOf((byte) 111));
orig.set("doubleProperty", Double.valueOf(333.33));
orig.set("dupProperty", new String[] { "New 0", "New 1", "New 2" });
orig.set("intArray", new int[] { 100, 200, 300 });
@@ -278,28 +234,13 @@ public class DynaBeanUtilsTestCase extends TestCase {
}
// Validate the results for scalar properties
- assertEquals("Copied boolean property",
- false,
- ((Boolean) bean.get("booleanProperty")).booleanValue());
- assertEquals("Copied byte property",
- (byte) 111,
- ((Byte) bean.get("byteProperty")).byteValue());
- assertEquals("Copied double property",
- 333.33,
- ((Double) bean.get("doubleProperty")).doubleValue(),
- 0.005);
- assertEquals("Copied int property",
- 333,
- ((Integer) bean.get("intProperty")).intValue());
- assertEquals("Copied long property",
- 3333,
- ((Long) bean.get("longProperty")).longValue());
- assertEquals("Copied short property",
- (short) 33,
- ((Short) bean.get("shortProperty")).shortValue());
- assertEquals("Copied string property",
- "Custom string",
- (String) bean.get("stringProperty"));
+ assertEquals("Copied boolean property", false, ((Boolean) bean.get("booleanProperty")).booleanValue());
+ assertEquals("Copied byte property", (byte) 111, ((Byte) bean.get("byteProperty")).byteValue());
+ assertEquals("Copied double property", 333.33, ((Double) bean.get("doubleProperty")).doubleValue(), 0.005);
+ assertEquals("Copied int property", 333, ((Integer) bean.get("intProperty")).intValue());
+ assertEquals("Copied long property", 3333, ((Long) bean.get("longProperty")).longValue());
+ assertEquals("Copied short property", (short) 33, ((Short) bean.get("shortProperty")).shortValue());
+ assertEquals("Copied string property", "Custom string", (String) bean.get("stringProperty"));
// Validate the results for array properties
final String[] dupProperty = (String[]) bean.get("dupProperty");
@@ -346,24 +287,14 @@ public class DynaBeanUtilsTestCase extends TestCase {
}
// Scalar properties
- assertEquals("booleanProperty", false,
- ((Boolean) bean.get("booleanProperty")).booleanValue());
- assertEquals("byteProperty", (byte) 111,
- ((Byte) bean.get("byteProperty")).byteValue());
- assertEquals("doubleProperty", 333.0,
- ((Double) bean.get("doubleProperty")).doubleValue(),
- 0.005);
- assertEquals("floatProperty", (float) 222.0,
- ((Float) bean.get("floatProperty")).floatValue(),
- (float) 0.005);
- assertEquals("intProperty", 111,
- ((Integer) bean.get("intProperty")).intValue());
- assertEquals("longProperty", 444,
- ((Long) bean.get("longProperty")).longValue());
- assertEquals("shortProperty", (short) 555,
- ((Short) bean.get("shortProperty")).shortValue());
- assertEquals("stringProperty", "New String Property",
- (String) bean.get("stringProperty"));
+ assertEquals("booleanProperty", false, ((Boolean) bean.get("booleanProperty")).booleanValue());
+ assertEquals("byteProperty", (byte) 111, ((Byte) bean.get("byteProperty")).byteValue());
+ assertEquals("doubleProperty", 333.0, ((Double) bean.get("doubleProperty")).doubleValue(), 0.005);
+ assertEquals("floatProperty", (float) 222.0, ((Float) bean.get("floatProperty")).floatValue(), (float) 0.005);
+ assertEquals("intProperty", 111, ((Integer) bean.get("intProperty")).intValue());
+ assertEquals("longProperty", 444, ((Long) bean.get("longProperty")).longValue());
+ assertEquals("shortProperty", (short) 555, ((Short) bean.get("shortProperty")).shortValue());
+ assertEquals("stringProperty", "New String Property", (String) bean.get("stringProperty"));
// Indexed Properties
final String[] dupProperty = (String[]) bean.get("dupProperty");
@@ -407,28 +338,13 @@ public class DynaBeanUtilsTestCase extends TestCase {
}
// Validate the results for scalar properties
- assertEquals("Copied boolean property",
- false,
- ((Boolean) bean.get("booleanProperty")).booleanValue());
- assertEquals("Copied byte property",
- (byte) 111,
- ((Byte) bean.get("byteProperty")).byteValue());
- assertEquals("Copied double property",
- 333.33,
- ((Double) bean.get("doubleProperty")).doubleValue(),
- 0.005);
- assertEquals("Copied int property",
- 333,
- ((Integer) bean.get("intProperty")).intValue());
- assertEquals("Copied long property",
- 3333,
- ((Long) bean.get("longProperty")).longValue());
- assertEquals("Copied short property",
- (short) 33,
- ((Short) bean.get("shortProperty")).shortValue());
- assertEquals("Copied string property",
- "Custom string",
- (String) bean.get("stringProperty"));
+ assertEquals("Copied boolean property", false, ((Boolean) bean.get("booleanProperty")).booleanValue());
+ assertEquals("Copied byte property", (byte) 111, ((Byte) bean.get("byteProperty")).byteValue());
+ assertEquals("Copied double property", 333.33, ((Double) bean.get("doubleProperty")).doubleValue(), 0.005);
+ assertEquals("Copied int property", 333, ((Integer) bean.get("intProperty")).intValue());
+ assertEquals("Copied long property", 3333, ((Long) bean.get("longProperty")).longValue());
+ assertEquals("Copied short property", (short) 33, ((Short) bean.get("shortProperty")).shortValue());
+ assertEquals("Copied string property", "Custom string", (String) bean.get("stringProperty"));
// Validate the results for array properties
final String[] dupProperty = (String[]) bean.get("dupProperty");
@@ -465,37 +381,19 @@ public class DynaBeanUtilsTestCase extends TestCase {
// Verify existence of all the properties that should be present
for (final String describe : describes) {
- assertTrue("Property '" + describe + "' is present",
- map.containsKey(describe));
+ assertTrue("Property '" + describe + "' is present", map.containsKey(describe));
}
- assertTrue("Property 'writeOnlyProperty' is not present",
- !map.containsKey("writeOnlyProperty"));
+ assertTrue("Property 'writeOnlyProperty' is not present", !map.containsKey("writeOnlyProperty"));
// Verify the values of scalar properties
- assertEquals("Value of 'booleanProperty'",
- Boolean.TRUE,
- map.get("booleanProperty"));
- assertEquals("Value of 'byteProperty'",
- Byte.valueOf((byte) 121),
- map.get("byteProperty"));
- assertEquals("Value of 'doubleProperty'",
- Double.valueOf(321.0),
- map.get("doubleProperty"));
- assertEquals("Value of 'floatProperty'",
- Float.valueOf((float) 123.0),
- map.get("floatProperty"));
- assertEquals("Value of 'intProperty'",
- Integer.valueOf(123),
- map.get("intProperty"));
- assertEquals("Value of 'longProperty'",
- Long.valueOf(321),
- map.get("longProperty"));
- assertEquals("Value of 'shortProperty'",
- Short.valueOf((short) 987),
- map.get("shortProperty"));
- assertEquals("Value of 'stringProperty'",
- "This is a string",
- (String) map.get("stringProperty"));
+ assertEquals("Value of 'booleanProperty'", Boolean.TRUE, map.get("booleanProperty"));
+ assertEquals("Value of 'byteProperty'", Byte.valueOf((byte) 121), map.get("byteProperty"));
+ assertEquals("Value of 'doubleProperty'", Double.valueOf(321.0), map.get("doubleProperty"));
+ assertEquals("Value of 'floatProperty'", Float.valueOf((float) 123.0), map.get("floatProperty"));
+ assertEquals("Value of 'intProperty'", Integer.valueOf(123), map.get("intProperty"));
+ assertEquals("Value of 'longProperty'", Long.valueOf(321), map.get("longProperty"));
+ assertEquals("Value of 'shortProperty'", Short.valueOf((short) 987), map.get("shortProperty"));
+ assertEquals("Value of 'stringProperty'", "This is a string", (String) map.get("stringProperty"));
}
@@ -507,7 +405,7 @@ public class DynaBeanUtilsTestCase extends TestCase {
try {
final HashMap<String, Object> map = new HashMap<>();
- // int intArray[] = new int[] { 123, 456, 789 };
+ // int intArray[] = new int[] { 123, 456, 789 };
final String[] intArrayIn = { "123", "456", "789" };
map.put("intArray", intArrayIn);
String[] stringArray = { "New String 0", "New String 1" };
@@ -517,8 +415,7 @@ public class DynaBeanUtilsTestCase extends TestCase {
final int[] intArray = (int[]) bean.get("intArray");
assertNotNull("intArray is present", intArray);
- assertEquals("intArray length",
- 3, intArray.length);
+ assertEquals("intArray length", 3, intArray.length);
assertEquals("intArray[0]", 123, intArray[0]);
assertEquals("intArray[1]", 456, intArray[1]);
assertEquals("intArray[2]", 789, intArray[2]);
@@ -537,21 +434,19 @@ public class DynaBeanUtilsTestCase extends TestCase {
}
/**
- * tests the string and int arrays of TestBean
+ * tests the string and int arrays of TestBean
*/
public void testGetArrayProperty() {
try {
String[] arr = BeanUtils.getArrayProperty(bean, "stringArray");
final String[] comp = (String[]) bean.get("stringArray");
- assertTrue("String array length = " + comp.length,
- comp.length == arr.length);
+ assertTrue("String array length = " + comp.length, comp.length == arr.length);
arr = BeanUtils.getArrayProperty(bean, "intArray");
final int[] iarr = (int[]) bean.get("intArray");
- assertTrue("String array length = " + iarr.length,
- iarr.length == arr.length);
+ assertTrue("String array length = " + iarr.length, iarr.length == arr.length);
} catch (final IllegalAccessException e) {
fail("IllegalAccessException");
} catch (final InvocationTargetException e) {
@@ -563,7 +458,7 @@ public class DynaBeanUtilsTestCase extends TestCase {
}
/**
- * tests getting an indexed property
+ * tests getting an indexed property
*/
public void testGetIndexedProperty1() {
try {
@@ -584,7 +479,7 @@ public class DynaBeanUtilsTestCase extends TestCase {
}
/**
- * tests getting an indexed property
+ * tests getting an indexed property
*/
public void testGetIndexedProperty2() {
try {
@@ -608,14 +503,13 @@ public class DynaBeanUtilsTestCase extends TestCase {
}
/**
- * tests getting a nested property
+ * tests getting a nested property
*/
public void testGetNestedProperty() {
try {
final String val = BeanUtils.getNestedProperty(bean, "nested.stringProperty");
final String comp = nested.getStringProperty();
- assertTrue("nested.StringProperty == " + comp,
- val.equals(comp));
+ assertTrue("nested.StringProperty == " + comp, val.equals(comp));
} catch (final IllegalAccessException e) {
fail("IllegalAccessException");
} catch (final InvocationTargetException e) {
@@ -626,15 +520,14 @@ public class DynaBeanUtilsTestCase extends TestCase {
}
/**
- * tests getting a 'whatever' property
+ * tests getting a 'whatever' property
*/
public void testGetGeneralProperty() {
try {
final String val = BeanUtils.getProperty(bean, "nested.intIndexed[2]");
final String comp = String.valueOf(bean.get("intIndexed", 2));
- assertTrue("nested.intIndexed[2] == " + comp,
- val.equals(comp));
+ assertTrue("nested.intIndexed[2] == " + comp, val.equals(comp));
} catch (final IllegalAccessException e) {
fail("IllegalAccessException");
} catch (final InvocationTargetException e) {
@@ -645,15 +538,14 @@ public class DynaBeanUtilsTestCase extends TestCase {
}
/**
- * tests getting a 'whatever' property
+ * tests getting a 'whatever' property
*/
public void testGetSimpleProperty() {
try {
final String val = BeanUtils.getSimpleProperty(bean, "shortProperty");
final String comp = String.valueOf(bean.get("shortProperty"));
- assertTrue("shortProperty == " + comp,
- val.equals(comp));
+ assertTrue("shortProperty == " + comp, val.equals(comp));
} catch (final IllegalAccessException e) {
fail("IllegalAccessException");
} catch (final InvocationTargetException e) {
@@ -677,20 +569,15 @@ public class DynaBeanUtilsTestCase extends TestCase {
BeanUtils.populate(bean, map);
final Integer intIndexed0 = (Integer) bean.get("intIndexed", 0);
- assertEquals("intIndexed[0] is 100",
- 100, intIndexed0.intValue());
+ assertEquals("intIndexed[0] is 100", 100, intIndexed0.intValue());
final Integer intIndexed1 = (Integer) bean.get("intIndexed", 1);
- assertEquals("intIndexed[1] is 10",
- 10, intIndexed1.intValue());
+ assertEquals("intIndexed[1] is 10", 10, intIndexed1.intValue());
final Integer intIndexed2 = (Integer) bean.get("intIndexed", 2);
- assertEquals("intIndexed[2] is 120",
- 120, intIndexed2.intValue());
+ assertEquals("intIndexed[2] is 120", 120, intIndexed2.intValue());
final Integer intIndexed3 = (Integer) bean.get("intIndexed", 3);
- assertEquals("intIndexed[3] is 30",
- 30, intIndexed3.intValue());
+ assertEquals("intIndexed[3] is 30", 30, intIndexed3.intValue());
final Integer intIndexed4 = (Integer) bean.get("intIndexed", 4);
- assertEquals("intIndexed[4] is 140",
- 140, intIndexed4.intValue());
+ assertEquals("intIndexed[4] is 140", 140, intIndexed4.intValue());
map.clear();
map.put("stringIndexed[1]", "New String 1");
@@ -698,21 +585,11 @@ public class DynaBeanUtilsTestCase extends TestCase {
BeanUtils.populate(bean, map);
- assertEquals("stringIndexed[0] is \"String 0\"",
- "String 0",
- (String) bean.get("stringIndexed", 0));
- assertEquals("stringIndexed[1] is \"New String 1\"",
- "New String 1",
- (String) bean.get("stringIndexed", 1));
- assertEquals("stringIndexed[2] is \"String 2\"",
- "String 2",
- (String) bean.get("stringIndexed", 2));
- assertEquals("stringIndexed[3] is \"New String 3\"",
- "New String 3",
- (String) bean.get("stringIndexed", 3));
- assertEquals("stringIndexed[4] is \"String 4\"",
- "String 4",
- (String) bean.get("stringIndexed", 4));
+ assertEquals("stringIndexed[0] is \"String 0\"", "String 0", (String) bean.get("stringIndexed", 0));
+ assertEquals("stringIndexed[1] is \"New String 1\"", "New String 1", (String) bean.get("stringIndexed", 1));
+ assertEquals("stringIndexed[2] is \"String 2\"", "String 2", (String) bean.get("stringIndexed", 2));
+ assertEquals("stringIndexed[3] is \"New String 3\"", "New String 3", (String) bean.get("stringIndexed", 3));
+ assertEquals("stringIndexed[4] is \"String 4\"", "String 4", (String) bean.get("stringIndexed", 4));
} catch (final IllegalAccessException e) {
fail("IllegalAccessException");
@@ -735,17 +612,10 @@ public class DynaBeanUtilsTestCase extends TestCase {
BeanUtils.populate(bean, map);
- assertEquals("mappedProperty(First Key)",
- "New First Value",
- (String) bean.get("mappedProperty", "First Key"));
- assertEquals("mappedProperty(Second Key)",
- "Second Value",
- (String) bean.get("mappedProperty", "Second Key"));
- assertEquals("mappedProperty(Third Key)",
- "New Third Value",
- (String) bean.get("mappedProperty", "Third Key"));
- assertNull("mappedProperty(Fourth Key",
- bean.get("mappedProperty", "Fourth Key"));
+ assertEquals("mappedProperty(First Key)", "New First Value", (String) bean.get("mappedProperty", "First Key"));
+ assertEquals("mappedProperty(Second Key)", "Second Value", (String) bean.get("mappedProperty", "Second Key"));
+ assertEquals("mappedProperty(Third Key)", "New Third Value", (String) bean.get("mappedProperty", "Third Key"));
+ assertNull("mappedProperty(Fourth Key", bean.get("mappedProperty", "Fourth Key"));
} catch (final IllegalAccessException e) {
fail("IllegalAccessException");
@@ -775,27 +645,14 @@ public class DynaBeanUtilsTestCase extends TestCase {
BeanUtils.populate(bean, map);
final TestBean nested = (TestBean) bean.get("nested");
- assertTrue("booleanProperty is false",
- !nested.getBooleanProperty());
- assertTrue("booleanSecond is true",
- nested.isBooleanSecond());
- assertEquals("doubleProperty is 432.0",
- 432.0,
- nested.getDoubleProperty(),
- 0.005);
- assertEquals("floatProperty is 123.0",
- (float) 123.0,
- nested.getFloatProperty(),
- (float) 0.005);
- assertEquals("intProperty is 543",
- 543, nested.getIntProperty());
- assertEquals("longProperty is 321",
- 321, nested.getLongProperty());
- assertEquals("shortProperty is 654",
- (short) 654, nested.getShortProperty());
- assertEquals("stringProperty is \"This is a string\"",
- "This is a string",
- nested.getStringProperty());
+ assertTrue("booleanProperty is false", !nested.getBooleanProperty());
+ assertTrue("booleanSecond is true", nested.isBooleanSecond());
+ assertEquals("doubleProperty is 432.0", 432.0, nested.getDoubleProperty(), 0.005);
+ assertEquals("floatProperty is 123.0", (float) 123.0, nested.getFloatProperty(), (float) 0.005);
+ assertEquals("intProperty is 543", 543, nested.getIntProperty());
+ assertEquals("longProperty is 321", 321, nested.getLongProperty());
+ assertEquals("shortProperty is 654", (short) 654, nested.getShortProperty());
+ assertEquals("stringProperty is \"This is a string\"", "This is a string", nested.getStringProperty());
} catch (final IllegalAccessException e) {
fail("IllegalAccessException");
@@ -832,25 +689,17 @@ public class DynaBeanUtilsTestCase extends TestCase {
final Boolean booleanSecond = (Boolean) bean.get("booleanSecond");
assertTrue("booleanSecond is true", booleanSecond.booleanValue());
final Double doubleProperty = (Double) bean.get("doubleProperty");
- assertEquals("doubleProperty is 432.0",
- 432.0, doubleProperty.doubleValue(), 0.005);
+ assertEquals("doubleProperty is 432.0", 432.0, doubleProperty.doubleValue(), 0.005);
final Float floatProperty = (Float) bean.get("floatProperty");
- assertEquals("floatProperty is 123.0",
- (float) 123.0, floatProperty.floatValue(),
- (float) 0.005);
+ assertEquals("floatProperty is 123.0", (float) 123.0, floatProperty.floatValue(), (float) 0.005);
final Integer intProperty = (Integer) bean.get("intProperty");
- assertEquals("intProperty is 543",
- 543, intProperty.intValue());
+ assertEquals("intProperty is 543", 543, intProperty.intValue());
final Long longProperty = (Long) bean.get("longProperty");
- assertEquals("longProperty is 321",
- 321, longProperty.longValue());
+ assertEquals("longProperty is 321", 321, longProperty.longValue());
assertNull("nullProperty is null", bean.get("nullProperty"));
final Short shortProperty = (Short) bean.get("shortProperty");
- assertEquals("shortProperty is 654",
- (short) 654, shortProperty.shortValue());
- assertEquals("stringProperty is \"This is a string\"",
- "This is a string",
- (String) bean.get("stringProperty"));
+ assertEquals("shortProperty is 654", (short) 654, shortProperty.shortValue());
+ assertEquals("stringProperty is \"This is a string\"", "This is a string", (String) bean.get("stringProperty"));
} catch (final IllegalAccessException e) {
fail("IllegalAccessException");
@@ -873,10 +722,8 @@ public class DynaBeanUtilsTestCase extends TestCase {
BeanUtils.setProperty(bean, "stringArray", null);
newValue = PropertyUtils.getSimpleProperty(bean, "stringArray");
assertNotNull("stringArray is not null", newValue);
- assertTrue("stringArray of correct type",
- newValue instanceof String[]);
- assertEquals("stringArray length",
- 1, ((String[]) newValue).length);
+ assertTrue("stringArray of correct type", newValue instanceof String[]);
+ assertEquals("stringArray length", 1, ((String[]) newValue).length);
PropertyUtils.setProperty(bean, "stringArray", oldValue);
// Indexed value into array
@@ -884,18 +731,14 @@ public class DynaBeanUtilsTestCase extends TestCase {
BeanUtils.setProperty(bean, "stringArray[2]", null);
newValue = PropertyUtils.getSimpleProperty(bean, "stringArray");
assertNotNull("stringArray is not null", newValue);
- assertTrue("stringArray of correct type",
- newValue instanceof String[]);
- assertEquals("stringArray length",
- 5, ((String[]) newValue).length);
- assertTrue("stringArray[2] is null",
- ((String[]) newValue)[2] == null);
+ assertTrue("stringArray of correct type", newValue instanceof String[]);
+ assertEquals("stringArray length", 5, ((String[]) newValue).length);
+ assertTrue("stringArray[2] is null", ((String[]) newValue)[2] == null);
PropertyUtils.setProperty(bean, "stringArray", oldValue);
// Value into scalar
BeanUtils.setProperty(bean, "stringProperty", null);
- assertTrue("stringProperty is now null",
- BeanUtils.getProperty(bean, "stringProperty") == null);
+ assertTrue("stringProperty is now null", BeanUtils.getProperty(bean, "stringProperty") == null);
}
@@ -904,9 +747,9 @@ public class DynaBeanUtilsTestCase extends TestCase {
*/
public void testSetPropertyOnPrimitiveWrappers() throws Exception {
- BeanUtils.setProperty(bean,"intProperty", Integer.valueOf(1));
- assertEquals(1,((Integer) bean.get("intProperty")).intValue());
- BeanUtils.setProperty(bean,"stringProperty", Integer.valueOf(1));
+ BeanUtils.setProperty(bean, "intProperty", Integer.valueOf(1));
+ assertEquals(1, ((Integer) bean.get("intProperty")).intValue());
+ BeanUtils.setProperty(bean, "stringProperty", Integer.valueOf(1));
assertEquals(1, Integer.parseInt((String) bean.get("stringProperty")));
}
@@ -929,12 +772,10 @@ public class DynaBeanUtilsTestCase extends TestCase {
BeanUtils.setProperty(bean, "byteProperty", Byte.valueOf((byte) 123));
assertEquals((byte) 123, ((Byte) bean.get("byteProperty")).byteValue());
-/*
- BeanUtils.setProperty(bean, "byteProperty", new Double((double) 123));
- assertEquals((byte) 123, ((Byte) bean.get("byteProperty")).byteValue());
- BeanUtils.setProperty(bean, "byteProperty", new Float((float) 123));
- assertEquals((byte) 123, ((Byte) bean.get("byteProperty")).byteValue());
-*/
+ /*
+ * BeanUtils.setProperty(bean, "byteProperty", new Double((double) 123)); assertEquals((byte) 123, ((Byte) bean.get("byteProperty")).byteValue());
+ * BeanUtils.setProperty(bean, "byteProperty", new Float((float) 123)); assertEquals((byte) 123, ((Byte) bean.get("byteProperty")).byteValue());
+ */
BeanUtils.setProperty(bean, "byteProperty", Integer.valueOf(123));
assertEquals((byte) 123, ((Byte) bean.get("byteProperty")).byteValue());
BeanUtils.setProperty(bean, "byteProperty", Long.valueOf(123));
@@ -991,12 +832,10 @@ public class DynaBeanUtilsTestCase extends TestCase {
BeanUtils.setProperty(bean, "longProperty", Byte.valueOf((byte) 123));
assertEquals(123, ((Integer) bean.get("intProperty")).intValue());
-/*
- BeanUtils.setProperty(bean, "longProperty", new Double((double) 123));
- assertEquals((int) 123, ((Integer) bean.get("intProperty")).intValue());
- BeanUtils.setProperty(bean, "longProperty", new Float((float) 123));
- assertEquals((int) 123, ((Integer) bean.get("intProperty")).intValue());
-*/
+ /*
+ * BeanUtils.setProperty(bean, "longProperty", new Double((double) 123)); assertEquals((int) 123, ((Integer) bean.get("intProperty")).intValue());
+ * BeanUtils.setProperty(bean, "longProperty", new Float((float) 123)); assertEquals((int) 123, ((Integer) bean.get("intProperty")).intValue());
+ */
BeanUtils.setProperty(bean, "longProperty", Integer.valueOf(123));
assertEquals(123, ((Integer) bean.get("intProperty")).intValue());
BeanUtils.setProperty(bean, "longProperty", Long.valueOf(123));
@@ -1013,12 +852,10 @@ public class DynaBeanUtilsTestCase extends TestCase {
BeanUtils.setProperty(bean, "longProperty", Byte.valueOf((byte) 123));
assertEquals(123, ((Long) bean.get("longProperty")).longValue());
-/*
- BeanUtils.setProperty(bean, "longProperty", new Double((double) 123));
- assertEquals((long) 123, ((Long) bean.get("longProperty")).longValue());
- BeanUtils.setProperty(bean, "longProperty", new Float((float) 123));
- assertEquals((long) 123, ((Long) bean.get("longProperty")).longValue());
-*/
+ /*
+ * BeanUtils.setProperty(bean, "longProperty", new Double((double) 123)); assertEquals((long) 123, ((Long) bean.get("longProperty")).longValue());
+ * BeanUtils.setProperty(bean, "longProperty", new Float((float) 123)); assertEquals((long) 123, ((Long) bean.get("longProperty")).longValue());
+ */
BeanUtils.setProperty(bean, "longProperty", Integer.valueOf(123));
assertEquals(123, ((Long) bean.get("longProperty")).longValue());
BeanUtils.setProperty(bean, "longProperty", Long.valueOf(123));
@@ -1046,12 +883,10 @@ public class DynaBeanUtilsTestCase extends TestCase {
BeanUtils.setProperty(bean, "shortProperty", Byte.valueOf((byte) 123));
assertEquals((short) 123, ((Short) bean.get("shortProperty")).shortValue());
-/*
- BeanUtils.setProperty(bean, "shortProperty", new Double((double) 123));
- assertEquals((short) 123, ((Short) bean.get("shortProperty")).shortValue());
- BeanUtils.setProperty(bean, "shortProperty", new Float((float) 123));
- assertEquals((short) 123, ((Short) bean.get("shortProperty")).shortValue());
-*/
+ /*
+ * BeanUtils.setProperty(bean, "shortProperty", new Double((double) 123)); assertEquals((short) 123, ((Short) bean.get("shortProperty")).shortValue());
+ * BeanUtils.setProperty(bean, "shortProperty", new Float((float) 123)); assertEquals((short) 123, ((Short) bean.get("shortProperty")).shortValue());
+ */
BeanUtils.setProperty(bean, "shortProperty", Integer.valueOf(123));
assertEquals((short) 123, ((Short) bean.get("shortProperty")).shortValue());
BeanUtils.setProperty(bean, "shortProperty", Long.valueOf(123));
@@ -1062,12 +897,11 @@ public class DynaBeanUtilsTestCase extends TestCase {
}
/**
- * Test copying a property using a nested indexed array expression,
- * with and without conversions.
+ * Test copying a property using a nested indexed array expression, with and without conversions.
*/
public void testCopyPropertyNestedIndexedArray() throws Exception {
- final int[] origArray = { 0, 10, 20, 30, 40};
+ final int[] origArray = { 0, 10, 20, 30, 40 };
final int[] intArray = { 0, 0, 0 };
((TestBean) bean.get("nested")).setIntArray(intArray);
final int[] intChanged = { 0, 0, 0 };
@@ -1076,29 +910,25 @@ public class DynaBeanUtilsTestCase extends TestCase {
BeanUtils.copyProperty(bean, "nested.intArray[1]", Integer.valueOf(1));
checkIntArray((int[]) bean.get("intArray"), origArray);
intChanged[1] = 1;
- checkIntArray(((TestBean) bean.get("nested")).getIntArray(),
- intChanged);
+ checkIntArray(((TestBean) bean.get("nested")).getIntArray(), intChanged);
// Widening conversion required
BeanUtils.copyProperty(bean, "nested.intArray[1]", Byte.valueOf((byte) 2));
checkIntArray((int[]) bean.get("intArray"), origArray);
intChanged[1] = 2;
- checkIntArray(((TestBean) bean.get("nested")).getIntArray(),
- intChanged);
+ checkIntArray(((TestBean) bean.get("nested")).getIntArray(), intChanged);
// Narrowing conversion required
BeanUtils.copyProperty(bean, "nested.intArray[1]", Long.valueOf(3));
checkIntArray((int[]) bean.get("intArray"), origArray);
intChanged[1] = 3;
- checkIntArray(((TestBean) bean.get("nested")).getIntArray(),
- intChanged);
+ checkIntArray(((TestBean) bean.get("nested")).getIntArray(), intChanged);
// String conversion required
BeanUtils.copyProperty(bean, "nested.intArray[1]", "4");
checkIntArray((int[]) bean.get("intArray"), origArray);
intChanged[1] = 4;
- checkIntArray(((TestBean) bean.get("nested")).getIntArray(),
- intChanged);
+ checkIntArray(((TestBean) bean.get("nested")).getIntArray(), intChanged);
}
@@ -1115,8 +945,7 @@ public class DynaBeanUtilsTestCase extends TestCase {
changedMap.put("Second Key", "Second Value");
// No conversion required
- BeanUtils.copyProperty(bean, "nested.mapProperty(Second Key)",
- "New Second Value");
+ BeanUtils.copyProperty(bean, "nested.mapProperty(Second Key)", "New Second Value");
checkMap((Map<?, ?>) bean.get("mapProperty"), origMap);
changedMap.put("Second Key", "New Second Value");
checkMap(((TestBean) bean.get("nested")).getMapProperty(), changedMap);
@@ -1124,8 +953,7 @@ public class DynaBeanUtilsTestCase extends TestCase {
}
/**
- * Test copying a property using a nested simple expression, with and
- * without conversions.
+ * Test copying a property using a nested simple expression, with and without conversions.
*/
public void testCopyPropertyNestedSimple() throws Exception {
@@ -1154,15 +982,12 @@ public class DynaBeanUtilsTestCase extends TestCase {
}
-
-
// Ensure that the nested intArray matches the specified values
protected void checkIntArray(final int[] actual, final int[] expected) {
assertNotNull("actual array not null", actual);
assertEquals("actual array length", expected.length, actual.length);
for (int i = 0; i < actual.length; i++) {
- assertEquals("actual array value[" + i + "]",
- expected[i], actual[i]);
+ assertEquals("actual array value[" + i + "]", expected[i], actual[i]);
}
}
@@ -1171,44 +996,27 @@ public class DynaBeanUtilsTestCase extends TestCase {
assertNotNull("actual map not null", actual);
assertEquals("actual map size", expected.size(), actual.size());
for (final Object key : expected.keySet()) {
- assertEquals("actual map value(" + key + ")",
- expected.get(key), actual.get(key));
+ assertEquals("actual map value(" + key + ")", expected.get(key), actual.get(key));
}
}
/**
- * Create and return a {@code DynaClass} instance for our test
- * {@code DynaBean}.
+ * Create and return a {@code DynaClass} instance for our test {@code DynaBean}.
*/
protected static DynaClass createDynaClass() {
final int[] intArray = {};
final String[] stringArray = {};
- final DynaClass dynaClass = new BasicDynaClass
- ("TestDynaClass", null,
- new DynaProperty[]{
- new DynaProperty("booleanProperty", Boolean.TYPE),
- new DynaProperty("booleanSecond", Boolean.TYPE),
- new DynaProperty("byteProperty", Byte.TYPE),
- new DynaProperty("doubleProperty", Double.TYPE),
- new DynaProperty("dupProperty", stringArray.getClass()),
- new DynaProperty("floatProperty", Float.TYPE),
- new DynaProperty("intArray", intArray.getClass()),
- new DynaProperty("intIndexed", intArray.getClass()),
- new DynaProperty("intProperty", Integer.TYPE),
- new DynaProperty("listIndexed", List.class),
- new DynaProperty("longProperty", Long.TYPE),
- new DynaProperty("mapProperty", Map.class),
- new DynaProperty("mappedProperty", Map.class),
- new DynaProperty("mappedIntProperty", Map.class),
- new DynaProperty("nested", TestBean.class),
- new DynaProperty("nullProperty", String.class),
- new DynaProperty("shortProperty", Short.TYPE),
- new DynaProperty("stringArray", stringArray.getClass()),
- new DynaProperty("stringIndexed", stringArray.getClass()),
- new DynaProperty("stringProperty", String.class),
- });
+ final DynaClass dynaClass = new BasicDynaClass("TestDynaClass", null, new DynaProperty[] { new DynaProperty("booleanProperty", Boolean.TYPE),
+ new DynaProperty("booleanSecond", Boolean.TYPE), new DynaProperty("byteProperty", Byte.TYPE), new DynaProperty("doubleProperty", Double.TYPE),
+ new DynaProperty("dupProperty", stringArray.getClass()), new DynaProperty("floatProperty", Float.TYPE),
+ new DynaProperty("intArray", intArray.getClass()), new DynaProperty("intIndexed", intArray.getClass()),
+ new DynaProperty("intProperty", Integer.TYPE), new DynaProperty("listIndexed", List.class), new DynaProperty("longProperty", Long.TYPE),
+ new DynaProperty("mapProperty", Map.class), new DynaProperty("mappedProperty", Map.class), new DynaProperty("mappedIntProperty", Map.class),
+ new DynaProperty("nested", TestBean.class), new DynaProperty("nullProperty", String.class), new DynaProperty("shortProperty", Short.TYPE),
+ new DynaProperty("stringArray", stringArray.getClass()), new DynaProperty("stringIndexed", stringArray.getClass()),
+ new DynaProperty("stringProperty", String.class), });
return dynaClass;
}
diff --git a/src/test/java/org/apache/commons/beanutils2/DynaPropertyTestCase.java b/src/test/java/org/apache/commons/beanutils2/DynaPropertyTestCase.java
index 571bb68e..90223245 100644
--- a/src/test/java/org/apache/commons/beanutils2/DynaPropertyTestCase.java
+++ b/src/test/java/org/apache/commons/beanutils2/DynaPropertyTestCase.java
@@ -46,6 +46,7 @@ public class DynaPropertyTestCase extends TestCase {
/**
* Creates the tests included in this test suite.
+ *
* @return a test suite
*/
public static Test suite() {
diff --git a/src/test/java/org/apache/commons/beanutils2/DynaPropertyUtilsTestCase.java b/src/test/java/org/apache/commons/beanutils2/DynaPropertyUtilsTestCase.java
index 8db009a3..92cb9db5 100644
--- a/src/test/java/org/apache/commons/beanutils2/DynaPropertyUtilsTestCase.java
+++ b/src/test/java/org/apache/commons/beanutils2/DynaPropertyUtilsTestCase.java
@@ -34,8 +34,6 @@ import junit.framework.TestSuite;
public class DynaPropertyUtilsTestCase extends TestCase {
-
-
/**
* The basic test bean for each test.
*/
@@ -44,35 +42,16 @@ public class DynaPropertyUtilsTestCase extends TestCase {
/**
* The set of properties that should be described.
*/
- protected String[] describes =
- { "booleanProperty",
- "booleanSecond",
- "doubleProperty",
- "floatProperty",
- "intArray",
- "intIndexed",
- "intProperty",
- "listIndexed",
- "longProperty",
- "mappedObjects",
- "mappedProperty",
- "mappedIntProperty",
- "nested",
- "nullProperty",
- // "readOnlyProperty",
- "shortProperty",
- "stringArray",
- "stringIndexed",
- "stringProperty"
- };
+ protected String[] describes = { "booleanProperty", "booleanSecond", "doubleProperty", "floatProperty", "intArray", "intIndexed", "intProperty",
+ "listIndexed", "longProperty", "mappedObjects", "mappedProperty", "mappedIntProperty", "nested", "nullProperty",
+ // "readOnlyProperty",
+ "shortProperty", "stringArray", "stringIndexed", "stringProperty" };
/**
* The nested bean pointed at by the "nested" property.
*/
protected TestBean nested = null;
-
-
/**
* Constructs a new instance of this test case.
*
@@ -84,8 +63,6 @@ public class DynaPropertyUtilsTestCase extends TestCase {
}
-
-
/**
* Sets up instance variables required by this test case.
*/
@@ -134,11 +111,9 @@ public class DynaPropertyUtilsTestCase extends TestCase {
bean.set("nested", nested);
// Property "nullProperty" is not initialized, so it should return null
bean.set("shortProperty", Short.valueOf((short) 987));
- final String[] stringArray =
- { "String 0", "String 1", "String 2", "String 3", "String 4" };
+ final String[] stringArray = { "String 0", "String 1", "String 2", "String 3", "String 4" };
bean.set("stringArray", stringArray);
- final String[] stringIndexed =
- { "String 0", "String 1", "String 2", "String 3", "String 4" };
+ final String[] stringIndexed = { "String 0", "String 1", "String 2", "String 3", "String 4" };
bean.set("stringIndexed", stringIndexed);
bean.set("stringProperty", "This is a string");
@@ -164,8 +139,6 @@ public class DynaPropertyUtilsTestCase extends TestCase {
}
-
-
/**
* Test copyProperties() when the origin is a {@code Map}.
*/
@@ -189,22 +162,13 @@ public class DynaPropertyUtilsTestCase extends TestCase {
}
// Scalar properties
- assertEquals("booleanProperty", false,
- ((Boolean) bean.get("booleanProperty")).booleanValue());
- assertEquals("doubleProperty", 333.0,
- ((Double) bean.get("doubleProperty")).doubleValue(),
- 0.005);
- assertEquals("floatProperty", (float) 222.0,
- ((Float) bean.get("floatProperty")).floatValue(),
- (float) 0.005);
- assertEquals("intProperty", 111,
- ((Integer) bean.get("intProperty")).intValue());
- assertEquals("longProperty", 444,
- ((Long) bean.get("longProperty")).longValue());
- assertEquals("shortProperty", (short) 555,
- ((Short) bean.get("shortProperty")).shortValue());
- assertEquals("stringProperty", "New String Property",
- (String) bean.get("stringProperty"));
+ assertEquals("booleanProperty", false, ((Boolean) bean.get("booleanProperty")).booleanValue());
+ assertEquals("doubleProperty", 333.0, ((Double) bean.get("doubleProperty")).doubleValue(), 0.005);
+ assertEquals("floatProperty", (float) 222.0, ((Float) bean.get("floatProperty")).floatValue(), (float) 0.005);
+ assertEquals("intProperty", 111, ((Integer) bean.get("intProperty")).intValue());
+ assertEquals("longProperty", 444, ((Long) bean.get("longProperty")).longValue());
+ assertEquals("shortProperty", (short) 555, ((Short) bean.get("shortProperty")).shortValue());
+ assertEquals("stringProperty", "New String Property", (String) bean.get("stringProperty"));
// Indexed Properties
final String[] dupProperty = (String[]) bean.get("dupProperty");
@@ -236,28 +200,18 @@ public class DynaPropertyUtilsTestCase extends TestCase {
// Verify existence of all the properties that should be present
for (final String describe : describes) {
- assertTrue("Property '" + describe + "' is present",
- map.containsKey(describe));
+ assertTrue("Property '" + describe + "' is present", map.containsKey(describe));
}
- assertTrue("Property 'writeOnlyProperty' is not present",
- !map.containsKey("writeOnlyProperty"));
+ assertTrue("Property 'writeOnlyProperty' is not present", !map.containsKey("writeOnlyProperty"));
// Verify the values of scalar properties
- assertEquals("Value of 'booleanProperty'",
- Boolean.TRUE, map.get("booleanProperty"));
- assertEquals("Value of 'doubleProperty'",
- Double.valueOf(321.0), map.get("doubleProperty"));
- assertEquals("Value of 'floatProperty'",
- Float.valueOf((float) 123.0), map.get("floatProperty"));
- assertEquals("Value of 'intProperty'",
- Integer.valueOf(123), map.get("intProperty"));
- assertEquals("Value of 'longProperty'",
- Long.valueOf(321), map.get("longProperty"));
- assertEquals("Value of 'shortProperty'",
- Short.valueOf((short) 987), map.get("shortProperty"));
- assertEquals("Value of 'stringProperty'",
- "This is a string",
- (String) map.get("stringProperty"));
+ assertEquals("Value of 'booleanProperty'", Boolean.TRUE, map.get("booleanProperty"));
+ assertEquals("Value of 'doubleProperty'", Double.valueOf(321.0), map.get("doubleProperty"));
+ assertEquals("Value of 'floatProperty'", Float.valueOf((float) 123.0), map.get("floatProperty"));
+ assertEquals("Value of 'intProperty'", Integer.valueOf(123), map.get("intProperty"));
+ assertEquals("Value of 'longProperty'", Long.valueOf(321), map.get("longProperty"));
+ assertEquals("Value of 'shortProperty'", Short.valueOf((short) 987), map.get("shortProperty"));
+ assertEquals("Value of 'stringProperty'", "This is a string", (String) map.get("stringProperty"));
}
@@ -289,8 +243,7 @@ public class DynaPropertyUtilsTestCase extends TestCase {
// Use index expression
try {
- PropertyUtils.getIndexedProperty(null,
- "intArray[0]");
+ PropertyUtils.getIndexedProperty(null, "intArray[0]");
fail("Should throw IllegalArgumentException 3");
} catch (final IllegalArgumentException e) {
// Expected response
@@ -339,8 +292,7 @@ public class DynaPropertyUtilsTestCase extends TestCase {
// Use index expression
try {
- PropertyUtils.getIndexedProperty(null,
- "intIndexed[0]");
+ PropertyUtils.getIndexedProperty(null, "intIndexed[0]");
fail("Should throw IllegalArgumentException 3");
} catch (final IllegalArgumentException e) {
// Expected response
@@ -380,61 +332,46 @@ public class DynaPropertyUtilsTestCase extends TestCase {
for (int i = 0; i < 5; i++) {
try {
- value =
- PropertyUtils.getIndexedProperty(bean, "intArray", i);
+ value = PropertyUtils.getIndexedProperty(bean, "intArray", i);
assertNotNull("intArray returned value " + i, value);
- assertTrue("intArray returned Integer " + i,
- value instanceof Integer);
- assertEquals("intArray returned correct " + i, i * 10,
- ((Integer) value).intValue());
+ assertTrue("intArray returned Integer " + i, value instanceof Integer);
+ assertEquals("intArray returned correct " + i, i * 10, ((Integer) value).intValue());
} catch (final Throwable t) {
fail("intArray " + i + " threw " + t);
}
try {
- value =
- PropertyUtils.getIndexedProperty(bean, "intIndexed", i);
+ value = PropertyUtils.getIndexedProperty(bean, "intIndexed", i);
assertNotNull("intIndexed returned value " + i, value);
- assertTrue("intIndexed returned Integer " + i,
- value instanceof Integer);
- assertEquals("intIndexed returned correct " + i, i * 10,
- ((Integer) value).intValue());
+ assertTrue("intIndexed returned Integer " + i, value instanceof Integer);
+ assertEquals("intIndexed returned correct " + i, i * 10, ((Integer) value).intValue());
} catch (final Throwable t) {
fail("intIndexed " + i + " threw " + t);
}
try {
- value =
- PropertyUtils.getIndexedProperty(bean, "listIndexed", i);
+ value = PropertyUtils.getIndexedProperty(bean, "listIndexed", i);
assertNotNull("listIndexed returned value " + i, value);
- assertTrue("list returned String " + i,
- value instanceof String);
- assertEquals("listIndexed returned correct " + i,
- "String " + i, (String) value);
+ assertTrue("list returned String " + i, value instanceof String);
+ assertEquals("listIndexed returned correct " + i, "String " + i, (String) value);
} catch (final Throwable t) {
fail("listIndexed " + i + " threw " + t);
}
try {
- value =
- PropertyUtils.getIndexedProperty(bean, "stringArray", i);
+ value = PropertyUtils.getIndexedProperty(bean, "stringArray", i);
assertNotNull("stringArray returned value " + i, value);
- assertTrue("stringArray returned String " + i,
- value instanceof String);
- assertEquals("stringArray returned correct " + i,
- "String " + i, (String) value);
+ assertTrue("stringArray returned String " + i, value instanceof String);
+ assertEquals("stringArray returned correct " + i, "String " + i, (String) value);
} catch (final Throwable t) {
fail("stringArray " + i + " threw " + t);
}
try {
- value =
- PropertyUtils.getIndexedProperty(bean, "stringIndexed", i);
+ value = PropertyUtils.getIndexedProperty(bean, "stringIndexed", i);
assertNotNull("stringIndexed returned value " + i, value);
- assertTrue("stringIndexed returned String " + i,
- value instanceof String);
- assertEquals("stringIndexed returned correct " + i,
- "String " + i, (String) value);
+ assertTrue("stringIndexed returned String " + i, value instanceof String);
+ assertEquals("stringIndexed returned correct " + i, "String " + i, (String) value);
} catch (final Throwable t) {
fail("stringIndexed " + i + " threw " + t);
}
@@ -446,66 +383,46 @@ public class DynaPropertyUtilsTestCase extends TestCase {
for (int i = 0; i < 5; i++) {
try {
- value =
- PropertyUtils.getIndexedProperty(bean,
- "intArray[" + i + "]");
+ value = PropertyUtils.getIndexedProperty(bean, "intArray[" + i + "]");
assertNotNull("intArray returned value " + i, value);
- assertTrue("intArray returned Integer " + i,
- value instanceof Integer);
- assertEquals("intArray returned correct " + i, i * 10,
- ((Integer) value).intValue());
+ assertTrue("intArray returned Integer " + i, value instanceof Integer);
+ assertEquals("intArray returned correct " + i, i * 10, ((Integer) value).intValue());
} catch (final Throwable t) {
fail("intArray " + i + " threw " + t);
}
try {
- value =
- PropertyUtils.getIndexedProperty(bean,
- "intIndexed[" + i + "]");
+ value = PropertyUtils.getIndexedProperty(bean, "intIndexed[" + i + "]");
assertNotNull("intIndexed returned value " + i, value);
- assertTrue("intIndexed returned Integer " + i,
- value instanceof Integer);
- assertEquals("intIndexed returned correct " + i, i * 10,
- ((Integer) value).intValue());
+ assertTrue("intIndexed returned Integer " + i, value instanceof Integer);
+ assertEquals("intIndexed returned correct " + i, i * 10, ((Integer) value).intValue());
} catch (final Throwable t) {
fail("intIndexed " + i + " threw " + t);
}
try {
- value =
- PropertyUtils.getIndexedProperty(bean,
- "listIndexed[" + i + "]");
+ value = PropertyUtils.getIndexedProperty(bean, "listIndexed[" + i + "]");
assertNotNull("listIndexed returned value " + i, value);
- assertTrue("listIndexed returned String " + i,
- value instanceof String);
- assertEquals("listIndexed returned correct " + i,
- "String " + i, (String) value);
+ assertTrue("listIndexed returned String " + i, value instanceof String);
+ assertEquals("listIndexed returned correct " + i, "String " + i, (String) value);
} catch (final Throwable t) {
fail("listIndexed " + i + " threw " + t);
}
try {
- value =
- PropertyUtils.getIndexedProperty(bean,
- "stringArray[" + i + "]");
+ value = PropertyUtils.getIndexedProperty(bean, "stringArray[" + i + "]");
assertNotNull("stringArray returned value " + i, value);
- assertTrue("stringArray returned String " + i,
- value instanceof String);
- assertEquals("stringArray returned correct " + i,
- "String " + i, (String) value);
+ assertTrue("stringArray returned String " + i, value instanceof String);
+ assertEquals("stringArray returned correct " + i, "String " + i, (String) value);
} catch (final Throwable t) {
fail("stringArray " + i + " threw " + t);
}
try {
- value =
- PropertyUtils.getIndexedProperty(bean,
- "stringIndexed[" + i + "]");
+ value = PropertyUtils.getIndexedProperty(bean, "stringIndexed[" + i + "]");
assertNotNull("stringIndexed returned value " + i, value);
- assertTrue("stringIndexed returned String " + i,
- value instanceof String);
- assertEquals("stringIndexed returned correct " + i,
- "String " + i, (String) value);
+ assertTrue("stringIndexed returned String " + i, value instanceof String);
+ assertEquals("stringIndexed returned correct " + i, "String " + i, (String) value);
} catch (final Throwable t) {
fail("stringIndexed " + i + " threw " + t);
}
@@ -515,9 +432,7 @@ public class DynaPropertyUtilsTestCase extends TestCase {
// Index out of bounds tests
try {
- value =
- PropertyUtils.getIndexedProperty(bean,
- "intArray", -1);
+ value = PropertyUtils.getIndexedProperty(bean, "intArray", -1);
fail("Should have thrown ArrayIndexOutOfBoundsException");
} catch (final ArrayIndexOutOfBoundsException t) {
// Expected results
@@ -526,9 +441,7 @@ public class DynaPropertyUtilsTestCase extends TestCase {
}
try {
- value =
- PropertyUtils.getIndexedProperty(bean,
- "intArray", 5);
+ value = PropertyUtils.getIndexedProperty(bean, "intArray", 5);
fail("Should have thrown ArrayIndexOutOfBoundsException");
} catch (final ArrayIndexOutOfBoundsException t) {
// Expected results
@@ -537,9 +450,7 @@ public class DynaPropertyUtilsTestCase extends TestCase {
}
try {
- value =
- PropertyUtils.getIndexedProperty(bean,
- "intIndexed", -1);
+ value = PropertyUtils.getIndexedProperty(bean, "intIndexed", -1);
fail("Should have thrown ArrayIndexOutOfBoundsException");
} catch (final ArrayIndexOutOfBoundsException t) {
// Expected results
@@ -548,9 +459,7 @@ public class DynaPropertyUtilsTestCase extends TestCase {
}
try {
- value =
- PropertyUtils.getIndexedProperty(bean,
- "intIndexed", 5);
+ value = PropertyUtils.getIndexedProperty(bean, "intIndexed", 5);
fail("Should have thrown ArrayIndexOutOfBoundsException");
} catch (final ArrayIndexOutOfBoundsException t) {
// Expected results
@@ -559,9 +468,7 @@ public class DynaPropertyUtilsTestCase extends TestCase {
}
try {
- value =
- PropertyUtils.getIndexedProperty(bean,
- "listIndexed", -1);
+ value = PropertyUtils.getIndexedProperty(bean, "listIndexed", -1);
fail("Should have thrown IndexOutOfBoundsException");
} catch (final IndexOutOfBoundsException t) {
// Expected results
@@ -570,9 +477,7 @@ public class DynaPropertyUtilsTestCase extends TestCase {
}
try {
- value =
- PropertyUtils.getIndexedProperty(bean,
- "listIndexed", 5);
+ value = PropertyUtils.getIndexedProperty(bean, "listIndexed", 5);
fail("Should have thrown IndexOutOfBoundsException");
} catch (final IndexOutOfBoundsException t) {
// Expected results
@@ -581,9 +486,7 @@ public class DynaPropertyUtilsTestCase extends TestCase {
}
try {
- value =
- PropertyUtils.getIndexedProperty(bean,
- "stringArray", -1);
+ value = PropertyUtils.getIndexedProperty(bean, "stringArray", -1);
fail("Should have thrown ArrayIndexOutOfBoundsException");
} catch (final ArrayIndexOutOfBoundsException t) {
// Expected results
@@ -592,9 +495,7 @@ public class DynaPropertyUtilsTestCase extends TestCase {
}
try {
- value =
- PropertyUtils.getIndexedProperty(bean,
- "stringArray", 5);
+ value = PropertyUtils.getIndexedProperty(bean, "stringArray", 5);
fail("Should have thrown ArrayIndexOutOfBoundsException");
} catch (final ArrayIndexOutOfBoundsException t) {
// Expected results
@@ -603,9 +504,7 @@ public class DynaPropertyUtilsTestCase extends TestCase {
}
try {
- value =
- PropertyUtils.getIndexedProperty(bean,
- "stringIndexed", -1);
+ value = PropertyUtils.getIndexedProperty(bean, "stringIndexed", -1);
fail("Should have thrown ArrayIndexOutOfBoundsException");
} catch (final ArrayIndexOutOfBoundsException t) {
// Expected results
@@ -614,9 +513,7 @@ public class DynaPropertyUtilsTestCase extends TestCase {
}
try {
- value =
- PropertyUtils.getIndexedProperty(bean,
- "stringIndexed", 5);
+ value = PropertyUtils.getIndexedProperty(bean, "stringIndexed", 5);
fail("Should have thrown ArrayIndexOutOfBoundsException");
} catch (final ArrayIndexOutOfBoundsException t) {
// Expected results
@@ -634,8 +531,7 @@ public class DynaPropertyUtilsTestCase extends TestCase {
// Use explicit key argument
try {
- PropertyUtils.getMappedProperty(null, "mappedProperty",
- "First Key");
+ PropertyUtils.getMappedProperty(null, "mappedProperty", "First Key");
fail("Should throw IllegalArgumentException 1");
} catch (final IllegalArgumentException e) {
// Expected response
@@ -664,8 +560,7 @@ public class DynaPropertyUtilsTestCase extends TestCase {
// Use key expression
try {
- PropertyUtils.getMappedProperty(null,
- "mappedProperty(First Key)");
+ PropertyUtils.getMappedProperty(null, "mappedProperty(First Key)");
fail("Should throw IllegalArgumentException 4");
} catch (final IllegalArgumentException e) {
// Expected response
@@ -699,35 +594,22 @@ public class DynaPropertyUtilsTestCase extends TestCase {
public void testGetMappedPeriods() {
bean.set("mappedProperty", "key.with.a.dot", "Special Value");
- assertEquals("Can retrieve directly",
- "Special Value",
- (String) bean.get("mappedProperty", "key.with.a.dot"));
- try {
- assertEquals("Can retrieve via getMappedProperty",
- "Special Value",
- PropertyUtils.getMappedProperty
- (bean, "mappedProperty", "key.with.a.dot"));
+ assertEquals("Can retrieve directly", "Special Value", (String) bean.get("mappedProperty", "key.with.a.dot"));
+ try {
+ assertEquals("Can retrieve via getMappedProperty", "Special Value", PropertyUtils.getMappedProperty(bean, "mappedProperty", "key.with.a.dot"));
} catch (final Exception e) {
fail("Thew exception: " + e);
}
try {
- assertEquals("Can retrieve via getNestedProperty",
- "Special Value",
- PropertyUtils.getNestedProperty
- (bean, "mappedProperty(key.with.a.dot)"));
+ assertEquals("Can retrieve via getNestedProperty", "Special Value", PropertyUtils.getNestedProperty(bean, "mappedProperty(key.with.a.dot)"));
} catch (final Exception e) {
fail("Thew exception: " + e);
}
bean.set("mappedObjects", "nested.property", new TestBean());
- assertNotNull("Can retrieve directly",
- bean.get("mappedObjects", "nested.property"));
- try {
- assertEquals("Can retrieve nested",
- "This is a string",
- PropertyUtils.getNestedProperty
- (bean,
- "mappedObjects(nested.property).stringProperty"));
+ assertNotNull("Can retrieve directly", bean.get("mappedObjects", "nested.property"));
+ try {
+ assertEquals("Can retrieve nested", "This is a string", PropertyUtils.getNestedProperty(bean, "mappedObjects(nested.property).stringProperty"));
} catch (final Exception e) {
fail("Thew exception: " + e);
}
@@ -735,41 +617,27 @@ public class DynaPropertyUtilsTestCase extends TestCase {
}
/**
- * Test getting mapped values with slashes in the key. This is different
- * from periods because slashes are not syntactically significant.
+ * Test getting mapped values with slashes in the key. This is different from periods because slashes are not syntactically significant.
*/
public void testGetMappedSlashes() {
bean.set("mappedProperty", "key/with/a/slash", "Special Value");
- assertEquals("Can retrieve directly",
- "Special Value",
- bean.get("mappedProperty", "key/with/a/slash"));
- try {
- assertEquals("Can retrieve via getMappedProperty",
- "Special Value",
- PropertyUtils.getMappedProperty
- (bean, "mappedProperty", "key/with/a/slash"));
+ assertEquals("Can retrieve directly", "Special Value", bean.get("mappedProperty", "key/with/a/slash"));
+ try {
+ assertEquals("Can retrieve via getMappedProperty", "Special Value", PropertyUtils.getMappedProperty(bean, "mappedProperty", "key/with/a/slash"));
} catch (final Exception e) {
fail("Thew exception: " + e);
}
try {
- assertEquals("Can retrieve via getNestedProperty",
- "Special Value",
- PropertyUtils.getNestedProperty
- (bean, "mappedProperty(key/with/a/slash)"));
+ assertEquals("Can retrieve via getNestedProperty", "Special Value", PropertyUtils.getNestedProperty(bean, "mappedProperty(key/with/a/slash)"));
} catch (final Exception e) {
fail("Thew exception: " + e);
}
bean.set("mappedObjects", "nested/property", new TestBean());
- assertNotNull("Can retrieve directly",
- bean.get("mappedObjects", "nested/property"));
- try {
- assertEquals("Can retrieve nested",
- "This is a string",
- PropertyUtils.getNestedProperty
- (bean,
- "mappedObjects(nested/property).stringProperty"));
+ assertNotNull("Can retrieve directly", bean.get("mappedObjects", "nested/property"));
+ try {
+ assertEquals("Can retrieve nested", "This is a string", PropertyUtils.getNestedProperty(bean, "mappedObjects(nested/property).stringProperty"));
} catch (final Exception e) {
fail("Thew exception: " + e);
}
@@ -786,24 +654,21 @@ public class DynaPropertyUtilsTestCase extends TestCase {
// Use explicit key argument
try {
- value = PropertyUtils.getMappedProperty(bean, "mappedProperty",
- "First Key");
+ value = PropertyUtils.getMappedProperty(bean, "mappedProperty", "First Key");
assertEquals("Can find first value", "First Value", value);
} catch (final Throwable t) {
fail("Finding first value threw " + t);
}
try {
- value = PropertyUtils.getMappedProperty(bean, "mappedProperty",
- "Second Key");
+ value = PropertyUtils.getMappedProperty(bean, "mappedProperty", "Second Key");
assertEquals("Can find second value", "Second Value", value);
} catch (final Throwable t) {
fail("Finding second value threw " + t);
}
try {
- value = PropertyUtils.getMappedProperty(bean, "mappedProperty",
- "Third Key");
+ value = PropertyUtils.getMappedProperty(bean, "mappedProperty", "Third Key");
assertNull("Can not find third value", value);
} catch (final Throwable t) {
fail("Finding third value threw " + t);
@@ -812,27 +677,21 @@ public class DynaPropertyUtilsTestCase extends TestCase {
// Use key expression with parentheses
try {
- value =
- PropertyUtils.getMappedProperty(bean,
- "mappedProperty(First Key)");
+ value = PropertyUtils.getMappedProperty(bean, "mappedProperty(First Key)");
assertEquals("Can find first value", "First Value", value);
} catch (final Throwable t) {
fail("Finding first value threw " + t);
}
try {
- value =
- PropertyUtils.getMappedProperty(bean,
- "mappedProperty(Second Key)");
+ value = PropertyUtils.getMappedProperty(bean, "mappedProperty(Second Key)");
assertEquals("Can find second value", "Second Value", value);
} catch (final Throwable t) {
fail("Finding second value threw " + t);
}
try {
- value =
- PropertyUtils.getMappedProperty(bean,
- "mappedProperty(Third Key)");
+ value = PropertyUtils.getMappedProperty(bean, "mappedProperty(Third Key)");
assertNull("Can not find third value", value);
} catch (final Throwable t) {
fail("Finding third value threw " + t);
@@ -841,27 +700,21 @@ public class DynaPropertyUtilsTestCase extends TestCase {
// Use key expression with dotted syntax
try {
- value =
- PropertyUtils.getNestedProperty(bean,
- "mapProperty.First Key");
+ value = PropertyUtils.getNestedProperty(bean, "mapProperty.First Key");
assertEquals("Can find first value", "First Value", value);
} catch (final Throwable t) {
fail("Finding first value threw " + t);
}
try {
- value =
- PropertyUtils.getNestedProperty(bean,
- "mapProperty.Second Key");
+ value = PropertyUtils.getNestedProperty(bean, "mapProperty.Second Key");
assertEquals("Can find second value", "Second Value", value);
} catch (final Throwable t) {
fail("Finding second value threw " + t);
}
try {
- value =
- PropertyUtils.getNestedProperty(bean,
- "mapProperty.Third Key");
+ value = PropertyUtils.getNestedProperty(bean, "mapProperty.Third Key");
assertNull("Can not find third value", value);
} catch (final Throwable t) {
fail("Finding third value threw " + t);
@@ -900,15 +753,11 @@ public class DynaPropertyUtilsTestCase extends TestCase {
public void testGetNestedBoolean() {
try {
- final Object value =
- PropertyUtils.getNestedProperty
- (bean, "nested.booleanProperty");
+ final Object value = PropertyUtils.getNestedProperty(bean, "nested.booleanProperty");
assertNotNull("Got a value", value);
assertTrue("Got correct type", value instanceof Boolean);
final TestBean nested = (TestBean) bean.get("nested");
- assertTrue("Got correct value",
- ((Boolean) value).booleanValue() ==
- nested.getBooleanProperty());
+ assertTrue("Got correct value", ((Boolean) value).booleanValue() == nested.getBooleanProperty());
} catch (final IllegalAccessException e) {
fail("IllegalAccessException");
} catch (final IllegalArgumentException e) {
@@ -927,16 +776,11 @@ public class DynaPropertyUtilsTestCase extends TestCase {
public void testGetNestedDouble() {
try {
- final Object value =
- PropertyUtils.getNestedProperty
- (bean, "nested.doubleProperty");
+ final Object value = PropertyUtils.getNestedProperty(bean, "nested.doubleProperty");
assertNotNull("Got a value", value);
assertTrue("Got correct type", value instanceof Double);
final TestBean nested = (TestBean) bean.get("nested");
- assertEquals("Got correct value",
- ((Double) value).doubleValue(),
- nested.getDoubleProperty(),
- 0.005);
+ assertEquals("Got correct value", ((Double) value).doubleValue(), nested.getDoubleProperty(), 0.005);
} catch (final IllegalAccessException e) {
fail("IllegalAccessException");
} catch (final IllegalArgumentException e) {
@@ -955,16 +799,11 @@ public class DynaPropertyUtilsTestCase extends TestCase {
public void testGetNestedFloat() {
try {
- final Object value =
- PropertyUtils.getNestedProperty
- (bean, "nested.floatProperty");
+ final Object value = PropertyUtils.getNestedProperty(bean, "nested.floatProperty");
assertNotNull("Got a value", value);
assertTrue("Got correct type", value instanceof Float);
final TestBean nested = (TestBean) bean.get("nested");
- assertEquals("Got correct value",
- ((Float) value).floatValue(),
- nested.getFloatProperty(),
- (float) 0.005);
+ assertEquals("Got correct value", ((Float) value).floatValue(), nested.getFloatProperty(), (float) 0.005);
} catch (final IllegalAccessException e) {
fail("IllegalAccessException");
} catch (final IllegalArgumentException e) {
@@ -983,15 +822,11 @@ public class DynaPropertyUtilsTestCase extends TestCase {
public void testGetNestedInt() {
try {
- final Object value =
- PropertyUtils.getNestedProperty
- (bean, "nested.intProperty");
+ final Object value = PropertyUtils.getNestedProperty(bean, "nested.intProperty");
assertNotNull("Got a value", value);
assertTrue("Got correct type", value instanceof Integer);
final TestBean nested = (TestBean) bean.get("nested");
- assertEquals("Got correct value",
- ((Integer) value).intValue(),
- nested.getIntProperty());
+ assertEquals("Got correct value", ((Integer) value).intValue(), nested.getIntProperty());
} catch (final IllegalAccessException e) {
fail("IllegalAccessException");
} catch (final IllegalArgumentException e) {
@@ -1010,15 +845,11 @@ public class DynaPropertyUtilsTestCase extends TestCase {
public void testGetNestedLong() {
try {
- final Object value =
- PropertyUtils.getNestedProperty
- (bean, "nested.longProperty");
+ final Object value = PropertyUtils.getNestedProperty(bean, "nested.longProperty");
assertNotNull("Got a value", value);
assertTrue("Got correct type", value instanceof Long);
final TestBean nested = (TestBean) bean.get("nested");
- assertEquals("Got correct value",
- ((Long) value).longValue(),
- nested.getLongProperty());
+ assertEquals("Got correct value", ((Long) value).longValue(), nested.getLongProperty());
} catch (final IllegalAccessException e) {
fail("IllegalAccessException");
} catch (final IllegalArgumentException e) {
@@ -1037,15 +868,11 @@ public class DynaPropertyUtilsTestCase extends TestCase {
public void testGetNestedReadOnly() {
try {
- final Object value =
- PropertyUtils.getNestedProperty
- (bean, "nested.readOnlyProperty");
+ final Object value = PropertyUtils.getNestedProperty(bean, "nested.readOnlyProperty");
assertNotNull("Got a value", value);
assertTrue("Got correct type", value instanceof String);
final TestBean nested = (TestBean) bean.get("nested");
- assertEquals("Got correct value",
- (String) value,
- nested.getReadOnlyProperty());
+ assertEquals("Got correct value", (String) value, nested.getReadOnlyProperty());
} catch (final IllegalAccessException e) {
fail("IllegalAccessException");
} catch (final IllegalArgumentException e) {
@@ -1064,15 +891,11 @@ public class DynaPropertyUtilsTestCase extends TestCase {
public void testGetNestedShort() {
try {
- final Object value =
- PropertyUtils.getNestedProperty
- (bean, "nested.shortProperty");
+ final Object value = PropertyUtils.getNestedProperty(bean, "nested.shortProperty");
assertNotNull("Got a value", value);
assertTrue("Got correct type", value instanceof Short);
final TestBean nested = (TestBean) bean.get("nested");
- assertEquals("Got correct value",
- ((Short) value).shortValue(),
- nested.getShortProperty());
+ assertEquals("Got correct value", ((Short) value).shortValue(), nested.getShortProperty());
} catch (final IllegalAccessException e) {
fail("IllegalAccessException");
} catch (final IllegalArgumentException e) {
@@ -1091,15 +914,11 @@ public class DynaPropertyUtilsTestCase extends TestCase {
public void testGetNestedString() {
try {
- final Object value =
- PropertyUtils.getNestedProperty
- (bean, "nested.stringProperty");
+ final Object value = PropertyUtils.getNestedProperty(bean, "nested.stringProperty");
assertNotNull("Got a value", value);
assertTrue("Got correct type", value instanceof String);
final TestBean nested = (TestBean) bean.get("nested");
- assertEquals("Got correct value",
- (String) value,
- nested.getStringProperty());
+ assertEquals("Got correct value", (String) value, nested.getStringProperty());
} catch (final IllegalAccessException e) {
fail("IllegalAccessException");
} catch (final IllegalArgumentException e) {
@@ -1163,13 +982,10 @@ public class DynaPropertyUtilsTestCase extends TestCase {
public void testGetSimpleBoolean() {
try {
- final Object value =
- PropertyUtils.getSimpleProperty(bean,
- "booleanProperty");
+ final Object value = PropertyUtils.getSimpleProperty(bean, "booleanProperty");
assertNotNull("Got a value", value);
assertTrue("Got correct type", value instanceof Boolean);
- assertTrue("Got correct value",
- ((Boolean) value).booleanValue());
+ assertTrue("Got correct value", ((Boolean) value).booleanValue());
} catch (final IllegalAccessException e) {
fail("IllegalAccessException");
} catch (final IllegalArgumentException e) {
@@ -1188,13 +1004,10 @@ public class DynaPropertyUtilsTestCase extends TestCase {
public void testGetSimpleDouble() {
try {
- final Object value =
- PropertyUtils.getSimpleProperty(bean,
- "doubleProperty");
+ final Object value = PropertyUtils.getSimpleProperty(bean, "doubleProperty");
assertNotNull("Got a value", value);
assertTrue("Got correct type", value instanceof Double);
- assertEquals("Got correct value",
- ((Double) value).doubleValue(), 321.0, 0.005);
+ assertEquals("Got correct value", ((Double) value).doubleValue(), 321.0, 0.005);
} catch (final IllegalAccessException e) {
fail("IllegalAccessException");
} catch (final IllegalArgumentException e) {
@@ -1213,15 +1026,10 @@ public class DynaPropertyUtilsTestCase extends TestCase {
public void testGetSimpleFloat() {
try {
- final Object value =
- PropertyUtils.getSimpleProperty(bean,
- "floatProperty");
+ final Object value = PropertyUtils.getSimpleProperty(bean, "floatProperty");
assertNotNull("Got a value", value);
assertTrue("Got correct type", value instanceof Float);
- assertEquals("Got correct value",
- ((Float) value).floatValue(),
- (float) 123.0,
- (float) 0.005);
+ assertEquals("Got correct value", ((Float) value).floatValue(), (float) 123.0, (float) 0.005);
} catch (final IllegalAccessException e) {
fail("IllegalAccessException");
} catch (final IllegalArgumentException e) {
@@ -1240,8 +1048,7 @@ public class DynaPropertyUtilsTestCase extends TestCase {
public void testGetSimpleIndexed() {
try {
- PropertyUtils.getSimpleProperty(bean,
- "intIndexed[0]");
+ PropertyUtils.getSimpleProperty(bean, "intIndexed[0]");
fail("Should have thrown IllegalArgumentException");
} catch (final IllegalAccessException e) {
fail("IllegalAccessException");
@@ -1261,14 +1068,10 @@ public class DynaPropertyUtilsTestCase extends TestCase {
public void testGetSimpleInt() {
try {
- final Object value =
- PropertyUtils.getSimpleProperty(bean,
- "intProperty");
+ final Object value = PropertyUtils.getSimpleProperty(bean, "intProperty");
assertNotNull("Got a value", value);
assertTrue("Got correct type", value instanceof Integer);
- assertEquals("Got correct value",
- ((Integer) value).intValue(),
- 123);
+ assertEquals("Got correct value", ((Integer) value).intValue(), 123);
} catch (final IllegalAccessException e) {
fail("IllegalAccessException");
} catch (final IllegalArgumentException e) {
@@ -1287,14 +1090,10 @@ public class DynaPropertyUtilsTestCase extends TestCase {
public void testGetSimpleLong() {
try {
- final Object value =
- PropertyUtils.getSimpleProperty(bean,
- "longProperty");
+ final Object value = PropertyUtils.getSimpleProperty(bean, "longProperty");
assertNotNull("Got a value", value);
assertTrue("Got correct type", value instanceof Long);
- assertEquals("Got correct value",
- ((Long) value).longValue(),
- 321);
+ assertEquals("Got correct value", ((Long) value).longValue(), 321);
} catch (final IllegalAccessException e) {
fail("IllegalAccessException");
} catch (final IllegalArgumentException e) {
@@ -1313,8 +1112,7 @@ public class DynaPropertyUtilsTestCase extends TestCase {
public void testGetSimpleNested() {
try {
- PropertyUtils.getSimpleProperty(bean,
- "nested.stringProperty");
+ PropertyUtils.getSimpleProperty(bean, "nested.stringProperty");
fail("Should have thrown IllegalArgumentException");
} catch (final IllegalAccessException e) {
fail("IllegalAccessException");
@@ -1334,14 +1132,10 @@ public class DynaPropertyUtilsTestCase extends TestCase {
public void testGetSimpleShort() {
try {
- final Object value =
- PropertyUtils.getSimpleProperty(bean,
- "shortProperty");
+ final Object value = PropertyUtils.getSimpleProperty(bean, "shortProperty");
assertNotNull("Got a value", value);
assertTrue("Got correct type", value instanceof Short);
- assertEquals("Got correct value",
- ((Short) value).shortValue(),
- (short) 987);
+ assertEquals("Got correct value", ((Short) value).shortValue(), (short) 987);
} catch (final IllegalAccessException e) {
fail("IllegalAccessException");
} catch (final IllegalArgumentException e) {
@@ -1360,14 +1154,10 @@ public class DynaPropertyUtilsTestCase extends TestCase {
public void testGetSimpleString() {
try {
- final Object value =
- PropertyUtils.getSimpleProperty(bean,
- "stringProperty");
+ final Object value = PropertyUtils.getSimpleProperty(bean, "stringProperty");
assertNotNull("Got a value", value);
assertTrue("Got correct type", value instanceof String);
- assertEquals("Got correct value",
- (String) value,
- "This is a string");
+ assertEquals("Got correct value", (String) value, "This is a string");
} catch (final IllegalAccessException e) {
fail("IllegalAccessException");
} catch (final IllegalArgumentException e) {
@@ -1396,8 +1186,7 @@ public class DynaPropertyUtilsTestCase extends TestCase {
fail("InvocationTargetException");
} catch (final NoSuchMethodException e) {
// Correct result for this test
- assertEquals("Unknown property 'unknown' on dynaclass '" +
- bean.getDynaClass() + "'", e.getMessage() );
+ assertEquals("Unknown property 'unknown' on dynaclass '" + bean.getDynaClass() + "'", e.getMessage());
}
}
@@ -1410,8 +1199,7 @@ public class DynaPropertyUtilsTestCase extends TestCase {
// Use explicit index argument
try {
- PropertyUtils.setIndexedProperty(null, "intArray", 0,
- Integer.valueOf(1));
+ PropertyUtils.setIndexedProperty(null, "intArray", 0, Integer.valueOf(1));
fail("Should throw IllegalArgumentException 1");
} catch (final IllegalArgumentException e) {
// Expected response
@@ -1420,8 +1208,7 @@ public class DynaPropertyUtilsTestCase extends TestCase {
}
try {
- PropertyUtils.setIndexedProperty(bean, null, 0,
- Integer.valueOf(1));
+ PropertyUtils.setIndexedProperty(bean, null, 0, Integer.valueOf(1));
fail("Should throw IllegalArgumentException 2");
} catch (final IllegalArgumentException e) {
// Expected response
@@ -1432,9 +1219,7 @@ public class DynaPropertyUtilsTestCase extends TestCase {
// Use index expression
try {
- PropertyUtils.setIndexedProperty(null,
- "intArray[0]",
- Integer.valueOf(1));
+ PropertyUtils.setIndexedProperty(null, "intArray[0]", Integer.valueOf(1));
fail("Should throw IllegalArgumentException 3");
} catch (final IllegalArgumentException e) {
// Expected response
@@ -1443,8 +1228,7 @@ public class DynaPropertyUtilsTestCase extends TestCase {
}
try {
- PropertyUtils.setIndexedProperty(bean, "[0]",
- Integer.valueOf(1));
+ PropertyUtils.setIndexedProperty(bean, "[0]", Integer.valueOf(1));
fail("Should throw NoSuchMethodException 4");
} catch (final NoSuchMethodException e) {
// Expected response
@@ -1453,8 +1237,7 @@ public class DynaPropertyUtilsTestCase extends TestCase {
}
try {
- PropertyUtils.setIndexedProperty(bean, "intArray",
- Integer.valueOf(1));
+ PropertyUtils.setIndexedProperty(bean, "intArray", Integer.valueOf(1));
fail("Should throw IllegalArgumentException 5");
} catch (final IllegalArgumentException e) {
// Expected response
@@ -1465,8 +1248,7 @@ public class DynaPropertyUtilsTestCase extends TestCase {
// Use explicit index argument
try {
- PropertyUtils.setIndexedProperty(null, "intIndexed", 0,
- Integer.valueOf(1));
+ PropertyUtils.setIndexedProperty(null, "intIndexed", 0, Integer.valueOf(1));
fail("Should throw IllegalArgumentException 1");
} catch (final IllegalArgumentException e) {
// Expected response
@@ -1475,8 +1257,7 @@ public class DynaPropertyUtilsTestCase extends TestCase {
}
try {
- PropertyUtils.setIndexedProperty(bean, null, 0,
- Integer.valueOf(1));
+ PropertyUtils.setIndexedProperty(bean, null, 0, Integer.valueOf(1));
fail("Should throw IllegalArgumentException 2");
} catch (final IllegalArgumentException e) {
// Expected response
@@ -1487,9 +1268,7 @@ public class DynaPropertyUtilsTestCase extends TestCase {
// Use index expression
try {
- PropertyUtils.setIndexedProperty(null,
- "intIndexed[0]",
- Integer.valueOf(1));
+ PropertyUtils.setIndexedProperty(null, "intIndexed[0]", Integer.valueOf(1));
fail("Should throw IllegalArgumentException 3");
} catch (final IllegalArgumentException e) {
// Expected response
@@ -1498,8 +1277,7 @@ public class DynaPropertyUtilsTestCase extends TestCase {
}
try {
- PropertyUtils.setIndexedProperty(bean, "[0]",
- Integer.valueOf(1));
+ PropertyUtils.setIndexedProperty(bean, "[0]", Integer.valueOf(1));
fail("Should throw NoSuchMethodException 4");
} catch (final NoSuchMethodException e) {
// Expected response
@@ -1508,8 +1286,7 @@ public class DynaPropertyUtilsTestCase extends TestCase {
}
try {
- PropertyUtils.setIndexedProperty(bean, "intIndexed",
- Integer.valueOf(1));
+ PropertyUtils.setIndexedProperty(bean, "intIndexed", Integer.valueOf(1));
fail("Should throw IllegalArgumentException 5");
} catch (final IllegalArgumentException e) {
// Expected response
@@ -1529,81 +1306,51 @@ public class DynaPropertyUtilsTestCase extends TestCase {
// Use explicit index argument
try {
- PropertyUtils.setIndexedProperty(bean,
- "intArray", 0,
- Integer.valueOf(1));
- value =
- PropertyUtils.getIndexedProperty(bean,
- "intArray", 0);
+ PropertyUtils.setIndexedProperty(bean, "intArray", 0, Integer.valueOf(1));
+ value = PropertyUtils.getIndexedProperty(bean, "intArray", 0);
assertNotNull("Returned new value 0", value);
- assertTrue("Returned Integer new value 0",
- value instanceof Integer);
- assertEquals("Returned correct new value 0", 1,
- ((Integer) value).intValue());
+ assertTrue("Returned Integer new value 0", value instanceof Integer);
+ assertEquals("Returned correct new value 0", 1, ((Integer) value).intValue());
} catch (final Throwable t) {
fail("Threw " + t);
}
try {
- PropertyUtils.setIndexedProperty(bean,
- "intIndexed", 1,
- Integer.valueOf(11));
- value =
- PropertyUtils.getIndexedProperty(bean,
- "intIndexed", 1);
+ PropertyUtils.setIndexedProperty(bean, "intIndexed", 1, Integer.valueOf(11));
+ value = PropertyUtils.getIndexedProperty(bean, "intIndexed", 1);
assertNotNull("Returned new value 1", value);
- assertTrue("Returned Integer new value 1",
- value instanceof Integer);
- assertEquals("Returned correct new value 1", 11,
- ((Integer) value).intValue());
+ assertTrue("Returned Integer new value 1", value instanceof Integer);
+ assertEquals("Returned correct new value 1", 11, ((Integer) value).intValue());
} catch (final Throwable t) {
fail("Threw " + t);
}
try {
- PropertyUtils.setIndexedProperty(bean,
- "listIndexed", 2,
- "New Value 2");
- value =
- PropertyUtils.getIndexedProperty(bean,
- "listIndexed", 2);
+ PropertyUtils.setIndexedProperty(bean, "listIndexed", 2, "New Value 2");
+ value = PropertyUtils.getIndexedProperty(bean, "listIndexed", 2);
assertNotNull("Returned new value 2", value);
- assertTrue("Returned String new value 2",
- value instanceof String);
- assertEquals("Returned correct new value 2", "New Value 2",
- (String) value);
+ assertTrue("Returned String new value 2", value instanceof String);
+ assertEquals("Returned correct new value 2", "New Value 2", (String) value);
} catch (final Throwable t) {
fail("Threw " + t);
}
try {
- PropertyUtils.setIndexedProperty(bean,
- "stringArray", 2,
- "New Value 2");
- value =
- PropertyUtils.getIndexedProperty(bean,
- "stringArray", 2);
+ PropertyUtils.setIndexedProperty(bean, "stringArray", 2, "New Value 2");
+ value = PropertyUtils.getIndexedProperty(bean, "stringArray", 2);
assertNotNull("Returned new value 2", value);
- assertTrue("Returned String new value 2",
- value instanceof String);
- assertEquals("Returned correct new value 2", "New Value 2",
- (String) value);
+ assertTrue("Returned String new value 2", value instanceof String);
+ assertEquals("Returned correct new value 2", "New Value 2", (String) value);
} catch (final Throwable t) {
fail("Threw " + t);
}
try {
- PropertyUtils.setIndexedProperty(bean,
- "stringArray", 3,
- "New Value 3");
- value =
- PropertyUtils.getIndexedProperty(bean,
- "stringArray", 3);
+ PropertyUtils.setIndexedProperty(bean, "stringArray", 3, "New Value 3");
+ value = PropertyUtils.getIndexedProperty(bean, "stringArray", 3);
assertNotNull("Returned new value 3", value);
- assertTrue("Returned String new value 3",
- value instanceof String);
- assertEquals("Returned correct new value 3", "New Value 3",
- (String) value);
+ assertTrue("Returned String new value 3", value instanceof String);
+ assertEquals("Returned correct new value 3", "New Value 3", (String) value);
} catch (final Throwable t) {
fail("Threw " + t);
}
@@ -1611,81 +1358,51 @@ public class DynaPropertyUtilsTestCase extends TestCase {
// Use index expression
try {
- PropertyUtils.setIndexedProperty(bean,
- "intArray[4]",
- Integer.valueOf(1));
- value =
- PropertyUtils.getIndexedProperty(bean,
- "intArray[4]");
+ PropertyUtils.setIndexedProperty(bean, "intArray[4]", Integer.valueOf(1));
+ value = PropertyUtils.getIndexedProperty(bean, "intArray[4]");
assertNotNull("Returned new value 4", value);
- assertTrue("Returned Integer new value 4",
- value instanceof Integer);
- assertEquals("Returned correct new value 4", 1,
- ((Integer) value).intValue());
+ assertTrue("Returned Integer new value 4", value instanceof Integer);
+ assertEquals("Returned correct new value 4", 1, ((Integer) value).intValue());
} catch (final Throwable t) {
fail("Threw " + t);
}
try {
- PropertyUtils.setIndexedProperty(bean,
- "intIndexed[3]",
- Integer.valueOf(11));
- value =
- PropertyUtils.getIndexedProperty(bean,
- "intIndexed[3]");
+ PropertyUtils.setIndexedProperty(bean, "intIndexed[3]", Integer.valueOf(11));
+ value = PropertyUtils.getIndexedProperty(bean, "intIndexed[3]");
assertNotNull("Returned new value 5", value);
- assertTrue("Returned Integer new value 5",
- value instanceof Integer);
- assertEquals("Returned correct new value 5", 11,
- ((Integer) value).intValue());
+ assertTrue("Returned Integer new value 5", value instanceof Integer);
+ assertEquals("Returned correct new value 5", 11, ((Integer) value).intValue());
} catch (final Throwable t) {
fail("Threw " + t);
}
try {
- PropertyUtils.setIndexedProperty(bean,
- "listIndexed[1]",
- "New Value 2");
- value =
- PropertyUtils.getIndexedProperty(bean,
- "listIndexed[1]");
+ PropertyUtils.setIndexedProperty(bean, "listIndexed[1]", "New Value 2");
+ value = PropertyUtils.getIndexedProperty(bean, "listIndexed[1]");
assertNotNull("Returned new value 6", value);
- assertTrue("Returned String new value 6",
- value instanceof String);
- assertEquals("Returned correct new value 6", "New Value 2",
- (String) value);
+ assertTrue("Returned String new value 6", value instanceof String);
+ assertEquals("Returned correct new value 6", "New Value 2", (String) value);
} catch (final Throwable t) {
fail("Threw " + t);
}
try {
- PropertyUtils.setIndexedProperty(bean,
- "stringArray[1]",
- "New Value 2");
- value =
- PropertyUtils.getIndexedProperty(bean,
- "stringArray[2]");
+ PropertyUtils.setIndexedProperty(bean, "stringArray[1]", "New Value 2");
+ value = PropertyUtils.getIndexedProperty(bean, "stringArray[2]");
assertNotNull("Returned new value 6", value);
- assertTrue("Returned String new value 6",
- value instanceof String);
- assertEquals("Returned correct new value 6", "New Value 2",
- (String) value);
+ assertTrue("Returned String new value 6", value instanceof String);
+ assertEquals("Returned correct new value 6", "New Value 2", (String) value);
} catch (final Throwable t) {
fail("Threw " + t);
}
try {
- PropertyUtils.setIndexedProperty(bean,
- "stringArray[0]",
- "New Value 3");
- value =
- PropertyUtils.getIndexedProperty(bean,
- "stringArray[0]");
+ PropertyUtils.setIndexedProperty(bean, "stringArray[0]", "New Value 3");
+ value = PropertyUtils.getIndexedProperty(bean, "stringArray[0]");
assertNotNull("Returned new value 7", value);
- assertTrue("Returned String new value 7",
- value instanceof String);
- assertEquals("Returned correct new value 7", "New Value 3",
- (String) value);
+ assertTrue("Returned String new value 7", value instanceof String);
+ assertEquals("Returned correct new value 7", "New Value 3", (String) value);
} catch (final Throwable t) {
fail("Threw " + t);
}
@@ -1693,9 +1410,7 @@ public class DynaPropertyUtilsTestCase extends TestCase {
// Index out of bounds tests
try {
- PropertyUtils.setIndexedProperty(bean,
- "intArray", -1,
- Integer.valueOf(0));
+ PropertyUtils.setIndexedProperty(bean, "intArray", -1, Integer.valueOf(0));
fail("Should have thrown ArrayIndexOutOfBoundsException");
} catch (final ArrayIndexOutOfBoundsException t) {
// Expected results
@@ -1704,9 +1419,7 @@ public class DynaPropertyUtilsTestCase extends TestCase {
}
try {
- PropertyUtils.setIndexedProperty(bean,
- "intArray", 5,
- Integer.valueOf(0));
+ PropertyUtils.setIndexedProperty(bean, "intArray", 5, Integer.valueOf(0));
fail("Should have thrown ArrayIndexOutOfBoundsException");
} catch (final ArrayIndexOutOfBoundsException t) {
// Expected results
@@ -1715,9 +1428,7 @@ public class DynaPropertyUtilsTestCase extends TestCase {
}
try {
- PropertyUtils.setIndexedProperty(bean,
- "intIndexed", -1,
- Integer.valueOf(0));
+ PropertyUtils.setIndexedProperty(bean, "intIndexed", -1, Integer.valueOf(0));
fail("Should have thrown ArrayIndexOutOfBoundsException");
} catch (final ArrayIndexOutOfBoundsException t) {
// Expected results
@@ -1726,9 +1437,7 @@ public class DynaPropertyUtilsTestCase extends TestCase {
}
try {
- PropertyUtils.setIndexedProperty(bean,
- "intIndexed", 5,
- Integer.valueOf(0));
+ PropertyUtils.setIndexedProperty(bean, "intIndexed", 5, Integer.valueOf(0));
fail("Should have thrown ArrayIndexOutOfBoundsException");
} catch (final ArrayIndexOutOfBoundsException t) {
// Expected results
@@ -1737,9 +1446,7 @@ public class DynaPropertyUtilsTestCase extends TestCase {
}
try {
- PropertyUtils.setIndexedProperty(bean,
- "listIndexed", 5,
- "New String");
+ PropertyUtils.setIndexedProperty(bean, "listIndexed", 5, "New String");
fail("Should have thrown IndexOutOfBoundsException");
} catch (final IndexOutOfBoundsException t) {
// Expected results
@@ -1748,9 +1455,7 @@ public class DynaPropertyUtilsTestCase extends TestCase {
}
try {
- PropertyUtils.setIndexedProperty(bean,
- "listIndexed", -1,
- "New String");
+ PropertyUtils.setIndexedProperty(bean, "listIndexed", -1, "New String");
fail("Should have thrown IndexOutOfBoundsException");
} catch (final IndexOutOfBoundsException t) {
// Expected results
@@ -1759,9 +1464,7 @@ public class DynaPropertyUtilsTestCase extends TestCase {
}
try {
- PropertyUtils.setIndexedProperty(bean,
- "stringArray", -1,
- "New String");
+ PropertyUtils.setIndexedProperty(bean, "stringArray", -1, "New String");
fail("Should have thrown ArrayIndexOutOfBoundsException");
} catch (final ArrayIndexOutOfBoundsException t) {
// Expected results
@@ -1770,9 +1473,7 @@ public class DynaPropertyUtilsTestCase extends TestCase {
}
try {
- PropertyUtils.setIndexedProperty(bean,
- "stringArray", 5,
- "New String");
+ PropertyUtils.setIndexedProperty(bean, "stringArray", 5, "New String");
fail("Should have thrown ArrayIndexOutOfBoundsException");
} catch (final ArrayIndexOutOfBoundsException t) {
// Expected results
@@ -1781,9 +1482,7 @@ public class DynaPropertyUtilsTestCase extends TestCase {
}
try {
- PropertyUtils.setIndexedProperty(bean,
- "stringIndexed", -1,
- "New String");
+ PropertyUtils.setIndexedProperty(bean, "stringIndexed", -1, "New String");
fail("Should have thrown ArrayIndexOutOfBoundsException");
} catch (final ArrayIndexOutOfBoundsException t) {
// Expected results
@@ -1792,9 +1491,7 @@ public class DynaPropertyUtilsTestCase extends TestCase {
}
try {
- PropertyUtils.setIndexedProperty(bean,
- "stringIndexed", 5,
- "New String");
+ PropertyUtils.setIndexedProperty(bean, "stringIndexed", 5, "New String");
fail("Should have thrown ArrayIndexOutOfBoundsException");
} catch (final ArrayIndexOutOfBoundsException t) {
// Expected results
@@ -1812,8 +1509,7 @@ public class DynaPropertyUtilsTestCase extends TestCase {
// Use explicit key argument
try {
- PropertyUtils.setMappedProperty(null, "mappedProperty",
- "First Key", "First Value");
+ PropertyUtils.setMappedProperty(null, "mappedProperty", "First Key", "First Value");
fail("Should throw IllegalArgumentException 1");
} catch (final IllegalArgumentException e) {
// Expected response
@@ -1822,8 +1518,7 @@ public class DynaPropertyUtilsTestCase extends TestCase {
}
try {
- PropertyUtils.setMappedProperty(bean, null, "First Key",
- "First Value");
+ PropertyUtils.setMappedProperty(bean, null, "First Key", "First Value");
fail("Should throw IllegalArgumentException 2");
} catch (final IllegalArgumentException e) {
// Expected response
@@ -1832,8 +1527,7 @@ public class DynaPropertyUtilsTestCase extends TestCase {
}
try {
- PropertyUtils.setMappedProperty(bean, "mappedProperty", null,
- "First Value");
+ PropertyUtils.setMappedProperty(bean, "mappedProperty", null, "First Value");
fail("Should throw IllegalArgumentException 3");
} catch (final IllegalArgumentException e) {
// Expected response
@@ -1844,9 +1538,7 @@ public class DynaPropertyUtilsTestCase extends TestCase {
// Use key expression
try {
- PropertyUtils.setMappedProperty(null,
- "mappedProperty(First Key)",
- "First Value");
+ PropertyUtils.setMappedProperty(null, "mappedProperty(First Key)", "First Value");
fail("Should throw IllegalArgumentException 4");
} catch (final IllegalArgumentException e) {
// Expected response
@@ -1855,8 +1547,7 @@ public class DynaPropertyUtilsTestCase extends TestCase {
}
try {
- PropertyUtils.setMappedProperty(bean, "(Second Key)",
- "Second Value");
+ PropertyUtils.setMappedProperty(bean, "(Second Key)", "Second Value");
fail("Should throw IllegalArgumentException 5");
} catch (final NoSuchMethodException e) {
// Expected response
@@ -1865,8 +1556,7 @@ public class DynaPropertyUtilsTestCase extends TestCase {
}
try {
- PropertyUtils.setMappedProperty(bean, "mappedProperty",
- "Third Value");
+ PropertyUtils.setMappedProperty(bean, "mappedProperty", "Third Value");
fail("Should throw IllegalArgumentException 6");
} catch (final IllegalArgumentException e) {
// Expected response
@@ -1886,23 +1576,20 @@ public class DynaPropertyUtilsTestCase extends TestCase {
// Use explicit key argument
try {
- value = PropertyUtils.getMappedProperty(bean, "mappedProperty",
- "Fourth Key");
+ value = PropertyUtils.getMappedProperty(bean, "mappedProperty", "Fourth Key");
assertNull("Can not find fourth value", value);
} catch (final Throwable t) {
fail("Finding fourth value threw " + t);
}
try {
- PropertyUtils.setMappedProperty(bean, "mappedProperty",
- "Fourth Key", "Fourth Value");
+ PropertyUtils.setMappedProperty(bean, "mappedProperty", "Fourth Key", "Fourth Value");
} catch (final Throwable t) {
fail("Setting fourth value threw " + t);
}
try {
- value = PropertyUtils.getMappedProperty(bean, "mappedProperty",
- "Fourth Key");
+ value = PropertyUtils.getMappedProperty(bean, "mappedProperty", "Fourth Key");
assertEquals("Can find fourth value", "Fourth Value", value);
} catch (final Throwable t) {
fail("Finding fourth value threw " + t);
@@ -1911,26 +1598,20 @@ public class DynaPropertyUtilsTestCase extends TestCase {
// Use key expression with parentheses
try {
- value =
- PropertyUtils.getMappedProperty(bean,
- "mappedProperty(Fifth Key)");
+ value = PropertyUtils.getMappedProperty(bean, "mappedProperty(Fifth Key)");
assertNull("Can not find fifth value", value);
} catch (final Throwable t) {
fail("Finding fifth value threw " + t);
}
try {
- PropertyUtils.setMappedProperty(bean,
- "mappedProperty(Fifth Key)",
- "Fifth Value");
+ PropertyUtils.setMappedProperty(bean, "mappedProperty(Fifth Key)", "Fifth Value");
} catch (final Throwable t) {
fail("Setting fifth value threw " + t);
}
try {
- value =
- PropertyUtils.getMappedProperty(bean,
- "mappedProperty(Fifth Key)");
+ value = PropertyUtils.getMappedProperty(bean, "mappedProperty(Fifth Key)");
assertEquals("Can find fifth value", "Fifth Value", value);
} catch (final Throwable t) {
fail("Finding fifth value threw " + t);
@@ -1939,26 +1620,20 @@ public class DynaPropertyUtilsTestCase extends TestCase {
// Use key expression with dotted expression
try {
- value =
- PropertyUtils.getNestedProperty(bean,
- "mapProperty.Sixth Key");
+ value = PropertyUtils.getNestedProperty(bean, "mapProperty.Sixth Key");
assertNull("Can not find sixth value", value);
} catch (final Throwable t) {
fail("Finding fifth value threw " + t);
}
try {
- PropertyUtils.setNestedProperty(bean,
- "mapProperty.Sixth Key",
- "Sixth Value");
+ PropertyUtils.setNestedProperty(bean, "mapProperty.Sixth Key", "Sixth Value");
} catch (final Throwable t) {
fail("Setting sixth value threw " + t);
}
try {
- value =
- PropertyUtils.getNestedProperty(bean,
- "mapProperty.Sixth Key");
+ value = PropertyUtils.getNestedProperty(bean, "mapProperty.Sixth Key");
assertEquals("Can find sixth value", "Sixth Value", value);
} catch (final Throwable t) {
fail("Finding sixth value threw " + t);
@@ -1999,12 +1674,8 @@ public class DynaPropertyUtilsTestCase extends TestCase {
try {
final boolean oldValue = nested.getBooleanProperty();
final boolean newValue = !oldValue;
- PropertyUtils.setNestedProperty(bean,
- "nested.booleanProperty",
- Boolean.valueOf(newValue));
- assertTrue("Matched new value",
- newValue ==
- nested.getBooleanProperty());
+ PropertyUtils.setNestedProperty(bean, "nested.booleanProperty", Boolean.valueOf(newValue));
+ assertTrue("Matched new value", newValue == nested.getBooleanProperty());
} catch (final IllegalAccessException e) {
fail("IllegalAccessException");
} catch (final IllegalArgumentException e) {
@@ -2025,13 +1696,8 @@ public class DynaPropertyUtilsTestCase extends TestCase {
try {
final double oldValue = nested.getDoubleProperty();
final double newValue = oldValue + 1.0;
- PropertyUtils.setNestedProperty(bean,
- "nested.doubleProperty",
- Double.valueOf(newValue));
- assertEquals("Matched new value",
- newValue,
- nested.getDoubleProperty(),
- 0.005);
+ PropertyUtils.setNestedProperty(bean, "nested.doubleProperty", Double.valueOf(newValue));
+ assertEquals("Matched new value", newValue, nested.getDoubleProperty(), 0.005);
} catch (final IllegalAccessException e) {
fail("IllegalAccessException");
} catch (final IllegalArgumentException e) {
@@ -2052,13 +1718,8 @@ public class DynaPropertyUtilsTestCase extends TestCase {
try {
final float oldValue = nested.getFloatProperty();
final float newValue = oldValue + (float) 1.0;
- PropertyUtils.setNestedProperty(bean,
- "nested.floatProperty",
- Float.valueOf(newValue));
- assertEquals("Matched new value",
- newValue,
- nested.getFloatProperty(),
- (float) 0.005);
+ PropertyUtils.setNestedProperty(bean, "nested.floatProperty", Float.valueOf(newValue));
+ assertEquals("Matched new value", newValue, nested.getFloatProperty(), (float) 0.005);
} catch (final IllegalAccessException e) {
fail("IllegalAccessException");
} catch (final IllegalArgumentException e) {
@@ -2079,12 +1740,8 @@ public class DynaPropertyUtilsTestCase extends TestCase {
try {
final int oldValue = nested.getIntProperty();
final int newValue = oldValue + 1;
- PropertyUtils.setNestedProperty(bean,
- "nested.intProperty",
- Integer.valueOf(newValue));
- assertEquals("Matched new value",
- newValue,
- nested.getIntProperty());
+ PropertyUtils.setNestedProperty(bean, "nested.intProperty", Integer.valueOf(newValue));
+ assertEquals("Matched new value", newValue, nested.getIntProperty());
} catch (final IllegalAccessException e) {
fail("IllegalAccessException");
} catch (final IllegalArgumentException e) {
@@ -2105,12 +1762,8 @@ public class DynaPropertyUtilsTestCase extends TestCase {
try {
final long oldValue = nested.getLongProperty();
final long newValue = oldValue + 1;
- PropertyUtils.setNestedProperty(bean,
- "nested.longProperty",
- Long.valueOf(newValue));
- assertEquals("Matched new value",
- newValue,
- nested.getLongProperty());
+ PropertyUtils.setNestedProperty(bean, "nested.longProperty", Long.valueOf(newValue));
+ assertEquals("Matched new value", newValue, nested.getLongProperty());
} catch (final IllegalAccessException e) {
fail("IllegalAccessException");
} catch (final IllegalArgumentException e) {
@@ -2131,9 +1784,7 @@ public class DynaPropertyUtilsTestCase extends TestCase {
try {
final String oldValue = nested.getWriteOnlyPropertyValue();
final String newValue = oldValue + " Extra Value";
- PropertyUtils.setNestedProperty(bean,
- "nested.readOnlyProperty",
- newValue);
+ PropertyUtils.setNestedProperty(bean, "nested.readOnlyProperty", newValue);
fail("Should have thrown NoSuchMethodException");
} catch (final IllegalAccessException e) {
fail("IllegalAccessException");
@@ -2156,12 +1807,8 @@ public class DynaPropertyUtilsTestCase extends TestCase {
final short oldValue = nested.getShortProperty();
short newValue = oldValue;
newValue++;
- PropertyUtils.setNestedProperty(bean,
- "nested.shortProperty",
- Short.valueOf(newValue));
- assertEquals("Matched new value",
- newValue,
- nested.getShortProperty());
+ PropertyUtils.setNestedProperty(bean, "nested.shortProperty", Short.valueOf(newValue));
+ assertEquals("Matched new value", newValue, nested.getShortProperty());
} catch (final IllegalAccessException e) {
fail("IllegalAccessException");
} catch (final IllegalArgumentException e) {
@@ -2182,12 +1829,8 @@ public class DynaPropertyUtilsTestCase extends TestCase {
try {
final String oldValue = nested.getStringProperty();
final String newValue = oldValue + " Extra Value";
- PropertyUtils.setNestedProperty(bean,
- "nested.stringProperty",
- newValue);
- assertEquals("Matched new value",
- newValue,
- nested.getStringProperty());
+ PropertyUtils.setNestedProperty(bean, "nested.stringProperty", newValue);
+ assertEquals("Matched new value", newValue, nested.getStringProperty());
} catch (final IllegalAccessException e) {
fail("IllegalAccessException");
} catch (final IllegalArgumentException e) {
@@ -2207,9 +1850,7 @@ public class DynaPropertyUtilsTestCase extends TestCase {
try {
final String newValue = "New String Value";
- PropertyUtils.setNestedProperty(bean,
- "nested.unknown",
- newValue);
+ PropertyUtils.setNestedProperty(bean, "nested.unknown", newValue);
fail("Should have thrown NoSuchMethodException");
} catch (final IllegalAccessException e) {
fail("IllegalAccessException");
@@ -2231,12 +1872,8 @@ public class DynaPropertyUtilsTestCase extends TestCase {
try {
final String oldValue = nested.getWriteOnlyPropertyValue();
final String newValue = oldValue + " Extra Value";
- PropertyUtils.setNestedProperty(bean,
- "nested.writeOnlyProperty",
- newValue);
- assertEquals("Matched new value",
- newValue,
- nested.getWriteOnlyPropertyValue());
+ PropertyUtils.setNestedProperty(bean, "nested.writeOnlyProperty", newValue);
+ assertEquals("Matched new value", newValue, nested.getWriteOnlyPropertyValue());
} catch (final IllegalAccessException e) {
fail("IllegalAccessException");
} catch (final IllegalArgumentException e) {
@@ -2282,12 +1919,8 @@ public class DynaPropertyUtilsTestCase extends TestCase {
try {
final boolean oldValue = ((Boolean) bean.get("booleanProperty")).booleanValue();
final boolean newValue = !oldValue;
- PropertyUtils.setSimpleProperty(bean,
- "booleanProperty",
- Boolean.valueOf(newValue));
- assertTrue("Matched new value",
- newValue ==
- ((Boolean) bean.get("booleanProperty")).booleanValue());
+ PropertyUtils.setSimpleProperty(bean, "booleanProperty", Boolean.valueOf(newValue));
+ assertTrue("Matched new value", newValue == ((Boolean) bean.get("booleanProperty")).booleanValue());
} catch (final IllegalAccessException e) {
fail("IllegalAccessException");
} catch (final IllegalArgumentException e) {
@@ -2308,13 +1941,8 @@ public class DynaPropertyUtilsTestCase extends TestCase {
try {
final double oldValue = ((Double) bean.get("doubleProperty")).doubleValue();
final double newValue = oldValue + 1.0;
- PropertyUtils.setSimpleProperty(bean,
- "doubleProperty",
- Double.valueOf(newValue));
- assertEquals("Matched new value",
- newValue,
- ((Double) bean.get("doubleProperty")).doubleValue(),
- 0.005);
+ PropertyUtils.setSimpleProperty(bean, "doubleProperty", Double.valueOf(newValue));
+ assertEquals("Matched new value", newValue, ((Double) bean.get("doubleProperty")).doubleValue(), 0.005);
} catch (final IllegalAccessException e) {
fail("IllegalAccessException");
} catch (final IllegalArgumentException e) {
@@ -2335,13 +1963,8 @@ public class DynaPropertyUtilsTestCase extends TestCase {
try {
final float oldValue = ((Float) bean.get("floatProperty")).floatValue();
final float newValue = oldValue + (float) 1.0;
- PropertyUtils.setSimpleProperty(bean,
- "floatProperty",
- Float.valueOf(newValue));
- assertEquals("Matched new value",
- newValue,
- ((Float) bean.get("floatProperty")).floatValue(),
- (float) 0.005);
+ PropertyUtils.setSimpleProperty(bean, "floatProperty", Float.valueOf(newValue));
+ assertEquals("Matched new value", newValue, ((Float) bean.get("floatProperty")).floatValue(), (float) 0.005);
} catch (final IllegalAccessException e) {
fail("IllegalAccessException");
} catch (final IllegalArgumentException e) {
@@ -2360,9 +1983,7 @@ public class DynaPropertyUtilsTestCase extends TestCase {
public void testSetSimpleIndexed() {
try {
- PropertyUtils.setSimpleProperty(bean,
- "stringIndexed[0]",
- "New String Value");
+ PropertyUtils.setSimpleProperty(bean, "stringIndexed[0]", "New String Value");
fail("Should have thrown IllegalArgumentException");
} catch (final IllegalAccessException e) {
fail("IllegalAccessException");
@@ -2384,12 +2005,8 @@ public class DynaPropertyUtilsTestCase extends TestCase {
try {
final int oldValue = ((Integer) bean.get("intProperty")).intValue();
final int newValue = oldValue + 1;
- PropertyUtils.setSimpleProperty(bean,
- "intProperty",
- Integer.valueOf(newValue));
- assertEquals("Matched new value",
- newValue,
- ((Integer) bean.get("intProperty")).intValue());
+ PropertyUtils.setSimpleProperty(bean, "intProperty", Integer.valueOf(newValue));
+ assertEquals("Matched new value", newValue, ((Integer) bean.get("intProperty")).intValue());
} catch (final IllegalAccessException e) {
fail("IllegalAccessException");
} catch (final IllegalArgumentException e) {
@@ -2410,12 +2027,8 @@ public class DynaPropertyUtilsTestCase extends TestCase {
try {
final long oldValue = ((Long) bean.get("longProperty")).longValue();
final long newValue = oldValue + 1;
- PropertyUtils.setSimpleProperty(bean,
- "longProperty",
- Long.valueOf(newValue));
- assertEquals("Matched new value",
- newValue,
- ((Long) bean.get("longProperty")).longValue());
+ PropertyUtils.setSimpleProperty(bean, "longProperty", Long.valueOf(newValue));
+ assertEquals("Matched new value", newValue, ((Long) bean.get("longProperty")).longValue());
} catch (final IllegalAccessException e) {
fail("IllegalAccessException");
} catch (final IllegalArgumentException e) {
@@ -2434,9 +2047,7 @@ public class DynaPropertyUtilsTestCase extends TestCase {
public void testSetSimpleNested() {
try {
- PropertyUtils.setSimpleProperty(bean,
- "nested.stringProperty",
- "New String Value");
+ PropertyUtils.setSimpleProperty(bean, "nested.stringProperty", "New String Value");
fail("Should have thrown IllegalArgumentException");
} catch (final IllegalAccessException e) {
fail("IllegalAccessException");
@@ -2459,12 +2070,8 @@ public class DynaPropertyUtilsTestCase extends TestCase {
final short oldValue = ((Short) bean.get("shortProperty")).shortValue();
short newValue = oldValue;
newValue++;
- PropertyUtils.setSimpleProperty(bean,
- "shortProperty",
- Short.valueOf(newValue));
- assertEquals("Matched new value",
- newValue,
- ((Short) bean.get("shortProperty")).shortValue());
+ PropertyUtils.setSimpleProperty(bean, "shortProperty", Short.valueOf(newValue));
+ assertEquals("Matched new value", newValue, ((Short) bean.get("shortProperty")).shortValue());
} catch (final IllegalAccessException e) {
fail("IllegalAccessException");
} catch (final IllegalArgumentException e) {
@@ -2485,12 +2092,8 @@ public class DynaPropertyUtilsTestCase extends TestCase {
try {
final String oldValue = (String) bean.get("stringProperty");
final String newValue = oldValue + " Extra Value";
- PropertyUtils.setSimpleProperty(bean,
- "stringProperty",
- newValue);
- assertEquals("Matched new value",
- newValue,
- (String) bean.get("stringProperty"));
+ PropertyUtils.setSimpleProperty(bean, "stringProperty", newValue);
+ assertEquals("Matched new value", newValue, (String) bean.get("stringProperty"));
} catch (final IllegalAccessException e) {
fail("IllegalAccessException");
} catch (final IllegalArgumentException e) {
@@ -2510,9 +2113,7 @@ public class DynaPropertyUtilsTestCase extends TestCase {
try {
final String newValue = "New String Value";
- PropertyUtils.setSimpleProperty(bean,
- "unknown",
- newValue);
+ PropertyUtils.setSimpleProperty(bean, "unknown", newValue);
fail("Should have thrown NoSuchMethodException");
} catch (final IllegalAccessException e) {
fail("IllegalAccessException");
@@ -2522,47 +2123,28 @@ public class DynaPropertyUtilsTestCase extends TestCase {
fail("InvocationTargetException");
} catch (final NoSuchMethodException e) {
// Correct result for this test
- assertEquals("Unknown property 'unknown' on dynaclass '" +
- bean.getDynaClass() + "'", e.getMessage() );
+ assertEquals("Unknown property 'unknown' on dynaclass '" + bean.getDynaClass() + "'", e.getMessage());
}
}
-
-
/**
- * Create and return a {@code DynaClass} instance for our test
- * {@code DynaBean}.
+ * Create and return a {@code DynaClass} instance for our test {@code DynaBean}.
*/
protected DynaClass createDynaClass() {
final int[] intArray = {};
final String[] stringArray = {};
- final DynaClass dynaClass = new BasicDynaClass
- ("TestDynaClass", null,
- new DynaProperty[]{
- new DynaProperty("booleanProperty", Boolean.TYPE),
- new DynaProperty("booleanSecond", Boolean.TYPE),
- new DynaProperty("doubleProperty", Double.TYPE),
- new DynaProperty("dupProperty", stringArray.getClass()),
- new DynaProperty("floatProperty", Float.TYPE),
- new DynaProperty("intArray", intArray.getClass()),
- new DynaProperty("intIndexed", intArray.getClass()),
- new DynaProperty("intProperty", Integer.TYPE),
- new DynaProperty("listIndexed", List.class),
- new DynaProperty("longProperty", Long.TYPE),
- new DynaProperty("mapProperty", Map.class),
- new DynaProperty("mappedObjects", Map.class),
- new DynaProperty("mappedProperty", Map.class),
- new DynaProperty("mappedIntProperty", Map.class),
- new DynaProperty("nested", TestBean.class),
- new DynaProperty("nullProperty", String.class),
- new DynaProperty("shortProperty", Short.TYPE),
- new DynaProperty("stringArray", stringArray.getClass()),
- new DynaProperty("stringIndexed", stringArray.getClass()),
- new DynaProperty("stringProperty", String.class),
- });
+ final DynaClass dynaClass = new BasicDynaClass("TestDynaClass", null, new DynaProperty[] { new DynaProperty("booleanProperty", Boolean.TYPE),
+ new DynaProperty("booleanSecond", Boolean.TYPE), new DynaProperty("doubleProperty", Double.TYPE),
+ new DynaProperty("dupProperty", stringArray.getClass()), new DynaProperty("floatProperty", Float.TYPE),
+ new DynaProperty("intArray", intArray.getClass()), new DynaProperty("intIndexed", intArray.getClass()),
+ new DynaProperty("intProperty", Integer.TYPE), new DynaProperty("listIndexed", List.class), new DynaProperty("longProperty", Long.TYPE),
+ new DynaProperty("mapProperty", Map.class), new DynaProperty("mappedObjects", Map.class), new DynaProperty("mappedProperty", Map.class),
+ new DynaProperty("mappedIntProperty", Map.class), new DynaProperty("nested", TestBean.class), new DynaProperty("nullProperty", String.class),
+ new DynaProperty("shortProperty", Short.TYPE), new DynaProperty("stringArray", stringArray.getClass()),
+ new DynaProperty("stringIndexed", stringArray.getClass()), new DynaProperty("stringProperty", String.class), });
return dynaClass;
}
diff --git a/src/test/java/org/apache/commons/beanutils2/ExtendMapBean.java b/src/test/java/org/apache/commons/beanutils2/ExtendMapBean.java
index f2b13d17..8211341f 100644
--- a/src/test/java/org/apache/commons/beanutils2/ExtendMapBean.java
+++ b/src/test/java/org/apache/commons/beanutils2/ExtendMapBean.java
@@ -28,15 +28,14 @@ public class ExtendMapBean extends Hashtable<Object, Object> {
private String dbName = "[UNSET]";
- public ExtendMapBean() {}
+ public ExtendMapBean() {
+ }
- public String getUnusuallyNamedProperty()
- {
+ public String getUnusuallyNamedProperty() {
return dbName;
}
- public void setUnusuallyNamedProperty(final String dbName)
- {
+ public void setUnusuallyNamedProperty(final String dbName) {
this.dbName = dbName;
}
diff --git a/src/test/java/org/apache/commons/beanutils2/FluentIntrospectionTestBean.java b/src/test/java/org/apache/commons/beanutils2/FluentIntrospectionTestBean.java
index 7c368c6f..d22c4b73 100644
--- a/src/test/java/org/apache/commons/beanutils2/FluentIntrospectionTestBean.java
+++ b/src/test/java/org/apache/commons/beanutils2/FluentIntrospectionTestBean.java
@@ -42,8 +42,7 @@ public class FluentIntrospectionTestBean extends AlphaBean {
return fluentGetProperty;
}
- public FluentIntrospectionTestBean setFluentGetProperty(
- final String fluentGetProperty) {
+ public FluentIntrospectionTestBean setFluentGetProperty(final String fluentGetProperty) {
this.fluentGetProperty = fluentGetProperty;
return this;
}
diff --git a/src/test/java/org/apache/commons/beanutils2/FluentPropertyBeanIntrospectorTestCase.java b/src/test/java/org/apache/commons/beanutils2/FluentPropertyBeanIntrospectorTestCase.java
index 1a3f559f..a3b171fc 100644
--- a/src/test/java/org/apache/commons/beanutils2/FluentPropertyBeanIntrospectorTestCase.java
+++ b/src/test/java/org/apache/commons/beanutils2/FluentPropertyBeanIntrospectorTestCase.java
@@ -30,14 +30,12 @@ import junit.framework.TestCase;
*/
public class FluentPropertyBeanIntrospectorTestCase extends TestCase {
/**
- * Puts all property descriptors into a map so that they can be accessed by
- * property name.
+ * Puts all property descriptors into a map so that they can be accessed by property name.
*
* @param descs the array with descriptors
* @return a map with property names as keys
*/
- private static Map<String, PropertyDescriptor> createDescriptorMap(
- final PropertyDescriptor[] descs) {
+ private static Map<String, PropertyDescriptor> createDescriptorMap(final PropertyDescriptor[] descs) {
final Map<String, PropertyDescriptor> map = new HashMap<>();
for (final PropertyDescriptor pd : descs) {
map.put(pd.getName(), pd);
@@ -46,15 +44,13 @@ public class FluentPropertyBeanIntrospectorTestCase extends TestCase {
}
/**
- * Convenience method for obtaining a specific property descriptor and
- * checking whether it exists.
+ * Convenience method for obtaining a specific property descriptor and checking whether it exists.
*
* @param props the map with property descriptors
- * @param name the name of the desired descriptor
+ * @param name the name of the desired descriptor
* @return the descriptor from the map
*/
- private static PropertyDescriptor fetchDescriptor(
- final Map<String, PropertyDescriptor> props, final String name) {
+ private static PropertyDescriptor fetchDescriptor(final Map<String, PropertyDescriptor> props, final String name) {
assertTrue("Property not found: " + name, props.containsKey(name));
return props.get(name);
}
@@ -78,8 +74,7 @@ public class FluentPropertyBeanIntrospectorTestCase extends TestCase {
final PropertyUtilsBean pu = new PropertyUtilsBean();
final FluentPropertyBeanIntrospector introspector = new FluentPropertyBeanIntrospector();
pu.addBeanIntrospector(introspector);
- final Map<String, PropertyDescriptor> props = createDescriptorMap(pu
- .getPropertyDescriptors(FluentIntrospectionTestBean.class));
+ final Map<String, PropertyDescriptor> props = createDescriptorMap(pu.getPropertyDescriptors(FluentIntrospectionTestBean.class));
PropertyDescriptor pd = fetchDescriptor(props, "name");
assertNotNull("No read method for name", pd.getReadMethod());
assertNotNull("No write method for name", pd.getWriteMethod());
@@ -88,10 +83,8 @@ public class FluentPropertyBeanIntrospectorTestCase extends TestCase {
assertNull("Read method for fluentProperty", pd.getReadMethod());
assertNotNull("No write method for fluentProperty", pd.getWriteMethod());
pd = fetchDescriptor(props, "fluentGetProperty");
- assertNotNull("No read method for fluentGetProperty",
- pd.getReadMethod());
- assertNotNull("No write method for fluentGetProperty",
- pd.getWriteMethod());
+ assertNotNull("No read method for fluentGetProperty", pd.getReadMethod());
+ assertNotNull("No write method for fluentGetProperty", pd.getWriteMethod());
}
public void testIntrospectionCaps() throws Exception {
@@ -101,8 +94,7 @@ public class FluentPropertyBeanIntrospectorTestCase extends TestCase {
pu.addBeanIntrospector(introspector);
- final Map<String, PropertyDescriptor> props = createDescriptorMap(
- pu.getPropertyDescriptors(CapsBean.class));
+ final Map<String, PropertyDescriptor> props = createDescriptorMap(pu.getPropertyDescriptors(CapsBean.class));
final PropertyDescriptor aDescriptor = fetchDescriptor(props, "URI");
diff --git a/src/test/java/org/apache/commons/beanutils2/IndexedPropertyTestCase.java b/src/test/java/org/apache/commons/beanutils2/IndexedPropertyTestCase.java
index a1eb4abc..b2f49396 100644
--- a/src/test/java/org/apache/commons/beanutils2/IndexedPropertyTestCase.java
+++ b/src/test/java/org/apache/commons/beanutils2/IndexedPropertyTestCase.java
@@ -32,14 +32,14 @@ import org.junit.Before;
import org.junit.Test;
/**
- * <p>Test Case for the Indexed Properties.</p>
+ * <p>
+ * Test Case for the Indexed Properties.
+ * </p>
*
*/
public class IndexedPropertyTestCase {
-
-
/**
* The test bean for each test.
*/
@@ -52,8 +52,6 @@ public class IndexedPropertyTestCase {
private List<Object> newList;
private ArrayList<Object> arrayList;
-
-
/**
* Sets up instance variables required by this test case.
*/
@@ -65,8 +63,8 @@ public class IndexedPropertyTestCase {
propertyUtilsBean = beanUtilsBean.getPropertyUtils();
// initialize Arrays and Lists
- testArray= new String[] {"array-0", "array-1", "array-2"};
- newArray = new String[] {"newArray-0", "newArray-1", "newArray-2"};
+ testArray = new String[] { "array-0", "array-1", "array-2" };
+ newArray = new String[] { "newArray-0", "newArray-1", "newArray-2" };
testList = new ArrayList<>();
testList.add("list-0");
@@ -83,7 +81,7 @@ public class IndexedPropertyTestCase {
arrayList.add("arrayList-1");
arrayList.add("arrayList-2");
- // initialize Test Bean properties
+ // initialize Test Bean properties
bean = new IndexedTestBean();
bean.setStringArray(testArray);
bean.setStringList(testList);
@@ -98,8 +96,6 @@ public class IndexedPropertyTestCase {
bean = null;
}
-
-
/**
* Test IndexedPropertyDescriptor for an Array
*/
@@ -107,12 +103,8 @@ public class IndexedPropertyTestCase {
public void testArrayIndexedPropertyDescriptor() throws Exception {
final PropertyDescriptor descriptor = propertyUtilsBean.getPropertyDescriptor(bean, "stringArray");
assertNotNull("No Array Descriptor", descriptor);
- assertEquals("Not IndexedPropertyDescriptor",
- IndexedPropertyDescriptor.class,
- descriptor.getClass());
- assertEquals("PropertyDescriptor Type invalid",
- testArray.getClass(),
- descriptor.getPropertyType());
+ assertEquals("Not IndexedPropertyDescriptor", IndexedPropertyDescriptor.class, descriptor.getClass());
+ assertEquals("PropertyDescriptor Type invalid", testArray.getClass(), descriptor.getPropertyType());
}
/**
@@ -124,12 +116,9 @@ public class IndexedPropertyTestCase {
assertNotNull("No List Descriptor", descriptor);
if (Jira492IndexedListsSupport.supportsIndexedLists()) {
// BEANUTILS-492 - can't assume lists are handled as arrays in Java 8+
- assertEquals("Not IndexedPropertyDescriptor",
- IndexedPropertyDescriptor.class, descriptor.getClass());
+ assertEquals("Not IndexedPropertyDescriptor", IndexedPropertyDescriptor.class, descriptor.getClass());
}
- assertEquals("PropertyDescriptor Type invalid",
- List.class,
- descriptor.getPropertyType());
+ assertEquals("PropertyDescriptor Type invalid", List.class, descriptor.getPropertyType());
}
/**
@@ -140,12 +129,9 @@ public class IndexedPropertyTestCase {
final PropertyDescriptor descriptor = propertyUtilsBean.getPropertyDescriptor(bean, "arrayList");
assertNotNull("No ArrayList Descriptor", descriptor);
if (Jira492IndexedListsSupport.supportsIndexedLists()) {
- assertEquals("Not IndexedPropertyDescriptor",
- IndexedPropertyDescriptor.class, descriptor.getClass());
+ assertEquals("Not IndexedPropertyDescriptor", IndexedPropertyDescriptor.class, descriptor.getClass());
}
- assertEquals("PropertyDescriptor Type invalid",
- ArrayList.class,
- descriptor.getPropertyType());
+ assertEquals("PropertyDescriptor Type invalid", ArrayList.class, descriptor.getPropertyType());
}
/**
@@ -153,8 +139,7 @@ public class IndexedPropertyTestCase {
*/
@Test
public void testArrayReadMethod() throws Exception {
- final PropertyDescriptor descriptor =
- propertyUtilsBean.getPropertyDescriptor(bean, "stringArray");
+ final PropertyDescriptor descriptor = propertyUtilsBean.getPropertyDescriptor(bean, "stringArray");
assertNotNull("No Array Read Method", descriptor.getReadMethod());
}
@@ -163,8 +148,7 @@ public class IndexedPropertyTestCase {
*/
@Test
public void testArrayWriteMethod() throws Exception {
- final PropertyDescriptor descriptor =
- propertyUtilsBean.getPropertyDescriptor(bean, "stringArray");
+ final PropertyDescriptor descriptor = propertyUtilsBean.getPropertyDescriptor(bean, "stringArray");
assertNotNull("No Array Write Method", descriptor.getWriteMethod());
}
@@ -173,8 +157,7 @@ public class IndexedPropertyTestCase {
*/
@Test
public void testArrayIndexedReadMethod() throws Exception {
- final IndexedPropertyDescriptor descriptor =
- (IndexedPropertyDescriptor)propertyUtilsBean.getPropertyDescriptor(bean, "stringArray");
+ final IndexedPropertyDescriptor descriptor = (IndexedPropertyDescriptor) propertyUtilsBean.getPropertyDescriptor(bean, "stringArray");
assertNotNull("No Array Indexed Read Method", descriptor.getIndexedReadMethod());
}
@@ -183,36 +166,29 @@ public class IndexedPropertyTestCase {
*/
@Test
public void testArrayIndexedWriteMethod() throws Exception {
- final IndexedPropertyDescriptor descriptor =
- (IndexedPropertyDescriptor)propertyUtilsBean.getPropertyDescriptor(bean, "stringArray");
+ final IndexedPropertyDescriptor descriptor = (IndexedPropertyDescriptor) propertyUtilsBean.getPropertyDescriptor(bean, "stringArray");
assertNotNull("No Array Indexed Write Method", descriptor.getIndexedWriteMethod());
}
/**
* Test Read Method for a List
*
- * JDK 1.3.1_04: Test Passes
- * JDK 1.4.2_05: Test Fails - getter which returns java.util.List not returned
- * by IndexedPropertyDescriptor.getReadMethod();
+ * JDK 1.3.1_04: Test Passes JDK 1.4.2_05: Test Fails - getter which returns java.util.List not returned by IndexedPropertyDescriptor.getReadMethod();
*/
@Test
public void testListReadMethod() throws Exception {
- final PropertyDescriptor descriptor =
- propertyUtilsBean.getPropertyDescriptor(bean, "stringList");
+ final PropertyDescriptor descriptor = propertyUtilsBean.getPropertyDescriptor(bean, "stringList");
assertNotNull("No List Read Method", descriptor.getReadMethod());
}
/**
* Test Write Method for a List
*
- * JDK 1.3.1_04: Test Passes
- * JDK 1.4.2_05: Test Fails - setter which java.util.List argument not returned
- * by IndexedPropertyDescriptor.getWriteMethod();
+ * JDK 1.3.1_04: Test Passes JDK 1.4.2_05: Test Fails - setter which java.util.List argument not returned by IndexedPropertyDescriptor.getWriteMethod();
*/
@Test
public void testListWriteMethod() throws Exception {
- final PropertyDescriptor descriptor =
- propertyUtilsBean.getPropertyDescriptor(bean, "stringList");
+ final PropertyDescriptor descriptor = propertyUtilsBean.getPropertyDescriptor(bean, "stringList");
assertNotNull("No List Write Method", descriptor.getWriteMethod());
}
@@ -223,9 +199,8 @@ public class IndexedPropertyTestCase {
public void testListIndexedReadMethod() throws Exception {
final PropertyDescriptor descriptor = propertyUtilsBean.getPropertyDescriptor(bean, "stringList");
assertNotNull("stringList descriptor not found", descriptor);
- assumeTrue("JDK does not support index bean properties on java.util.List",
- Jira492IndexedListsSupport.supportsIndexedLists());
- assertNotNull("No List Indexed Read Method", ((IndexedPropertyDescriptor)descriptor).getIndexedReadMethod());
+ assumeTrue("JDK does not support index bean properties on java.util.List", Jira492IndexedListsSupport.supportsIndexedLists());
+ assertNotNull("No List Indexed Read Method", ((IndexedPropertyDescriptor) descriptor).getIndexedReadMethod());
}
/**
@@ -235,9 +210,8 @@ public class IndexedPropertyTestCase {
public void testListIndexedWriteMethod() throws Exception {
final PropertyDescriptor descriptor = propertyUtilsBean.getPropertyDescriptor(bean, "stringList");
assertNotNull("stringList descriptor not found", descriptor);
- assumeTrue("JDK does not support index bean properties on java.util.List",
- Jira492IndexedListsSupport.supportsIndexedLists());
- assertNotNull("No List Indexed Write Method", ((IndexedPropertyDescriptor)descriptor).getIndexedWriteMethod());
+ assumeTrue("JDK does not support index bean properties on java.util.List", Jira492IndexedListsSupport.supportsIndexedLists());
+ assertNotNull("No List Indexed Write Method", ((IndexedPropertyDescriptor) descriptor).getIndexedWriteMethod());
}
/**
@@ -245,8 +219,7 @@ public class IndexedPropertyTestCase {
*/
@Test
public void testArrayListReadMethod() throws Exception {
- final PropertyDescriptor descriptor =
- propertyUtilsBean.getPropertyDescriptor(bean, "arrayList");
+ final PropertyDescriptor descriptor = propertyUtilsBean.getPropertyDescriptor(bean, "arrayList");
assertNotNull("No ArrayList Read Method", descriptor.getReadMethod());
}
@@ -255,8 +228,7 @@ public class IndexedPropertyTestCase {
*/
@Test
public void testArrayListWriteMethod() throws Exception {
- final PropertyDescriptor descriptor =
- propertyUtilsBean.getPropertyDescriptor(bean, "arrayList");
+ final PropertyDescriptor descriptor = propertyUtilsBean.getPropertyDescriptor(bean, "arrayList");
assertNotNull("No ArrayList Write Method", descriptor.getWriteMethod());
}
@@ -265,20 +237,17 @@ public class IndexedPropertyTestCase {
*/
@Test
public void testGetArray() throws Exception {
- assertEquals(testArray,
- propertyUtilsBean.getProperty(bean, "stringArray"));
+ assertEquals(testArray, propertyUtilsBean.getProperty(bean, "stringArray"));
}
/**
* Test getting an array property as a String
*
- * NOTE: Why does retrieving array just return the first element in the array, whereas
- * retrieving a List returns a comma separated list of all the elements?
+ * NOTE: Why does retrieving array just return the first element in the array, whereas retrieving a List returns a comma separated list of all the elements?
*/
@Test
public void testGetArrayAsString() throws Exception {
- assertEquals("array-0",
- beanUtilsBean.getProperty(bean, "stringArray"));
+ assertEquals("array-0", beanUtilsBean.getProperty(bean, "stringArray"));
}
/**
@@ -286,8 +255,7 @@ public class IndexedPropertyTestCase {
*/
@Test
public void testGetArrayItemA() throws Exception {
- assertEquals("array-1",
- beanUtilsBean.getProperty(bean, "stringArray[1]"));
+ assertEquals("array-1", beanUtilsBean.getProperty(bean, "stringArray[1]"));
}
/**
@@ -295,34 +263,27 @@ public class IndexedPropertyTestCase {
*/
@Test
public void testGetArrayItemB() throws Exception {
- assertEquals("array-1",
- beanUtilsBean.getIndexedProperty(bean, "stringArray", 1));
+ assertEquals("array-1", beanUtilsBean.getIndexedProperty(bean, "stringArray", 1));
}
/**
* Test getting a List
*
- * JDK 1.3.1_04: Test Passes
- * JDK 1.4.2_05: Test Fails - fails NoSuchMethodException, i.e. reason as testListReadMethod()
- * failed.
+ * JDK 1.3.1_04: Test Passes JDK 1.4.2_05: Test Fails - fails NoSuchMethodException, i.e. reason as testListReadMethod() failed.
*/
@Test
public void testGetList() throws Exception {
- assertEquals(testList,
- propertyUtilsBean.getProperty(bean, "stringList"));
+ assertEquals(testList, propertyUtilsBean.getProperty(bean, "stringList"));
}
/**
* Test getting a List property as a String
*
- * JDK 1.3.1_04: Test Passes
- * JDK 1.4.2_05: Test Fails - fails NoSuchMethodException, i.e. reason as testListReadMethod()
- * failed.
+ * JDK 1.3.1_04: Test Passes JDK 1.4.2_05: Test Fails - fails NoSuchMethodException, i.e. reason as testListReadMethod() failed.
*/
@Test
public void testGetListAsString() throws Exception {
- assertEquals("list-0",
- beanUtilsBean.getProperty(bean, "stringList"));
+ assertEquals("list-0", beanUtilsBean.getProperty(bean, "stringList"));
}
/**
@@ -330,8 +291,7 @@ public class IndexedPropertyTestCase {
*/
@Test
public void testGetListItemA() throws Exception {
- assertEquals("list-1",
- beanUtilsBean.getProperty(bean, "stringList[1]"));
+ assertEquals("list-1", beanUtilsBean.getProperty(bean, "stringList[1]"));
}
/**
@@ -339,8 +299,7 @@ public class IndexedPropertyTestCase {
*/
@Test
public void testGetListItemB() throws Exception {
- assertEquals("list-1",
- beanUtilsBean.getIndexedProperty(bean, "stringList", 1));
+ assertEquals("list-1", beanUtilsBean.getIndexedProperty(bean, "stringList", 1));
}
/**
@@ -348,10 +307,9 @@ public class IndexedPropertyTestCase {
*
* JDK 1.3.1_04 and 1.4.2_05: Test Fails - IllegalArgumentException can't invoke setter, argument type mismatch
*
- * Fails because of a bug in BeanUtilsBean.setProperty() method. Value is always converted to the array's component
- * type which in this case is a String. Then it calls the setStringArray(String[]) passing a String rather than
- * String[] causing this exception. If there isn't an "index" value then the PropertyType (rather than
- * IndexedPropertyType) should be used.
+ * Fails because of a bug in BeanUtilsBean.setProperty() method. Value is always converted to the array's component type which in this case is a String.
+ * Then it calls the setStringArray(String[]) passing a String rather than String[] causing this exception. If there isn't an "index" value then the
+ * PropertyType (rather than IndexedPropertyType) should be used.
*
*/
@Test
@@ -359,7 +317,7 @@ public class IndexedPropertyTestCase {
beanUtilsBean.setProperty(bean, "stringArray", newArray);
final Object value = bean.getStringArray();
assertEquals("Type is different", newArray.getClass(), value.getClass());
- final String[] array = (String[])value;
+ final String[] array = (String[]) value;
assertEquals("Array Length is different", newArray.length, array.length);
for (int i = 0; i < array.length; i++) {
assertEquals("Element " + i + " is different", newArray[i], array[i]);
@@ -387,17 +345,15 @@ public class IndexedPropertyTestCase {
/**
* Test setting a List property
*
- * JDK 1.3.1_04: Test Passes
- * JDK 1.4.2_05: Test Fails - setter which returns java.util.List not returned
- * by IndexedPropertyDescriptor.getWriteMethod() - therefore
- * setProperty does nothing and values remain unchanged.
+ * JDK 1.3.1_04: Test Passes JDK 1.4.2_05: Test Fails - setter which returns java.util.List not returned by IndexedPropertyDescriptor.getWriteMethod() -
+ * therefore setProperty does nothing and values remain unchanged.
*/
@Test
public void testSetList() throws Exception {
beanUtilsBean.setProperty(bean, "stringList", newList);
final Object value = bean.getStringList();
assertEquals("Type is different", newList.getClass(), value.getClass());
- final List<?> list = (List<?>)value;
+ final 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));
@@ -427,8 +383,7 @@ public class IndexedPropertyTestCase {
*/
@Test
public void testGetArrayList() throws Exception {
- assertEquals(arrayList,
- propertyUtilsBean.getProperty(bean, "arrayList"));
+ assertEquals(arrayList, propertyUtilsBean.getProperty(bean, "arrayList"));
}
/**
@@ -439,7 +394,7 @@ public class IndexedPropertyTestCase {
beanUtilsBean.setProperty(bean, "arrayList", newList);
final Object value = bean.getArrayList();
assertEquals("Type is different", newList.getClass(), value.getClass());
- final List<?> list = (List<?>)value;
+ final 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));
diff --git a/src/test/java/org/apache/commons/beanutils2/IndexedTestBean.java b/src/test/java/org/apache/commons/beanutils2/IndexedTestBean.java
index e90199e8..30aa8a00 100644
--- a/src/test/java/org/apache/commons/beanutils2/IndexedTestBean.java
+++ b/src/test/java/org/apache/commons/beanutils2/IndexedTestBean.java
@@ -30,8 +30,6 @@ public class IndexedTestBean {
private List<String> stringList;
private ArrayList<Object> arrayList;
-
-
/**
* Default Constructor.
*/
diff --git a/src/test/java/org/apache/commons/beanutils2/LazyDynaBeanTestCase.java b/src/test/java/org/apache/commons/beanutils2/LazyDynaBeanTestCase.java
index f7bd39c3..30707950 100644
--- a/src/test/java/org/apache/commons/beanutils2/LazyDynaBeanTestCase.java
+++ b/src/test/java/org/apache/commons/beanutils2/LazyDynaBeanTestCase.java
@@ -27,21 +27,23 @@ import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
- * <p>Test Case for the {@code LazyDynaBean} implementation class.</p>
+ * <p>
+ * Test Case for the {@code LazyDynaBean} implementation class.
+ * </p>
*
*/
public class LazyDynaBeanTestCase extends TestCase {
- protected LazyDynaBean bean = null;
+ protected LazyDynaBean bean = null;
protected LazyDynaClass dynaClass = null;
- protected String testProperty = "myProperty";
- protected String testPropertyA = "myProperty-A";
- protected String testPropertyB = "myProperty-B";
- protected String testString1 = "myStringValue-1";
- protected String testString2 = "myStringValue-2";
- protected Integer testInteger1 = Integer.valueOf(30);
- protected Integer testInteger2 = Integer.valueOf(40);
- protected String testKey = "myKey";
+ protected String testProperty = "myProperty";
+ protected String testPropertyA = "myProperty-A";
+ protected String testPropertyB = "myProperty-B";
+ protected String testString1 = "myStringValue-1";
+ protected String testString2 = "myStringValue-2";
+ protected Integer testInteger1 = Integer.valueOf(30);
+ protected Integer testInteger2 = Integer.valueOf(40);
+ protected String testKey = "myKey";
/**
* Constructs a new instance of this test case.
@@ -72,7 +74,7 @@ public class LazyDynaBeanTestCase extends TestCase {
@Override
public void setUp() throws Exception {
bean = new LazyDynaBean();
- dynaClass = (LazyDynaClass)bean.getDynaClass();
+ dynaClass = (LazyDynaClass) bean.getDynaClass();
dynaClass.setReturnNull(true);
}
@@ -81,7 +83,7 @@ public class LazyDynaBeanTestCase extends TestCase {
*/
@Override
public void tearDown() {
- bean = null;
+ bean = null;
}
/**
@@ -164,12 +166,12 @@ public class LazyDynaBeanTestCase extends TestCase {
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));
}
/**
@@ -191,12 +193,12 @@ public class LazyDynaBeanTestCase extends TestCase {
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));
}
/**
@@ -213,10 +215,9 @@ public class LazyDynaBeanTestCase extends TestCase {
// Set the mapped property using PropertyUtils
try {
- PropertyUtils.setProperty(bean, testProperty+"("+testKey+")", testString1);
- }
- catch (final NoSuchMethodException | InvocationTargetException | IllegalAccessException ex) {
- fail("testIndexedPropertyUtils threw "+ex);
+ PropertyUtils.setProperty(bean, testProperty + "(" + testKey + ")", testString1);
+ } catch (final NoSuchMethodException | InvocationTargetException | IllegalAccessException ex) {
+ fail("testIndexedPropertyUtils threw " + ex);
}
// Check property value correctly set
@@ -278,13 +279,13 @@ public class LazyDynaBeanTestCase extends TestCase {
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", Integer.valueOf(index+1), Integer.valueOf(((ArrayList<?>)bean.get(testProperty)).size()));
+ assertEquals("Check First Array length is correct", Integer.valueOf(index + 1), Integer.valueOf(((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", Integer.valueOf(index+1), Integer.valueOf(((ArrayList<?>)bean.get(testProperty)).size()));
+ assertEquals("Check Second Array length is correct", Integer.valueOf(index + 1), Integer.valueOf(((ArrayList<?>) bean.get(testProperty)).size()));
}
/**
@@ -292,7 +293,7 @@ public class LazyDynaBeanTestCase extends TestCase {
*/
public void testIndexedLinkedList() {
- int index = 3;
+ int index = 3;
// Check the property & value doesn't exist
assertNull("Check Indexed Property doesn't exist", dynaClass.getDynaProperty(testProperty));
@@ -308,13 +309,13 @@ public class LazyDynaBeanTestCase extends TestCase {
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", Integer.valueOf(index+1), Integer.valueOf(((LinkedList<?>)bean.get(testProperty)).size()));
+ assertEquals("Check First Array length is correct", Integer.valueOf(index + 1), Integer.valueOf(((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", Integer.valueOf(index+1), Integer.valueOf(((LinkedList<?>)bean.get(testProperty)).size()));
+ assertEquals("Check Second Array length is correct", Integer.valueOf(index + 1), Integer.valueOf(((LinkedList<?>) bean.get(testProperty)).size()));
}
/**
@@ -322,7 +323,7 @@ public class LazyDynaBeanTestCase extends TestCase {
*/
public void testIndexedPrimitiveArray() {
- int index = 3;
+ int index = 3;
final int[] primitiveArray = {};
// Check the property & value doesn't exist
@@ -339,15 +340,15 @@ public class LazyDynaBeanTestCase extends TestCase {
assertNotNull("Check Indexed Property is not null", bean.get(testProperty));
assertEquals("Check Indexed Property is correct type", primitiveArray.getClass(), bean.get(testProperty).getClass());
assertEquals("Check First Indexed Value is correct(a)", testInteger1, bean.get(testProperty, index));
- assertEquals("Check First Indexed Value is correct(b)", testInteger1, Integer.valueOf(((int[])bean.get(testProperty))[index]));
- assertEquals("Check Array length is correct", Integer.valueOf(index+1), Integer.valueOf(((int[])bean.get(testProperty)).length));
+ assertEquals("Check First Indexed Value is correct(b)", testInteger1, Integer.valueOf(((int[]) bean.get(testProperty))[index]));
+ assertEquals("Check Array length is correct", Integer.valueOf(index + 1), Integer.valueOf(((int[]) bean.get(testProperty)).length));
// Set a second indexed value, should automatically grow the int[] and set appropriate indexed value
index = index + 2;
bean.set(testProperty, index, testInteger2);
assertEquals("Check Second Indexed Value is correct(a)", testInteger2, bean.get(testProperty, index));
- assertEquals("Check Second Indexed Value is correct(b)", testInteger2, Integer.valueOf(((int[])bean.get(testProperty))[index]));
- assertEquals("Check Second Array length is correct", Integer.valueOf(index+1), Integer.valueOf(((int[])bean.get(testProperty)).length));
+ assertEquals("Check Second Indexed Value is correct(b)", testInteger2, Integer.valueOf(((int[]) bean.get(testProperty))[index]));
+ assertEquals("Check Second Array length is correct", Integer.valueOf(index + 1), Integer.valueOf(((int[]) bean.get(testProperty)).length));
}
@@ -356,7 +357,7 @@ public class LazyDynaBeanTestCase extends TestCase {
*/
public void testIndexedObjectArray() {
- int index = 3;
+ int index = 3;
final Object objectArray = new String[0];
// Check the property & value doesn't exist
@@ -373,15 +374,15 @@ public class LazyDynaBeanTestCase extends TestCase {
assertNotNull("Check Indexed Property is not null", bean.get(testProperty));
assertEquals("Check Indexed Property is correct type", objectArray.getClass(), bean.get(testProperty).getClass());
assertEquals("Check First Indexed Value is correct(a)", testString1, bean.get(testProperty, index));
- assertEquals("Check First Indexed Value is correct(b)", testString1, ((String[])bean.get(testProperty))[index]);
- assertEquals("Check Array length is correct", Integer.valueOf(index+1), Integer.valueOf(((String[])bean.get(testProperty)).length));
+ assertEquals("Check First Indexed Value is correct(b)", testString1, ((String[]) bean.get(testProperty))[index]);
+ assertEquals("Check Array length is correct", Integer.valueOf(index + 1), Integer.valueOf(((String[]) bean.get(testProperty)).length));
// Set a second indexed value, should automatically grow the String[] and set appropriate indexed value
index = index + 2;
bean.set(testProperty, index, testString2);
assertEquals("Check Second Indexed Value is correct(a)", testString2, bean.get(testProperty, index));
- assertEquals("Check Second Indexed Value is correct(b)", testString2, ((String[])bean.get(testProperty))[index]);
- assertEquals("Check Second Array length is correct", Integer.valueOf(index+1), Integer.valueOf(((String[])bean.get(testProperty)).length));
+ assertEquals("Check Second Indexed Value is correct(b)", testString2, ((String[]) bean.get(testProperty))[index]);
+ assertEquals("Check Second Array length is correct", Integer.valueOf(index + 1), Integer.valueOf(((String[]) bean.get(testProperty)).length));
}
/**
@@ -389,7 +390,7 @@ public class LazyDynaBeanTestCase extends TestCase {
*/
public void testIndexedDynaBeanArray() {
- final int index = 3;
+ final int index = 3;
final Object objectArray = new LazyDynaMap[0];
// Check the property & value doesn't exist
@@ -410,7 +411,7 @@ public class LazyDynaBeanTestCase extends TestCase {
final LazyDynaMap newMap = new LazyDynaMap();
newMap.set(testPropertyB, testString2);
bean.set(testPropertyA, index, newMap);
- assertEquals("Check Indexed Value is correct(a)", testString2, ((DynaBean)bean.get(testPropertyA, index)).get(testPropertyB));
+ assertEquals("Check Indexed Value is correct(a)", testString2, ((DynaBean) bean.get(testPropertyA, index)).get(testPropertyB));
}
@@ -419,7 +420,7 @@ public class LazyDynaBeanTestCase extends TestCase {
*/
public void testIndexedPropertyUtils() {
- final int index = 3;
+ final int index = 3;
dynaClass.setReturnNull(false);
// Check the property & value doesn't exist
@@ -429,10 +430,9 @@ public class LazyDynaBeanTestCase extends TestCase {
// Use PropertyUtils to set the indexed value
try {
- PropertyUtils.setProperty(bean, testProperty+"["+index+"]", testString1);
- }
- catch (final NoSuchMethodException | InvocationTargetException | IllegalAccessException ex) {
- fail("testIndexedPropertyUtils threw "+ex);
+ PropertyUtils.setProperty(bean, testProperty + "[" + index + "]", testString1);
+ } catch (final NoSuchMethodException | InvocationTargetException | IllegalAccessException ex) {
+ fail("testIndexedPropertyUtils threw " + ex);
}
// Check property value correctly set
@@ -445,7 +445,7 @@ public class LazyDynaBeanTestCase extends TestCase {
*/
public void testIndexedPropertyRestricted() {
- final int index = 3;
+ final int index = 3;
// Set the MutableDyanClass to 'restricted' (i.e. no new properties cab be added
dynaClass.setRestricted(true);
@@ -469,7 +469,7 @@ public class LazyDynaBeanTestCase extends TestCase {
* Test setting indexed property for type which is not List or Array
*/
public void testIndexedInvalidType() {
- final int index = 3;
+ final int index = 3;
dynaClass.add(testProperty, String.class);
assertFalse("Check Property is not indexed", dynaClass.getDynaProperty(testProperty).isIndexed());
try {
diff --git a/src/test/java/org/apache/commons/beanutils2/LazyDynaClassTestCase.java b/src/test/java/org/apache/commons/beanutils2/LazyDynaClassTestCase.java
index 3c546c3f..26039732 100644
--- a/src/test/java/org/apache/commons/beanutils2/LazyDynaClassTestCase.java
+++ b/src/test/java/org/apache/commons/beanutils2/LazyDynaClassTestCase.java
@@ -21,13 +21,15 @@ import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
- * <p>Test Case for the {@code LazyDynaClass} implementation class.</p>
+ * <p>
+ * Test Case for the {@code LazyDynaClass} implementation class.
+ * </p>
*
*/
public class LazyDynaClassTestCase extends TestCase {
protected LazyDynaClass dynaClass = null;
- protected String testProperty = "myProperty";
+ protected String testProperty = "myProperty";
/**
* Constructs a new instance of this test case.
@@ -42,7 +44,7 @@ public class LazyDynaClassTestCase extends TestCase {
* Run this Test
*/
public static void main(final String[] args) {
- junit.textui.TestRunner.run(suite());
+ junit.textui.TestRunner.run(suite());
}
/**
@@ -105,7 +107,7 @@ public class LazyDynaClassTestCase extends TestCase {
*/
public void testAddPropertyNullName1() {
try {
- dynaClass.add((String)null);
+ dynaClass.add((String) null);
fail("null property name not prevented");
} catch (final IllegalArgumentException expected) {
// expected result
diff --git a/src/test/java/org/apache/commons/beanutils2/LazyDynaListTestCase.java b/src/test/java/org/apache/commons/beanutils2/LazyDynaListTestCase.java
index de50e5ea..c526e55e 100644
--- a/src/test/java/org/apache/commons/beanutils2/LazyDynaListTestCase.java
+++ b/src/test/java/org/apache/commons/beanutils2/LazyDynaListTestCase.java
@@ -31,7 +31,9 @@ import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
- * <p>Test Case for the {@code LazyDynaList}class.</p>
+ * <p>
+ * Test Case for the {@code LazyDynaList}class.
+ * </p>
*
*/
public class LazyDynaListTestCase extends TestCase {
@@ -39,17 +41,13 @@ public class LazyDynaListTestCase extends TestCase {
private static final String BASIC_PROP1 = "BasicDynaClass_Property1";
private static final String BASIC_PROP2 = "BasicDynaClass_Property2";
- protected DynaProperty[] properties = {
- new DynaProperty(BASIC_PROP1, String.class),
- new DynaProperty(BASIC_PROP2, HashMap.class)};
+ protected DynaProperty[] properties = { new DynaProperty(BASIC_PROP1, String.class), new DynaProperty(BASIC_PROP2, HashMap.class) };
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);
-
-
/**
* Constructs a new instance of this test case.
*
@@ -59,8 +57,6 @@ public class LazyDynaListTestCase extends TestCase {
super(name);
}
-
-
/**
* Run thus Test
*/
@@ -89,8 +85,6 @@ public class LazyDynaListTestCase extends TestCase {
public void tearDown() {
}
-
-
/**
* Test DynaBean Create
*/
@@ -181,7 +175,7 @@ public class LazyDynaListTestCase extends TestCase {
final TreeMap<?, ?>[] testArray = new TreeMap[size];
for (int i = 0; i < size; i++) {
final TreeMap<String, Object> map = new TreeMap<>();
- map.put("prop"+i, "val"+i);
+ map.put("prop" + i, "val" + i);
testArray[i] = map;
testList.add(testArray[i]);
}
@@ -191,14 +185,14 @@ public class LazyDynaListTestCase extends TestCase {
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);
assertEquals("3. check size", size, mapArray.length);
for (int i = 0; i < size; i++) {
- assertEquals("4."+i+" DynaBean error ", "val"+i, dynaArray[i].get("prop"+i));
- assertEquals("5."+i+" Map error ", "val"+i, mapArray[i].get("prop"+i));
+ assertEquals("4." + i + " DynaBean error ", "val" + i, dynaArray[i].get("prop" + i));
+ assertEquals("5." + i + " Map error ", "val" + i, mapArray[i].get("prop" + i));
}
// ----- Create LazyArrayList from Array -----
@@ -206,14 +200,14 @@ public class LazyDynaListTestCase extends TestCase {
assertEquals("6. check size", size, lazyList.size());
dynaArray = lazyList.toDynaBeanArray();
- mapArray = (TreeMap[])lazyList.toArray();
+ mapArray = (TreeMap[]) lazyList.toArray();
// Check values
assertEquals("7. check size", size, dynaArray.length);
assertEquals("8. check size", size, mapArray.length);
for (int i = 0; i < size; i++) {
- assertEquals("9."+i+" DynaBean error ", "val"+i, dynaArray[i].get("prop"+i));
- assertEquals("10."+i+" Map error ", "val"+i, mapArray[i].get("prop"+i));
+ assertEquals("9." + i + " DynaBean error ", "val" + i, dynaArray[i].get("prop" + i));
+ assertEquals("10." + i + " Map error ", "val" + i, mapArray[i].get("prop" + i));
}
}
@@ -240,7 +234,7 @@ public class LazyDynaListTestCase extends TestCase {
Object array = list.toArray();
assertNotNull("3. Array Not Created", array);
assertEquals("4. Not DynaBean[]", testClass, array.getClass().getComponentType());
- DynaBean[] dynaArray = (DynaBean[])array;
+ DynaBean[] dynaArray = (DynaBean[]) array;
assertEquals("5. Array Size Wrong", 2, dynaArray.length);
// Test get(index) created correct DynaBean - Fourth
@@ -252,14 +246,14 @@ public class LazyDynaListTestCase extends TestCase {
array = list.toArray();
assertNotNull("8. Array Not Created", array);
assertEquals("9. Not DynaBean[]", testClass, array.getClass().getComponentType());
- dynaArray = (DynaBean[])array;
+ dynaArray = (DynaBean[]) array;
assertEquals("10. Array Size Wrong", 4, dynaArray.length);
// Test fail if different type added
try {
list.add(2, wrongBean);
fail("Expected IllegalArgumentException");
- } catch(final IllegalArgumentException ignore) {
+ } catch (final IllegalArgumentException ignore) {
// expected result
}
@@ -268,7 +262,7 @@ public class LazyDynaListTestCase extends TestCase {
assertNotNull("Test Property Not Found", testProperty);
dynaArray = list.toDynaBeanArray();
for (int i = 0; i < dynaArray.length; i++) {
- dynaArray[i].set(testProperty, "orig_pos"+i);
+ dynaArray[i].set(testProperty, "orig_pos" + i);
}
// Create Collection
@@ -277,14 +271,14 @@ public class LazyDynaListTestCase extends TestCase {
collection.add(testDynaClass.newInstance());
collection.add(testDynaClass.newInstance());
collection.add(testDynaClass.newInstance());
- } catch(final Exception ex) {
+ } catch (final Exception ex) {
fail("1. FAILED: " + ex);
}
final int expectedSize = dynaArray.length + collection.size();
- final String origValue = (String)((DynaBean)collection.get(0)).get(testProperty);
- ((DynaBean)collection.get(0)).set(testProperty, origValue+"_updated_"+0);
- ((DynaBean)collection.get(1)).set(testProperty, origValue+"_updated_"+1);
- ((DynaBean)collection.get(2)).set(testProperty, origValue+"_updated_"+2);
+ final String origValue = (String) ((DynaBean) collection.get(0)).get(testProperty);
+ ((DynaBean) collection.get(0)).set(testProperty, origValue + "_updated_" + 0);
+ ((DynaBean) collection.get(1)).set(testProperty, origValue + "_updated_" + 1);
+ ((DynaBean) collection.get(2)).set(testProperty, origValue + "_updated_" + 2);
// Test Insert - addAll(index, Collection)
list.addAll(1, collection);
@@ -295,11 +289,11 @@ public class LazyDynaListTestCase extends TestCase {
assertEquals("11. Array Size Wrong", expectedSize, dynaArray.length);
// Check Beans have inserted correctly - by checking the property values
- assertEquals("12. Wrong Value", "orig_pos0", dynaArray[0].get(testProperty));
- assertEquals("13. Wrong Value", origValue+"_updated_"+0, dynaArray[1].get(testProperty));
- assertEquals("14. Wrong Value", origValue+"_updated_"+1, dynaArray[2].get(testProperty));
- assertEquals("15. Wrong Value", origValue+"_updated_"+2, dynaArray[3].get(testProperty));
- assertEquals("16. Wrong Value", "orig_pos1", dynaArray[4].get(testProperty));
+ assertEquals("12. Wrong Value", "orig_pos0", dynaArray[0].get(testProperty));
+ assertEquals("13. Wrong Value", origValue + "_updated_" + 0, dynaArray[1].get(testProperty));
+ assertEquals("14. Wrong Value", origValue + "_updated_" + 1, dynaArray[2].get(testProperty));
+ assertEquals("15. Wrong Value", origValue + "_updated_" + 2, dynaArray[3].get(testProperty));
+ assertEquals("16. Wrong Value", "orig_pos1", dynaArray[4].get(testProperty));
// Test Insert - add(index, Object)
try {
@@ -307,10 +301,10 @@ public class LazyDynaListTestCase extends TestCase {
extraElement.set(testProperty, "extraOne");
list.add(2, extraElement);
dynaArray = list.toDynaBeanArray();
- assertEquals("17. Wrong Value", origValue+"_updated_"+0, dynaArray[1].get(testProperty));
- assertEquals("18. Wrong Value", "extraOne", dynaArray[2].get(testProperty));
- assertEquals("19. Wrong Value", origValue+"_updated_"+1, dynaArray[3].get(testProperty));
- } catch(final Exception ex) {
+ assertEquals("17. Wrong Value", origValue + "_updated_" + 0, dynaArray[1].get(testProperty));
+ assertEquals("18. Wrong Value", "extraOne", dynaArray[2].get(testProperty));
+ assertEquals("19. Wrong Value", origValue + "_updated_" + 1, dynaArray[3].get(testProperty));
+ } catch (final Exception ex) {
fail("2. FAILED: " + ex);
}
@@ -340,7 +334,7 @@ public class LazyDynaListTestCase extends TestCase {
assertEquals("2. Not LazyDynaMap", LazyDynaMap.class, dynaBean.getClass());
// Test get(index) created correct Map - First
- Object map = ((LazyDynaMap)dynaBean).getMap();
+ Object map = ((LazyDynaMap) dynaBean).getMap();
assertNotNull("3. Map Not Created", map);
assertEquals("4. Wrong Map", testClass, map.getClass());
@@ -348,7 +342,7 @@ public class LazyDynaListTestCase extends TestCase {
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
@@ -357,7 +351,7 @@ public class LazyDynaListTestCase extends TestCase {
assertEquals("9. Not LazyDynaMap", LazyDynaMap.class, dynaBean.getClass());
// Test get(index) created correct Map - Third
- map = ((LazyDynaMap)dynaBean).getMap();
+ map = ((LazyDynaMap) dynaBean).getMap();
assertNotNull("10. Map Not Created", map);
assertEquals("11. Wrong Map", testClass, map.getClass());
@@ -365,14 +359,14 @@ public class LazyDynaListTestCase extends TestCase {
array = list.toArray();
assertNotNull("12. Array Not Created", array);
assertEquals("13. Not Map[]", testClass, array.getClass().getComponentType());
- mapArray = (Map[])array;
+ mapArray = (Map[]) array;
assertEquals("14. Array Size Wrong", 3, mapArray.length);
// Test fail if different type added
try {
list.add(2, wrongBean);
fail("Expected IllegalArgumentException");
- } catch(final IllegalArgumentException ignore) {
+ } catch (final IllegalArgumentException ignore) {
// expected result
}
@@ -389,7 +383,7 @@ public class LazyDynaListTestCase extends TestCase {
assertEquals("2. Not WrapDynaBean", WrapDynaBean.class, dynaBean.getClass());
// Test get(index) created correct POJO - First
- Object pojoBean = ((WrapDynaBean)dynaBean).getInstance();
+ Object pojoBean = ((WrapDynaBean) dynaBean).getInstance();
assertNotNull("3. POJO Not Created", pojoBean);
assertEquals("4. Not WrapDynaBean", testClass, pojoBean.getClass());
@@ -397,7 +391,7 @@ public class LazyDynaListTestCase extends TestCase {
Object array = list.toArray();
assertNotNull("5. Array Not Created", array);
assertEquals("6. Wrong array", testClass, array.getClass().getComponentType());
- Object[] pojoArray = (Object[])array;
+ Object[] pojoArray = (Object[]) array;
assertEquals("7. Array Size Wrong", 1, pojoArray.length);
// Test get(index) created correct DynaBean - Second
@@ -406,7 +400,7 @@ public class LazyDynaListTestCase extends TestCase {
assertEquals("9. Not WrapDynaBean", WrapDynaBean.class, dynaBean.getClass());
// Test get(index) created correct POJO - Second
- pojoBean = ((WrapDynaBean)dynaBean).getInstance();
+ pojoBean = ((WrapDynaBean) dynaBean).getInstance();
assertNotNull("10. POJO Not Created", pojoBean);
assertEquals("11. Not WrapDynaBean", testClass, pojoBean.getClass());
@@ -414,14 +408,14 @@ public class LazyDynaListTestCase extends TestCase {
array = list.toArray();
assertNotNull("12. Array Not Created", array);
assertEquals("13. Wrong array", testClass, array.getClass().getComponentType());
- pojoArray = (Object[])array;
+ pojoArray = (Object[]) array;
assertEquals("14. Array Size Wrong", 2, pojoArray.length);
// Test fail if different type added
try {
list.add(2, wrongBean);
fail("Expected IllegalArgumentException");
- } catch(final IllegalArgumentException ignore) {
+ } catch (final IllegalArgumentException ignore) {
// expected result
}
@@ -434,7 +428,7 @@ public class LazyDynaListTestCase extends TestCase {
// Create LazyArrayList for DynaBeans
LazyDynaList target = new LazyDynaList(basicDynaClass);
- BasicDynaBean bean = (BasicDynaBean)target.get(0);
+ BasicDynaBean bean = (BasicDynaBean) target.get(0);
// Set a Property
assertNull("pre-set check", bean.get(BASIC_PROP1));
@@ -442,12 +436,12 @@ public class LazyDynaListTestCase extends TestCase {
assertEquals("post-set check", "value1", bean.get(BASIC_PROP1));
// Serialize/Deserialize
- final LazyDynaList result = (LazyDynaList)serializeDeserialize(target, "DynaBean");
+ final LazyDynaList result = (LazyDynaList) serializeDeserialize(target, "DynaBean");
target = null;
bean = null;
// Confirm property value
- bean = (BasicDynaBean)result.get(0);
+ bean = (BasicDynaBean) result.get(0);
assertEquals("post-serialize check", "value1", bean.get(BASIC_PROP1));
}
@@ -459,7 +453,7 @@ public class LazyDynaListTestCase extends TestCase {
// Create LazyArrayList for DynaBeans
LazyDynaList target = new LazyDynaList();
- LazyDynaBean bean = (LazyDynaBean)target.get(0);
+ LazyDynaBean bean = (LazyDynaBean) target.get(0);
// Set a Property
assertNull("pre-set check", bean.get(BASIC_PROP1));
@@ -467,12 +461,12 @@ public class LazyDynaListTestCase extends TestCase {
assertEquals("post-set check", "value1", bean.get(BASIC_PROP1));
// Serialize/Deserialize
- final LazyDynaList result = (LazyDynaList)serializeDeserialize(target, "DynaBean");
+ final LazyDynaList result = (LazyDynaList) serializeDeserialize(target, "DynaBean");
target = null;
bean = null;
// Confirm property value
- bean = (LazyDynaBean)result.get(0);
+ bean = (LazyDynaBean) result.get(0);
assertEquals("post-serialize check", "value1", bean.get(BASIC_PROP1));
}
@@ -484,7 +478,7 @@ public class LazyDynaListTestCase extends TestCase {
// Create LazyArrayList for DynaBeans
LazyDynaList target = new LazyDynaList(treeMapDynaClass);
- LazyDynaMap bean = (LazyDynaMap)target.get(0);
+ LazyDynaMap bean = (LazyDynaMap) target.get(0);
// Set a Property
assertNull("pre-set check", bean.get(BASIC_PROP1));
@@ -492,12 +486,12 @@ public class LazyDynaListTestCase extends TestCase {
assertEquals("post-set check", "value1", bean.get(BASIC_PROP1));
// Serialize/Deserialize
- final LazyDynaList result = (LazyDynaList)serializeDeserialize(target, "Map");
+ final LazyDynaList result = (LazyDynaList) serializeDeserialize(target, "Map");
target = null;
bean = null;
// Confirm property value
- bean = (LazyDynaMap)result.get(0);
+ bean = (LazyDynaMap) result.get(0);
assertEquals("post-serialize check", "value1", bean.get(BASIC_PROP1));
}
@@ -509,7 +503,7 @@ public class LazyDynaListTestCase extends TestCase {
// Create LazyArrayList for DynaBeans
LazyDynaList target = new LazyDynaList(pojoDynaClass);
- WrapDynaBean bean = (WrapDynaBean)target.get(0);
+ WrapDynaBean bean = (WrapDynaBean) target.get(0);
// Set a Property
assertEquals("pre-set check", "This is a string", bean.get("stringProperty"));
@@ -517,7 +511,7 @@ public class LazyDynaListTestCase extends TestCase {
assertEquals("post-set check", "value1", bean.get("stringProperty"));
// Serialize/Deserialize
- final LazyDynaList result = (LazyDynaList)serializeDeserialize(target, "POJO");
+ final LazyDynaList result = (LazyDynaList) serializeDeserialize(target, "POJO");
target = null;
bean = null;
@@ -525,7 +519,7 @@ public class LazyDynaListTestCase extends TestCase {
result.add(null);
// Confirm property value
- bean = (WrapDynaBean)result.get(0);
+ bean = (WrapDynaBean) result.get(0);
assertEquals("post-serialize check", "value1", bean.get("stringProperty"));
}
@@ -549,8 +543,7 @@ public class LazyDynaListTestCase extends TestCase {
// Deserialize the test object
Object result = null;
try {
- final ByteArrayInputStream bais =
- new ByteArrayInputStream(baos.toByteArray());
+ final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
final ObjectInputStream ois = new ObjectInputStream(bais);
result = ois.readObject();
bais.close();
diff --git a/src/test/java/org/apache/commons/beanutils2/LazyDynaMapTestCase.java b/src/test/java/org/apache/commons/beanutils2/LazyDynaMapTestCase.java
index 1b700279..0c657460 100644
--- a/src/test/java/org/apache/commons/beanutils2/LazyDynaMapTestCase.java
+++ b/src/test/java/org/apache/commons/beanutils2/LazyDynaMapTestCase.java
@@ -29,22 +29,22 @@ import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
- * <p>Test Case for the {@code LazyDynaMap} implementation class.</p>
+ * <p>
+ * Test Case for the {@code LazyDynaMap} implementation class.
+ * </p>
*
*/
public class LazyDynaMapTestCase extends TestCase {
- protected LazyDynaMap dynaMap = null;
- protected String testProperty = "myProperty";
- protected String testPropertyA = "myProperty-A";
- protected String testPropertyB = "myProperty-B";
- protected String testString1 = "myStringValue-1";
- protected String testString2 = "myStringValue-2";
- protected Integer testInteger1 = Integer.valueOf(30);
- protected Integer testInteger2 = Integer.valueOf(40);
- protected String testKey = "myKey";
-
-
+ protected LazyDynaMap dynaMap = null;
+ protected String testProperty = "myProperty";
+ protected String testPropertyA = "myProperty-A";
+ protected String testPropertyB = "myProperty-B";
+ protected String testString1 = "myStringValue-1";
+ protected String testString2 = "myStringValue-2";
+ protected Integer testInteger1 = Integer.valueOf(30);
+ protected Integer testInteger2 = Integer.valueOf(40);
+ protected String testKey = "myKey";
/**
* Constructs a new instance of this test case.
@@ -55,8 +55,6 @@ public class LazyDynaMapTestCase extends TestCase {
super(name);
}
-
-
/**
* Run thus Test
*/
@@ -85,11 +83,9 @@ public class LazyDynaMapTestCase extends TestCase {
*/
@Override
public void tearDown() {
- dynaMap = null;
+ dynaMap = null;
}
-
-
/**
* General Tests
*/
@@ -160,12 +156,12 @@ public class LazyDynaMapTestCase extends TestCase {
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 +183,12 @@ public class LazyDynaMapTestCase extends TestCase {
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));
}
/**
@@ -209,10 +205,9 @@ public class LazyDynaMapTestCase extends TestCase {
// Set the mapped property using PropertyUtils
try {
- PropertyUtils.setProperty(dynaMap, testProperty+"("+testKey+")", testString1);
- }
- catch (final NoSuchMethodException | InvocationTargetException | IllegalAccessException ex) {
- fail("testIndexedPropertyUtils threw "+ex);
+ PropertyUtils.setProperty(dynaMap, testProperty + "(" + testKey + ")", testString1);
+ } catch (final NoSuchMethodException | InvocationTargetException | IllegalAccessException ex) {
+ fail("testIndexedPropertyUtils threw " + ex);
}
// Check property value correctly set
@@ -274,13 +269,13 @@ public class LazyDynaMapTestCase extends TestCase {
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", Integer.valueOf(index+1), Integer.valueOf(((ArrayList<?>)dynaMap.get(testProperty)).size()));
+ assertEquals("Check First Array length is correct", Integer.valueOf(index + 1), Integer.valueOf(((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", Integer.valueOf(index+1), Integer.valueOf(((ArrayList<?>)dynaMap.get(testProperty)).size()));
+ assertEquals("Check Second Array length is correct", Integer.valueOf(index + 1), Integer.valueOf(((ArrayList<?>) dynaMap.get(testProperty)).size()));
}
/**
@@ -288,7 +283,7 @@ public class LazyDynaMapTestCase extends TestCase {
*/
public void testIndexedLinkedList() {
- int index = 3;
+ int index = 3;
// Check the property & value doesn't exist
assertNull("Check Indexed Property doesn't exist", dynaMap.getDynaProperty(testProperty));
@@ -304,13 +299,13 @@ public class LazyDynaMapTestCase extends TestCase {
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", Integer.valueOf(index+1), Integer.valueOf(((LinkedList<?>)dynaMap.get(testProperty)).size()));
+ assertEquals("Check First Array length is correct", Integer.valueOf(index + 1), Integer.valueOf(((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", Integer.valueOf(index+1), Integer.valueOf(((LinkedList<?>)dynaMap.get(testProperty)).size()));
+ assertEquals("Check Second Array length is correct", Integer.valueOf(index + 1), Integer.valueOf(((LinkedList<?>) dynaMap.get(testProperty)).size()));
}
/**
@@ -318,7 +313,7 @@ public class LazyDynaMapTestCase extends TestCase {
*/
public void testIndexedPrimitiveArray() {
- int index = 3;
+ int index = 3;
final int[] primitiveArray = {};
// Check the property & value doesn't exist
@@ -335,15 +330,15 @@ public class LazyDynaMapTestCase extends TestCase {
assertNotNull("Check Indexed Property is not null", dynaMap.get(testProperty));
assertEquals("Check Indexed Property is correct type", primitiveArray.getClass(), dynaMap.get(testProperty).getClass());
assertEquals("Check First Indexed Value is correct(a)", testInteger1, dynaMap.get(testProperty, index));
- assertEquals("Check First Indexed Value is correct(b)", testInteger1, Integer.valueOf(((int[])dynaMap.get(testProperty))[index]));
- assertEquals("Check Array length is correct", Integer.valueOf(index+1), Integer.valueOf(((int[])dynaMap.get(testProperty)).length));
+ assertEquals("Check First Indexed Value is correct(b)", testInteger1, Integer.valueOf(((int[]) dynaMap.get(testProperty))[index]));
+ assertEquals("Check Array length is correct", Integer.valueOf(index + 1), Integer.valueOf(((int[]) dynaMap.get(testProperty)).length));
// Set a second indexed value, should automatically grow the int[] and set appropriate indexed value
index = index + 2;
dynaMap.set(testProperty, index, testInteger2);
assertEquals("Check Second Indexed Value is correct(a)", testInteger2, dynaMap.get(testProperty, index));
- assertEquals("Check Second Indexed Value is correct(b)", testInteger2, Integer.valueOf(((int[])dynaMap.get(testProperty))[index]));
- assertEquals("Check Second Array length is correct", Integer.valueOf(index+1), Integer.valueOf(((int[])dynaMap.get(testProperty)).length));
+ assertEquals("Check Second Indexed Value is correct(b)", testInteger2, Integer.valueOf(((int[]) dynaMap.get(testProperty))[index]));
+ assertEquals("Check Second Array length is correct", Integer.valueOf(index + 1), Integer.valueOf(((int[]) dynaMap.get(testProperty)).length));
}
@@ -352,7 +347,7 @@ public class LazyDynaMapTestCase extends TestCase {
*/
public void testIndexedObjectArray() {
- int index = 3;
+ int index = 3;
final Object objectArray = new String[0];
// Check the property & value doesn't exist
@@ -369,15 +364,15 @@ public class LazyDynaMapTestCase extends TestCase {
assertNotNull("Check Indexed Property is not null", dynaMap.get(testProperty));
assertEquals("Check Indexed Property is correct type", objectArray.getClass(), dynaMap.get(testProperty).getClass());
assertEquals("Check First Indexed Value is correct(a)", testString1, dynaMap.get(testProperty, index));
- assertEquals("Check First Indexed Value is correct(b)", testString1, ((String[])dynaMap.get(testProperty))[index]);
- assertEquals("Check Array length is correct", Integer.valueOf(index+1), Integer.valueOf(((String[])dynaMap.get(testProperty)).length));
+ assertEquals("Check First Indexed Value is correct(b)", testString1, ((String[]) dynaMap.get(testProperty))[index]);
+ assertEquals("Check Array length is correct", Integer.valueOf(index + 1), Integer.valueOf(((String[]) dynaMap.get(testProperty)).length));
// Set a second indexed value, should automatically grow the String[] and set appropriate indexed value
index = index + 2;
dynaMap.set(testProperty, index, testString2);
assertEquals("Check Second Indexed Value is correct(a)", testString2, dynaMap.get(testProperty, index));
- assertEquals("Check Second Indexed Value is correct(b)", testString2, ((String[])dynaMap.get(testProperty))[index]);
- assertEquals("Check Second Array length is correct", Integer.valueOf(index+1), Integer.valueOf(((String[])dynaMap.get(testProperty)).length));
+ assertEquals("Check Second Indexed Value is correct(b)", testString2, ((String[]) dynaMap.get(testProperty))[index]);
+ assertEquals("Check Second Array length is correct", Integer.valueOf(index + 1), Integer.valueOf(((String[]) dynaMap.get(testProperty)).length));
}
/**
@@ -385,7 +380,7 @@ public class LazyDynaMapTestCase extends TestCase {
*/
public void testIndexedDynaBeanArray() {
- final int index = 3;
+ final int index = 3;
final Object objectArray = new LazyDynaBean[0];
// Check the property & value doesn't exist
@@ -406,7 +401,7 @@ public class LazyDynaMapTestCase extends TestCase {
final LazyDynaBean newBean = new LazyDynaBean();
newBean.set(testPropertyB, testString2);
dynaMap.set(testPropertyA, index, newBean);
- assertEquals("Check Indexed Value is correct(a)", testString2, ((DynaBean)dynaMap.get(testPropertyA, index)).get(testPropertyB));
+ assertEquals("Check Indexed Value is correct(a)", testString2, ((DynaBean) dynaMap.get(testPropertyA, index)).get(testPropertyB));
}
@@ -415,7 +410,7 @@ public class LazyDynaMapTestCase extends TestCase {
*/
public void testIndexedPropertyUtils() {
- final int index = 3;
+ final int index = 3;
dynaMap.setReturnNull(false);
// Check the property & value doesn't exist
@@ -425,10 +420,9 @@ public class LazyDynaMapTestCase extends TestCase {
// Use PropertyUtils to set the indexed value
try {
- PropertyUtils.setProperty(dynaMap, testProperty+"["+index+"]", testString1);
- }
- catch (final NoSuchMethodException | InvocationTargetException | IllegalAccessException ex) {
- fail("testIndexedPropertyUtils threw "+ex);
+ PropertyUtils.setProperty(dynaMap, testProperty + "[" + index + "]", testString1);
+ } catch (final NoSuchMethodException | InvocationTargetException | IllegalAccessException ex) {
+ fail("testIndexedPropertyUtils threw " + ex);
}
// Check property value correctly set
@@ -441,7 +435,7 @@ public class LazyDynaMapTestCase extends TestCase {
*/
public void testIndexedPropertyRestricted() {
- final int index = 3;
+ final int index = 3;
// Set the MutableDyanClass to 'restricted' (i.e. no new properties cab be added
dynaMap.setRestricted(true);
@@ -465,7 +459,7 @@ public class LazyDynaMapTestCase extends TestCase {
* Test setting indexed property for type which is not List or Array
*/
public void testIndexedInvalidType() {
- final int index = 3;
+ final int index = 3;
dynaMap.set(testProperty, "Test String");
assertFalse("Check Property is not indexed", dynaMap.getDynaProperty(testProperty).isIndexed());
try {
@@ -486,13 +480,13 @@ public class LazyDynaMapTestCase extends TestCase {
final 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());
- final LazyDynaMap newOne = (LazyDynaMap)orig.newInstance();
+ final LazyDynaMap newOne = (LazyDynaMap) orig.newInstance();
final Map<String, Object> newMap = newOne.getMap();
assertEquals("Check Map type", TreeMap.class, newMap.getClass());
- final ArrayList<?> indexProp = (ArrayList<?>)newMap.get("indexProp");
+ final ArrayList<?> indexProp = (ArrayList<?>) newMap.get("indexProp");
assertNotNull("Indexed Prop missing", indexProp);
assertEquals("Index prop size", 0, indexProp.size());
}
diff --git a/src/test/java/org/apache/commons/beanutils2/MappedPropertyChildBean.java b/src/test/java/org/apache/commons/beanutils2/MappedPropertyChildBean.java
index d7b098a7..f9e5c7e0 100644
--- a/src/test/java/org/apache/commons/beanutils2/MappedPropertyChildBean.java
+++ b/src/test/java/org/apache/commons/beanutils2/MappedPropertyChildBean.java
@@ -22,6 +22,6 @@ package org.apache.commons.beanutils2;
*
*/
-public class MappedPropertyChildBean extends MappedPropertyTestBean{
+public class MappedPropertyChildBean extends MappedPropertyTestBean {
}
diff --git a/src/test/java/org/apache/commons/beanutils2/MappedPropertyChildInterface.java b/src/test/java/org/apache/commons/beanutils2/MappedPropertyChildInterface.java
index 4189f449..10c81ba3 100644
--- a/src/test/java/org/apache/commons/beanutils2/MappedPropertyChildInterface.java
+++ b/src/test/java/org/apache/commons/beanutils2/MappedPropertyChildInterface.java
@@ -22,7 +22,6 @@ package org.apache.commons.beanutils2;
*
*/
-public interface MappedPropertyChildInterface extends MappedPropertyTestInterface {
+public interface MappedPropertyChildInterface extends MappedPropertyTestInterface {
}
-
diff --git a/src/test/java/org/apache/commons/beanutils2/MappedPropertyTestBean.java b/src/test/java/org/apache/commons/beanutils2/MappedPropertyTestBean.java
index 41338057..84c56d0b 100644
--- a/src/test/java/org/apache/commons/beanutils2/MappedPropertyTestBean.java
+++ b/src/test/java/org/apache/commons/beanutils2/MappedPropertyTestBean.java
@@ -30,8 +30,6 @@ public class MappedPropertyTestBean {
private final Map<Object, Object> map = new HashMap<>();
private final Map<Object, Object> myMap = new HashMap<>();
-
-
public String getMapproperty(final String key) {
return (String) map.get(key);
}
@@ -41,7 +39,7 @@ public class MappedPropertyTestBean {
}
public boolean isMappedBoolean(final String key) {
- return ((Boolean)map.get(key)).booleanValue();
+ return ((Boolean) map.get(key)).booleanValue();
}
public void setMappedBoolean(final String key, final boolean value) {
@@ -75,6 +73,7 @@ public class MappedPropertyTestBean {
public String getInvalidGetter(final String key, final String other) {
return (String) map.get(key);
}
+
public Map<Object, Object> getMyMap() {
return myMap;
}
@@ -82,15 +81,18 @@ public class MappedPropertyTestBean {
public void setInvalidGetter(final String key, final String value) {
map.put(key, value);
}
+
public String getInvalidSetter(final String key) {
return (String) map.get(key);
}
+
public void setInvalidSetter(final String key, final String value, final String other) {
}
public Long getDifferentTypes(final String key) {
- return Long.valueOf(((Number)map.get(key)).longValue());
+ return Long.valueOf(((Number) map.get(key)).longValue());
}
+
public void setDifferentTypes(final String key, final Integer value) {
map.put(key, value);
}
diff --git a/src/test/java/org/apache/commons/beanutils2/MappedPropertyTestCase.java b/src/test/java/org/apache/commons/beanutils2/MappedPropertyTestCase.java
index 831c4584..6cf50504 100644
--- a/src/test/java/org/apache/commons/beanutils2/MappedPropertyTestCase.java
+++ b/src/test/java/org/apache/commons/beanutils2/MappedPropertyTestCase.java
@@ -21,13 +21,13 @@ import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
- * <p>Test Case for the {@code MappedPropertyDescriptor}.</p>
+ * <p>
+ * Test Case for the {@code MappedPropertyDescriptor}.
+ * </p>
*
*/
public class MappedPropertyTestCase extends TestCase {
-
-
/**
* Constructs a new instance of this test case.
*
@@ -37,13 +37,11 @@ public class MappedPropertyTestCase extends TestCase {
super(name);
}
-
-
/**
* Run this Test
*/
public static void main(final String[] args) {
- junit.textui.TestRunner.run(suite());
+ junit.textui.TestRunner.run(suite());
}
/**
@@ -67,8 +65,6 @@ public class MappedPropertyTestCase extends TestCase {
public void tearDown() {
}
-
-
/**
* Test valid method name
*/
@@ -76,8 +72,7 @@ public class MappedPropertyTestCase extends TestCase {
final String property = "mapproperty";
final Class<?> clazz = MappedPropertyTestBean.class;
try {
- final MappedPropertyDescriptor desc
- = new MappedPropertyDescriptor(property, clazz);
+ final MappedPropertyDescriptor desc = new MappedPropertyDescriptor(property, clazz);
assertNotNull("Getter is missing", desc.getMappedReadMethod());
assertNotNull("Setter is missing", desc.getMappedWriteMethod());
} catch (final Exception ex) {
@@ -92,8 +87,7 @@ public class MappedPropertyTestCase extends TestCase {
final String property = "mappedBoolean";
final Class<?> clazz = MappedPropertyTestBean.class;
try {
- final MappedPropertyDescriptor desc
- = new MappedPropertyDescriptor(property, clazz);
+ final MappedPropertyDescriptor desc = new MappedPropertyDescriptor(property, clazz);
assertNotNull("Getter is missing", desc.getMappedReadMethod());
assertNotNull("Setter is missing", desc.getMappedWriteMethod());
} catch (final Exception ex) {
@@ -122,8 +116,7 @@ public class MappedPropertyTestCase extends TestCase {
final String property = "mappedGetterOnly";
final Class<?> clazz = MappedPropertyTestBean.class;
try {
- final MappedPropertyDescriptor desc
- = new MappedPropertyDescriptor(property, clazz);
+ final MappedPropertyDescriptor desc = new MappedPropertyDescriptor(property, clazz);
assertNotNull("Getter is missing", desc.getMappedReadMethod());
assertNull("Setter is found", desc.getMappedWriteMethod());
} catch (final Exception ex) {
@@ -138,8 +131,7 @@ public class MappedPropertyTestCase extends TestCase {
final String property = "mappedSetterOnly";
final Class<?> clazz = MappedPropertyTestBean.class;
try {
- final MappedPropertyDescriptor desc
- = new MappedPropertyDescriptor(property, clazz);
+ final MappedPropertyDescriptor desc = new MappedPropertyDescriptor(property, clazz);
assertNull("Getter is found", desc.getMappedReadMethod());
assertNotNull("Setter is missing", desc.getMappedWriteMethod());
} catch (final Exception ex) {
@@ -154,8 +146,7 @@ public class MappedPropertyTestCase extends TestCase {
final String property = "invalidSetter";
final Class<?> clazz = MappedPropertyTestBean.class;
try {
- final MappedPropertyDescriptor desc
- = new MappedPropertyDescriptor(property, clazz);
+ final MappedPropertyDescriptor desc = new MappedPropertyDescriptor(property, clazz);
assertNotNull("Getter is missing", desc.getMappedReadMethod());
assertNull("Setter is found", desc.getMappedWriteMethod());
} catch (final Exception ex) {
@@ -170,8 +161,7 @@ public class MappedPropertyTestCase extends TestCase {
final String property = "invalidGetter";
final Class<?> clazz = MappedPropertyTestBean.class;
try {
- final MappedPropertyDescriptor desc
- = new MappedPropertyDescriptor(property, clazz);
+ final MappedPropertyDescriptor desc = new MappedPropertyDescriptor(property, clazz);
assertNull("Getter is found", desc.getMappedReadMethod());
assertNotNull("Setter is missing", desc.getMappedWriteMethod());
} catch (final Exception ex) {
@@ -182,16 +172,14 @@ public class MappedPropertyTestCase extends TestCase {
/**
* Test Mapped Property - Different Types
*
- * Expect to find the getDifferentTypes() method, but not
- * the setDifferentTypes() method because setDifferentTypes()
- * sets and Integer, while getDifferentTypes() returns a Long.
+ * Expect to find the getDifferentTypes() method, but not the setDifferentTypes() method because setDifferentTypes() sets and Integer, while
+ * getDifferentTypes() returns a Long.
*/
public void testDifferentTypes() {
final String property = "differentTypes";
final Class<?> clazz = MappedPropertyTestBean.class;
try {
- final MappedPropertyDescriptor desc
- = new MappedPropertyDescriptor(property, clazz);
+ final MappedPropertyDescriptor desc = new MappedPropertyDescriptor(property, clazz);
assertNotNull("Getter is missing", desc.getMappedReadMethod());
assertNull("Setter is found", desc.getMappedWriteMethod());
} catch (final Exception ex) {
@@ -206,8 +194,8 @@ public class MappedPropertyTestCase extends TestCase {
final MappedPropertyTestBean bean = new MappedPropertyTestBean();
try {
final String testValue = "test value";
- final String testKey = "testKey";
- BeanUtils.setProperty(bean, "myMap("+testKey+")", "test value");
+ final String testKey = "testKey";
+ BeanUtils.setProperty(bean, "myMap(" + testKey + ")", "test value");
assertEquals("Map getter", testValue, bean.getMyMap().get(testKey));
} catch (final Exception ex) {
fail("Test set mapped property failed: " + ex);
@@ -221,8 +209,7 @@ public class MappedPropertyTestCase extends TestCase {
final String property = "anyMapped";
final Class<?> clazz = MappedPropertyTestBean.class;
try {
- final MappedPropertyDescriptor desc
- = new MappedPropertyDescriptor(property, clazz);
+ final MappedPropertyDescriptor desc = new MappedPropertyDescriptor(property, clazz);
assertNull("Getter is found", desc.getMappedReadMethod());
assertNotNull("Setter is missing", desc.getMappedWriteMethod());
} catch (final Exception ex) {
@@ -237,8 +224,7 @@ public class MappedPropertyTestCase extends TestCase {
final String property = "mappedPrimitive";
final Class<?> clazz = MappedPropertyTestBean.class;
try {
- final MappedPropertyDescriptor desc
- = new MappedPropertyDescriptor(property, clazz);
+ final MappedPropertyDescriptor desc = new MappedPropertyDescriptor(property, clazz);
assertNull("Getter is found", desc.getMappedReadMethod());
assertNotNull("Setter is missing", desc.getMappedWriteMethod());
} catch (final Exception ex) {
@@ -267,8 +253,7 @@ public class MappedPropertyTestCase extends TestCase {
final String property = "mapproperty";
final Class<?> clazz = MappedPropertyChildBean.class;
try {
- final MappedPropertyDescriptor desc
- = new MappedPropertyDescriptor(property, clazz);
+ final MappedPropertyDescriptor desc = new MappedPropertyDescriptor(property, clazz);
assertNotNull("Getter is missing", desc.getMappedReadMethod());
assertNotNull("Setter is missing", desc.getMappedWriteMethod());
} catch (final Exception ex) {
@@ -296,8 +281,7 @@ public class MappedPropertyTestCase extends TestCase {
final String property = "mapproperty";
final Class<?> clazz = MappedPropertyTestInterface.class;
try {
- final MappedPropertyDescriptor desc
- = new MappedPropertyDescriptor(property, clazz);
+ final MappedPropertyDescriptor desc = new MappedPropertyDescriptor(property, clazz);
assertNotNull("Getter is missing", desc.getMappedReadMethod());
assertNotNull("Setter is missing", desc.getMappedWriteMethod());
} catch (final Exception ex) {
@@ -325,8 +309,7 @@ public class MappedPropertyTestCase extends TestCase {
final String property = "mapproperty";
final Class<?> clazz = MappedPropertyChildInterface.class;
try {
- final MappedPropertyDescriptor desc
- = new MappedPropertyDescriptor(property, clazz);
+ final MappedPropertyDescriptor desc = new MappedPropertyDescriptor(property, clazz);
assertNotNull("Getter is missing", desc.getMappedReadMethod());
assertNotNull("Setter is missing", desc.getMappedWriteMethod());
} catch (final Exception ex) {
diff --git a/src/test/java/org/apache/commons/beanutils2/MethodUtilsTestCase.java b/src/test/java/org/apache/commons/beanutils2/MethodUtilsTestCase.java
index aa57e77b..1aa83dbc 100644
--- a/src/test/java/org/apache/commons/beanutils2/MethodUtilsTestCase.java
+++ b/src/test/java/org/apache/commons/beanutils2/MethodUtilsTestCase.java
@@ -29,13 +29,13 @@ import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
- * <p> Test case for {@code MethodUtils} </p>
+ * <p>
+ * Test case for {@code MethodUtils}
+ * </p>
*
*/
public class MethodUtilsTestCase extends TestCase {
-
-
/**
* Constructs a new instance of this test case.
*
@@ -45,8 +45,6 @@ public class MethodUtilsTestCase extends TestCase {
super(name);
}
-
-
/**
* Sets up instance variables required by this test case.
*/
@@ -68,15 +66,13 @@ public class MethodUtilsTestCase extends TestCase {
public void tearDown() {
}
-
-
/**
- * <p> Test {@code getAccessibleMethod}.
+ * <p>
+ * Test {@code getAccessibleMethod}.
*/
public void testGetAccessibleMethod() {
// easy bit first - find a public method
- final Method method = MethodUtils.getAccessibleMethod
- (TestBean.class, "setStringProperty", String.class);
+ final Method method = MethodUtils.getAccessibleMethod(TestBean.class, "setStringProperty", String.class);
assertMethod(method, "setStringProperty");
}
@@ -84,10 +80,7 @@ public class MethodUtilsTestCase extends TestCase {
public void testGetAccessibleMethodFromInterface() {
Method method;
// trickier this one - find a method in a direct interface
- method = MethodUtils.getAccessibleMethod
- (PrivateBeanFactory.create().getClass(),
- "methodBar",
- String.class);
+ method = MethodUtils.getAccessibleMethod(PrivateBeanFactory.create().getClass(), "methodBar", String.class);
assertMethod(method, "methodBar");
}
@@ -95,65 +88,48 @@ public class MethodUtilsTestCase extends TestCase {
public void testGetAccessibleMethodIndirectInterface() {
Method method;
// trickier this one - find a method in a indirect interface
- method = MethodUtils.getAccessibleMethod
- (PrivateBeanFactory.createSubclass().getClass(),
- "methodBaz",
- String.class);
+ method = MethodUtils.getAccessibleMethod(PrivateBeanFactory.createSubclass().getClass(), "methodBaz", String.class);
assertMethod(method, "methodBaz");
}
private static void assertMethod(final Method method, final String methodName) {
assertNotNull(method);
- assertEquals("Method is not named correctly", methodName,
- method.getName());
- assertTrue("Method is not public",
- Modifier.isPublic(method.getModifiers()));
+ assertEquals("Method is not named correctly", methodName, method.getName());
+ assertTrue("Method is not public", Modifier.isPublic(method.getModifiers()));
}
/**
- * <p> Test {@code invokeExactMethod}.
+ * <p>
+ * Test {@code invokeExactMethod}.
*/
public void testInvokeExactMethod() throws Exception {
- final TestBean bean = new TestBean();
- final Object ret = MethodUtils.invokeExactMethod(bean, "setStringProperty", "TEST");
+ final TestBean bean = new TestBean();
+ final Object ret = MethodUtils.invokeExactMethod(bean, "setStringProperty", "TEST");
- assertNull(ret);
- assertEquals("Method ONE was invoked", "TEST", bean.getStringProperty());
+ assertNull(ret);
+ assertEquals("Method ONE was invoked", "TEST", bean.getStringProperty());
}
public void testInvokeExactMethodFromInterface() throws Exception {
- final Object ret = MethodUtils.invokeExactMethod(
- PrivateBeanFactory.create(),
- "methodBar",
- "ANOTHER TEST");
+ final Object ret = MethodUtils.invokeExactMethod(PrivateBeanFactory.create(), "methodBar", "ANOTHER TEST");
assertEquals("Method TWO wasn't invoked correctly", "ANOTHER TEST", ret);
}
public void testInvokeExactMethodIndirectInterface() throws Exception {
- final Object ret = MethodUtils.invokeExactMethod(
- PrivateBeanFactory.createSubclass(),
- "methodBaz",
- "YET ANOTHER TEST");
+ final Object ret = MethodUtils.invokeExactMethod(PrivateBeanFactory.createSubclass(), "methodBaz", "YET ANOTHER TEST");
assertEquals("Method TWO was invoked correctly", "YET ANOTHER TEST", ret);
}
public void testInvokeExactMethodNullArray() throws Exception {
- final Object result = MethodUtils.invokeExactMethod(
- new AlphaBean("parent"),
- "getName",
- null);
+ final Object result = MethodUtils.invokeExactMethod(new AlphaBean("parent"), "getName", null);
assertEquals("parent", result);
}
public void testInvokeExactMethodNullArrayNullArray() throws Exception {
- final Object result = MethodUtils.invokeExactMethod(
- new AlphaBean("parent"),
- "getName",
- null,
- null);
+ final Object result = MethodUtils.invokeExactMethod(new AlphaBean("parent"), "getName", null, null);
assertEquals("parent", result);
}
@@ -165,25 +141,21 @@ public class MethodUtilsTestCase extends TestCase {
}
/**
- * <p> Test {@code invokeMethod}.
+ * <p>
+ * Test {@code invokeMethod}.
*/
public void testInvokeMethod() throws Exception {
final AbstractParent parent = new AlphaBean("parent");
final BetaBean childOne = new BetaBean("ChildOne");
- assertEquals(
- "Cannot invoke through abstract class (1)",
- "ChildOne",
- MethodUtils.invokeMethod(parent, "testAddChild", childOne));
+ assertEquals("Cannot invoke through abstract class (1)", "ChildOne", MethodUtils.invokeMethod(parent, "testAddChild", childOne));
}
public void testInvokeMethodObject() throws Exception {
final AbstractParent parent = new AlphaBean("parent");
final Child childTwo = new AlphaBean("ChildTwo");
- assertEquals("Cannot invoke through interface (1)",
- "ChildTwo",
- MethodUtils.invokeMethod(parent, "testAddChild", childTwo));
+ assertEquals("Cannot invoke through interface (1)", "ChildTwo", MethodUtils.invokeMethod(parent, "testAddChild", childTwo));
}
public void testInvokeMethodArray() throws Exception {
@@ -194,9 +166,7 @@ public class MethodUtilsTestCase extends TestCase {
params[0] = "parameter";
params[1] = childTwo;
- assertEquals("Cannot invoke through abstract class",
- "ChildTwo",
- MethodUtils.invokeMethod(parent, "testAddChild2", params));
+ assertEquals("Cannot invoke through abstract class", "ChildTwo", MethodUtils.invokeMethod(parent, "testAddChild2", params));
}
public void testInvokeMethodUnknown() throws Exception {
@@ -213,20 +183,13 @@ public class MethodUtilsTestCase extends TestCase {
}
public void testInvokeMethodNullArray() throws Exception {
- final Object result = MethodUtils.invokeMethod(
- new AlphaBean("parent"),
- "getName",
- null);
+ final Object result = MethodUtils.invokeMethod(new AlphaBean("parent"), "getName", null);
assertEquals("parent", result);
}
public void testInvokeMethodNullArrayNullArray() throws Exception {
- final Object result = MethodUtils.invokeMethod(
- new AlphaBean("parent"),
- "getName",
- null,
- null);
+ final Object result = MethodUtils.invokeMethod(new AlphaBean("parent"), "getName", null, null);
assertEquals("parent", result);
}
@@ -281,14 +244,13 @@ public class MethodUtilsTestCase extends TestCase {
value = MethodUtils.invokeStaticMethod(TestBean.class, "currentCounter", new Object[0]);
assertEquals("currentCounter value", current, ((Integer) value).intValue());
- MethodUtils.invokeStaticMethod(TestBean.class, "incrementCounter", new Object[] { Integer.valueOf(8) } );
+ MethodUtils.invokeStaticMethod(TestBean.class, "incrementCounter", new Object[] { Integer.valueOf(8) });
current += 8;
value = MethodUtils.invokeStaticMethod(TestBean.class, "currentCounter", new Object[0]);
assertEquals("currentCounter value", current, ((Integer) value).intValue());
- MethodUtils.invokeExactStaticMethod(TestBean.class, "incrementCounter",
- new Object[] { Integer.valueOf(8) }, new Class[] { Number.class } );
+ MethodUtils.invokeExactStaticMethod(TestBean.class, "incrementCounter", new Object[] { Integer.valueOf(8) }, new Class[] { Number.class });
current += 16;
value = MethodUtils.invokeStaticMethod(TestBean.class, "currentCounter", new Object[0]);
@@ -319,46 +281,30 @@ public class MethodUtilsTestCase extends TestCase {
try {
// Return initial value of the counter
- value = MethodUtils.invokeMethod
- (bean, "currentCounter", new Object[0], new Class[0]);
+ value = MethodUtils.invokeMethod(bean, "currentCounter", new Object[0], new Class[0]);
assertNotNull("currentCounter exists", value);
- assertTrue("currentCounter type",
- value instanceof Integer);
- assertEquals("currentCounter value",
- current,
- ((Integer) value).intValue());
+ assertTrue("currentCounter type", value instanceof Integer);
+ assertEquals("currentCounter value", current, ((Integer) value).intValue());
// Increment via no-arguments version
- MethodUtils.invokeMethod
- (bean, "incrementCounter", new Object[0], new Class[0]);
+ MethodUtils.invokeMethod(bean, "incrementCounter", new Object[0], new Class[0]);
// Validate updated value
current++;
- value = MethodUtils.invokeMethod
- (bean, "currentCounter", new Object[0], new Class[0]);
+ value = MethodUtils.invokeMethod(bean, "currentCounter", new Object[0], new Class[0]);
assertNotNull("currentCounter exists", value);
- assertTrue("currentCounter type",
- value instanceof Integer);
- assertEquals("currentCounter value",
- current,
- ((Integer) value).intValue());
+ assertTrue("currentCounter type", value instanceof Integer);
+ assertEquals("currentCounter value", current, ((Integer) value).intValue());
// Increment via specified-argument version
- MethodUtils.invokeMethod
- (bean, "incrementCounter",
- new Object[] { Integer.valueOf(5) },
- new Class[] { Integer.TYPE });
+ MethodUtils.invokeMethod(bean, "incrementCounter", new Object[] { Integer.valueOf(5) }, new Class[] { Integer.TYPE });
// Validate updated value
current += 5;
- value = MethodUtils.invokeMethod
- (bean, "currentCounter", new Object[0], new Class[0]);
+ value = MethodUtils.invokeMethod(bean, "currentCounter", new Object[0], new Class[0]);
assertNotNull("currentCounter exists", value);
- assertTrue("currentCounter type",
- value instanceof Integer);
- assertEquals("currentCounter value",
- current,
- ((Integer) value).intValue());
+ assertTrue("currentCounter type", value instanceof Integer);
+ assertEquals("currentCounter value", current, ((Integer) value).intValue());
} catch (final Exception e) {
fail("Threw exception" + e);
@@ -378,46 +324,30 @@ public class MethodUtilsTestCase extends TestCase {
try {
// Return initial value of the counter
- value = MethodUtils.invokeExactMethod
- (bean, "currentCounter", new Object[0], new Class[0]);
+ value = MethodUtils.invokeExactMethod(bean, "currentCounter", new Object[0], new Class[0]);
assertNotNull("currentCounter exists", value);
- assertTrue("currentCounter type",
- value instanceof Integer);
- assertEquals("currentCounter value",
- current,
- ((Integer) value).intValue());
+ assertTrue("currentCounter type", value instanceof Integer);
+ assertEquals("currentCounter value", current, ((Integer) value).intValue());
// Increment via no-arguments version
- MethodUtils.invokeExactMethod
- (bean, "incrementCounter", new Object[0], new Class[0]);
+ MethodUtils.invokeExactMethod(bean, "incrementCounter", new Object[0], new Class[0]);
// Validate updated value
current++;
- value = MethodUtils.invokeExactMethod
- (bean, "currentCounter", new Object[0], new Class[0]);
+ value = MethodUtils.invokeExactMethod(bean, "currentCounter", new Object[0], new Class[0]);
assertNotNull("currentCounter exists", value);
- assertTrue("currentCounter type",
- value instanceof Integer);
- assertEquals("currentCounter value",
- current,
- ((Integer) value).intValue());
+ assertTrue("currentCounter type", value instanceof Integer);
+ assertEquals("currentCounter value", current, ((Integer) value).intValue());
// Increment via specified-argument version
- MethodUtils.invokeExactMethod
- (bean, "incrementCounter",
- new Object[] { Integer.valueOf(5) },
- new Class[] { Integer.TYPE });
+ MethodUtils.invokeExactMethod(bean, "incrementCounter", new Object[] { Integer.valueOf(5) }, new Class[] { Integer.TYPE });
// Validate updated value
current += 5;
- value = MethodUtils.invokeExactMethod
- (bean, "currentCounter", new Object[0], new Class[0]);
+ value = MethodUtils.invokeExactMethod(bean, "currentCounter", new Object[0], new Class[0]);
assertNotNull("currentCounter exists", value);
- assertTrue("currentCounter type",
- value instanceof Integer);
- assertEquals("currentCounter value",
- current,
- ((Integer) value).intValue());
+ assertTrue("currentCounter type", value instanceof Integer);
+ assertEquals("currentCounter value", current, ((Integer) value).intValue());
} catch (final Exception e) {
fail("Threw exception" + e);
@@ -436,60 +366,30 @@ public class MethodUtilsTestCase extends TestCase {
try {
// Acquire the methods we need
- final Method currentCounterMethod = MethodUtils.getAccessibleMethod
- (TestBean.class, "currentCounter",
- new Class[0]);
- assertNotNull("currentCounterMethod exists",
- currentCounterMethod);
- assertEquals("currentCounterMethod name",
- "currentCounter",
- currentCounterMethod.getName());
- assertEquals("currentCounterMethod args",
- 0,
- currentCounterMethod.getParameterTypes().length);
- assertTrue("currentCounterMethod public",
- Modifier.isPublic(currentCounterMethod.getModifiers()));
- assertTrue("currentCounterMethod static",
- Modifier.isStatic(currentCounterMethod.getModifiers()));
- final Method incrementCounterMethod1 = MethodUtils.getAccessibleMethod
- (TestBean.class, "incrementCounter",
- new Class[0]);
- assertNotNull("incrementCounterMethod1 exists",
- incrementCounterMethod1);
- assertEquals("incrementCounterMethod1 name",
- "incrementCounter",
- incrementCounterMethod1.getName());
- assertEquals("incrementCounterMethod1 args",
- 0,
- incrementCounterMethod1.getParameterTypes().length);
- assertTrue("incrementCounterMethod1 public",
- Modifier.isPublic(incrementCounterMethod1.getModifiers()));
- assertTrue("incrementCounterMethod1 static",
- Modifier.isStatic(incrementCounterMethod1.getModifiers()));
- final Method incrementCounterMethod2 = MethodUtils.getAccessibleMethod
- (TestBean.class, "incrementCounter",
- new Class[] { Integer.TYPE });
- assertNotNull("incrementCounterMethod2 exists",
- incrementCounterMethod2);
- assertEquals("incrementCounterMethod2 name",
- "incrementCounter",
- incrementCounterMethod2.getName());
- assertEquals("incrementCounterMethod2 args",
- 1,
- incrementCounterMethod2.getParameterTypes().length);
- assertTrue("incrementCounterMethod2 public",
- Modifier.isPublic(incrementCounterMethod2.getModifiers()));
- assertTrue("incrementCounterMethod2 static",
- Modifier.isStatic(incrementCounterMethod2.getModifiers()));
+ final Method currentCounterMethod = MethodUtils.getAccessibleMethod(TestBean.class, "currentCounter", new Class[0]);
+ assertNotNull("currentCounterMethod exists", currentCounterMethod);
+ assertEquals("currentCounterMethod name", "currentCounter", currentCounterMethod.getName());
+ assertEquals("currentCounterMethod args", 0, currentCounterMethod.getParameterTypes().length);
+ assertTrue("currentCounterMethod public", Modifier.isPublic(currentCounterMethod.getModifiers()));
+ assertTrue("currentCounterMethod static", Modifier.isStatic(currentCounterMethod.getModifiers()));
+ final Method incrementCounterMethod1 = MethodUtils.getAccessibleMethod(TestBean.class, "incrementCounter", new Class[0]);
+ assertNotNull("incrementCounterMethod1 exists", incrementCounterMethod1);
+ assertEquals("incrementCounterMethod1 name", "incrementCounter", incrementCounterMethod1.getName());
+ assertEquals("incrementCounterMethod1 args", 0, incrementCounterMethod1.getParameterTypes().length);
+ assertTrue("incrementCounterMethod1 public", Modifier.isPublic(incrementCounterMethod1.getModifiers()));
+ assertTrue("incrementCounterMethod1 static", Modifier.isStatic(incrementCounterMethod1.getModifiers()));
+ final Method incrementCounterMethod2 = MethodUtils.getAccessibleMethod(TestBean.class, "incrementCounter", new Class[] { Integer.TYPE });
+ assertNotNull("incrementCounterMethod2 exists", incrementCounterMethod2);
+ assertEquals("incrementCounterMethod2 name", "incrementCounter", incrementCounterMethod2.getName());
+ assertEquals("incrementCounterMethod2 args", 1, incrementCounterMethod2.getParameterTypes().length);
+ assertTrue("incrementCounterMethod2 public", Modifier.isPublic(incrementCounterMethod2.getModifiers()));
+ assertTrue("incrementCounterMethod2 static", Modifier.isStatic(incrementCounterMethod2.getModifiers()));
// Return initial value of the counter
value = currentCounterMethod.invoke(null);
assertNotNull("currentCounter exists", value);
- assertTrue("currentCounter type",
- value instanceof Integer);
- assertEquals("currentCounter value",
- current,
- ((Integer) value).intValue());
+ assertTrue("currentCounter type", value instanceof Integer);
+ assertEquals("currentCounter value", current, ((Integer) value).intValue());
// Increment via no-arguments version
incrementCounterMethod1.invoke(null);
@@ -498,11 +398,8 @@ public class MethodUtilsTestCase extends TestCase {
current++;
value = currentCounterMethod.invoke(null);
assertNotNull("currentCounter exists", value);
- assertTrue("currentCounter type",
- value instanceof Integer);
- assertEquals("currentCounter value",
- current,
- ((Integer) value).intValue());
+ assertTrue("currentCounter type", value instanceof Integer);
+ assertEquals("currentCounter value", current, ((Integer) value).intValue());
// Increment via specified-argument version
incrementCounterMethod2.invoke(null, Integer.valueOf(5));
@@ -511,11 +408,8 @@ public class MethodUtilsTestCase extends TestCase {
current += 5;
value = currentCounterMethod.invoke(null);
assertNotNull("currentCounter exists", value);
- assertTrue("currentCounter type",
- value instanceof Integer);
- assertEquals("currentCounter value",
- current,
- ((Integer) value).intValue());
+ assertTrue("currentCounter type", value instanceof Integer);
+ assertEquals("currentCounter value", current, ((Integer) value).intValue());
} catch (final Exception e) {
fail("Threw exception" + e);
@@ -572,16 +466,13 @@ public class MethodUtilsTestCase extends TestCase {
public void testParentMethod() throws Exception {
final String a = "A";
- assertAll(
- () -> {
- final String actual1 = (String) MethodUtils.invokeMethod(a, "toLowerCase", null);
- assertEquals("a", actual1);
- },
- () -> {
- final char actual2 = (char) MethodUtils.invokeMethod(a, "charAt", 0);
- assertEquals('A', actual2);
- }
- );
+ assertAll(() -> {
+ final String actual1 = (String) MethodUtils.invokeMethod(a, "toLowerCase", null);
+ assertEquals("a", actual1);
+ }, () -> {
+ final char actual2 = (char) MethodUtils.invokeMethod(a, "charAt", 0);
+ assertEquals('A', actual2);
+ });
}
/**
diff --git a/src/test/java/org/apache/commons/beanutils2/NestedTestBean.java b/src/test/java/org/apache/commons/beanutils2/NestedTestBean.java
index 5f2194af..d53010ff 100644
--- a/src/test/java/org/apache/commons/beanutils2/NestedTestBean.java
+++ b/src/test/java/org/apache/commons/beanutils2/NestedTestBean.java
@@ -24,13 +24,10 @@ package org.apache.commons.beanutils2;
public class NestedTestBean {
-
public NestedTestBean(final String name) {
setName(name);
}
-
-
private String name;
public String getName() {
@@ -88,6 +85,4 @@ public class NestedTestBean {
return simpleBean;
}
-
-
}
diff --git a/src/test/java/org/apache/commons/beanutils2/PropertyUtilsBenchCase.java b/src/test/java/org/apache/commons/beanutils2/PropertyUtilsBenchCase.java
index 40859f44..2dd9a276 100644
--- a/src/test/java/org/apache/commons/beanutils2/PropertyUtilsBenchCase.java
+++ b/src/test/java/org/apache/commons/beanutils2/PropertyUtilsBenchCase.java
@@ -31,8 +31,6 @@ import junit.framework.TestSuite;
public class PropertyUtilsBenchCase extends TestCase {
-
-
/**
* Constructs a new instance of this test case.
*
@@ -44,8 +42,6 @@ public class PropertyUtilsBenchCase extends TestCase {
}
-
-
// Basic loop counter
private long counter = 100000;
@@ -64,8 +60,6 @@ public class PropertyUtilsBenchCase extends TestCase {
// PropertyUtilsBean instance to be used
private PropertyUtilsBean pu = null;
-
-
/**
* Sets up instance variables required by this test case.
*/
@@ -79,18 +73,11 @@ public class PropertyUtilsBenchCase extends TestCase {
}
// Set up DynaClass for our DynaBean instances
- dynaClass = new BasicDynaClass
- ("BenchDynaClass", null,
- new DynaProperty[]{
- new DynaProperty("booleanProperty", Boolean.TYPE),
- new DynaProperty("byteProperty", Byte.TYPE),
- new DynaProperty("doubleProperty", Double.TYPE),
- new DynaProperty("floatProperty", Float.TYPE),
- new DynaProperty("intProperty", Integer.TYPE),
- new DynaProperty("longProperty", Long.TYPE),
- new DynaProperty("shortProperty", Short.TYPE),
- new DynaProperty("stringProperty", String.class),
- });
+ dynaClass = new BasicDynaClass("BenchDynaClass", null,
+ new DynaProperty[] { new DynaProperty("booleanProperty", Boolean.TYPE), new DynaProperty("byteProperty", Byte.TYPE),
+ new DynaProperty("doubleProperty", Double.TYPE), new DynaProperty("floatProperty", Float.TYPE),
+ new DynaProperty("intProperty", Integer.TYPE), new DynaProperty("longProperty", Long.TYPE),
+ new DynaProperty("shortProperty", Short.TYPE), new DynaProperty("stringProperty", String.class), });
// Create input instances
inBean = new BenchBean();
@@ -146,8 +133,6 @@ public class PropertyUtilsBenchCase extends TestCase {
}
-
-
// Time copyProperties() from a bean
public void testCopyPropertiesBean() throws Exception {
@@ -163,8 +148,7 @@ public class PropertyUtilsBenchCase extends TestCase {
pu.copyProperties(outBean, inBean);
}
stopMillis = System.currentTimeMillis();
- System.err.println("PU.copyProperties(bean,bean), count=" + counter +
- ", time=" + (stopMillis - startMillis));
+ System.err.println("PU.copyProperties(bean,bean), count=" + counter + ", time=" + (stopMillis - startMillis));
// Bean->Dyna
for (long i = 0; i < counter; i++) {
@@ -175,8 +159,7 @@ public class PropertyUtilsBenchCase extends TestCase {
pu.copyProperties(outDyna, inBean);
}
stopMillis = System.currentTimeMillis();
- System.err.println("PU.copyProperties(dyna,bean), count=" + counter +
- ", time=" + (stopMillis - startMillis));
+ System.err.println("PU.copyProperties(dyna,bean), count=" + counter + ", time=" + (stopMillis - startMillis));
}
@@ -195,8 +178,7 @@ public class PropertyUtilsBenchCase extends TestCase {
pu.copyProperties(outBean, inDyna);
}
stopMillis = System.currentTimeMillis();
- System.err.println("PU.copyProperties(bean,dyna), count=" + counter +
- ", time=" + (stopMillis - startMillis));
+ System.err.println("PU.copyProperties(bean,dyna), count=" + counter + ", time=" + (stopMillis - startMillis));
// Dyna->Dyna
for (long i = 0; i < counter; i++) {
@@ -207,8 +189,7 @@ public class PropertyUtilsBenchCase extends TestCase {
pu.copyProperties(outDyna, inDyna);
}
stopMillis = System.currentTimeMillis();
- System.err.println("PU.copyProperties(dyna,dyna), count=" + counter +
- ", time=" + (stopMillis - startMillis));
+ System.err.println("PU.copyProperties(dyna,dyna), count=" + counter + ", time=" + (stopMillis - startMillis));
}
@@ -227,8 +208,7 @@ public class PropertyUtilsBenchCase extends TestCase {
pu.copyProperties(outBean, inMap);
}
stopMillis = System.currentTimeMillis();
- System.err.println("PU.copyProperties(bean, map), count=" + counter +
- ", time=" + (stopMillis - startMillis));
+ System.err.println("PU.copyProperties(bean, map), count=" + counter + ", time=" + (stopMillis - startMillis));
// Dyna->Dyna
for (long i = 0; i < counter; i++) {
@@ -239,11 +219,8 @@ public class PropertyUtilsBenchCase extends TestCase {
pu.copyProperties(outDyna, inMap);
}
stopMillis = System.currentTimeMillis();
- System.err.println("PU.copyProperties(dyna, map), count=" + counter +
- ", time=" + (stopMillis - startMillis));
+ System.err.println("PU.copyProperties(dyna, map), count=" + counter + ", time=" + (stopMillis - startMillis));
}
-
-
}
diff --git a/src/test/java/org/apache/commons/beanutils2/PropertyUtilsTestCase.java b/src/test/java/org/apache/commons/beanutils2/PropertyUtilsTestCase.java
index 8c280ccb..f30e08a5 100644
--- a/src/test/java/org/apache/commons/beanutils2/PropertyUtilsTestCase.java
+++ b/src/test/java/org/apache/commons/beanutils2/PropertyUtilsTestCase.java
@@ -38,12 +38,14 @@ import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
- * <p>Test Case for the PropertyUtils class. The majority of these tests use
- * instances of the TestBean class, so be sure to update the tests if you
- * change the characteristics of that class.</p>
+ * <p>
+ * Test Case for the PropertyUtils class. The majority of these tests use instances of the TestBean class, so be sure to update the tests if you change the
+ * characteristics of that class.
+ * </p>
*
- * <p>So far, this test case has tests for the following methods of the
- * {@code PropertyUtils} class:</p>
+ * <p>
+ * So far, this test case has tests for the following methods of the {@code PropertyUtils} class:
+ * </p>
* <ul>
* <li>getIndexedProperty(Object,String)</li>
* <li>getIndexedProperty(Object,String,int)</li>
@@ -66,27 +68,20 @@ import junit.framework.TestSuite;
public class PropertyUtilsTestCase extends TestCase {
-
-
/**
- * The fully qualified class name of our private directly
- * implemented interface.
+ * The fully qualified class name of our private directly implemented interface.
*/
- private static final String PRIVATE_DIRECT_CLASS =
- "org.apache.commons.beanutils2.priv.PrivateDirect";
+ private static final String PRIVATE_DIRECT_CLASS = "org.apache.commons.beanutils2.priv.PrivateDirect";
/**
- * The fully qualified class name of our private indirectly
- * implemented interface.
+ * The fully qualified class name of our private indirectly implemented interface.
*/
- private static final String PRIVATE_INDIRECT_CLASS =
- "org.apache.commons.beanutils2.priv.PrivateIndirect";
+ private static final String PRIVATE_INDIRECT_CLASS = "org.apache.commons.beanutils2.priv.PrivateIndirect";
/**
* The fully qualified class name of our test bean class.
*/
- private static final String TEST_BEAN_CLASS =
- "org.apache.commons.beanutils2.TestBean";
+ private static final String TEST_BEAN_CLASS = "org.apache.commons.beanutils2.TestBean";
/**
* The basic test bean for each test.
@@ -116,55 +111,25 @@ public class PropertyUtilsTestCase extends TestCase {
/**
* The set of properties that should be described.
*/
- protected String[] describes =
- { "booleanProperty",
- "booleanSecond",
- "doubleProperty",
- "floatProperty",
- "intArray",
- // "intIndexed",
- "intProperty",
- "listIndexed",
- "longProperty",
- // "mappedObjects",
- // "mappedProperty",
- // "mappedIntProperty",
- "nested",
- "nullProperty",
- // "readOnlyProperty",
- "shortProperty",
- "stringArray",
- // "stringIndexed",
- "stringProperty"
- };
-
- /**
- * The set of property names we expect to have returned when calling
- * {@code getPropertyDescriptors()}. You should update this list
- * when new properties are added to TestBean.
- */
- protected final static String[] properties = {
- "booleanProperty",
- "booleanSecond",
- "doubleProperty",
- "dupProperty",
- "floatProperty",
- "intArray",
- "intIndexed",
- "intProperty",
- "listIndexed",
- "longProperty",
- "nested",
- "nullProperty",
- "readOnlyProperty",
- "shortProperty",
- "stringArray",
- "stringIndexed",
- "stringProperty",
- "writeOnlyProperty",
- };
-
+ protected String[] describes = { "booleanProperty", "booleanSecond", "doubleProperty", "floatProperty", "intArray",
+ // "intIndexed",
+ "intProperty", "listIndexed", "longProperty",
+ // "mappedObjects",
+ // "mappedProperty",
+ // "mappedIntProperty",
+ "nested", "nullProperty",
+ // "readOnlyProperty",
+ "shortProperty", "stringArray",
+ // "stringIndexed",
+ "stringProperty" };
+ /**
+ * The set of property names we expect to have returned when calling {@code getPropertyDescriptors()}. You should update this list when new properties are
+ * added to TestBean.
+ */
+ protected final static String[] properties = { "booleanProperty", "booleanSecond", "doubleProperty", "dupProperty", "floatProperty", "intArray",
+ "intIndexed", "intProperty", "listIndexed", "longProperty", "nested", "nullProperty", "readOnlyProperty", "shortProperty", "stringArray",
+ "stringIndexed", "stringProperty", "writeOnlyProperty", };
/**
* Constructs a new instance of this test case.
@@ -177,8 +142,6 @@ public class PropertyUtilsTestCase extends TestCase {
}
-
-
/**
* Sets up instance variables required by this test case.
*/
@@ -191,11 +154,8 @@ public class PropertyUtilsTestCase extends TestCase {
beanPrivateSubclass = PrivateBeanFactory.createSubclass();
beanPublicSubclass = new TestBeanPublicSubclass();
- final DynaProperty[] properties = {
- new DynaProperty("stringProperty", String.class),
- new DynaProperty("nestedBean", TestBean.class),
- new DynaProperty("nullDynaBean", DynaBean.class)
- };
+ final DynaProperty[] properties = { new DynaProperty("stringProperty", String.class), new DynaProperty("nestedBean", TestBean.class),
+ new DynaProperty("nullDynaBean", DynaBean.class) };
final BasicDynaClass dynaClass = new BasicDynaClass("nestedDynaBean", BasicDynaBean.class, properties);
final BasicDynaBean nestedDynaBean = new BasicDynaBean(dynaClass);
nestedDynaBean.set("nestedBean", bean);
@@ -227,8 +187,6 @@ public class PropertyUtilsTestCase extends TestCase {
PropertyUtils.resetBeanIntrospectors();
}
-
-
/**
* Test copyProperties() when the origin is a {@code Map}.
*/
@@ -252,20 +210,13 @@ public class PropertyUtilsTestCase extends TestCase {
}
// Scalar properties
- assertEquals("booleanProperty", false,
- bean.getBooleanProperty());
- assertEquals("doubleProperty", 333.0,
- bean.getDoubleProperty(), 0.005);
- assertEquals("floatProperty", (float) 222.0,
- bean.getFloatProperty(), (float) 0.005);
- assertEquals("intProperty", 111,
- bean.getIntProperty());
- assertEquals("longProperty", 444,
- bean.getLongProperty());
- assertEquals("shortProperty", (short) 555,
- bean.getShortProperty());
- assertEquals("stringProperty", "New String Property",
- bean.getStringProperty());
+ assertEquals("booleanProperty", false, bean.getBooleanProperty());
+ assertEquals("doubleProperty", 333.0, bean.getDoubleProperty(), 0.005);
+ assertEquals("floatProperty", (float) 222.0, bean.getFloatProperty(), (float) 0.005);
+ assertEquals("intProperty", 111, bean.getIntProperty());
+ assertEquals("longProperty", 444, bean.getLongProperty());
+ assertEquals("shortProperty", (short) 555, bean.getShortProperty());
+ assertEquals("stringProperty", "New String Property", bean.getStringProperty());
// Indexed Properties
final String[] dupProperty = bean.getDupProperty();
@@ -297,28 +248,18 @@ public class PropertyUtilsTestCase extends TestCase {
// Verify existence of all the properties that should be present
for (final String describe : describes) {
- assertTrue("Property '" + describe + "' is present",
- map.containsKey(describe));
+ assertTrue("Property '" + describe + "' is present", map.containsKey(describe));
}
- assertTrue("Property 'writeOnlyProperty' is not present",
- !map.containsKey("writeOnlyProperty"));
+ assertTrue("Property 'writeOnlyProperty' is not present", !map.containsKey("writeOnlyProperty"));
// Verify the values of scalar properties
- assertEquals("Value of 'booleanProperty'",
- Boolean.TRUE, map.get("booleanProperty"));
- assertEquals("Value of 'doubleProperty'",
- Double.valueOf(321.0), map.get("doubleProperty"));
- assertEquals("Value of 'floatProperty'",
- Float.valueOf((float) 123.0), map.get("floatProperty"));
- assertEquals("Value of 'intProperty'",
- Integer.valueOf(123), map.get("intProperty"));
- assertEquals("Value of 'longProperty'",
- Long.valueOf(321), map.get("longProperty"));
- assertEquals("Value of 'shortProperty'",
- Short.valueOf((short) 987), map.get("shortProperty"));
- assertEquals("Value of 'stringProperty'",
- "This is a string",
- (String) map.get("stringProperty"));
+ assertEquals("Value of 'booleanProperty'", Boolean.TRUE, map.get("booleanProperty"));
+ assertEquals("Value of 'doubleProperty'", Double.valueOf(321.0), map.get("doubleProperty"));
+ assertEquals("Value of 'floatProperty'", Float.valueOf((float) 123.0), map.get("floatProperty"));
+ assertEquals("Value of 'intProperty'", Integer.valueOf(123), map.get("intProperty"));
+ assertEquals("Value of 'longProperty'", Long.valueOf(321), map.get("longProperty"));
+ assertEquals("Value of 'shortProperty'", Short.valueOf((short) 987), map.get("shortProperty"));
+ assertEquals("Value of 'stringProperty'", "This is a string", (String) map.get("stringProperty"));
}
@@ -352,8 +293,7 @@ public class PropertyUtilsTestCase extends TestCase {
*/
public void testGetDescriptorBoolean() {
- testGetDescriptorBase("booleanProperty", "getBooleanProperty",
- "setBooleanProperty");
+ testGetDescriptorBase("booleanProperty", "getBooleanProperty", "setBooleanProperty");
}
@@ -362,8 +302,7 @@ public class PropertyUtilsTestCase extends TestCase {
*/
public void testGetDescriptorDouble() {
- testGetDescriptorBase("doubleProperty", "getDoubleProperty",
- "setDoubleProperty");
+ testGetDescriptorBase("doubleProperty", "getDoubleProperty", "setDoubleProperty");
}
@@ -372,8 +311,7 @@ public class PropertyUtilsTestCase extends TestCase {
*/
public void testGetDescriptorFloat() {
- testGetDescriptorBase("floatProperty", "getFloatProperty",
- "setFloatProperty");
+ testGetDescriptorBase("floatProperty", "getFloatProperty", "setFloatProperty");
}
@@ -382,35 +320,30 @@ public class PropertyUtilsTestCase extends TestCase {
*/
public void testGetDescriptorInt() {
- testGetDescriptorBase("intProperty", "getIntProperty",
- "setIntProperty");
+ testGetDescriptorBase("intProperty", "getIntProperty", "setIntProperty");
}
/**
- * <p>Negative tests on an invalid property with two different boolean
- * getters (which is fine, according to the JavaBeans spec) but a
- * String setter instead of a boolean setter.</p>
+ * <p>
+ * Negative tests on an invalid property with two different boolean getters (which is fine, according to the JavaBeans spec) but a String setter instead of
+ * a boolean setter.
+ * </p>
*
- * <p>Although one could logically argue that this combination of method
- * signatures should not identify a property at all, there is a sentence
- * in Section 8.3.1 making it clear that the behavior tested for here
- * is correct: "If we find only one of these methods, then we regard
- * it as defining either a read-only or write-only property called
- * <em><property-name></em>.</p>
+ * <p>
+ * Although one could logically argue that this combination of method signatures should not identify a property at all, there is a sentence in Section 8.3.1
+ * making it clear that the behavior tested for here is correct: "If we find only one of these methods, then we regard it as defining either a read-only or
+ * write-only property called <em><property-name></em>.
+ * </p>
*/
public void testGetDescriptorInvalidBoolean() throws Exception {
- final PropertyDescriptor pd =
- PropertyUtils.getPropertyDescriptor(bean, "invalidBoolean");
- assertNotNull("invalidBoolean is a property", pd);
- assertNotNull("invalidBoolean has a getter method",
- pd.getReadMethod());
- assertNull("invalidBoolean has no write method",
- pd.getWriteMethod());
- assertTrue("invalidBoolean getter method is isInvalidBoolean or getInvalidBoolean",
- Arrays.asList("isInvalidBoolean", "getInvalidBoolean")
- .contains(pd.getReadMethod().getName()));
+ final PropertyDescriptor pd = PropertyUtils.getPropertyDescriptor(bean, "invalidBoolean");
+ assertNotNull("invalidBoolean is a property", pd);
+ assertNotNull("invalidBoolean has a getter method", pd.getReadMethod());
+ assertNull("invalidBoolean has no write method", pd.getWriteMethod());
+ assertTrue("invalidBoolean getter method is isInvalidBoolean or getInvalidBoolean",
+ Arrays.asList("isInvalidBoolean", "getInvalidBoolean").contains(pd.getReadMethod().getName()));
}
/**
@@ -418,8 +351,7 @@ public class PropertyUtilsTestCase extends TestCase {
*/
public void testGetDescriptorLong() {
- testGetDescriptorBase("longProperty", "getLongProperty",
- "setLongProperty");
+ testGetDescriptorBase("longProperty", "getLongProperty", "setLongProperty");
}
@@ -434,53 +366,39 @@ public class PropertyUtilsTestCase extends TestCase {
final Integer testIntegerValue = Integer.valueOf(1234);
bean.setMappedIntProperty("key.with.a.dot", testIntegerValue.intValue());
- assertEquals("Can retrieve directly",
- testIntegerValue,
- Integer.valueOf(bean.getMappedIntProperty("key.with.a.dot")));
- try {
- desc = PropertyUtils.getPropertyDescriptor
- (bean, "mappedIntProperty(key.with.a.dot)");
- assertEquals("Check descriptor type (A)",
- Integer.TYPE,
- ((MappedPropertyDescriptor)desc).getMappedPropertyType());
+ assertEquals("Can retrieve directly", testIntegerValue, Integer.valueOf(bean.getMappedIntProperty("key.with.a.dot")));
+ try {
+ desc = PropertyUtils.getPropertyDescriptor(bean, "mappedIntProperty(key.with.a.dot)");
+ assertEquals("Check descriptor type (A)", Integer.TYPE, ((MappedPropertyDescriptor) desc).getMappedPropertyType());
} catch (final Exception e) {
fail("Threw exception (A): " + e);
}
bean.setMappedObjects("nested.property", new TestBean(testIntegerValue.intValue()));
- assertEquals("Can retrieve directly",
- testIntegerValue,
- Integer.valueOf(((TestBean)bean.getMappedObjects("nested.property")).getIntProperty()));
- try {
- desc = PropertyUtils.getPropertyDescriptor
- (bean, "mappedObjects(nested.property).intProperty");
- assertEquals("Check descriptor type (B)",
- Integer.TYPE,
- desc.getPropertyType());
+ assertEquals("Can retrieve directly", testIntegerValue, Integer.valueOf(((TestBean) bean.getMappedObjects("nested.property")).getIntProperty()));
+ try {
+ desc = PropertyUtils.getPropertyDescriptor(bean, "mappedObjects(nested.property).intProperty");
+ assertEquals("Check descriptor type (B)", Integer.TYPE, desc.getPropertyType());
} catch (final Exception e) {
fail("Threw exception (B): " + e);
}
}
/**
- * Positive getPropertyDescriptor on property
- * {@code readOnlyProperty}.
+ * Positive getPropertyDescriptor on property {@code readOnlyProperty}.
*/
public void testGetDescriptorReadOnly() {
- testGetDescriptorBase("readOnlyProperty", "getReadOnlyProperty",
- null);
+ testGetDescriptorBase("readOnlyProperty", "getReadOnlyProperty", null);
}
/**
- * Positive getPropertyDescriptor on property {@code booleanSecond}
- * that uses an "is" method as the getter.
+ * Positive getPropertyDescriptor on property {@code booleanSecond} that uses an "is" method as the getter.
*/
public void testGetDescriptorSecond() {
- testGetDescriptorBase("booleanSecond", "isBooleanSecond",
- "setBooleanSecond");
+ testGetDescriptorBase("booleanSecond", "isBooleanSecond", "setBooleanSecond");
}
@@ -489,8 +407,7 @@ public class PropertyUtilsTestCase extends TestCase {
*/
public void testGetDescriptorShort() {
- testGetDescriptorBase("shortProperty", "getShortProperty",
- "setShortProperty");
+ testGetDescriptorBase("shortProperty", "getShortProperty", "setShortProperty");
}
@@ -499,8 +416,7 @@ public class PropertyUtilsTestCase extends TestCase {
*/
public void testGetDescriptorString() {
- testGetDescriptorBase("stringProperty", "getStringProperty",
- "setStringProperty");
+ testGetDescriptorBase("stringProperty", "getStringProperty", "setStringProperty");
}
@@ -514,24 +430,20 @@ public class PropertyUtilsTestCase extends TestCase {
}
/**
- * Positive getPropertyDescriptor on property
- * {@code writeOnlyProperty}.
+ * Positive getPropertyDescriptor on property {@code writeOnlyProperty}.
*/
public void testGetDescriptorWriteOnly() {
- testGetDescriptorBase("writeOnlyProperty", null,
- "setWriteOnlyProperty");
+ testGetDescriptorBase("writeOnlyProperty", null, "setWriteOnlyProperty");
}
/**
- * Positive test for getPropertyDescriptors(). Each property name
- * listed in {@code properties} should be returned exactly once.
+ * Positive test for getPropertyDescriptors(). Each property name listed in {@code properties} should be returned exactly once.
*/
public void testGetDescriptors() {
- final PropertyDescriptor[] pd =
- PropertyUtils.getPropertyDescriptors(bean);
+ final PropertyDescriptor[] pd = PropertyUtils.getPropertyDescriptors(bean);
assertNotNull("Got descriptors", pd);
final int[] count = new int[properties.length];
for (final PropertyDescriptor element : pd) {
@@ -596,8 +508,7 @@ public class PropertyUtilsTestCase extends TestCase {
// Use index expression
try {
- PropertyUtils.getIndexedProperty(null,
- "intArray[0]");
+ PropertyUtils.getIndexedProperty(null, "intArray[0]");
fail("Should throw IllegalArgumentException 3");
} catch (final IllegalArgumentException e) {
// Expected response
@@ -646,8 +557,7 @@ public class PropertyUtilsTestCase extends TestCase {
// Use index expression
try {
- PropertyUtils.getIndexedProperty(null,
- "intIndexed[0]");
+ PropertyUtils.getIndexedProperty(null, "intIndexed[0]");
fail("Should throw IllegalArgumentException 3");
} catch (final IllegalArgumentException e) {
// Expected response
@@ -687,74 +597,55 @@ public class PropertyUtilsTestCase extends TestCase {
for (int i = 0; i < 5; i++) {
try {
- value = PropertyUtils.getIndexedProperty
- (bean, "dupProperty", i);
+ value = PropertyUtils.getIndexedProperty(bean, "dupProperty", i);
assertNotNull("dupProperty returned value " + i, value);
- assertTrue("dupProperty returned String " + i,
- value instanceof String);
- assertEquals("dupProperty returned correct " + i,
- "Dup " + i,
- (String) value);
+ assertTrue("dupProperty returned String " + i, value instanceof String);
+ assertEquals("dupProperty returned correct " + i, "Dup " + i, (String) value);
} catch (final Throwable t) {
fail("dupProperty " + i + " threw " + t);
}
try {
- value =
- PropertyUtils.getIndexedProperty(bean, "intArray", i);
+ value = PropertyUtils.getIndexedProperty(bean, "intArray", i);
assertNotNull("intArray returned value " + i, value);
- assertTrue("intArray returned Integer " + i,
- value instanceof Integer);
- assertEquals("intArray returned correct " + i, i * 10,
- ((Integer) value).intValue());
+ assertTrue("intArray returned Integer " + i, value instanceof Integer);
+ assertEquals("intArray returned correct " + i, i * 10, ((Integer) value).intValue());
} catch (final Throwable t) {
fail("intArray " + i + " threw " + t);
}
try {
- value =
- PropertyUtils.getIndexedProperty(bean, "intIndexed", i);
+ value = PropertyUtils.getIndexedProperty(bean, "intIndexed", i);
assertNotNull("intIndexed returned value " + i, value);
- assertTrue("intIndexed returned Integer " + i,
- value instanceof Integer);
- assertEquals("intIndexed returned correct " + i, i * 10,
- ((Integer) value).intValue());
+ assertTrue("intIndexed returned Integer " + i, value instanceof Integer);
+ assertEquals("intIndexed returned correct " + i, i * 10, ((Integer) value).intValue());
} catch (final Throwable t) {
fail("intIndexed " + i + " threw " + t);
}
try {
- value =
- PropertyUtils.getIndexedProperty(bean, "listIndexed", i);
+ value = PropertyUtils.getIndexedProperty(bean, "listIndexed", i);
assertNotNull("listIndexed returned value " + i, value);
- assertTrue("list returned String " + i,
- value instanceof String);
- assertEquals("listIndexed returned correct " + i,
- "String " + i, (String) value);
+ assertTrue("list returned String " + i, value instanceof String);
+ assertEquals("listIndexed returned correct " + i, "String " + i, (String) value);
} catch (final Throwable t) {
fail("listIndexed " + i + " threw " + t);
}
try {
- value =
- PropertyUtils.getIndexedProperty(bean, "stringArray", i);
+ value = PropertyUtils.getIndexedProperty(bean, "stringArray", i);
assertNotNull("stringArray returned value " + i, value);
- assertTrue("stringArray returned String " + i,
- value instanceof String);
- assertEquals("stringArray returned correct " + i,
- "String " + i, (String) value);
+ assertTrue("stringArray returned String " + i, value instanceof String);
+ assertEquals("stringArray returned correct " + i, "String " + i, (String) value);
} catch (final Throwable t) {
fail("stringArray " + i + " threw " + t);
}
try {
- value =
- PropertyUtils.getIndexedProperty(bean, "stringIndexed", i);
+ value = PropertyUtils.getIndexedProperty(bean, "stringIndexed", i);
assertNotNull("stringIndexed returned value " + i, value);
- assertTrue("stringIndexed returned String " + i,
- value instanceof String);
- assertEquals("stringIndexed returned correct " + i,
- "String " + i, (String) value);
+ assertTrue("stringIndexed returned String " + i, value instanceof String);
+ assertEquals("stringIndexed returned correct " + i, "String " + i, (String) value);
} catch (final Throwable t) {
fail("stringIndexed " + i + " threw " + t);
}
@@ -766,79 +657,55 @@ public class PropertyUtilsTestCase extends TestCase {
for (int i = 0; i < 5; i++) {
try {
- value = PropertyUtils.getIndexedProperty
- (bean, "dupProperty[" + i + "]");
+ value = PropertyUtils.getIndexedProperty(bean, "dupProperty[" + i + "]");
assertNotNull("dupProperty returned value " + i, value);
- assertTrue("dupProperty returned String " + i,
- value instanceof String);
- assertEquals("dupProperty returned correct " + i,
- "Dup " + i,
- (String) value);
+ assertTrue("dupProperty returned String " + i, value instanceof String);
+ assertEquals("dupProperty returned correct " + i, "Dup " + i, (String) value);
} catch (final Throwable t) {
fail("dupProperty " + i + " threw " + t);
}
try {
- value =
- PropertyUtils.getIndexedProperty(bean,
- "intArray[" + i + "]");
+ value = PropertyUtils.getIndexedProperty(bean, "intArray[" + i + "]");
assertNotNull("intArray returned value " + i, value);
- assertTrue("intArray returned Integer " + i,
- value instanceof Integer);
- assertEquals("intArray returned correct " + i, i * 10,
- ((Integer) value).intValue());
+ assertTrue("intArray returned Integer " + i, value instanceof Integer);
+ assertEquals("intArray returned correct " + i, i * 10, ((Integer) value).intValue());
} catch (final Throwable t) {
fail("intArray " + i + " threw " + t);
}
try {
- value =
- PropertyUtils.getIndexedProperty(bean,
- "intIndexed[" + i + "]");
+ value = PropertyUtils.getIndexedProperty(bean, "intIndexed[" + i + "]");
assertNotNull("intIndexed returned value " + i, value);
- assertTrue("intIndexed returned Integer " + i,
- value instanceof Integer);
- assertEquals("intIndexed returned correct " + i, i * 10,
- ((Integer) value).intValue());
+ assertTrue("intIndexed returned Integer " + i, value instanceof Integer);
+ assertEquals("intIndexed returned correct " + i, i * 10, ((Integer) value).intValue());
} catch (final Throwable t) {
fail("intIndexed " + i + " threw " + t);
}
try {
- value =
- PropertyUtils.getIndexedProperty(bean,
- "listIndexed[" + i + "]");
+ value = PropertyUtils.getIndexedProperty(bean, "listIndexed[" + i + "]");
assertNotNull("listIndexed returned value " + i, value);
- assertTrue("listIndexed returned String " + i,
- value instanceof String);
- assertEquals("listIndexed returned correct " + i,
- "String " + i, (String) value);
+ assertTrue("listIndexed returned String " + i, value instanceof String);
+ assertEquals("listIndexed returned correct " + i, "String " + i, (String) value);
} catch (final Throwable t) {
fail("listIndexed " + i + " threw " + t);
}
try {
- value =
- PropertyUtils.getIndexedProperty(bean,
- "stringArray[" + i + "]");
+ value = PropertyUtils.getIndexedProperty(bean, "stringArray[" + i + "]");
assertNotNull("stringArray returned value " + i, value);
- assertTrue("stringArray returned String " + i,
- value instanceof String);
- assertEquals("stringArray returned correct " + i,
- "String " + i, (String) value);
+ assertTrue("stringArray returned String " + i, value instanceof String);
+ assertEquals("stringArray returned correct " + i, "String " + i, (String) value);
} catch (final Throwable t) {
fail("stringArray " + i + " threw " + t);
}
try {
- value =
- PropertyUtils.getIndexedProperty(bean,
- "stringIndexed[" + i + "]");
+ value = PropertyUtils.getIndexedProperty(bean, "stringIndexed[" + i + "]");
assertNotNull("stringIndexed returned value " + i, value);
- assertTrue("stringIndexed returned String " + i,
- value instanceof String);
- assertEquals("stringIndexed returned correct " + i,
- "String " + i, (String) value);
+ assertTrue("stringIndexed returned String " + i, value instanceof String);
+ assertEquals("stringIndexed returned correct " + i, "String " + i, (String) value);
} catch (final Throwable t) {
fail("stringIndexed " + i + " threw " + t);
}
@@ -848,9 +715,7 @@ public class PropertyUtilsTestCase extends TestCase {
// Index out of bounds tests
try {
- value =
- PropertyUtils.getIndexedProperty(bean,
- "dupProperty", -1);
+ value = PropertyUtils.getIndexedProperty(bean, "dupProperty", -1);
fail("Should have thrown ArrayIndexOutOfBoundsException");
} catch (final ArrayIndexOutOfBoundsException t) {
// Expected results
@@ -859,9 +724,7 @@ public class PropertyUtilsTestCase extends TestCase {
}
try {
- value =
- PropertyUtils.getIndexedProperty(bean,
- "dupProperty", 5);
+ value = PropertyUtils.getIndexedProperty(bean, "dupProperty", 5);
fail("Should have thrown ArrayIndexOutOfBoundsException");
} catch (final ArrayIndexOutOfBoundsException t) {
// Expected results
@@ -870,9 +733,7 @@ public class PropertyUtilsTestCase extends TestCase {
}
try {
- value =
- PropertyUtils.getIndexedProperty(bean,
- "intArray", -1);
+ value = PropertyUtils.getIndexedProperty(bean, "intArray", -1);
fail("Should have thrown ArrayIndexOutOfBoundsException");
} catch (final ArrayIndexOutOfBoundsException t) {
// Expected results
@@ -881,9 +742,7 @@ public class PropertyUtilsTestCase extends TestCase {
}
try {
- value =
- PropertyUtils.getIndexedProperty(bean,
- "intArray", 5);
+ value = PropertyUtils.getIndexedProperty(bean, "intArray", 5);
fail("Should have thrown ArrayIndexOutOfBoundsException");
} catch (final ArrayIndexOutOfBoundsException t) {
// Expected results
@@ -892,9 +751,7 @@ public class PropertyUtilsTestCase extends TestCase {
}
try {
- value =
- PropertyUtils.getIndexedProperty(bean,
- "intIndexed", -1);
+ value = PropertyUtils.getIndexedProperty(bean, "intIndexed", -1);
fail("Should have thrown ArrayIndexOutOfBoundsException");
} catch (final ArrayIndexOutOfBoundsException t) {
// Expected results
@@ -903,9 +760,7 @@ public class PropertyUtilsTestCase extends TestCase {
}
try {
- value =
- PropertyUtils.getIndexedProperty(bean,
- "intIndexed", 5);
+ value = PropertyUtils.getIndexedProperty(bean, "intIndexed", 5);
fail("Should have thrown ArrayIndexOutOfBoundsException");
} catch (final ArrayIndexOutOfBoundsException t) {
// Expected results
@@ -914,9 +769,7 @@ public class PropertyUtilsTestCase extends TestCase {
}
try {
- value =
- PropertyUtils.getIndexedProperty(bean,
- "listIndexed", -1);
+ value = PropertyUtils.getIndexedProperty(bean, "listIndexed", -1);
fail("Should have thrown IndexOutOfBoundsException");
} catch (final IndexOutOfBoundsException t) {
// Expected results
@@ -925,9 +778,7 @@ public class PropertyUtilsTestCase extends TestCase {
}
try {
- value =
- PropertyUtils.getIndexedProperty(bean,
- "listIndexed", 5);
+ value = PropertyUtils.getIndexedProperty(bean, "listIndexed", 5);
fail("Should have thrown IndexOutOfBoundsException");
} catch (final IndexOutOfBoundsException t) {
// Expected results
@@ -936,9 +787,7 @@ public class PropertyUtilsTestCase extends TestCase {
}
try {
- value =
- PropertyUtils.getIndexedProperty(bean,
- "stringArray", -1);
+ value = PropertyUtils.getIndexedProperty(bean, "stringArray", -1);
fail("Should have thrown ArrayIndexOutOfBoundsException");
} catch (final ArrayIndexOutOfBoundsException t) {
// Expected results
@@ -947,9 +796,7 @@ public class PropertyUtilsTestCase extends TestCase {
}
try {
- value =
- PropertyUtils.getIndexedProperty(bean,
- "stringArray", 5);
+ value = PropertyUtils.getIndexedProperty(bean, "stringArray", 5);
fail("Should have thrown ArrayIndexOutOfBoundsException");
} catch (final ArrayIndexOutOfBoundsException t) {
// Expected results
@@ -958,9 +805,7 @@ public class PropertyUtilsTestCase extends TestCase {
}
try {
- value =
- PropertyUtils.getIndexedProperty(bean,
- "stringIndexed", -1);
+ value = PropertyUtils.getIndexedProperty(bean, "stringIndexed", -1);
fail("Should have thrown ArrayIndexOutOfBoundsException");
} catch (final ArrayIndexOutOfBoundsException t) {
// Expected results
@@ -969,9 +814,7 @@ public class PropertyUtilsTestCase extends TestCase {
}
try {
- value =
- PropertyUtils.getIndexedProperty(bean,
- "stringIndexed", 5);
+ value = PropertyUtils.getIndexedProperty(bean, "stringIndexed", 5);
fail("Should have thrown ArrayIndexOutOfBoundsException");
} catch (final ArrayIndexOutOfBoundsException t) {
// Expected results
@@ -985,14 +828,14 @@ public class PropertyUtilsTestCase extends TestCase {
* Test getting an indexed value out of a multi-dimensional array
*/
public void testGetIndexedArray() {
- final String[] firstArray = {"FIRST-1", "FIRST-2", "FIRST-3"};
- final String[] secondArray = {"SECOND-1", "SECOND-2", "SECOND-3", "SECOND-4"};
- final String[][] mainArray = {firstArray, secondArray};
+ final String[] firstArray = { "FIRST-1", "FIRST-2", "FIRST-3" };
+ final String[] secondArray = { "SECOND-1", "SECOND-2", "SECOND-3", "SECOND-4" };
+ final String[][] mainArray = { firstArray, secondArray };
final TestBean bean = new TestBean(mainArray);
try {
- assertEquals("firstArray[0]", firstArray[0], PropertyUtils.getProperty(bean, "string2dArray[0][0]"));
- assertEquals("firstArray[1]", firstArray[1], PropertyUtils.getProperty(bean, "string2dArray[0][1]"));
... 10200 lines suppressed ...