You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by si...@apache.org on 2012/01/19 22:44:05 UTC

svn commit: r1233585 [2/2] - in /commons/sandbox/beanutils2/trunk: ./ src/ src/changes/ src/main/ src/main/assembly/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/commons/ src/main/java/org/apache/commons/beanutil...

Added: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/converters/AbstractConverter.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/converters/AbstractConverter.java?rev=1233585&view=auto
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/converters/AbstractConverter.java (added)
+++ commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/converters/AbstractConverter.java Thu Jan 19 21:44:04 2012
@@ -0,0 +1,55 @@
+package org.apache.commons.beanutils2.converters;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+
+import org.apache.commons.beanutils2.Converter;
+
+public abstract class AbstractConverter<S, T>
+    implements Converter<S, T>
+{
+
+    private final Type sourceType;
+
+    private final Type targetType;
+
+    public AbstractConverter()
+    {
+        Type superclass = getClass().getGenericSuperclass();
+        if ( superclass instanceof Class )
+        {
+            throw new RuntimeException( "Missing type parameter." );
+        }
+        ParameterizedType parameterizedType = (ParameterizedType) superclass;
+        sourceType = parameterizedType.getActualTypeArguments()[0];
+        targetType = parameterizedType.getActualTypeArguments()[1];
+    }
+
+    public final Type getSourceType()
+    {
+        return sourceType;
+    }
+
+    public final Type getTargetType()
+    {
+        return targetType;
+    }
+
+}

Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/converters/AbstractConverter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/converters/AbstractConverter.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/converters/AbstractConverter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/converters/package-info.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/converters/package-info.java?rev=1233585&view=auto
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/converters/package-info.java (added)
+++ commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/converters/package-info.java Thu Jan 19 21:44:04 2012
@@ -0,0 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ *
+ */
+package org.apache.commons.beanutils2.converters;

Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/converters/package-info.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/converters/package-info.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/converters/package-info.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/package-info.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/package-info.java?rev=1233585&view=auto
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/package-info.java (added)
+++ commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/package-info.java Thu Jan 19 21:44:04 2012
@@ -0,0 +1,24 @@
+/**
+ * The <i>Bean Introspection Utilities</i> component of the Apache Commons subproject offers low-level utility classes
+ * that assist in getting and setting property values on Java classes that follow the naming design patterns outlined in
+ * the JavaBeans Specification, as well as mechanisms for dynamically defining and accessing bean properties, using
+ * fluent APIs.
+ */
+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
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */

Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/package-info.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/package-info.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/package-info.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/ConstructorsTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/ConstructorsTestCase.java?rev=1233585&view=auto
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/ConstructorsTestCase.java (added)
+++ commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/ConstructorsTestCase.java Thu Jan 19 21:44:04 2012
@@ -0,0 +1,177 @@
+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
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import static org.apache.commons.beanutils2.Argument.argument;
+import static org.apache.commons.beanutils2.BeanUtils.on;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import org.junit.Test;
+
+/**
+ * <p>
+ * Test case for <code>ConstructorUtils</code>
+ * </p>
+ */
+public class ConstructorsTestCase
+{
+
+    // ------------------------------------------------ Individual Test Methods
+
+    @Test
+    public void testInvokeConstructor()
+        throws Exception
+    {
+        {
+            TestBean obj = on( TestBean.class ).invokeConstructor( argument( "TEST" ) ).get();
+            assertNotNull( obj );
+            assertEquals( "TEST", obj.getStringProperty() );
+        }
+        {
+            TestBean obj = on( TestBean.class ).invokeConstructor( argument( new Float( 17.3f ) ) ).get();
+            assertNotNull( obj );
+            assertEquals( 17.3f, obj.getFloatProperty(), 0.0f );
+        }
+    }
+
+    @Test
+    public void testInvokeConstructorWithArgArray()
+        throws Exception
+    {
+        TestBean obj = on( TestBean.class ).invokeConstructor( argument( new Float( 17.3f ) ), argument( "TEST" ) ).get();
+        assertNotNull( obj );
+        assertEquals( 17.3f, obj.getFloatProperty(), 0.0f );
+        assertEquals( "TEST", obj.getStringProperty() );
+    }
+
+    @Test
+    public void testInvokeConstructorWithTypeArray()
+        throws Exception
+    {
+        {
+            TestBean obj = on( TestBean.class ).invokeConstructor( argument( Boolean.TYPE, Boolean.TRUE ),
+                                                                   argument( String.class, "TEST" ) ).get();
+            assertNotNull( obj );
+            assertEquals( true, obj.getBooleanProperty() );
+            assertEquals( "TEST", obj.getStringProperty() );
+        }
+        {
+            TestBean obj = on( TestBean.class ).invokeConstructor( argument( Boolean.class, Boolean.TRUE ),
+                                                                   argument( String.class, "TEST" ) ).get();
+            assertNotNull( obj );
+            assertEquals( true, obj.isBooleanSecond() );
+            assertEquals( "TEST", obj.getStringProperty() );
+        }
+    }
+
+    @Test
+    public void testInvokeExactConstructor()
+        throws Exception
+    {
+        {
+            TestBean obj = on( TestBean.class ).invokeExactConstructor( argument( "TEST" ) ).get();
+            assertNotNull( obj );
+            assertEquals( "TEST", obj.getStringProperty() );
+        }
+        {
+            try
+            {
+                TestBean obj = on( TestBean.class ).invokeExactConstructor( argument( new Float( 17.3f ) ) ).get();
+                fail( "Expected NoSuchMethodException" );
+            }
+            catch ( NoSuchMethodException e )
+            {
+                // expected
+            }
+        }
+        {
+            TestBean obj = on( TestBean.class ).invokeExactConstructor( argument( Boolean.TRUE ) ).get();
+            assertNotNull( obj );
+
+            assertEquals( true, obj.isBooleanSecond() );
+        }
+    }
+
+    @Test
+    public void testInvokeExactConstructorWithArgArray()
+        throws Exception
+    {
+        {
+            try
+            {
+                TestBean obj = on( TestBean.class ).invokeExactConstructor( argument( new Float( 17.3f ) ),
+                                                                            argument( "TEST" ) ).get();
+                fail( "Expected NoSuchMethodException" );
+            }
+            catch ( NoSuchMethodException e )
+            {
+                // expected
+            }
+        }
+        {
+            TestBean obj = on( TestBean.class ).invokeExactConstructor( argument( Boolean.TRUE ),
+                                                                        argument( "TEST" ) ).get();
+            assertNotNull( obj );
+            assertEquals( true, obj.isBooleanSecond() );
+            assertEquals( "TEST", obj.getStringProperty() );
+        }
+    }
+
+    @Test
+    public void testInvokeExactConstructorWithTypeArray()
+        throws Exception
+    {
+        {
+            TestBean obj = on( TestBean.class ).invokeExactConstructor( argument( Boolean.TYPE, Boolean.TRUE ),
+                                                                        argument( String.class, "TEST" ) ).get();
+            assertNotNull( obj );
+            assertEquals( true, obj.getBooleanProperty() );
+            assertEquals( "TEST", obj.getStringProperty() );
+        }
+        {
+            TestBean obj = on( TestBean.class ).invokeExactConstructor( argument( Boolean.class, Boolean.TRUE ),
+                                                                        argument( String.class, "TEST" ) ).get();
+            assertNotNull( obj );
+            assertEquals( true, obj.isBooleanSecond() );
+            assertEquals( "TEST", obj.getStringProperty() );
+        }
+        {
+            TestBean obj = on( TestBean.class ).invokeExactConstructor( argument( Float.TYPE, new Float( 17.3f ) ),
+                                                                        argument( String.class, "TEST" ) ).get();
+            assertNotNull( obj );
+
+            assertEquals( 17.3f, obj.getFloatProperty(), 0.0f );
+            assertEquals( "TEST", obj.getStringProperty() );
+        }
+        {
+            try
+            {
+                TestBean obj = on( TestBean.class ).invokeExactConstructor( argument( Float.class, new Float( 17.3f ) ),
+                                                                            argument( String.class, "TEST" ) ).get();
+                fail( "Expected NoSuchMethodException" );
+            }
+            catch ( NoSuchMethodException e )
+            {
+                // expected
+            }
+        }
+    }
+
+}

