You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by tf...@apache.org on 2013/04/02 00:05:56 UTC

svn commit: r1463317 - in /db/torque/torque4/trunk/torque-generator/src: main/java/org/apache/torque/generator/source/model/ test/java/org/apache/torque/generator/source/model/

Author: tfischer
Date: Mon Apr  1 22:05:55 2013
New Revision: 1463317

URL: http://svn.apache.org/r1463317
Log:
TORQUE-273 further implement utility class for setting properties by reflection 

Added:
    db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/source/model/NoSuchPropertyException.java
      - copied, changed from r1462477, db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/source/model/NoSuchPropertyException.java
    db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/source/model/PropertyNotReadableException.java
    db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/source/model/PropertyNotWriteableException.java
Modified:
    db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/source/model/PropertyAccess.java
    db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/source/model/PropertyAccessTest.java

Copied: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/source/model/NoSuchPropertyException.java (from r1462477, db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/source/model/NoSuchPropertyException.java)
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/source/model/NoSuchPropertyException.java?p2=db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/source/model/NoSuchPropertyException.java&p1=db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/source/model/NoSuchPropertyException.java&r1=1462477&r2=1463317&rev=1463317&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/source/model/NoSuchPropertyException.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/source/model/NoSuchPropertyException.java Mon Apr  1 22:05:55 2013
@@ -25,9 +25,15 @@ public class NoSuchPropertyException ext
 {
     public NoSuchPropertyException(Object target, String name)
     {
-        super("Neither public field nor public setter exists for property "
+        super("Neither public field nor public getter/setter"
+                + " exists for property "
                 + name
                 + " of class "
                 + target.getClass().getName());
     }
+
+    protected NoSuchPropertyException(String message)
+    {
+        super(message);
+    }
 }

Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/source/model/PropertyAccess.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/source/model/PropertyAccess.java?rev=1463317&r1=1463316&r2=1463317&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/source/model/PropertyAccess.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/source/model/PropertyAccess.java Mon Apr  1 22:05:55 2013
@@ -25,8 +25,16 @@ import java.lang.reflect.Field;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Queue;
+import java.util.Set;
 
-import org.apache.commons.beanutils.BeanUtils;
 import org.apache.commons.beanutils.PropertyUtils;
 import org.apache.torque.generator.source.SourceException;
 
@@ -41,7 +49,20 @@ public class PropertyAccess
 
     private String propertyName;
 
+    private Field field;
+
+    private Method writeMethod;
+
+    private Method readMethod;
+
+    /**
+     *
+     * @param target
+     * @param propertyName
+     * @throws SourceException
+     */
     public PropertyAccess(Object target, String propertyName)
+            throws SourceException
     {
         if (target == null)
         {
@@ -53,24 +74,46 @@ public class PropertyAccess
         }
         this.target = target;
         this.propertyName = propertyName;
+        this.field = determinePublicField(target, propertyName);
+        if (this.field == null)
+        {
+            PropertyDescriptor propertyDescriptor = determinePropertyDescriptor(target, propertyName);
+            if (propertyDescriptor != null)
+            {
+                this.readMethod = propertyDescriptor.getReadMethod();
+                this.writeMethod = propertyDescriptor.getWriteMethod();
+            }
+        }
     }
 
-    public void setSingleProperty(Object value)
+    /**
+     * Returns the public field of the class of the object <code>target</code>
+     * with name <code>name</code>.
+     *
+     * @param target the target object, not null.
+     * @param name the name of the field, not null.
+     * @return the field if a public field with the given name exists,
+     *         or null if no public filed with the given name exists.
+     *
+     * @throws SourceException if security settings prevent reading the field
+     *         of the object.
+     */
+    private static Field determinePublicField(Object target, String name)
             throws SourceException
     {
-        // try public field
         try
         {
-            Field field = target.getClass().getField(propertyName);
-            if (Modifier.isPublic(field.getModifiers()))
+            Field fieldCandidate = target.getClass().getField(name);
+            if (Modifier.isPublic(fieldCandidate.getModifiers()))
             {
-                field.set(target, value);
-                return;
+                return fieldCandidate;
             }
         }
         catch (SecurityException e)
         {
             throw createSetFieldException(
+                    target,
+                    name,
                     null,
                     " because access is denied to the field or package",
                     e);
@@ -79,6 +122,124 @@ public class PropertyAccess
         {
             // do nothing, field does not exist
         }
+        return null;
+    }
+
+    private static PropertyDescriptor determinePropertyDescriptor(
+                Object target,
+                String name)
+            throws SourceException
+    {
+        try
+        {
+            PropertyDescriptor propertyDescriptor
+                    = PropertyUtils.getPropertyDescriptor(target, name);
+            return propertyDescriptor;
+        }
+        catch (NoSuchMethodException e)
+        {
+            throw new SourceException(e);
+        }
+        catch (IllegalAccessException e)
+        {
+            throw new SourceException(e);
+        }
+        catch (InvocationTargetException e)
+        {
+            throw new SourceException(e);
+        }
+    }
+
+    public void setProperty(Object value)
+            throws SourceException
+    {
+        if (field != null)
+        {
+            if (field.getType().isArray()
+                    && (value == null || !value.getClass().isArray()))
+            {
+                setMemberinArrayField(value);
+            }
+            else if (Collection.class.isAssignableFrom(field.getType())
+                    && (value == null
+                        || !Collection.class.isAssignableFrom(value.getClass())))
+            {
+                setMemberinCollectionField(value);
+            }
+            else
+            {
+                setPropertyStrictUsingField(value);
+            }
+            return;
+        }
+        else if (writeMethod != null)
+        {
+            if (writeMethod.getParameterTypes()[0].isArray()
+                    && (value == null || !value.getClass().isArray()))
+            {
+                setMemberinArrayField(value);
+            }
+            else if (Collection.class.isAssignableFrom(
+                        writeMethod.getParameterTypes()[0])
+                    && (value == null
+                        || !Collection.class.isAssignableFrom(value.getClass())))
+            {
+                setMemberinCollectionField(value);
+            }
+            else
+            {
+                setPropertyStrictUsingSetter(value);
+            }
+            return;
+        }
+        else if (readMethod != null)
+        {
+            if (Collection.class.isAssignableFrom(
+                    readMethod.getReturnType())
+                && (value == null
+                    || !Collection.class.isAssignableFrom(value.getClass())))
+            {
+                setMemberinCollectionField(value);
+                return;
+            }
+            throw new PropertyNotWriteableException(target, propertyName);
+        }
+        else
+        {
+            throw new NoSuchPropertyException(target, propertyName);
+        }
+    }
+
+    public void setPropertyStrict(Object value)
+            throws SourceException
+    {
+        if (field != null)
+        {
+            setPropertyStrictUsingField(value);
+            return;
+        }
+        else if (writeMethod != null)
+        {
+            setPropertyStrictUsingSetter(value);
+            return;
+        }
+        else if (readMethod != null)
+        {
+            throw new PropertyNotWriteableException(target, propertyName);
+        }
+        else
+        {
+            throw new NoSuchPropertyException(target, propertyName);
+        }
+    }
+
+    private void setPropertyStrictUsingField(Object value)
+            throws SourceException
+    {
+        try
+        {
+            field.set(target, value);
+        }
         catch (IllegalArgumentException e)
         {
             if (value == null) {
@@ -93,43 +254,24 @@ public class PropertyAccess
                     " because the argument has the wrong type "
                             + value.getClass().getName() ,
                     e);
-        } catch (IllegalAccessException e)
+        }
+        catch (IllegalAccessException e)
         {
             throw createSetFieldException(
                     null,
                     " because the field cannot be accessed",
                     e);
         }
+    }
 
-        // try setter
+    private void setPropertyStrictUsingSetter(Object value)
+            throws SourceException
+    {
         try
         {
-            PropertyDescriptor propertyDescriptor
-                    = PropertyUtils.getPropertyDescriptor(target, propertyName);
-            if (propertyDescriptor == null)
-            {
-                throw new NoSuchPropertyException(target, propertyName);
-            }
-            Method writeMethod = propertyDescriptor.getWriteMethod();
-            if (writeMethod == null)
-            {
-                throw new NoSuchPropertyException(target, propertyName);
-            }
             writeMethod.invoke(target, value);
             return;
         }
-        catch (NoSuchMethodException e)
-        {
-            throw new SourceException(e);
-        }
-        catch (IllegalAccessException e)
-        {
-            throw new SourceException(e);
-        }
-        catch (InvocationTargetException e)
-        {
-            throw new SourceException(e);
-        }
         catch (IllegalArgumentException e)
         {
             if (value == null) {
@@ -145,90 +287,180 @@ public class PropertyAccess
                             + value.getClass().getName() ,
                     e);
         }
+        catch (IllegalAccessException e)
+        {
+            throw new SourceException(e);
+        }
+        catch (InvocationTargetException e)
+        {
+            throw new SourceException(e);
+        }
+    }
+
+    public Object getProperty() throws SourceException {
+        if (field != null) {
+            return getPropertyUsingField();
+        } else if (readMethod != null) {
+            return getPropertyUsingGetter();
+        } else {
+            throw new PropertyNotReadableException(target, propertyName);
+        }
     }
 
-    public void setProperty(Object value) throws SourceException
+    private Object getPropertyUsingField() throws SourceException
     {
         try
         {
-            setSingleProperty(value);
-            return;
+            return field.get(target);
         }
-        catch (NoSuchPropertyException e)
+        catch (IllegalArgumentException e)
         {
-
+            throw new SourceException(e);
         }
+        catch (IllegalAccessException e)
+        {
+            throw new SourceException(e);
+        }
+    }
 
+    private Object getPropertyUsingGetter() throws SourceException
+    {
         try
         {
-            String propertyName = this.propertyName;
-            PropertyDescriptor propertyDescriptor
-                = PropertyUtils.getPropertyDescriptor(target, propertyName);
-            if (propertyDescriptor == null) {
-                propertyName = this.propertyName + "s";
-                propertyDescriptor
-                    = PropertyUtils.getPropertyDescriptor(target, propertyName);
-            }
-            if (propertyDescriptor == null) {
-                propertyName = this.propertyName + "Array";
-                propertyDescriptor
-                    = PropertyUtils.getPropertyDescriptor(target, propertyName);
-            }
-            if (propertyDescriptor == null) {
-                throw new SourceException("No property named "
-                        + this.propertyName + ", "
-                        + this.propertyName + "s, "
-                        + this.propertyName + "Array, "
-                        + "found on model element "
-                        + target.getClass().getName()
-                        + ". This property is needed because the source element"
-                        + " has a child element named "
-                        + this.propertyName);
-            }
-            Object childModelElement = null;
-            if (propertyDescriptor.getPropertyType().isArray())
-            {
-                Object[] oldChildModelElement = (Object[]) PropertyUtils.getProperty(target, propertyName);
-                int newIndex;
-                if (oldChildModelElement == null) {
-                    childModelElement = Array.newInstance(propertyDescriptor.getPropertyType().getComponentType(), 1);
-                    newIndex = 0;
-                }
-                else {
-                    childModelElement = Array.newInstance(propertyDescriptor.getPropertyType().getComponentType(), oldChildModelElement.length + 1);
-                    System.arraycopy(oldChildModelElement, 0, childModelElement, 0, oldChildModelElement.length);
-                    newIndex = oldChildModelElement.length;
-                }
-                ((Object[]) childModelElement)[newIndex] = value;
-            }
-            else
+            return readMethod.invoke(target);
+        }
+        catch (IllegalArgumentException e)
+        {
+            throw new SourceException(e);
+        }
+        catch (IllegalAccessException e)
+        {
+            throw new SourceException(e);
+        }
+        catch (InvocationTargetException e)
+        {
+            throw new SourceException(e);
+        }
+    }
+
+    /**
+     * Returns the class of the property.
+     *
+     * @return the class of the property,
+     *         or null if the property does not exist.
+     */
+    public Class<?> getPropertyType() {
+        if (field != null)
+        {
+            return field.getType();
+        }
+        if (writeMethod != null)
+        {
+            return writeMethod.getParameterTypes()[0];
+        }
+        if (readMethod != null)
+        {
+            return readMethod.getReturnType();
+        }
+        return null;
+    }
+
+    /**
+     * Returns the class of the generic type property.
+     *
+     * @return the class of the generic type of the property,
+     *         or null if the property does not exist.
+     */
+    public Type getPropertyGenericType()
+    {
+        if (field != null)
+        {
+            return field.getGenericType();
+        }
+        if (writeMethod != null)
+        {
+            return writeMethod.getGenericParameterTypes()[0];
+        }
+        if (readMethod != null)
+        {
+            return readMethod.getGenericReturnType();
+        }
+        return null;
+    }
+
+    public Class<?> getFirstGenericTypeArgument()
+    {
+        Type type = getPropertyGenericType();
+        if (type instanceof ParameterizedType)
+        {
+            Object firstType
+                = ((ParameterizedType) type).getActualTypeArguments()[0];
+            if (firstType instanceof Class)
             {
-                childModelElement = value;
+                return (Class<?>) firstType;
             }
+        }
+        return null;
+    }
+
+    private void setMemberinArrayField(Object value) throws SourceException
+    {
+        Object[] oldContent = (Object[]) getProperty();
+        int newIndex;
+        Object newContent;
+        if (oldContent == null) {
+            newContent = Array.newInstance(getPropertyType().getComponentType(), 1);
+            newIndex = 0;
+        }
+        else {
+            newContent = Array.newInstance(getPropertyType().getComponentType(), oldContent.length + 1);
+            System.arraycopy(oldContent, 0, newContent, 0, oldContent.length);
+            newIndex = oldContent.length;
+        }
+        ((Object[]) newContent)[newIndex] = value;
+        setPropertyStrict(newContent);
+    }
+
+    private void setMemberinCollectionField(Object value) throws SourceException
+    {
+        @SuppressWarnings("unchecked")
+        Collection<Object> content = (Collection<Object>) getProperty();
+        if (content == null) {
+            content = getCollectionInstance();
+            setPropertyStrict(content);
+        }
+        content.add(value);
+    }
+
+    private Collection<Object> getCollectionInstance() throws SourceException
+    {
+        Class<?> type = getPropertyType();
+        if (Collection.class == type || List.class == type) {
+            return new ArrayList<Object>();
+        }
+        else if (Set.class == type) {
+            return new HashSet<Object>();
+        }
+        else if (Queue.class == type) {
+            return new LinkedList<Object>();
+        }
+        else
+        {
             try
             {
-                BeanUtils.setProperty(target, propertyName, childModelElement);
+                @SuppressWarnings("unchecked")
+                Collection<Object> result
+                        = (Collection<Object>) type.newInstance();
+                return result;
             }
-            catch (IllegalAccessException e)
+            catch (InstantiationException e)
             {
                 throw new SourceException(e);
             }
-            catch (InvocationTargetException e)
+            catch (IllegalAccessException e)
             {
                 throw new SourceException(e);
             }
-        } catch (IllegalAccessException e)
-        {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-        } catch (InvocationTargetException e)
-        {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-        } catch (NoSuchMethodException e)
-        {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
         }
     }
 
@@ -237,6 +469,21 @@ public class PropertyAccess
             String reason,
             Throwable cause)
     {
+        return createSetFieldException(
+                target,
+                propertyName,
+                value,
+                reason,
+                cause);
+    }
+
+    private static SourceException createSetFieldException(
+            Object target,
+            String propertyName,
+            Object value,
+            String reason,
+            Throwable cause)
+    {
         StringBuilder message = new StringBuilder("The field ")
             .append(propertyName)
             .append(" of class ")

Added: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/source/model/PropertyNotReadableException.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/source/model/PropertyNotReadableException.java?rev=1463317&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/source/model/PropertyNotReadableException.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/source/model/PropertyNotReadableException.java Mon Apr  1 22:05:55 2013
@@ -0,0 +1,40 @@
+package org.apache.torque.generator.source.model;
+
+/*
+ * 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 org.apache.torque.generator.source.SourceException;
+
+public class PropertyNotReadableException extends SourceException
+{
+    public PropertyNotReadableException(Object target, String name)
+    {
+        this(target, name, null);
+    }
+
+    public PropertyNotReadableException(Object target, String name, String detail)
+    {
+        super("The property "
+                + name
+                + " of class "
+                + target.getClass().getName()
+                + " is not readable"
+                + (detail == null ? "" : " : " + detail));
+    }
+}

Added: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/source/model/PropertyNotWriteableException.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/source/model/PropertyNotWriteableException.java?rev=1463317&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/source/model/PropertyNotWriteableException.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/source/model/PropertyNotWriteableException.java Mon Apr  1 22:05:55 2013
@@ -0,0 +1,40 @@
+package org.apache.torque.generator.source.model;
+
+/*
+ * 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 org.apache.torque.generator.source.SourceException;
+
+public class PropertyNotWriteableException extends SourceException
+{
+    public PropertyNotWriteableException(Object target, String name)
+    {
+        this(target, name, null);
+    }
+
+    public PropertyNotWriteableException(Object target, String name, String detail)
+    {
+        super("The property "
+                + name
+                + " of class "
+                + target.getClass().getName()
+                + " is not writeable"
+                + (detail == null ? "" : " : " + detail));
+    }
+}

Modified: db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/source/model/PropertyAccessTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/source/model/PropertyAccessTest.java?rev=1463317&r1=1463316&r2=1463317&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/source/model/PropertyAccessTest.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/source/model/PropertyAccessTest.java Mon Apr  1 22:05:55 2013
@@ -19,13 +19,28 @@ package org.apache.torque.generator.sour
  * under the License.
  */
 
+import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
 
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Queue;
+import java.util.Set;
+import java.util.Vector;
+
 import org.apache.torque.generator.source.SourceException;
 import org.junit.Before;
 import org.junit.Test;
 
+/**
+ * Tests for the PropertyAccess class.
+ *
+ * @version $Id: $
+ */
 public class PropertyAccessTest
 {
     private TestClass testClass;
@@ -65,18 +80,18 @@ public class PropertyAccessTest
     }
 
     @Test
-    public void testSetSinglePropertyNotExistentField() throws Exception
+    public void testSetPropertyNotExistentField() throws Exception
     {
         PropertyAccess propertyAccess
                 = new PropertyAccess(testClass, "fieldDoesNotExist");
         try
         {
-            propertyAccess.setSingleProperty(2);
+            propertyAccess.setProperty(2);
             fail("Exception expected");
         }
         catch (NoSuchPropertyException e)
         {
-            assertEquals("Neither public field nor public setter exists "
+            assertEquals("Neither public field nor public getter/setter exists "
                     + "for property fieldDoesNotExist of class "
                     + "org.apache.torque.generator.source.model"
                     + ".PropertyAccessTest$TestClass",
@@ -85,18 +100,18 @@ public class PropertyAccessTest
     }
 
     @Test
-    public void testAccessPrivateField() throws Exception
+    public void testSetPropertyPrivateField() throws Exception
     {
         PropertyAccess propertyAccess
                 = new PropertyAccess(testClass, "privateIntField");
         try
         {
-            propertyAccess.setSingleProperty(2);
+            propertyAccess.setProperty(2);
             fail("Exception expected");
         }
         catch (NoSuchPropertyException e)
         {
-            assertEquals("Neither public field nor public setter exists "
+            assertEquals("Neither public field nor public getter/setter exists "
                     + "for property privateIntField of class "
                     + "org.apache.torque.generator.source.model"
                     + ".PropertyAccessTest$TestClass",
@@ -105,18 +120,18 @@ public class PropertyAccessTest
     }
 
     @Test
-    public void testAccessProtectedField() throws Exception
+    public void testSetPropertyProtectedField() throws Exception
     {
         PropertyAccess propertyAccess
                 = new PropertyAccess(testClass, "protectedIntField");
         try
         {
-            propertyAccess.setSingleProperty(2);
+            propertyAccess.setProperty(2);
             fail("Exception expected");
         }
         catch (NoSuchPropertyException e)
         {
-            assertEquals("Neither public field nor public setter exists "
+            assertEquals("Neither public field nor public getter/setter exists "
                     + "for property protectedIntField of class "
                     + "org.apache.torque.generator.source.model"
                     + ".PropertyAccessTest$TestClass",
@@ -125,18 +140,18 @@ public class PropertyAccessTest
     }
 
     @Test
-    public void testAccessField() throws Exception
+    public void testSetPropertyField() throws Exception
     {
         PropertyAccess propertyAccess
                 = new PropertyAccess(testClass, "intField");
         try
         {
-            propertyAccess.setSingleProperty(2);
+            propertyAccess.setProperty(2);
             fail("Exception expected");
         }
         catch (NoSuchPropertyException e)
         {
-            assertEquals("Neither public field nor public setter exists "
+            assertEquals("Neither public field nor public getter/setter exists "
                     + "for property intField of class "
                     + "org.apache.torque.generator.source.model"
                     + ".PropertyAccessTest$TestClass",
@@ -145,11 +160,11 @@ public class PropertyAccessTest
     }
 
     @Test
-    public void testAccessPublicField() throws Exception
+    public void testSetPropertyPublicField() throws Exception
     {
         PropertyAccess propertyAccess
                 = new PropertyAccess(testClass, "publicIntField");
-        propertyAccess.setSingleProperty(2);
+        propertyAccess.setProperty(2);
         assertEquals(2, testClass.publicIntField);
     }
 
@@ -158,12 +173,12 @@ public class PropertyAccessTest
     {
         PropertyAccess propertyAccess
                 = new PropertyAccess(testClass, "publicIntFieldFromBaseClass");
-        propertyAccess.setSingleProperty(2);
+        propertyAccess.setProperty(2);
         assertEquals(2, testClass.publicIntFieldFromBaseClass);
     }
 
     @Test
-    public void testAccessPublicFieldWrongClass() throws Exception
+    public void testSetPropertyPublicFieldWrongClass() throws Exception
     {
         PropertyAccess propertyAccess
                 = new PropertyAccess(testClass, "publicIntField");
@@ -184,13 +199,13 @@ public class PropertyAccessTest
     }
 
     @Test
-    public void testAccessIntFieldNull() throws Exception
+    public void testSetPropertyIntFieldNull() throws Exception
     {
         PropertyAccess propertyAccess
                 = new PropertyAccess(testClass, "publicIntField");
         try
         {
-            propertyAccess.setSingleProperty(null);
+            propertyAccess.setProperty(null);
             fail("Exception expected");
         }
         catch (SourceException e)
@@ -204,57 +219,210 @@ public class PropertyAccessTest
     }
 
     @Test
-    public void testAccessPublicStringField() throws Exception
+    public void testSetPropertyPublicStringField() throws Exception
     {
         PropertyAccess propertyAccess
                 = new PropertyAccess(testClass, "publicStringField");
-        propertyAccess.setSingleProperty("abc");
+        propertyAccess.setProperty("abc");
         assertEquals("abc", testClass.publicStringField);
     }
 
     @Test
-    public void testAccessPublicStringFieldNull() throws Exception
+    public void testSetPropertyPublicStringFieldNull() throws Exception
     {
         PropertyAccess propertyAccess
                 = new PropertyAccess(testClass, "publicStringField");
         testClass.publicStringField = "abc";
-        propertyAccess.setSingleProperty(null);
+        propertyAccess.setProperty(null);
         assertEquals(null, testClass.publicStringField);
     }
 
     @Test
-    public void testSetSinglePropertyOnlyGetter() throws Exception
+    public void testSetPropertyPublicStringArrayField() throws Exception
+    {
+        PropertyAccess propertyAccess
+                = new PropertyAccess(testClass, "publicStringArrayField");
+        propertyAccess.setProperty("abc");
+        assertArrayEquals(new Object[] {"abc"}, testClass.publicStringArrayField);
+    }
+
+    @Test
+    public void testSetPropertyPublicStringArrayFieldAlreadyFilled()
+            throws Exception
+    {
+        PropertyAccess propertyAccess
+                = new PropertyAccess(testClass, "publicStringArrayField");
+        testClass.publicStringArrayField = new String[] {"def", "XYZ"};
+        propertyAccess.setProperty("abc");
+        assertArrayEquals(
+                new String[] {"def", "XYZ", "abc"},
+                testClass.publicStringArrayField);
+    }
+
+    @Test
+    public void testSetPropertyPublicStringArrayFieldNull() throws Exception
+    {
+        PropertyAccess propertyAccess
+                = new PropertyAccess(testClass, "publicStringArrayField");
+        testClass.publicStringArrayField = new String[] {"abc"};
+        propertyAccess.setProperty(null);
+        assertArrayEquals(
+                new String[] {"abc", null},
+                testClass.publicStringArrayField);
+    }
+
+    @Test
+    public void testSetPropertyPublicStringArrayFieldArray() throws Exception
+    {
+        PropertyAccess propertyAccess
+                = new PropertyAccess(testClass, "publicStringArrayField");
+        testClass.publicStringArrayField = new String[] {"XYZ", "def"};
+        propertyAccess.setProperty(new String[] {"abc"});
+        assertArrayEquals(new String[] {"abc"}, testClass.publicStringArrayField);
+    }
+
+
+    @Test
+    public void testSetPropertyPublicStringCollectionField() throws Exception
+    {
+        PropertyAccess propertyAccess
+                = new PropertyAccess(testClass, "publicStringCollectionField");
+        propertyAccess.setProperty("abc");
+        List<String> expected = new ArrayList<String>();
+        expected.add("abc");
+        assertEquals(expected, testClass.publicStringCollectionField);
+    }
+
+    @Test
+    public void testSetPropertyPublicStringCollectionFieldAlreadyFilled()
+            throws Exception
+    {
+        PropertyAccess propertyAccess
+                = new PropertyAccess(testClass, "publicStringCollectionField");
+        List<String> initial = new ArrayList<String>();
+        initial.add("def");
+        initial.add("XYZ");
+        testClass.publicStringCollectionField = initial;
+        propertyAccess.setProperty("abc");
+        List<String> expected = new ArrayList<String>();
+        expected.add("def");
+        expected.add("XYZ");
+        expected.add("abc");
+        assertEquals(expected, testClass.publicStringCollectionField);
+    }
+
+    @Test
+    public void testSetPropertyPublicStringCollectionFieldNull() throws Exception
+    {
+        PropertyAccess propertyAccess
+                = new PropertyAccess(testClass, "publicStringCollectionField");
+        testClass.publicStringField = "abc";
+        propertyAccess.setProperty(null);
+        List<String> expected = new ArrayList<String>();
+        expected.add(null);
+        assertEquals(expected, testClass.publicStringCollectionField);
+    }
+
+    /**
+     * Checks that a collection field gets overwritten if it is set
+     * using a collection.
+     *
+     * @throws Exception if the test fails.
+     */
+    @Test
+    public void testSetPropertyPublicStringCollectionFieldCollection()
+            throws Exception
+    {
+        PropertyAccess propertyAccess
+                = new PropertyAccess(testClass, "publicStringCollectionField");
+        List<String> initial = new ArrayList<String>();
+        initial.add("def");
+        initial.add("XYZ");
+        testClass.publicStringCollectionField = initial;
+        List<String> setValue = new ArrayList<String>();
+        setValue.add("abc");
+        propertyAccess.setProperty(setValue);
+        List<String> expected = new ArrayList<String>();
+        expected.add("abc");
+        assertEquals(expected, testClass.publicStringCollectionField);
+    }
+
+    @Test
+    public void testSetPropertyPublicStringListField() throws Exception
+    {
+        PropertyAccess propertyAccess
+                = new PropertyAccess(testClass, "publicStringListField");
+        propertyAccess.setProperty("abc");
+        List<String> expected = new ArrayList<String>();
+        expected.add("abc");
+        assertEquals(expected, testClass.publicStringListField);
+    }
+
+    @Test
+    public void testSetPropertyPublicStringSetField() throws Exception
+    {
+        PropertyAccess propertyAccess
+                = new PropertyAccess(testClass, "publicStringSetField");
+        propertyAccess.setProperty("abc");
+        Set<String> expected = new HashSet<String>();
+        expected.add("abc");
+        assertEquals(expected, testClass.publicStringSetField);
+    }
+
+    @Test
+    public void testSetPropertyPublicStringQueueField() throws Exception
+    {
+        PropertyAccess propertyAccess
+                = new PropertyAccess(testClass, "publicStringQueueField");
+        propertyAccess.setProperty("abc");
+        LinkedList<String> expected = new LinkedList<String>();
+        expected.add("abc");
+        assertEquals(expected, testClass.publicStringQueueField);
+    }
+
+    @Test
+    public void testSetPropertyPublicStringVectorField() throws Exception
+    {
+        PropertyAccess propertyAccess
+                = new PropertyAccess(testClass, "publicStringVectorField");
+        propertyAccess.setProperty("abc");
+        Vector<String> expected = new Vector<String>();
+        expected.add("abc");
+        assertEquals(expected, testClass.publicStringVectorField);
+    }
+
+    @Test
+    public void testSetPropertyOnlyGetter() throws Exception
     {
         PropertyAccess propertyAccess
                 = new PropertyAccess(testClass, "onlyGetter");
         try
         {
-            propertyAccess.setSingleProperty(2);
+            propertyAccess.setProperty(2);
             fail("Exception expected");
         }
-        catch (NoSuchPropertyException e)
+        catch (PropertyNotWriteableException e)
         {
-            assertEquals("Neither public field nor public setter exists "
-                    + "for property onlyGetter of class "
-                    + "org.apache.torque.generator.source.model"
-                    + ".PropertyAccessTest$TestClass",
+            assertEquals("The property onlyGetter of class "
+                    + "org.apache.torque.generator.source.model."
+                    + "PropertyAccessTest$TestClass is not writeable",
                 e.getMessage());
         }
     }
 
     @Test
-    public void testAccessPrivateSetter() throws Exception
+    public void testSetPropertyPrivateSetter() throws Exception
     {
         PropertyAccess propertyAccess
                 = new PropertyAccess(testClass, "privateIntSetter");
         try
         {
-            propertyAccess.setSingleProperty(2);
+            propertyAccess.setProperty(2);
             fail("Exception expected");
         }
         catch (NoSuchPropertyException e)
         {
-            assertEquals("Neither public field nor public setter exists "
+            assertEquals("Neither public field nor public getter/setter exists "
                     + "for property privateIntSetter of class "
                     + "org.apache.torque.generator.source.model"
                     + ".PropertyAccessTest$TestClass",
@@ -263,18 +431,18 @@ public class PropertyAccessTest
     }
 
     @Test
-    public void testAccessProtectedSetter() throws Exception
+    public void testSetPropertyProtectedSetter() throws Exception
     {
         PropertyAccess propertyAccess
                 = new PropertyAccess(testClass, "protectedIntSetter");
         try
         {
-            propertyAccess.setSingleProperty(2);
+            propertyAccess.setProperty(2);
             fail("Exception expected");
         }
         catch (NoSuchPropertyException e)
         {
-            assertEquals("Neither public field nor public setter exists "
+            assertEquals("Neither public field nor public getter/setter exists "
                     + "for property protectedIntSetter of class "
                     + "org.apache.torque.generator.source.model"
                     + ".PropertyAccessTest$TestClass",
@@ -283,18 +451,18 @@ public class PropertyAccessTest
     }
 
     @Test
-    public void testAccessSetter() throws Exception
+    public void testSetPropertySetter() throws Exception
     {
         PropertyAccess propertyAccess
                 = new PropertyAccess(testClass, "intSetter");
         try
         {
-            propertyAccess.setSingleProperty(2);
+            propertyAccess.setProperty(2);
             fail("Exception expected");
         }
         catch (NoSuchPropertyException e)
         {
-            assertEquals("Neither public field nor public setter exists "
+            assertEquals("Neither public field nor public getter/setter exists "
                     + "for property intSetter of class "
                     + "org.apache.torque.generator.source.model"
                     + ".PropertyAccessTest$TestClass",
@@ -303,25 +471,25 @@ public class PropertyAccessTest
     }
 
     @Test
-    public void testAccessPublicSetter() throws Exception
+    public void testSetPropertyPublicSetter() throws Exception
     {
         PropertyAccess propertyAccess
                 = new PropertyAccess(testClass, "publicIntSetter");
-        propertyAccess.setSingleProperty(2);
+        propertyAccess.setProperty(2);
         assertEquals(2, testClass.publicIntField);
     }
 
     @Test
-    public void testAccessPublicSetterFromBaseClass() throws Exception
+    public void testSetPropertyPublicSetterFromBaseClass() throws Exception
     {
         PropertyAccess propertyAccess
                 = new PropertyAccess(testClass, "publicIntSetterFromBaseClass");
-        propertyAccess.setSingleProperty(2);
+        propertyAccess.setProperty(2);
         assertEquals(2, testClass.publicIntFieldFromBaseClass);
     }
 
     @Test
-    public void testAccessPublicSetterWrongClass() throws Exception
+    public void testSetPropertyPublicSetterWrongClass() throws Exception
     {
         PropertyAccess propertyAccess
                 = new PropertyAccess(testClass, "publicIntSetter");
@@ -342,13 +510,13 @@ public class PropertyAccessTest
     }
 
     @Test
-    public void testAccessIntSetterNull() throws Exception
+    public void testSetPropertyIntSetterNull() throws Exception
     {
         PropertyAccess propertyAccess
                 = new PropertyAccess(testClass, "publicIntSetter");
         try
         {
-            propertyAccess.setSingleProperty(null);
+            propertyAccess.setProperty(null);
             fail("Exception expected");
         }
         catch (SourceException e)
@@ -362,22 +530,369 @@ public class PropertyAccessTest
     }
 
     @Test
-    public void testAccessPublicStringSetter() throws Exception
+    public void testSetPropertyPublicStringSetter() throws Exception
     {
         PropertyAccess propertyAccess
                 = new PropertyAccess(testClass, "publicStringSetter");
-        propertyAccess.setSingleProperty("abc");
+        propertyAccess.setProperty("abc");
         assertEquals("abc", testClass.publicStringField);
     }
 
     @Test
-    public void testAccessPublicStringSetterNull() throws Exception
+    public void testSetPropertyPublicStringSetterNull() throws Exception
     {
         PropertyAccess propertyAccess
                 = new PropertyAccess(testClass, "publicStringSetter");
         testClass.publicStringField = "abc";
-        propertyAccess.setSingleProperty(null);
-        assertEquals(null, testClass.publicStringField);
+        propertyAccess.setProperty(null);
+        assertArrayEquals(null, testClass.publicStringArrayField);
+    }
+
+    @Test
+    public void testSetPropertyPublicStringArraySetter() throws Exception
+    {
+        PropertyAccess propertyAccess
+                = new PropertyAccess(testClass, "publicStringArraySetter");
+        propertyAccess.setProperty("abc");
+        assertArrayEquals(new Object[] {"abc"}, testClass.publicStringArrayField);
+    }
+
+    @Test
+    public void testSetPropertyPublicStringArraySetterAlreadyFilled()
+            throws Exception
+    {
+        PropertyAccess propertyAccess
+                = new PropertyAccess(testClass, "publicStringArraySetter");
+        testClass.publicStringArrayField = new String[] {"def", "XYZ"};
+        propertyAccess.setProperty("abc");
+        assertArrayEquals(
+                new Object[] {"def", "XYZ", "abc"},
+                testClass.publicStringArrayField);
+    }
+
+    @Test
+    public void testSetPropertyPublicStringArraySetterNull() throws Exception
+    {
+        PropertyAccess propertyAccess
+                = new PropertyAccess(testClass, "publicStringArraySetter");
+        testClass.publicStringArrayField = new String[] {"abc"};
+        propertyAccess.setProperty(null);
+        assertArrayEquals(new Object[] {"abc", null}, testClass.publicStringArrayField);
+    }
+
+    @Test
+    public void testSetPropertyPublicStringArraySetterArray() throws Exception
+    {
+        PropertyAccess propertyAccess
+                = new PropertyAccess(testClass, "publicStringArraySetter");
+        propertyAccess.setProperty(new String[] {"abc"});
+        assertArrayEquals(new String[] {"abc"}, testClass.publicStringArrayField);
+    }
+
+    @Test
+    public void testSetPropertyPublicStringArraySetterWithoutGetter()
+            throws Exception
+    {
+        PropertyAccess propertyAccess
+                = new PropertyAccess(testClass, "publicStringArraySetterWithoutGetter");
+        try{
+            propertyAccess.setProperty("abc");
+            fail("Exception expected");
+        }
+       catch (PropertyNotReadableException e)
+       {
+           assertEquals("The property publicStringArraySetterWithoutGetter "
+                   + "of class "
+                   + "org.apache.torque.generator.source.model.PropertyAccessTest$TestClass"
+                   + " is not readable",
+               e.getMessage());
+       }
+    }
+
+    @Test
+    public void testSetPropertyPublicStringArrayGetterWithoutSetter()
+            throws Exception
+    {
+        PropertyAccess propertyAccess
+                = new PropertyAccess(testClass, "publicStringArrayGetterWithoutSetter");
+        try{
+            propertyAccess.setProperty("abc");
+            fail("Exception expected");
+        }
+       catch (PropertyNotWriteableException e)
+       {
+           assertEquals("The property publicStringArrayGetterWithoutSetter "
+                   + "of class "
+                   + "org.apache.torque.generator.source.model.PropertyAccessTest$TestClass"
+                   + " is not writeable",
+               e.getMessage());
+       }
+    }
+
+    @Test
+    public void testSetPropertyPublicStringCollectionSetter() throws Exception
+    {
+        PropertyAccess propertyAccess
+                = new PropertyAccess(testClass, "publicStringCollectionSetter");
+        propertyAccess.setProperty("abc");
+        List<String> expected = new ArrayList<String>();
+        expected.add("abc");
+        assertEquals(expected, testClass.publicStringCollectionField);
+    }
+
+    @Test
+    public void testSetPropertyPublicStringCollectionSetterAlreadyFilled()
+            throws Exception
+    {
+        PropertyAccess propertyAccess
+                = new PropertyAccess(testClass, "publicStringCollectionSetter");
+        List<String> initial = new ArrayList<String>();
+        initial.add("def");
+        initial.add("XYZ");
+        testClass.publicStringCollectionField = initial;
+        propertyAccess.setProperty("abc");
+        List<String> expected = new ArrayList<String>();
+        expected.add("def");
+        expected.add("XYZ");
+        expected.add("abc");
+        assertEquals(expected, testClass.publicStringCollectionField);
+    }
+
+    @Test
+    public void testSetPropertyPublicStringCollectionSetterNull()
+            throws Exception
+    {
+        PropertyAccess propertyAccess
+                = new PropertyAccess(testClass, "publicStringCollectionSetter");
+        testClass.publicStringField = "abc";
+        propertyAccess.setProperty(null);
+        List<String> expected = new ArrayList<String>();
+        expected.add(null);
+        assertEquals(expected, testClass.publicStringCollectionField);
+    }
+
+    /**
+     * Checks that a collection setter field gets overwritten if it is set
+     * using a collection.
+     *
+     * @throws Exception if the test fails.
+     */
+    @Test
+    public void testSetPropertyPublicStringCollectionSetterCollection()
+            throws Exception
+    {
+        PropertyAccess propertyAccess
+                = new PropertyAccess(testClass, "publicStringCollectionSetter");
+        List<String> initial = new ArrayList<String>();
+        initial.add("def");
+        initial.add("XYZ");
+        testClass.publicStringCollectionField = initial;
+        List<String> setValue = new ArrayList<String>();
+        setValue.add("abc");
+        propertyAccess.setProperty(setValue);
+        List<String> expected = new ArrayList<String>();
+        expected.add("abc");
+        assertEquals(expected, testClass.publicStringCollectionField);
+    }
+
+    @Test
+    public void testSetPropertyPublicStringListSetter() throws Exception
+    {
+        PropertyAccess propertyAccess
+                = new PropertyAccess(testClass, "publicStringListSetter");
+        propertyAccess.setProperty("abc");
+        List<String> expected = new ArrayList<String>();
+        expected.add("abc");
+        assertEquals(expected, testClass.publicStringListField);
+    }
+
+    @Test
+    public void testSetPropertyPublicStringSetSetter() throws Exception
+    {
+        PropertyAccess propertyAccess
+                = new PropertyAccess(testClass, "publicStringSetSetter");
+        propertyAccess.setProperty("abc");
+        Set<String> expected = new HashSet<String>();
+        expected.add("abc");
+        assertEquals(expected, testClass.publicStringSetField);
+    }
+
+    @Test
+    public void testSetPropertyPublicStringQueueSetter() throws Exception
+    {
+        PropertyAccess propertyAccess
+                = new PropertyAccess(testClass, "publicStringQueueSetter");
+        propertyAccess.setProperty("abc");
+        LinkedList<String> expected = new LinkedList<String>();
+        expected.add("abc");
+        assertEquals(expected, testClass.publicStringQueueField);
+    }
+
+    @Test
+    public void testSetPropertyPublicStringVectorSetter() throws Exception
+    {
+        PropertyAccess propertyAccess
+                = new PropertyAccess(testClass, "publicStringVectorSetter");
+        propertyAccess.setProperty("abc");
+        Vector<String> expected = new Vector<String>();
+        expected.add("abc");
+        assertEquals(expected, testClass.publicStringVectorField);
+    }
+
+    /**
+     * Checks that a collection setter field gets overwritten if it is set
+     * using a collection.
+     *
+     * @throws Exception if the test fails.
+     */
+    @Test
+    public void testSetPropertyPublicStringCollectionOnlyGetter()
+            throws Exception
+    {
+        PropertyAccess propertyAccess
+                = new PropertyAccess(testClass, "publicStringCollectionGetterWithoutSetter");
+        try
+        {
+            propertyAccess.setProperty("abc");
+            fail("Exception expected");
+        }
+        catch (PropertyNotWriteableException e)
+        {
+            assertEquals("The property "
+                    + "publicStringCollectionGetterWithoutSetter of class "
+                    + "org.apache.torque.generator.source.model."
+                    + "PropertyAccessTest$TestClass is not writeable",
+                e.getMessage());
+        }
+    }
+
+    /**
+     * Checks that a collection setter field gets overwritten if it is set
+     * using a collection.
+     *
+     * @throws Exception if the test fails.
+     */
+    @Test
+    public void testSetPropertyPublicStringCollectionOnlyGetterAlreadyFilled()
+            throws Exception
+    {
+        PropertyAccess propertyAccess
+                = new PropertyAccess(testClass, "publicStringCollectionGetterWithoutSetter");
+        List<String> initial = new ArrayList<String>();
+        initial.add("def");
+        initial.add("XYZ");
+        testClass.publicStringCollectionField = initial;
+        propertyAccess.setProperty("abc");
+        List<String> expected = new ArrayList<String>();
+        expected.add("def");
+        expected.add("XYZ");
+        expected.add("abc");
+        assertEquals(expected, testClass.publicStringCollectionField);
+    }
+
+    // start tests of getPropertyType method
+
+    @Test
+    public void testGetPropertyTypeNotExistentField() throws Exception
+    {
+        PropertyAccess propertyAccess
+            = new PropertyAccess(testClass, "fieldDoesNotExist");
+        assertEquals(null, propertyAccess.getPropertyType());
+    }
+
+    @Test
+    public void testGetPropertyTypePrivateField() throws Exception
+    {
+        PropertyAccess propertyAccess
+            = new PropertyAccess(testClass, "privateIntField");
+        assertEquals(null, propertyAccess.getPropertyType());
+    }
+
+    @Test
+    public void testGetPropertyTypePublicIntField() throws Exception
+    {
+        PropertyAccess propertyAccess
+            = new PropertyAccess(testClass, "publicIntField");
+        assertEquals(int.class, propertyAccess.getPropertyType());
+    }
+
+    @Test
+    public void testGetPropertyTypePublicStringField() throws Exception
+    {
+        PropertyAccess propertyAccess
+            = new PropertyAccess(testClass, "publicStringField");
+        assertEquals(String.class, propertyAccess.getPropertyType());
+    }
+
+    @Test
+    public void testGetPropertyTypePublicIntSetter() throws Exception
+    {
+        PropertyAccess propertyAccess
+            = new PropertyAccess(testClass, "publicIntSetter");
+        assertEquals(int.class, propertyAccess.getPropertyType());
+    }
+
+    @Test
+    public void testGetPropertyTypePublicStringSetter() throws Exception
+    {
+        PropertyAccess propertyAccess
+            = new PropertyAccess(testClass, "publicStringSetter");
+        assertEquals(String.class, propertyAccess.getPropertyType());
+    }
+
+    // start tests of getFirstGenericTypeArgument method
+
+    @Test
+    public void testGetFirstGenericTypeArgumentNotExistentField() throws Exception
+    {
+        PropertyAccess propertyAccess
+            = new PropertyAccess(testClass, "fieldDoesNotExist");
+        assertEquals(null, propertyAccess.getFirstGenericTypeArgument());
+    }
+
+    @Test
+    public void testGetFirstGenericTypeArgumentPrivateField() throws Exception
+    {
+        PropertyAccess propertyAccess
+            = new PropertyAccess(testClass, "privateIntField");
+        assertEquals(null, propertyAccess.getFirstGenericTypeArgument());
+    }
+
+    @Test
+    public void testGetFirstGenericTypeArgumentPublicIntField() throws Exception
+    {
+        PropertyAccess propertyAccess
+            = new PropertyAccess(testClass, "publicIntField");
+        assertEquals(null, propertyAccess.getFirstGenericTypeArgument());
+    }
+
+    @Test
+    public void testGetFirstGenericTypeArgumentPublicCollectionField()
+            throws Exception
+    {
+        PropertyAccess propertyAccess
+            = new PropertyAccess(testClass, "publicStringCollectionField");
+        assertEquals(String.class, propertyAccess.getFirstGenericTypeArgument());
+    }
+
+    @Test
+    public void testGetFirstGenericTypeArgumentPublicCollectionSetter()
+            throws Exception
+    {
+        PropertyAccess propertyAccess
+            = new PropertyAccess(testClass, "publicStringCollectionSetter");
+        assertEquals(String.class, propertyAccess.getFirstGenericTypeArgument());
+    }
+
+    @Test
+    public void testGetFirstGenericTypeArgumentPublicCollectionGetterWithoutSetter()
+            throws Exception
+    {
+        PropertyAccess propertyAccess
+            = new PropertyAccess(
+                    testClass,
+                    "publicStringCollectionGetterWithoutSetter");
+        assertEquals(String.class, propertyAccess.getFirstGenericTypeArgument());
     }
 
     public static class TestClass extends TestBaseClass
@@ -392,6 +907,18 @@ public class PropertyAccessTest
 
         public String publicStringField;
 
+        public String[] publicStringArrayField;
+
+        public Collection<String> publicStringCollectionField;
+
+        public List<String> publicStringListField;
+
+        public Set<String> publicStringSetField;
+
+        public Queue<String> publicStringQueueField;
+
+        public Vector<String> publicStringVectorField;
+
         public int getOnlyGetter()
         {
             return 0;
@@ -421,6 +948,86 @@ public class PropertyAccessTest
         {
             publicStringField = value;
         }
+
+        public void setPublicStringArraySetter(String[] value)
+        {
+            publicStringArrayField = value;
+        }
+
+        public String[] getPublicStringArraySetter()
+        {
+            return publicStringArrayField;
+        }
+
+        public void setPublicStringArraySetterWithoutGetter(String[] value)
+        {
+            publicStringArrayField = value;
+        }
+
+        public String[] getPublicStringArrayGetterWithoutSetter()
+        {
+            return publicStringArrayField;
+        }
+
+        public void setPublicStringCollectionSetter(Collection<String> value)
+        {
+            publicStringCollectionField = value;
+        }
+
+        public Collection<String> getPublicStringCollectionSetter()
+        {
+            return publicStringCollectionField;
+        }
+
+        public void setPublicStringCollectionSetterWithoutGetter(Collection<String> value)
+        {
+            publicStringCollectionField = value;
+        }
+
+        public Collection<String> getPublicStringCollectionGetterWithoutSetter()
+        {
+            return publicStringCollectionField;
+        }
+
+        public void setPublicStringListSetter(List<String> value)
+        {
+            publicStringListField = value;
+        }
+
+        public List<String> getPublicStringListSetter()
+        {
+            return publicStringListField;
+        }
+
+        public void setPublicStringSetSetter(Set<String> value)
+        {
+            publicStringSetField = value;
+        }
+
+        public Set<String> getPublicStringSetSetter()
+        {
+            return publicStringSetField;
+        }
+
+        public void setPublicStringQueueSetter(Queue<String> value)
+        {
+            publicStringQueueField = value;
+        }
+
+        public Queue<String> getPublicStringQueueSetter()
+        {
+            return publicStringQueueField;
+        }
+
+        public void setPublicStringVectorSetter(Vector<String> value)
+        {
+            publicStringVectorField = value;
+        }
+
+        public Vector<String> getPublicStringVectorSetter()
+        {
+            return publicStringVectorField;
+        }
     }
 
     public static class TestBaseClass



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org