You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by br...@apache.org on 2014/05/03 15:14:55 UTC
svn commit: r1592200 [9/9] - in /commons/sandbox/beanutils2/trunk: config/
src/changes/ src/main/java/org/apache/commons/beanutils2/
src/main/java/org/apache/commons/beanutils2/transformers/
src/test/java/org/apache/commons/beanutils2/ src/test/java/or...
Modified: commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/VoidMethodsTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/VoidMethodsTestCase.java?rev=1592200&r1=1592199&r2=1592200&view=diff
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/VoidMethodsTestCase.java (original)
+++ commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/VoidMethodsTestCase.java Sat May 3 13:14:53 2014
@@ -1,5 +1,3 @@
-package org.apache.commons.beanutils2;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -17,6 +15,8 @@ package org.apache.commons.beanutils2;
* limitations under the License.
*/
+package org.apache.commons.beanutils2;
+
import static org.apache.commons.beanutils2.BeanUtils.on;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
@@ -31,121 +31,104 @@ import org.junit.Test;
/**
* Test case to make sure, that methods with void signature are handled correctly.
*/
-public class VoidMethodsTestCase
-{
+public class VoidMethodsTestCase {
private BeanAccessor<?> voidAccessor = null;
@Before
public void setUp()
- throws Exception
- {
- voidAccessor = on( TestBean.class ).invokeStatic( "incrementCounter" ).with();
- assertTrue( voidAccessor instanceof NullBeanAccessor );
+ throws Exception {
+ voidAccessor = on(TestBean.class).invokeStatic("incrementCounter").with();
+ assertTrue(voidAccessor instanceof NullBeanAccessor);
}
@After
- public void tearDown()
- {
+ public void tearDown() {
voidAccessor = null;
}
@Test
public void get()
- throws Exception
- {
- assertNull( voidAccessor.get() );
+ throws Exception {
+ assertNull(voidAccessor.get());
}
- @Test( expected = NullPointerException.class )
+ @Test(expected = NullPointerException.class)
public void getProperty()
- throws Exception
- {
- voidAccessor.get( "propertyName" );
+ throws Exception {
+ voidAccessor.get("propertyName");
}
- @Test( expected = NullPointerException.class )
+ @Test(expected = NullPointerException.class)
public void getIndexed()
- throws Exception
- {
- voidAccessor.getIndexed( "propertyName" );
+ throws Exception {
+ voidAccessor.getIndexed("propertyName");
}
- @Test( expected = NullPointerException.class )
+ @Test(expected = NullPointerException.class)
public void getMapped()
- throws Exception
- {
- voidAccessor.getMapped( "propertyName" );
+ throws Exception {
+ voidAccessor.getMapped("propertyName");
}
- @Test( expected = NullPointerException.class )
+ @Test(expected = NullPointerException.class)
public void setProperty()
- throws Exception
- {
- voidAccessor.set( "propertyName" );
+ throws Exception {
+ voidAccessor.set("propertyName");
}
- @Test( expected = NullPointerException.class )
+ @Test(expected = NullPointerException.class)
public void setIndexed()
- throws Exception
- {
- voidAccessor.setIndexed( "propertyName" );
+ throws Exception {
+ voidAccessor.setIndexed("propertyName");
}
- @Test( expected = NullPointerException.class )
+ @Test(expected = NullPointerException.class)
public void setMapped()
- throws Exception
- {
- voidAccessor.setMapped( "propertyName" );
+ throws Exception {
+ voidAccessor.setMapped("propertyName");
}
@Test
- public void cast()
- {
- assertNull( voidAccessor.cast() );
+ public void cast() {
+ assertNull(voidAccessor.cast());
}
@Test
public void cloneBean()
- throws Exception
- {
- assertNull( voidAccessor.cloneBean() );
+ throws Exception {
+ assertNull(voidAccessor.cloneBean());
}
- @Test( expected = NullPointerException.class )
+ @Test(expected = NullPointerException.class)
public void describe()
- throws Exception
- {
+ throws Exception {
voidAccessor.describe();
}
- @Test( expected = NullPointerException.class )
+ @Test(expected = NullPointerException.class)
public void populate()
- throws Exception
- {
- voidAccessor.populate( new HashMap<String, Object>( 0 ) );
+ throws Exception {
+ voidAccessor.populate(new HashMap<String, Object>(0));
}
@Test
public void copyPropertiesTo()
- throws Exception
- {
+ throws Exception {
// no idea how to invoke this
// voidAccessor.copyPropertiesTo( target );
}
- @Test( expected = NullPointerException.class )
+ @Test(expected = NullPointerException.class)
public void invoke()
- throws Exception
- {
- voidAccessor.invoke( "methodName" );
+ throws Exception {
+ voidAccessor.invoke("methodName");
}
- @Test( expected = NullPointerException.class )
+ @Test(expected = NullPointerException.class)
public void invokeExact()
- throws Exception
- {
- voidAccessor.invokeExact( "methodName" );
+ throws Exception {
+ voidAccessor.invokeExact("methodName");
}
}
Modified: commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/issues/JiraSandbox433TestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/issues/JiraSandbox433TestCase.java?rev=1592200&r1=1592199&r2=1592200&view=diff
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/issues/JiraSandbox433TestCase.java (original)
+++ commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/issues/JiraSandbox433TestCase.java Sat May 3 13:14:53 2014
@@ -1,5 +1,3 @@
-package org.apache.commons.beanutils2.issues;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -19,6 +17,8 @@ package org.apache.commons.beanutils2.is
* under the License.
*/
+package org.apache.commons.beanutils2.issues;
+
import static org.apache.commons.beanutils2.Argument.argument;
import static org.apache.commons.beanutils2.BeanUtils.on;
@@ -30,58 +30,47 @@ import org.junit.Test;
/**
* Setting properties or invoking methods to often results in a NullPointerException
*/
-public class JiraSandbox433TestCase
-{
+public class JiraSandbox433TestCase {
private final static int COUNT = 50000;
private TestBean testBean;
@Before
- public void setUp()
- {
+ public void setUp() {
testBean = new TestBean();
}
@After
- public void tearDown()
- {
+ public void tearDown() {
testBean = null;
}
@Test
- public void setPropertyVeryOften()
- {
- for ( int i = 0; i < COUNT; i++ )
- {
- on( testBean ).set( "intProperty" ).with( i );
+ public void setPropertyVeryOften() {
+ for (int i = 0; i < COUNT; i++) {
+ on(testBean).set("intProperty").with(i);
}
}
@Test
- public void getPropertyVeryOften()
- {
- for ( int i = 0; i < COUNT; i++ )
- {
- on( testBean ).get( "intProperty" );
+ public void getPropertyVeryOften() {
+ for (int i = 0; i < COUNT; i++) {
+ on(testBean).get("intProperty");
}
}
@Test
- public void callMethodVeryOften()
- {
- for ( int i = 0; i < COUNT; i++ )
- {
- on( testBean ).invoke( "setIntProperty" ).with( argument( i ) );
+ public void callMethodVeryOften() {
+ for (int i = 0; i < COUNT; i++) {
+ on(testBean).invoke("setIntProperty").with(argument(i));
}
}
@Test
- public void callConstructorVeryOften()
- {
- for ( int i = 0; i < COUNT; i++ )
- {
- on( TestBean.class ).newInstance();
+ public void callConstructorVeryOften() {
+ for (int i = 0; i < COUNT; i++) {
+ on(TestBean.class).newInstance();
}
}
}
\ No newline at end of file
Modified: commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/testbeans/AbstractTestBean.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/testbeans/AbstractTestBean.java?rev=1592200&r1=1592199&r2=1592200&view=diff
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/testbeans/AbstractTestBean.java (original)
+++ commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/testbeans/AbstractTestBean.java Sat May 3 13:14:53 2014
@@ -1,5 +1,3 @@
-package org.apache.commons.beanutils2.testbeans;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -17,11 +15,12 @@ package org.apache.commons.beanutils2.te
* limitations under the License.
*/
+package org.apache.commons.beanutils2.testbeans;
+
/**
* Abstract test bean for testing Instantiation Exceptions.
*/
-public abstract class AbstractTestBean
-{
+public abstract class AbstractTestBean {
public AbstractTestBean() {
// do nothing
Modified: commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/testbeans/MappedPropertyChildBean.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/testbeans/MappedPropertyChildBean.java?rev=1592200&r1=1592199&r2=1592200&view=diff
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/testbeans/MappedPropertyChildBean.java (original)
+++ commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/testbeans/MappedPropertyChildBean.java Sat May 3 13:14:53 2014
@@ -1,5 +1,3 @@
-package org.apache.commons.beanutils2.testbeans;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -17,14 +15,15 @@ package org.apache.commons.beanutils2.te
* limitations under the License.
*/
+package org.apache.commons.beanutils2.testbeans;
+
/**
* Inherited Mapped property test bean.
* Extracted from BeanUtils1
*
- * @version $Revision: 1088801 $ $Date: 2011-04-05 00:06:02 +0200 (Tue, 05 Apr 2011) $
+ * @version $Id $
*/
public class MappedPropertyChildBean
- extends MappedPropertyTestBean
-{
+ extends MappedPropertyTestBean {
}
Modified: commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/testbeans/MappedPropertyChildInterface.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/testbeans/MappedPropertyChildInterface.java?rev=1592200&r1=1592199&r2=1592200&view=diff
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/testbeans/MappedPropertyChildInterface.java (original)
+++ commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/testbeans/MappedPropertyChildInterface.java Sat May 3 13:14:53 2014
@@ -1,5 +1,3 @@
-package org.apache.commons.beanutils2.testbeans;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -17,6 +15,8 @@ package org.apache.commons.beanutils2.te
* limitations under the License.
*/
+package org.apache.commons.beanutils2.testbeans;
+
/**
* Test Child Interface
* Extracted from BeanUtils1
@@ -24,7 +24,6 @@ package org.apache.commons.beanutils2.te
* @version $Revision: 1088801 $ $Date: 2011-04-05 00:06:02 +0200 (Tue, 05 Apr 2011) $
*/
public interface MappedPropertyChildInterface
- extends MappedPropertyTestInterface
-{
+ extends MappedPropertyTestInterface {
}
Modified: commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/testbeans/MappedPropertyTestBean.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/testbeans/MappedPropertyTestBean.java?rev=1592200&r1=1592199&r2=1592200&view=diff
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/testbeans/MappedPropertyTestBean.java (original)
+++ commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/testbeans/MappedPropertyTestBean.java Sat May 3 13:14:53 2014
@@ -1,5 +1,3 @@
-package org.apache.commons.beanutils2.testbeans;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -17,6 +15,8 @@ package org.apache.commons.beanutils2.te
* limitations under the License.
*/
+package org.apache.commons.beanutils2.testbeans;
+
import java.util.HashMap;
import java.util.Map;
@@ -27,8 +27,7 @@ import java.util.Map;
* @author Robert Burrell Donkin
* @version $Revision: 658830 $ $Date: 2008-05-21 21:56:21 +0200 (Wed, 21 May 2008) $
*/
-public class MappedPropertyTestBean
-{
+public class MappedPropertyTestBean {
// TODO generics
private final Map map = new HashMap();
@@ -37,88 +36,71 @@ public class MappedPropertyTestBean
// -------------------------------------------------------------- Properties
- public String getMapproperty( String key )
- {
- return (String) map.get( key );
+ public String getMapproperty(String key) {
+ return (String) map.get(key);
}
- public void setMapproperty( String key, String value )
- {
- map.put( key, value );
+ public void setMapproperty(String key, String value) {
+ map.put(key, value);
}
- public boolean isMappedBoolean( String key )
- {
- return ( (Boolean) map.get( key ) ).booleanValue();
+ public boolean isMappedBoolean(String key) {
+ return ((Boolean) map.get(key)).booleanValue();
}
- public void setMappedBoolean( String key, boolean value )
- {
- map.put( key, ( value ? Boolean.TRUE : Boolean.FALSE ) );
+ public void setMappedBoolean(String key, boolean value) {
+ map.put(key, (value ? Boolean.TRUE : Boolean.FALSE));
}
- protected String getProtectedMapped( String key )
- {
- return (String) map.get( key );
+ protected String getProtectedMapped(String key) {
+ return (String) map.get(key);
}
- protected void setProtectedMapped( String key, String value )
- {
- map.put( key, value );
+ protected void setProtectedMapped(String key, String value) {
+ map.put(key, value);
}
- public void setMappedPrimitive( int key, int value )
- {
- map.put( new Integer( key ), new Integer( value ) );
+ public void setMappedPrimitive(int key, int value) {
+ map.put(new Integer(key), new Integer(value));
}
- public void setAnyMapped( MappedPropertyTestBean key, MappedPropertyTestBean value )
- {
- map.put( key, value );
+ public void setAnyMapped(MappedPropertyTestBean key, MappedPropertyTestBean value) {
+ map.put(key, value);
}
- public void setMappedSetterOnly( String key, String value )
- {
- map.put( key, value );
+ public void setMappedSetterOnly(String key, String value) {
+ map.put(key, value);
}
- public String getMappedGetterOnly( String key )
- {
- return (String) map.get( key );
+ public String getMappedGetterOnly(String key) {
+ return (String) map.get(key);
}
- public String getInvalidGetter( String key, String other )
- {
- return (String) map.get( key );
+ public String getInvalidGetter(String key, String other) {
+ return (String) map.get(key);
}
- public Map getMyMap()
- {
+ public Map getMyMap() {
return myMap;
}
- public void setInvalidGetter( String key, String value )
- {
- map.put( key, value );
+ public void setInvalidGetter(String key, String value) {
+ map.put(key, value);
}
- public String getInvalidSetter( String key )
- {
- return (String) map.get( key );
+ public String getInvalidSetter(String key) {
+ return (String) map.get(key);
}
- public void setInvalidSetter( String key, String value, String other )
- {
+ public void setInvalidSetter(String key, String value, String other) {
}
- public Long getDifferentTypes( String key )
- {
- return new Long( ( (Number) map.get( key ) ).longValue() );
+ public Long getDifferentTypes(String key) {
+ return new Long(((Number) map.get(key)).longValue());
}
- public void setDifferentTypes( String key, Integer value )
- {
- map.put( key, value );
+ public void setDifferentTypes(String key, Integer value) {
+ map.put(key, value);
}
}
Modified: commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/testbeans/MappedPropertyTestInterface.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/testbeans/MappedPropertyTestInterface.java?rev=1592200&r1=1592199&r2=1592200&view=diff
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/testbeans/MappedPropertyTestInterface.java (original)
+++ commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/testbeans/MappedPropertyTestInterface.java Sat May 3 13:14:53 2014
@@ -1,5 +1,3 @@
-package org.apache.commons.beanutils2.testbeans;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -17,17 +15,18 @@ package org.apache.commons.beanutils2.te
* limitations under the License.
*/
+package org.apache.commons.beanutils2.testbeans;
+
/**
* Test Interface
* Extracted from BeanUtils1
*
* @version $Revision: 1088801 $ $Date: 2011-04-05 00:06:02 +0200 (Tue, 05 Apr 2011) $
*/
-public interface MappedPropertyTestInterface
-{
+public interface MappedPropertyTestInterface {
- public String getMapproperty( String key );
+ public String getMapproperty(String key);
- public void setMapproperty( String key, String value );
+ public void setMapproperty(String key, String value);
}
Modified: commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/testbeans/TestBean.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/testbeans/TestBean.java?rev=1592200&r1=1592199&r2=1592200&view=diff
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/testbeans/TestBean.java (original)
+++ commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/testbeans/TestBean.java Sat May 3 13:14:53 2014
@@ -1,5 +1,3 @@
-package org.apache.commons.beanutils2.testbeans;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -19,6 +17,8 @@ package org.apache.commons.beanutils2.te
* under the License.
*/
+package org.apache.commons.beanutils2.testbeans;
+
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
@@ -35,8 +35,7 @@ import org.apache.commons.lang3.builder.
* @version $Revision$ $Date$
*/
public class TestBean
- implements Serializable
-{
+ implements Serializable {
/**
*
@@ -44,589 +43,507 @@ public class TestBean
private static final long serialVersionUID = 1L;
// ----------------------------------------------------------- Constructors
+ /**
+ * A static variable that is accessed and updated via static methods for MethodUtils testing.
+ */
+ private static int counter = 0;
+ /**
+ * An integer array property accessed as an indexed property.
+ */
+ private final int intIndexed[] = {0, 10, 20, 30, 40};
+ /**
+ * A read-only String property.
+ */
+ private final String readOnlyProperty = "Read Only String Property";
+ /**
+ * A String array property accessed as an indexed property.
+ */
+ private final String[] stringIndexed = {"String 0", "String 1", "String 2", "String 3", "String 4"};
+ /**
+ * A boolean property.
+ */
+ private boolean booleanProperty = true;
+ /**
+ * A boolean property that uses an "is" method for the getter.
+ */
+ private boolean booleanSecond = true;
+ /**
+ * A byte property.
+ */
+ private byte byteProperty = (byte) 121;
+ /**
+ * A java.util.Date property.
+ */
+ private java.util.Date dateProperty;
+ /**
+ * A java.util.Date property.
+ */
+ private java.util.Date[] dateArrayProperty;
+ /**
+ * A double property.
+ */
+ private double doubleProperty = 321.0;
+ /**
+ * An "indexed property" accessible via both array and subscript based getters and setters.
+ */
+ private String[] dupProperty = {"Dup 0", "Dup 1", "Dup 2", "Dup 3", "Dup 4"};
+ /**
+ * A float property.
+ */
+ private float floatProperty = (float) 123.0;
+ /**
+ * An integer array property accessed as an array.
+ */
+ private int intArray[] = {0, 10, 20, 30, 40};
+ /**
+ * An integer property.
+ */
+ private int intProperty = 123;
- public TestBean()
- {
- listIndexed.add( "String 0" );
- listIndexed.add( "String 1" );
- listIndexed.add( "String 2" );
- listIndexed.add( "String 3" );
- listIndexed.add( "String 4" );
+ // ------------------------------------------------------------- Properties
+ /**
+ * A List property accessed as an indexed property.
+ */
+ private List<String> listIndexed = new ArrayList<String>();
+ /**
+ * A long property.
+ */
+ private long longProperty = 321;
+ /**
+ * A mapped property with only a getter and setter for a Map.
+ */
+ private Map<String, Object> mapProperty = null;
+ /**
+ * A mapped property that has String keys and Object values.
+ */
+ private Map<String, Object> mappedObjects = null;
+ /**
+ * A mapped property that has String keys and String values.
+ */
+ private Map<String, Object> mappedProperty = null;
+ /**
+ * A mapped property that has String keys and int values.
+ */
+ private Map<String, Object> mappedIntProperty = null;
+ /**
+ * A nested reference to another test bean (populated as needed).
+ */
+ private TestBean nested = null;
+ /**
+ * Another nested reference to another test bean,
+ */
+ private TestBean anotherNested = null;
+ private MappedTestBean mappedNested = null;
+ /**
+ * A String property with an initial value of null.
+ */
+ private String nullProperty = null;
+ /**
+ * A short property.
+ */
+ private short shortProperty = (short) 987;
+ /**
+ * A String array property accessed as a String.
+ */
+ private String[] stringArray = {"String 0", "String 1", "String 2", "String 3", "String 4"};
+ private String[][] string2dArray =
+ new String[][]{new String[]{"1", "2", "3"}, new String[]{"4", "5", "6"}};
+ /**
+ * A String property.
+ */
+ private String stringProperty = "This is a string";
+ /**
+ * A write-only String property.
+ */
+ private String writeOnlyProperty = "Write Only String Property";
+ /**
+ * An invalid property that has two boolean getters (getInvalidBoolean and isInvalidBoolean) plus a String setter
+ * (setInvalidBoolean). By the rules described in the JavaBeans Specification, this will be considered a read-only
+ * boolean property, using isInvalidBoolean() as the getter.
+ */
+ private boolean invalidBoolean = false;
+
+ public TestBean() {
+ listIndexed.add("String 0");
+ listIndexed.add("String 1");
+ listIndexed.add("String 2");
+ listIndexed.add("String 3");
+ listIndexed.add("String 4");
}
- public TestBean( String stringProperty )
- {
- setStringProperty( stringProperty );
+ public TestBean(String stringProperty) {
+ setStringProperty(stringProperty);
}
- public TestBean( float floatProperty )
- {
- setFloatProperty( floatProperty );
+ public TestBean(float floatProperty) {
+ setFloatProperty(floatProperty);
}
- public TestBean( boolean booleanProperty )
- {
- setBooleanProperty( booleanProperty );
+ public TestBean(boolean booleanProperty) {
+ setBooleanProperty(booleanProperty);
}
- public TestBean( Boolean booleanSecond )
- {
- setBooleanSecond( booleanSecond.booleanValue() );
+ public TestBean(Boolean booleanSecond) {
+ setBooleanSecond(booleanSecond.booleanValue());
}
- public TestBean( float floatProperty, String stringProperty )
- {
- setFloatProperty( floatProperty );
- setStringProperty( stringProperty );
+ public TestBean(float floatProperty, String stringProperty) {
+ setFloatProperty(floatProperty);
+ setStringProperty(stringProperty);
}
- public TestBean( boolean booleanProperty, String stringProperty )
- {
- setBooleanProperty( booleanProperty );
- setStringProperty( stringProperty );
+ public TestBean(boolean booleanProperty, String stringProperty) {
+ setBooleanProperty(booleanProperty);
+ setStringProperty(stringProperty);
}
- public TestBean( Boolean booleanSecond, String stringProperty )
- {
- setBooleanSecond( booleanSecond.booleanValue() );
- setStringProperty( stringProperty );
+ public TestBean(Boolean booleanSecond, String stringProperty) {
+ setBooleanSecond(booleanSecond.booleanValue());
+ setStringProperty(stringProperty);
}
- public TestBean( Integer intProperty )
- {
- setIntProperty( intProperty.intValue() );
+ public TestBean(Integer intProperty) {
+ setIntProperty(intProperty.intValue());
}
- public TestBean( double doubleProperty )
- {
- setDoubleProperty( doubleProperty );
+ public TestBean(double doubleProperty) {
+ setDoubleProperty(doubleProperty);
}
- TestBean( int intProperty )
- {
- setIntProperty( intProperty );
+ TestBean(int intProperty) {
+ setIntProperty(intProperty);
}
- protected TestBean( boolean booleanProperty, boolean booleanSecond, String stringProperty )
- {
- setBooleanProperty( booleanProperty );
- setBooleanSecond( booleanSecond );
- setStringProperty( stringProperty );
+ protected TestBean(boolean booleanProperty, boolean booleanSecond, String stringProperty) {
+ setBooleanProperty(booleanProperty);
+ setBooleanSecond(booleanSecond);
+ setStringProperty(stringProperty);
}
- public TestBean( List<String> listIndexed )
- {
+ public TestBean(List<String> listIndexed) {
this.listIndexed = listIndexed;
}
- public TestBean( String[][] string2dArray )
- {
+ public TestBean(String[][] string2dArray) {
this.string2dArray = string2dArray;
}
- // ------------------------------------------------------------- Properties
-
/**
- * A boolean property.
+ * @return the current value of the counter.
*/
- private boolean booleanProperty = true;
+ public static int currentCounter() {
- public boolean getBooleanProperty()
- {
- return ( booleanProperty );
- }
+ return (counter);
- public void setBooleanProperty( boolean booleanProperty )
- {
- this.booleanProperty = booleanProperty;
}
/**
- * A boolean property that uses an "is" method for the getter.
+ * Increment the current value of the counter by 1.
*/
- private boolean booleanSecond = true;
+ public static void incrementCounter() {
- public boolean isBooleanSecond()
- {
- return ( booleanSecond );
- }
+ incrementCounter(1);
- public void setBooleanSecond( boolean booleanSecond )
- {
- this.booleanSecond = booleanSecond;
}
/**
- * A byte property.
+ * Increment the current value of the counter by the specified amount.
+ *
+ * @param amount Amount to be added to the current counter
*/
- private byte byteProperty = (byte) 121;
+ public static void incrementCounter(int amount) {
- public byte getByteProperty()
- {
- return ( this.byteProperty );
- }
+ counter += amount;
- public void setByteProperty( byte byteProperty )
- {
- this.byteProperty = byteProperty;
}
/**
- * A java.util.Date property.
+ * Increments the current value of the count by the specified amount * 2. It has the same name as the method above
+ * so as to test the looseness of getMethod.
+ *
+ * @param amount the amount to increment the counter
*/
- private java.util.Date dateProperty;
+ public static void incrementCounter(Number amount) {
+ counter += 2 * amount.intValue();
+ }
- public java.util.Date getDateProperty()
- {
- return dateProperty;
+ public boolean getBooleanProperty() {
+ return (booleanProperty);
}
- public void setDateProperty( java.util.Date dateProperty )
- {
- this.dateProperty = dateProperty;
+ public void setBooleanProperty(boolean booleanProperty) {
+ this.booleanProperty = booleanProperty;
}
- /**
- * A java.util.Date property.
- */
- private java.util.Date[] dateArrayProperty;
+ public boolean isBooleanSecond() {
+ return (booleanSecond);
+ }
- public java.util.Date[] getDateArrayProperty()
- {
- return dateArrayProperty;
+ public void setBooleanSecond(boolean booleanSecond) {
+ this.booleanSecond = booleanSecond;
}
- public void setDateArrayProperty( java.util.Date[] dateArrayProperty )
- {
- this.dateArrayProperty = dateArrayProperty;
+ public byte getByteProperty() {
+ return (this.byteProperty);
}
- /**
- * A double property.
- */
- private double doubleProperty = 321.0;
+ public void setByteProperty(byte byteProperty) {
+ this.byteProperty = byteProperty;
+ }
- public double getDoubleProperty()
- {
- return ( this.doubleProperty );
+ public java.util.Date getDateProperty() {
+ return dateProperty;
}
- public void setDoubleProperty( double doubleProperty )
- {
- this.doubleProperty = doubleProperty;
+ public void setDateProperty(java.util.Date dateProperty) {
+ this.dateProperty = dateProperty;
}
- /**
- * An "indexed property" accessible via both array and subscript based getters and setters.
- */
- private String[] dupProperty = { "Dup 0", "Dup 1", "Dup 2", "Dup 3", "Dup 4" };
+ public java.util.Date[] getDateArrayProperty() {
+ return dateArrayProperty;
+ }
- public String[] getDupProperty()
- {
- return ( this.dupProperty );
+ public void setDateArrayProperty(java.util.Date[] dateArrayProperty) {
+ this.dateArrayProperty = dateArrayProperty;
}
- public String getDupProperty( int index )
- {
- return ( this.dupProperty[index] );
+ public double getDoubleProperty() {
+ return (this.doubleProperty);
}
- public void setDupProperty( int index, String value )
- {
- this.dupProperty[index] = value;
+ public void setDoubleProperty(double doubleProperty) {
+ this.doubleProperty = doubleProperty;
+ }
+
+ public String[] getDupProperty() {
+ return (this.dupProperty);
}
- public void setDupProperty( String[] dupProperty )
- {
+ public void setDupProperty(String[] dupProperty) {
this.dupProperty = dupProperty;
}
- /**
- * A float property.
- */
- private float floatProperty = (float) 123.0;
+ public String getDupProperty(int index) {
+ return (this.dupProperty[index]);
+ }
- public float getFloatProperty()
- {
- return ( this.floatProperty );
+ public void setDupProperty(int index, String value) {
+ this.dupProperty[index] = value;
}
- public void setFloatProperty( float floatProperty )
- {
- this.floatProperty = floatProperty;
+ public float getFloatProperty() {
+ return (this.floatProperty);
}
- /**
- * An integer array property accessed as an array.
- */
- private int intArray[] = { 0, 10, 20, 30, 40 };
+ public void setFloatProperty(float floatProperty) {
+ this.floatProperty = floatProperty;
+ }
- public int[] getIntArray()
- {
- return ( this.intArray );
+ public int[] getIntArray() {
+ return (this.intArray);
}
- public void setIntArray( int[] intArray )
- {
+ public void setIntArray(int[] intArray) {
this.intArray = intArray;
}
- /**
- * An integer array property accessed as an indexed property.
- */
- private final int intIndexed[] = { 0, 10, 20, 30, 40 };
-
- public int getIntIndexed( int index )
- {
- return ( intIndexed[index] );
+ public int getIntIndexed(int index) {
+ return (intIndexed[index]);
}
- public void setIntIndexed( int index, int value )
- {
+ public void setIntIndexed(int index, int value) {
intIndexed[index] = value;
}
- /**
- * An integer property.
- */
- private int intProperty = 123;
-
- public int getIntProperty()
- {
- return ( this.intProperty );
+ public int getIntProperty() {
+ return (this.intProperty);
}
- public void setIntProperty( int intProperty )
- {
+ public void setIntProperty(int intProperty) {
this.intProperty = intProperty;
}
- /**
- * A List property accessed as an indexed property.
- */
- private List<String> listIndexed = new ArrayList<String>();
-
- public List<String> getListIndexed()
- {
- return ( listIndexed );
+ public List<String> getListIndexed() {
+ return (listIndexed);
}
- /**
- * A long property.
- */
- private long longProperty = 321;
-
- public long getLongProperty()
- {
- return ( this.longProperty );
+ public long getLongProperty() {
+ return (this.longProperty);
}
- public void setLongProperty( long longProperty )
- {
+ public void setLongProperty(long longProperty) {
this.longProperty = longProperty;
}
- /**
- * A mapped property with only a getter and setter for a Map.
- */
- private Map<String, Object> mapProperty = null;
-
- public Map<String, Object> getMapProperty()
- {
+ public Map<String, Object> getMapProperty() {
// Create the map the very first time
- if ( mapProperty == null )
- {
+ if (mapProperty == null) {
mapProperty = new HashMap<String, Object>();
- mapProperty.put( "First Key", "First Value" );
- mapProperty.put( "Second Key", "Second Value" );
+ mapProperty.put("First Key", "First Value");
+ mapProperty.put("Second Key", "Second Value");
}
- return ( mapProperty );
+ return (mapProperty);
}
- public void setMapProperty( Map<String, Object> mapProperty )
- {
+ public void setMapProperty(Map<String, Object> mapProperty) {
// Create the map the very first time
- if ( mapProperty == null )
- {
+ if (mapProperty == null) {
mapProperty = new HashMap<String, Object>();
- mapProperty.put( "First Key", "First Value" );
- mapProperty.put( "Second Key", "Second Value" );
+ mapProperty.put("First Key", "First Value");
+ mapProperty.put("Second Key", "Second Value");
}
this.mapProperty = mapProperty;
}
- /**
- * A mapped property that has String keys and Object values.
- */
- private Map<String, Object>mappedObjects = null;
-
- public Object getMappedObjects( String key )
- {
+ public Object getMappedObjects(String key) {
// Create the map the very first time
- if ( mappedObjects == null )
- {
+ if (mappedObjects == null) {
mappedObjects = new HashMap<String, Object>();
- mappedObjects.put( "First Key", "First Value" );
- mappedObjects.put( "Second Key", "Second Value" );
+ mappedObjects.put("First Key", "First Value");
+ mappedObjects.put("Second Key", "Second Value");
}
- return ( mappedObjects.get( key ) );
+ return (mappedObjects.get(key));
}
- public void setMappedObjects( String key, Object value )
- {
+ public void setMappedObjects(String key, Object value) {
// Create the map the very first time
- if ( mappedObjects == null )
- {
+ if (mappedObjects == null) {
mappedObjects = new HashMap<String, Object>();
- mappedObjects.put( "First Key", "First Value" );
- mappedObjects.put( "Second Key", "Second Value" );
+ mappedObjects.put("First Key", "First Value");
+ mappedObjects.put("Second Key", "Second Value");
}
- mappedObjects.put( key, value );
+ mappedObjects.put(key, value);
}
- /**
- * A mapped property that has String keys and String values.
- */
- private Map<String, Object>mappedProperty = null;
-
- public String getMappedProperty( String key )
- {
+ public String getMappedProperty(String key) {
// Create the map the very first time
- if ( mappedProperty == null )
- {
+ if (mappedProperty == null) {
mappedProperty = new HashMap<String, Object>();
- mappedProperty.put( "First Key", "First Value" );
- mappedProperty.put( "Second Key", "Second Value" );
+ mappedProperty.put("First Key", "First Value");
+ mappedProperty.put("Second Key", "Second Value");
}
- return ( (String) mappedProperty.get( key ) );
+ return ((String) mappedProperty.get(key));
}
- public void setMappedProperty( String key, String value )
- {
+ public void setMappedProperty(String key, String value) {
// Create the map the very first time
- if ( mappedProperty == null )
- {
+ if (mappedProperty == null) {
mappedProperty = new HashMap<String, Object>();
- mappedProperty.put( "First Key", "First Value" );
- mappedProperty.put( "Second Key", "Second Value" );
+ mappedProperty.put("First Key", "First Value");
+ mappedProperty.put("Second Key", "Second Value");
}
- mappedProperty.put( key, value );
+ mappedProperty.put(key, value);
}
- /**
- * A mapped property that has String keys and int values.
- */
- private Map<String, Object>mappedIntProperty = null;
-
- public int getMappedIntProperty( String key )
- {
+ public int getMappedIntProperty(String key) {
// Create the map the very first time
- if ( mappedIntProperty == null )
- {
+ if (mappedIntProperty == null) {
mappedIntProperty = new HashMap<String, Object>();
- mappedIntProperty.put( "One", new Integer( 1 ) );
- mappedIntProperty.put( "Two", new Integer( 2 ) );
+ mappedIntProperty.put("One", new Integer(1));
+ mappedIntProperty.put("Two", new Integer(2));
}
- Integer x = (Integer) mappedIntProperty.get( key );
- return ( ( x == null ) ? 0 : x.intValue() );
+ Integer x = (Integer) mappedIntProperty.get(key);
+ return ((x == null) ? 0 : x.intValue());
}
- public void setMappedIntProperty( String key, int value )
- {
- mappedIntProperty.put( key, new Integer( value ) );
+ public void setMappedIntProperty(String key, int value) {
+ mappedIntProperty.put(key, new Integer(value));
}
- /**
- * A nested reference to another test bean (populated as needed).
- */
- private TestBean nested = null;
-
- public TestBean getNested()
- {
- if ( nested == null )
+ public TestBean getNested() {
+ if (nested == null)
nested = new TestBean();
- return ( nested );
+ return (nested);
}
- /**
- * Another nested reference to another test bean,
- */
- private TestBean anotherNested = null;
-
- public TestBean getAnotherNested()
- {
+ public TestBean getAnotherNested() {
return anotherNested;
}
- public void setAnotherNested( TestBean anotherNested )
- {
+ public void setAnotherNested(TestBean anotherNested) {
this.anotherNested = anotherNested;
}
- /*
- * Another nested reference to a bean containing mapp properties
- */
- public class MappedTestBean
- {
- public void setValue( String key, String val )
- {
- }
-
- public String getValue( String key )
- {
- return "Mapped Value";
- }
- }
-
- private MappedTestBean mappedNested = null;
-
- public MappedTestBean getMappedNested()
- {
- if ( mappedNested == null )
- {
+ public MappedTestBean getMappedNested() {
+ if (mappedNested == null) {
mappedNested = new MappedTestBean();
}
return mappedNested;
}
- /**
- * A String property with an initial value of null.
- */
- private String nullProperty = null;
-
- public String getNullProperty()
- {
- return ( this.nullProperty );
+ public String getNullProperty() {
+ return (this.nullProperty);
}
- public void setNullProperty( String nullProperty )
- {
+ public void setNullProperty(String nullProperty) {
this.nullProperty = nullProperty;
}
- /**
- * A read-only String property.
- */
- private final String readOnlyProperty = "Read Only String Property";
-
- public String getReadOnlyProperty()
- {
- return ( this.readOnlyProperty );
+ public String getReadOnlyProperty() {
+ return (this.readOnlyProperty);
}
- /**
- * A short property.
- */
- private short shortProperty = (short) 987;
-
- public short getShortProperty()
- {
- return ( this.shortProperty );
+ public short getShortProperty() {
+ return (this.shortProperty);
}
- public void setShortProperty( short shortProperty )
- {
+ public void setShortProperty(short shortProperty) {
this.shortProperty = shortProperty;
}
- /**
- * A String array property accessed as a String.
- */
- private String[] stringArray = { "String 0", "String 1", "String 2", "String 3", "String 4" };
-
- public String[] getStringArray()
- {
- return ( this.stringArray );
+ public String[] getStringArray() {
+ return (this.stringArray);
}
- public void setStringArray( String[] stringArray )
- {
+ public void setStringArray(String[] stringArray) {
this.stringArray = stringArray;
}
- /**
- * A String array property accessed as an indexed property.
- */
- private final String[] stringIndexed = { "String 0", "String 1", "String 2", "String 3", "String 4" };
-
- public String getStringIndexed( int index )
- {
- return ( stringIndexed[index] );
+ public String getStringIndexed(int index) {
+ return (stringIndexed[index]);
}
- public void setStringIndexed( int index, String value )
- {
+ public void setStringIndexed(int index, String value) {
stringIndexed[index] = value;
}
- private String[][] string2dArray =
- new String[][] { new String[] { "1", "2", "3" }, new String[] { "4", "5", "6" } };
+ // ------------------------------------------------------ Invalid Properties
- public String[] getString2dArray( int index )
- {
+ public String[] getString2dArray(int index) {
return string2dArray[index];
}
- /**
- * A String property.
- */
- private String stringProperty = "This is a string";
-
- public String getStringProperty()
- {
- return ( this.stringProperty );
+ public String getStringProperty() {
+ return (this.stringProperty);
}
- public void setStringProperty( String stringProperty )
- {
+ public void setStringProperty(String stringProperty) {
this.stringProperty = stringProperty;
}
- /**
- * A write-only String property.
- */
- private String writeOnlyProperty = "Write Only String Property";
-
- public String getWriteOnlyPropertyValue()
- {
- return ( this.writeOnlyProperty );
+ public String getWriteOnlyPropertyValue() {
+ return (this.writeOnlyProperty);
}
- public void setWriteOnlyProperty( String writeOnlyProperty )
- {
+ public void setWriteOnlyProperty(String writeOnlyProperty) {
this.writeOnlyProperty = writeOnlyProperty;
}
- // ------------------------------------------------------ Invalid Properties
-
- /**
- * <p>
- * An invalid property that has two boolean getters (getInvalidBoolean and isInvalidBoolean) plus a String setter
- * (setInvalidBoolean). By the rules described in the JavaBeans Specification, this will be considered a read-only
- * boolean property, using isInvalidBoolean() as the getter.
- * </p>
- */
- private boolean invalidBoolean = false;
+ // ------------------------------------------------------- Static Variables
- public boolean getInvalidBoolean()
- {
- return ( this.invalidBoolean );
+ public boolean getInvalidBoolean() {
+ return (this.invalidBoolean);
}
- public boolean isInvalidBoolean()
- {
- return ( this.invalidBoolean );
+ public boolean isInvalidBoolean() {
+ return (this.invalidBoolean);
}
- public void setInvalidBoolean( String invalidBoolean )
- {
- if ( "true".equalsIgnoreCase( invalidBoolean ) || "yes".equalsIgnoreCase( invalidBoolean )
- || "1".equalsIgnoreCase( invalidBoolean ) )
- {
+ public void setInvalidBoolean(String invalidBoolean) {
+ if ("true".equalsIgnoreCase(invalidBoolean) || "yes".equalsIgnoreCase(invalidBoolean)
+ || "1".equalsIgnoreCase(invalidBoolean)) {
this.invalidBoolean = true;
- }
- else
- {
+ } else {
this.invalidBoolean = false;
}
}
@@ -635,101 +552,61 @@ public class TestBean
* {@inheritDoc}
*/
@Override
- public boolean equals( Object obj )
- {
- if ( obj == this )
- {
+ public boolean equals(Object obj) {
+ if (obj == this) {
return true;
}
- if ( obj == null )
- {
+ if (obj == null) {
return false;
}
- if ( !( obj instanceof TestBean ) )
- {
+ if (!(obj instanceof TestBean)) {
return false;
}
TestBean rhs = (TestBean) obj;
return new EqualsBuilder()
- .append( this.booleanProperty, rhs.booleanProperty )
- .append( this.booleanSecond,rhs.booleanSecond )
- .append( this.invalidBoolean,rhs.invalidBoolean )
- .append( this.byteProperty,rhs.byteProperty )
- .append( this.dateProperty,rhs.dateProperty )
- .append( this.doubleProperty,rhs.doubleProperty )
- .append( this.floatProperty,rhs.floatProperty )
- .append( this.intProperty,rhs.intProperty )
- .append( this.longProperty,rhs.longProperty )
- .append( this.shortProperty,rhs.shortProperty )
- .append( this.nullProperty,rhs.nullProperty )
- .append( this.anotherNested, rhs.anotherNested )
- .append( this.dateArrayProperty, rhs.dateArrayProperty )
- .append( this.dupProperty, rhs.dupProperty )
- .append( this.intArray, rhs.intArray )
- .append( this.intIndexed, rhs.intIndexed )
- .append( this.listIndexed, rhs.listIndexed )
- .append( this.mappedIntProperty, rhs.mappedIntProperty )
- .append( this.mappedNested, rhs.mappedNested )
- .append( this.mappedObjects, rhs.mappedObjects )
- .append( this.mappedProperty, rhs.mappedProperty )
- .append( this.mapProperty, rhs.mapProperty )
- .append( this.nested, rhs.nested )
- .append( this.readOnlyProperty, rhs.readOnlyProperty )
- .append( this.string2dArray, rhs.string2dArray )
- .append( this.stringArray, rhs.stringArray)
- .append( this.stringIndexed, rhs.stringIndexed )
- .append( this.stringProperty, rhs.stringProperty )
- .append( this.writeOnlyProperty, rhs.writeOnlyProperty )
- .build();
- }
-
- // ------------------------------------------------------- Static Variables
-
- /**
- * A static variable that is accessed and updated via static methods for MethodUtils testing.
- */
- private static int counter = 0;
-
- /**
- * Return the current value of the counter.
- */
- public static int currentCounter()
- {
-
- return ( counter );
-
- }
-
- /**
- * Increment the current value of the counter by 1.
- */
- public static void incrementCounter()
- {
-
- incrementCounter( 1 );
-
+ .append(this.booleanProperty, rhs.booleanProperty)
+ .append(this.booleanSecond, rhs.booleanSecond)
+ .append(this.invalidBoolean, rhs.invalidBoolean)
+ .append(this.byteProperty, rhs.byteProperty)
+ .append(this.dateProperty, rhs.dateProperty)
+ .append(this.doubleProperty, rhs.doubleProperty)
+ .append(this.floatProperty, rhs.floatProperty)
+ .append(this.intProperty, rhs.intProperty)
+ .append(this.longProperty, rhs.longProperty)
+ .append(this.shortProperty, rhs.shortProperty)
+ .append(this.nullProperty, rhs.nullProperty)
+ .append(this.anotherNested, rhs.anotherNested)
+ .append(this.dateArrayProperty, rhs.dateArrayProperty)
+ .append(this.dupProperty, rhs.dupProperty)
+ .append(this.intArray, rhs.intArray)
+ .append(this.intIndexed, rhs.intIndexed)
+ .append(this.listIndexed, rhs.listIndexed)
+ .append(this.mappedIntProperty, rhs.mappedIntProperty)
+ .append(this.mappedNested, rhs.mappedNested)
+ .append(this.mappedObjects, rhs.mappedObjects)
+ .append(this.mappedProperty, rhs.mappedProperty)
+ .append(this.mapProperty, rhs.mapProperty)
+ .append(this.nested, rhs.nested)
+ .append(this.readOnlyProperty, rhs.readOnlyProperty)
+ .append(this.string2dArray, rhs.string2dArray)
+ .append(this.stringArray, rhs.stringArray)
+ .append(this.stringIndexed, rhs.stringIndexed)
+ .append(this.stringProperty, rhs.stringProperty)
+ .append(this.writeOnlyProperty, rhs.writeOnlyProperty)
+ .build();
}
- /**
- * Increment the current value of the counter by the specified amount.
- *
- * @param amount Amount to be added to the current counter
+ /*
+ * Another nested reference to a bean containing mapp properties
*/
- public static void incrementCounter( int amount )
- {
-
- counter += amount;
-
- }
+ public class MappedTestBean {
+ public void setValue(String key, String val) {
+ }
- /**
- * Increments the current value of the count by the specified amount * 2. It has the same name as the method above
- * so as to test the looseness of getMethod.
- */
- public static void incrementCounter( Number amount )
- {
- counter += 2 * amount.intValue();
+ public String getValue(String key) {
+ return "Mapped Value";
+ }
}
}
Modified: commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/testbeans/TestBeanUtils.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/testbeans/TestBeanUtils.java?rev=1592200&r1=1592199&r2=1592200&view=diff
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/testbeans/TestBeanUtils.java (original)
+++ commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/testbeans/TestBeanUtils.java Sat May 3 13:14:53 2014
@@ -1,5 +1,3 @@
-package org.apache.commons.beanutils2.testbeans;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -17,36 +15,34 @@ package org.apache.commons.beanutils2.te
* limitations under the License.
*/
+package org.apache.commons.beanutils2.testbeans;
+
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
-public final class TestBeanUtils
-{
- private TestBeanUtils()
- {
+public final class TestBeanUtils {
+ private TestBeanUtils() {
// private constructor to prevent instantiation
}
- public static void changeArrayProperties( TestBean testBean )
- {
- int intArray[] = new int[] { 123, 456, 789 };
- String stringArray[] = new String[] { "New String 0", "New String 1" };
- testBean.setIntArray( intArray );
- testBean.setStringArray( stringArray );
+ public static void changeArrayProperties(TestBean testBean) {
+ int intArray[] = new int[]{123, 456, 789};
+ String stringArray[] = new String[]{"New String 0", "New String 1"};
+ testBean.setIntArray(intArray);
+ testBean.setStringArray(stringArray);
}
- public static void changeScalarProperties( TestBean testBean )
- {
- testBean.setBooleanProperty( false );
+ public static void changeScalarProperties(TestBean testBean) {
+ testBean.setBooleanProperty(false);
// booleanSecond is left at true
- testBean.setByteProperty( (byte) 111 );
- testBean.setDoubleProperty( 432.0 );
+ testBean.setByteProperty((byte) 111);
+ testBean.setDoubleProperty(432.0);
// floatProperty is left at 123.0
- testBean.setIntProperty( 543 );
- testBean.setLongProperty( 123456789l );
- testBean.setNullProperty( "Non-null value" );
- testBean.setShortProperty( (short) 654 );
+ testBean.setIntProperty(543);
+ testBean.setLongProperty(123456789l);
+ testBean.setNullProperty("Non-null value");
+ testBean.setShortProperty((short) 654);
// stringProperty is left at "This is a string"
}
@@ -55,57 +51,58 @@ public final class TestBeanUtils
* {@code expected}.
*
* @param expected the {@code TestBean} with the expected properties.
- * @param actual the {@code TestBean} with the actual values.
+ * @param actual the {@code TestBean} with the actual values.
*/
- public static void assertReadWritePropertiesEquals( TestBean expected, TestBean actual )
- {
- assertEquals( "Property 'anotherNested' is not equal!", expected.getAnotherNested(), actual.getAnotherNested() );
- assertEquals( "Property 'booleanProperty' is not equal!", expected.getBooleanProperty(),
- actual.getBooleanProperty() );
- assertEquals( "Property 'booleanSecond' is not equal!", expected.isBooleanSecond(), actual.isBooleanSecond() );
- assertEquals( "Property 'byteProperty' is not equal!", expected.getByteProperty(), actual.getByteProperty() );
- assertArrayEquals( "Property 'DateArrayProperty' is not equal!", expected.getDateArrayProperty(),
- actual.getDateArrayProperty() );
- assertEquals( "Property 'dateProperty' is not equal!", expected.getDateProperty(), actual.getDateProperty() );
- assertEquals( "Property 'doubleProperty' is not equal!", expected.getDoubleProperty(),
- actual.getDoubleProperty(), 0.0 );
- assertArrayEquals( "Property 'dupProperty' is not equal!", expected.getDupProperty(), actual.getDupProperty() );
- assertEquals( "Property 'floatProperty' is not equal!", expected.getFloatProperty(), actual.getFloatProperty(),
- 0.0 );
- assertArrayEquals( "Property 'intArrayProperty' is not equal!", expected.getIntArray(), actual.getIntArray() );
- assertEquals( "Property 'intProperty' is not equal!", expected.getIntProperty(), actual.getIntProperty() );
- assertEquals( "Property 'invalidBoolean' is not equal!", expected.getInvalidBoolean(),
- actual.getInvalidBoolean() );
- assertEquals( "Property 'listIndexed' is not equal!", expected.getListIndexed(), actual.getListIndexed() );
- assertEquals( "Property 'longProperty' is not equal!", expected.getLongProperty(), actual.getLongProperty() );
- assertEquals( "Property 'mapProperty' is not equal!", expected.getMapProperty(), actual.getMapProperty() );
- assertEquals( "Property 'nested' is not equal!", expected.getNested(), actual.getNested() );
- assertEquals( "Property 'nullProperty' is not equal!", expected.getNullProperty(), actual.getNullProperty() );
- assertEquals( "Property 'shortProperty' is not equal!", expected.getShortProperty(), actual.getShortProperty() );
- assertArrayEquals( "Property 'stringArray' is not equal!", expected.getStringArray(), actual.getStringArray() );
- assertEquals( "Property 'stringProperty' is not equal!", expected.getStringProperty(),
- actual.getStringProperty() );
+ public static void assertReadWritePropertiesEquals(TestBean expected, TestBean actual) {
+ assertEquals("Property 'anotherNested' is not equal!", expected.getAnotherNested(), actual.getAnotherNested());
+ assertEquals("Property 'booleanProperty' is not equal!", expected.getBooleanProperty(),
+ actual.getBooleanProperty());
+ assertEquals("Property 'booleanSecond' is not equal!", expected.isBooleanSecond(), actual.isBooleanSecond());
+ assertEquals("Property 'byteProperty' is not equal!", expected.getByteProperty(), actual.getByteProperty());
+ assertArrayEquals("Property 'DateArrayProperty' is not equal!", expected.getDateArrayProperty(),
+ actual.getDateArrayProperty());
+ assertEquals("Property 'dateProperty' is not equal!", expected.getDateProperty(), actual.getDateProperty());
+ assertEquals("Property 'doubleProperty' is not equal!", expected.getDoubleProperty(),
+ actual.getDoubleProperty(), 0.0);
+ assertArrayEquals("Property 'dupProperty' is not equal!", expected.getDupProperty(), actual.getDupProperty());
+ assertEquals("Property 'floatProperty' is not equal!", expected.getFloatProperty(), actual.getFloatProperty(),
+ 0.0);
+ assertArrayEquals("Property 'intArrayProperty' is not equal!", expected.getIntArray(), actual.getIntArray());
+ assertEquals("Property 'intProperty' is not equal!", expected.getIntProperty(), actual.getIntProperty());
+ assertEquals("Property 'invalidBoolean' is not equal!", expected.getInvalidBoolean(),
+ actual.getInvalidBoolean());
+ assertEquals("Property 'listIndexed' is not equal!", expected.getListIndexed(), actual.getListIndexed());
+ assertEquals("Property 'longProperty' is not equal!", expected.getLongProperty(), actual.getLongProperty());
+ assertEquals("Property 'mapProperty' is not equal!", expected.getMapProperty(), actual.getMapProperty());
+ assertEquals("Property 'nested' is not equal!", expected.getNested(), actual.getNested());
+ assertEquals("Property 'nullProperty' is not equal!", expected.getNullProperty(), actual.getNullProperty());
+ assertEquals("Property 'shortProperty' is not equal!", expected.getShortProperty(), actual.getShortProperty());
+ assertArrayEquals("Property 'stringArray' is not equal!", expected.getStringArray(), actual.getStringArray());
+ assertEquals("Property 'stringProperty' is not equal!", expected.getStringProperty(),
+ actual.getStringProperty());
}
/**
* Asserts, that complex properties of {@code referenced} are the same as in {@code referencing} (that they are just
* referenced).
+ *
+ * @param referenced the referenced TeatBean
+ * @param referencing the referencing TestBean
*/
- public static void assertShallow( TestBean referenced, TestBean referencing )
- {
- assertSame( referenced.getAnotherNested(), referencing.getAnotherNested() );
- assertSame( referenced.getDateArrayProperty(), referencing.getDateArrayProperty() );
- assertSame( referenced.getDateProperty(), referencing.getDateProperty() );
- assertSame( referenced.getDateProperty(), referencing.getDateProperty() );
- assertSame( referenced.getDupProperty(), referencing.getDupProperty() );
- assertSame( referenced.getIntArray(), referencing.getIntArray() );
- assertSame( referenced.getMapProperty(), referencing.getMapProperty() );
+ public static void assertShallow(TestBean referenced, TestBean referencing) {
+ assertSame(referenced.getAnotherNested(), referencing.getAnotherNested());
+ assertSame(referenced.getDateArrayProperty(), referencing.getDateArrayProperty());
+ assertSame(referenced.getDateProperty(), referencing.getDateProperty());
+ assertSame(referenced.getDateProperty(), referencing.getDateProperty());
+ assertSame(referenced.getDupProperty(), referencing.getDupProperty());
+ assertSame(referenced.getIntArray(), referencing.getIntArray());
+ assertSame(referenced.getMapProperty(), referencing.getMapProperty());
// mappedNested and nested are lazy initialized, so the following getXXX calls will create new instances on
// both, clone and original, causing the assertions to fail.
// assertSame(clone.getMappedNested(), original.getMappedNested());
// assertSame(clone.getNested(), original.getNested());
- assertSame( referenced.getStringArray(), referencing.getStringArray() );
- assertSame( referenced.getStringProperty(), referencing.getStringProperty() );
+ assertSame(referenced.getStringArray(), referencing.getStringArray());
+ assertSame(referenced.getStringProperty(), referencing.getStringProperty());
}
}
Modified: commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/testbeans/ThrowingExceptionBean.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/testbeans/ThrowingExceptionBean.java?rev=1592200&r1=1592199&r2=1592200&view=diff
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/testbeans/ThrowingExceptionBean.java (original)
+++ commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/testbeans/ThrowingExceptionBean.java Sat May 3 13:14:53 2014
@@ -1,5 +1,3 @@
-package org.apache.commons.beanutils2.testbeans;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -17,14 +15,14 @@ package org.apache.commons.beanutils2.te
* limitations under the License.
*/
+package org.apache.commons.beanutils2.testbeans;
+
/**
* Utility test class that is used to evaluate if exceptions are thrown correctly.
*/
-public class ThrowingExceptionBean
-{
+public class ThrowingExceptionBean {
- public ThrowingExceptionBean()
- {
+ public ThrowingExceptionBean() {
// default constructor
}
@@ -33,158 +31,129 @@ public class ThrowingExceptionBean
*
* @param e The exception to throw
*/
- public ThrowingExceptionBean( RuntimeException e )
- {
+ public ThrowingExceptionBean(RuntimeException e) {
throw e;
}
- @SuppressWarnings( "unused" )
- private ThrowingExceptionBean( Integer i )
- {
+ @SuppressWarnings("unused")
+ private ThrowingExceptionBean(Integer i) {
// used in illegal access test cases
}
- protected ThrowingExceptionBean( Short s )
- {
+ protected ThrowingExceptionBean(Short s) {
// used in illegal access test cases
}
- ThrowingExceptionBean( Byte b )
- {
+ ThrowingExceptionBean(Byte b) {
// used in illegal access test cases
}
- public String getExceptionProperty()
- {
+ public static void staticException(String message) {
+ throw new RuntimeException(message);
+ }
+
+ public String getExceptionProperty() {
throw new RuntimeException();
}
- public void setExceptionProperty( String string )
- {
+ public void setExceptionProperty(String string) {
throw new RuntimeException();
}
- @SuppressWarnings( "unused" )
+ @SuppressWarnings("unused")
// used in IllegalAccessException test cases via reflection
- private String getPrivateProperty()
- {
+ private String getPrivateProperty() {
return "";
}
- @SuppressWarnings( "unused" )
+ @SuppressWarnings("unused")
// used in IllegalAccessException test cases via reflection
- private void setPrivateProperty()
- {
+ private void setPrivateProperty() {
// do nothing
}
- protected String getProtectedProperty()
- {
+ protected String getProtectedProperty() {
return "";
}
- protected void setProtectedProperty()
- {
+ protected void setProtectedProperty() {
// do nothing
}
- String getDefaultProperty()
- {
+ String getDefaultProperty() {
return "";
}
- void setDefaultProperty()
- {
+ void setDefaultProperty() {
// do nothing
}
- public int getExceptionIndexed( int index )
- {
- throw new RuntimeException( "Get indexed always throws an exception!" );
+ public int getExceptionIndexed(int index) {
+ throw new RuntimeException("Get indexed always throws an exception!");
}
- public void setExceptionIndexed( int index, RuntimeException e )
- {
+ public void setExceptionIndexed(int index, RuntimeException e) {
throw e;
}
- @SuppressWarnings( "unused" ) // used in IllegalAccessException test cases
- private int getPrivateIndexed( int index )
- {
+ @SuppressWarnings("unused") // used in IllegalAccessException test cases
+ private int getPrivateIndexed(int index) {
return 1;
}
- @SuppressWarnings( "unused" ) // used in IllegalAccessException test cases
- private void setPrivateIndexed( int index, int value )
- {
+ @SuppressWarnings("unused") // used in IllegalAccessException test cases
+ private void setPrivateIndexed(int index, int value) {
// do nothing
}
- protected int getProtectedIndexed( int index )
- {
+ protected int getProtectedIndexed(int index) {
return 1;
}
- protected void setProtectedIndexed( int index, int value )
- {
+ protected void setProtectedIndexed(int index, int value) {
// do nothing
}
- int getDefaultIndexed( int index )
- {
+ int getDefaultIndexed(int index) {
return 1;
}
- void setDefaultIndexed( int index, int value )
- {
+ void setDefaultIndexed(int index, int value) {
// do nothing
}
- public RuntimeException getExceptionMapped( String key)
- {
- throw new RuntimeException( "Get indexed always throws an exception!" );
+ public RuntimeException getExceptionMapped(String key) {
+ throw new RuntimeException("Get indexed always throws an exception!");
}
- public void setExceptionMapped( String key, RuntimeException e )
- {
+ public void setExceptionMapped(String key, RuntimeException e) {
throw e;
}
- @SuppressWarnings( "unused" ) // used in IllegalAccessException test cases
- private String getPrivateMapped( String key )
- {
+ @SuppressWarnings("unused") // used in IllegalAccessException test cases
+ private String getPrivateMapped(String key) {
return "A Value";
}
- @SuppressWarnings( "unused" ) // used in IllegalAccessException test cases
- private void setPrivateMapped( String key, Object value )
- {
+ @SuppressWarnings("unused") // used in IllegalAccessException test cases
+ private void setPrivateMapped(String key, Object value) {
// do nothing
}
- protected String getProtectedMapped( String key )
- {
+ protected String getProtectedMapped(String key) {
return "A Value";
}
- protected void setProtectedMapped( String key, String value)
- {
+ protected void setProtectedMapped(String key, String value) {
// do nothing
}
- String getDefaultMapped( String key )
- {
+ String getDefaultMapped(String key) {
return "A Value";
}
- void setDefaultMapped( String key, String value )
- {
+ void setDefaultMapped(String key, String value) {
// do nothing
}
- public static void staticException( String message )
- {
- throw new RuntimeException( message );
- }
-
}