Propchange: commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/ConstructorsTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/ConstructorsTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/ConstructorsTestCase.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/TestBean.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/TestBean.java?rev=1233585&view=auto
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/TestBean.java (added)
+++ commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/TestBean.java Thu Jan 19 21:44:04 2012
@@ -0,0 +1,678 @@
+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
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.io.Serializable;
+
+/**
+ * General purpose test bean for JUnit tests for the "beanutils" component.
+ *
+ * @author Craig R. McClanahan
+ * @author Rodney Waldhoff
+ * @version $Revision$ $Date$
+ */
+public class TestBean
+    implements Serializable
+{
+
+    /**
+     *
+     */
+    private static final long serialVersionUID = 1L;
+
+    // ----------------------------------------------------------- Constructors
+
+    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( float floatProperty )
+    {
+        setFloatProperty( floatProperty );
+    }
+
+    public TestBean( boolean booleanProperty )
+    {
+        setBooleanProperty( booleanProperty );
+    }
+
+    public TestBean( Boolean booleanSecond )
+    {
+        setBooleanSecond( booleanSecond.booleanValue() );
+    }
+
+    public TestBean( float floatProperty, String stringProperty )
+    {
+        setFloatProperty( floatProperty );
+        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( Integer intProperty )
+    {
+        setIntProperty( intProperty.intValue() );
+    }
+
+    public TestBean( double doubleProperty )
+    {
+        setDoubleProperty( doubleProperty );
+    }
+
+    TestBean( int intProperty )
+    {
+        setIntProperty( intProperty );
+    }
+
+    protected TestBean( boolean booleanProperty, boolean booleanSecond, String stringProperty )
+    {
+        setBooleanProperty( booleanProperty );
+        setBooleanSecond( booleanSecond );
+        setStringProperty( stringProperty );
+    }
+
+    public TestBean( List<String> listIndexed )
+    {
+        this.listIndexed = listIndexed;
+    }
+
+    public TestBean( String[][] string2dArray )
+    {
+        this.string2dArray = string2dArray;
+    }
+
+    // ------------------------------------------------------------- Properties
+
+    /**
+     * A boolean property.
+     */
+    private boolean booleanProperty = true;
+
+    public boolean getBooleanProperty()
+    {
+        return ( booleanProperty );
+    }
+
+    public void setBooleanProperty( boolean booleanProperty )
+    {
+        this.booleanProperty = booleanProperty;
+    }
+
+    /**
+     * A boolean property that uses an "is" method for the getter.
+     */
+    private boolean booleanSecond = true;
+
+    public boolean isBooleanSecond()
+    {
+        return ( booleanSecond );
+    }
+
+    public void setBooleanSecond( boolean booleanSecond )
+    {
+        this.booleanSecond = booleanSecond;
+    }
+
+    /**
+     * A byte property.
+     */
+    private byte byteProperty = (byte) 121;
+
+    public byte getByteProperty()
+    {
+        return ( this.byteProperty );
+    }
+
+    public void setByteProperty( byte byteProperty )
+    {
+        this.byteProperty = byteProperty;
+    }
+
+    /**
+     * A java.util.Date property.
+     */
+    private java.util.Date dateProperty;
+
+    public java.util.Date getDateProperty()
+    {
+        return dateProperty;
+    }
+
+    public void setDateProperty( java.util.Date dateProperty )
+    {
+        this.dateProperty = dateProperty;
+    }
+
+    /**
+     * A java.util.Date property.
+     */
+    private java.util.Date[] dateArrayProperty;
+
+    public java.util.Date[] getDateArrayProperty()
+    {
+        return dateArrayProperty;
+    }
+
+    public void setDateArrayProperty( java.util.Date[] dateArrayProperty )
+    {
+        this.dateArrayProperty = dateArrayProperty;
+    }
+
+    /**
+     * A double property.
+     */
+    private double doubleProperty = 321.0;
+
+    public double getDoubleProperty()
+    {
+        return ( this.doubleProperty );
+    }
+
+    public void setDoubleProperty( double doubleProperty )
+    {
+        this.doubleProperty = doubleProperty;
+    }
+
+    /**
+     * 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 String[] getDupProperty()
+    {
+        return ( this.dupProperty );
+    }
+
+    public String getDupProperty( int index )
+    {
+        return ( this.dupProperty[index] );
+    }
+
+    public void setDupProperty( int index, String value )
+    {
+        this.dupProperty[index] = value;
+    }
+
+    public void setDupProperty( String[] dupProperty )
+    {
+        this.dupProperty = dupProperty;
+    }
+
+    /**
+     * A float property.
+     */
+    private float floatProperty = (float) 123.0;
+
+    public float getFloatProperty()
+    {
+        return ( this.floatProperty );
+    }
+
+    public void setFloatProperty( float floatProperty )
+    {
+        this.floatProperty = floatProperty;
+    }
+
+    /**
+     * An integer array property accessed as an array.
+     */
+    private int intArray[] = { 0, 10, 20, 30, 40 };
+
+    public int[] getIntArray()
+    {
+        return ( this.intArray );
+    }
+
+    public void setIntArray( int[] intArray )
+    {
+        this.intArray = intArray;
+    }
+
+    /**
+     * An integer array property accessed as an indexed property.
+     */
+    private int intIndexed[] = { 0, 10, 20, 30, 40 };
+
+    public int getIntIndexed( int index )
+    {
+        return ( intIndexed[index] );
+    }
+
+    public void setIntIndexed( int index, int value )
+    {
+        intIndexed[index] = value;
+    }
+
+    /**
+     * An integer property.
+     */
+    private int intProperty = 123;
+
+    public int getIntProperty()
+    {
+        return ( this.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 );
+    }
+
+    /**
+     * A long property.
+     */
+    private long longProperty = 321;
+
+    public long getLongProperty()
+    {
+        return ( this.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()
+    {
+        // Create the map the very first time
+        if ( mapProperty == null )
+        {
+            mapProperty = new HashMap<String, Object>();
+            mapProperty.put( "First Key", "First Value" );
+            mapProperty.put( "Second Key", "Second Value" );
+        }
+        return ( mapProperty );
+    }
+
+    public void setMapProperty( Map<String, Object> mapProperty )
+    {
+        // Create the map the very first time
+        if ( mapProperty == null )
+        {
+            mapProperty = new HashMap<String, Object>();
+            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 )
+    {
+        // Create the map the very first time
+        if ( mappedObjects == null )
+        {
+            mappedObjects = new HashMap<String, Object>();
+            mappedObjects.put( "First Key", "First Value" );
+            mappedObjects.put( "Second Key", "Second Value" );
+        }
+        return ( mappedObjects.get( key ) );
+    }
+
+    public void setMappedObjects( String key, Object value )
+    {
+        // Create the map the very first time
+        if ( mappedObjects == null )
+        {
+            mappedObjects = new HashMap<String, Object>();
+            mappedObjects.put( "First Key", "First Value" );
+            mappedObjects.put( "Second Key", "Second 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 )
+    {
+        // Create the map the very first time
+        if ( mappedProperty == null )
+        {
+            mappedProperty = new HashMap<String, Object>();
+            mappedProperty.put( "First Key", "First Value" );
+            mappedProperty.put( "Second Key", "Second Value" );
+        }
+        return ( (String) mappedProperty.get( key ) );
+    }
+
+    public void setMappedProperty( String key, String value )
+    {
+        // Create the map the very first time
+        if ( mappedProperty == null )
+        {
+            mappedProperty = new HashMap<String, Object>();
+            mappedProperty.put( "First Key", "First Value" );
+            mappedProperty.put( "Second Key", "Second 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 )
+    {
+        // Create the map the very first time
+        if ( mappedIntProperty == null )
+        {
+            mappedIntProperty = new HashMap<String, Object>();
+            mappedIntProperty.put( "One", new Integer( 1 ) );
+            mappedIntProperty.put( "Two", new Integer( 2 ) );
+        }
+        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 ) );
+    }
+
+    /**
+     * A nested reference to another test bean (populated as needed).
+     */
+    private TestBean nested = null;
+
+    public TestBean getNested()
+    {
+        if ( nested == null )
+            nested = new TestBean();
+        return ( nested );
+    }
+
+    /**
+     * Another nested reference to another test bean,
+     */
+    private TestBean anotherNested = null;
+
+    public TestBean getAnotherNested()
+    {
+        return 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 )
+        {
+            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 void setNullProperty( String nullProperty )
+    {
+        this.nullProperty = nullProperty;
+    }
+
+    /**
+     * A read-only String property.
+     */
+    private String readOnlyProperty = "Read Only String Property";
+
+    public String getReadOnlyProperty()
+    {
+        return ( this.readOnlyProperty );
+    }
+
+    /**
+     * A short property.
+     */
+    private short shortProperty = (short) 987;
+
+    public short getShortProperty()
+    {
+        return ( this.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 void setStringArray( String[] stringArray )
+    {
+        this.stringArray = stringArray;
+    }
+
+    /**
+     * A String array property accessed as an indexed property.
+     */
+    private String[] stringIndexed = { "String 0", "String 1", "String 2", "String 3", "String 4" };
+
+    public String getStringIndexed( int index )
+    {
+        return ( stringIndexed[index] );
+    }
+
+    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" } };
+
+    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 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 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;
+
+    public boolean getInvalidBoolean()
+    {
+        return ( this.invalidBoolean );
+    }
+
+    public boolean isInvalidBoolean()
+    {
+        return ( this.invalidBoolean );
+    }
+
+    public void setInvalidBoolean( String invalidBoolean )
+    {
+        if ( "true".equalsIgnoreCase( invalidBoolean ) || "yes".equalsIgnoreCase( invalidBoolean )
+            || "1".equalsIgnoreCase( invalidBoolean ) )
+        {
+            this.invalidBoolean = true;
+        }
+        else
+        {
+            this.invalidBoolean = false;
+        }
+    }
+
+    // ------------------------------------------------------- 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 );
+
+    }
+
+    /**
+     * Increment the current value of the counter by the specified amount.
+     *
+     * @param amount Amount to be added to the current counter
+     */
+    public static void incrementCounter( int amount )
+    {
+
+        counter += amount;
+
+    }
+
+    /**
+     * 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();
+    }
+
+}

Propchange: commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/TestBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/TestBean.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/TestBean.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain