db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject cvs commit: db-ojb/src/test/org/apache/ojb/broker/metadata PersistentFieldTest.java
Date Sat, 26 Jun 2004 23:51:37 GMT
arminw      2004/06/26 16:51:37

  Modified:    src/java/org/apache/ojb/broker/metadata/fieldaccess
                        AbstractPersistentField.java
                        PersistentFieldDirectAccessImplNew.java
                        PersistentFieldIntrospectorImpl.java
                        PersistentFieldIntrospectorImplNew.java
                        PersistentFieldPrivilegedImplNew.java
               src/test/org/apache/ojb/broker/metadata
                        PersistentFieldTest.java
  Log:
  add more tests
  fix problems with boundary conditions
  
  Revision  Changes    Path
  1.22      +6 -4      db-ojb/src/java/org/apache/ojb/broker/metadata/fieldaccess/AbstractPersistentField.java
  
  Index: AbstractPersistentField.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/fieldaccess/AbstractPersistentField.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- AbstractPersistentField.java	26 Apr 2004 16:50:04 -0000	1.21
  +++ AbstractPersistentField.java	26 Jun 2004 23:51:37 -0000	1.22
  @@ -15,13 +15,13 @@
    * limitations under the License.
    */
   
  +import java.lang.reflect.Field;
  +
  +import org.apache.commons.lang.SystemUtils;
   import org.apache.ojb.broker.core.proxy.ProxyHelper;
   import org.apache.ojb.broker.metadata.MetadataException;
   import org.apache.ojb.broker.util.logging.Logger;
   import org.apache.ojb.broker.util.logging.LoggerFactory;
  -import org.apache.commons.lang.SystemUtils;
  -
  -import java.lang.reflect.Field;
   
   /**
    * Abstract {@link PersistentField} base implementation.
  @@ -86,6 +86,7 @@
        */
       public void set(Object targetObject, Object value) throws MetadataException
       {
  +        if(targetObject == null) return;
           if (isNestedField())
           {
               if (value != null || !getField().getType().isPrimitive())
  @@ -104,6 +105,7 @@
        */
       public Object get(Object targetObject) throws MetadataException
       {
  +        if(targetObject == null) return null;
           if (isNestedField())
           {
               return getNestedObject(targetObject, fieldName);
  
  
  
  1.2       +17 -23    db-ojb/src/java/org/apache/ojb/broker/metadata/fieldaccess/PersistentFieldDirectAccessImplNew.java
  
  Index: PersistentFieldDirectAccessImplNew.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/fieldaccess/PersistentFieldDirectAccessImplNew.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PersistentFieldDirectAccessImplNew.java	25 Jun 2004 18:08:05 -0000	1.1
  +++ PersistentFieldDirectAccessImplNew.java	26 Jun 2004 23:51:37 -0000	1.2
  @@ -39,13 +39,10 @@
   {
       private static final long serialVersionUID = -5458024240998909205L;
   
  -    private static int NESTED_UNKOWM = 0;
  -    private static int NESTED_TRUE = 1;
  -    private static int NESTED_FALSE = 2;
  -
  +    private transient boolean isInitialized;
       private transient List fieldsList;
       private transient Field field;
  -    private transient int isNestedField;
  +    private transient boolean nonNested;
   
       public PersistentFieldDirectAccessImplNew()
       {
  @@ -73,35 +70,32 @@
        */
       protected Field getField()
       {
  -        if (field == null)
  +        // make sure class was initialized
  +        if (!isInitialized)
           {
               /*
               first we build a graph of fields for nested fields support,
               but for best performance on non-nested fields we also keep
  -            the latest field separate and build a 'isNested' flag.
  +            the latest field separate and set a 'is nested' flag.
               */
               fieldsList = getFieldGraph(makeAccessible());
               field = (Field) fieldsList.get(fieldsList.size() - 1);
  -            isNestedField = fieldsList.size() > 1 ? NESTED_TRUE : NESTED_FALSE;
  +            nonNested = fieldsList.size() == 1;
  +            isInitialized = true;
           }
           return field;
       }
   
       private List getFieldsList()
       {
  -        // make sure class is init
  -        if (field == null) getField();
  +        // make sure class was initialized
  +        if (!isInitialized) getField();
           return fieldsList;
       }
   
       protected boolean isNestedField()
       {
  -        // make sure class is init
  -        if(isNestedField == NESTED_UNKOWM)
  -        {
  -            getField();
  -        }
  -        return isNestedField == NESTED_TRUE;
  +        return !nonNested;
       }
   
       /**
  @@ -109,6 +103,8 @@
        */
       public void set(Object target, Object value) throws MetadataException
       {
  +        // if target null, we have nothing to do
  +        if(target == null) return;
           Object current = target;
           if (isNestedField())
           {
  @@ -121,10 +117,6 @@
                   Object attribute = null;
                   try
                   {
  -//                    System.out.println("" + (field != null ? field.getName() : null)
  -//                            + "/" + (field != null ? field.getType() : null)
  -//                            + "    " + (current != null ? current.getClass() : null));
  -                    //attribute = field.get(current);
                       attribute = getValueFrom(field, current);
                   }
                   catch (Exception e)
  @@ -133,6 +125,8 @@
                   }
                   if (attribute != null || value != null)
                   {
  +                    // if the intermediary nested object is null, we have to create
  +                    // a new instance to set the value
                       if (attribute == null)
                       {
                           try
  @@ -166,7 +160,7 @@
                   current = attribute;
               }
           }
  -        if(current != null) setValueFor(getField(), current, value);
  +        setValueFor(getField(), current, value);
       }
   
       /**
  @@ -180,8 +174,8 @@
               List fields = getFieldsList();
               for (int i = 0; i < fields.size(); i++)
               {
  -                result = getValueFrom((Field) fields.get(i), result);
                   if (result == null) break;
  +                result = getValueFrom((Field) fields.get(i), result);
               }
           }
           else
  
  
  
  1.11      +3 -1      db-ojb/src/java/org/apache/ojb/broker/metadata/fieldaccess/PersistentFieldIntrospectorImpl.java
  
  Index: PersistentFieldIntrospectorImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/fieldaccess/PersistentFieldIntrospectorImpl.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- PersistentFieldIntrospectorImpl.java	26 Jun 2004 10:52:03 -0000	1.10
  +++ PersistentFieldIntrospectorImpl.java	26 Jun 2004 23:51:37 -0000	1.11
  @@ -74,6 +74,7 @@
        */
       public void doSet(Object anObject, Object aValue) throws MetadataException
       {
  +        if(anObject == null) return;
           Method m = getPropertyDescriptor().getWriteMethod();
           Object[] args = {aValue};
           if (m != null)
  @@ -110,6 +111,7 @@
        */
       public Object doGet(Object anObject) throws MetadataException
       {
  +        if(anObject == null) return null;
           Method m = getPropertyDescriptor().getReadMethod();
           Object[] args = null;
   
  
  
  
  1.2       +4 -13     db-ojb/src/java/org/apache/ojb/broker/metadata/fieldaccess/PersistentFieldIntrospectorImplNew.java
  
  Index: PersistentFieldIntrospectorImplNew.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/fieldaccess/PersistentFieldIntrospectorImplNew.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PersistentFieldIntrospectorImplNew.java	26 Jun 2004 10:52:03 -0000	1.1
  +++ PersistentFieldIntrospectorImplNew.java	26 Jun 2004 23:51:37 -0000	1.2
  @@ -70,18 +70,9 @@
           return this.rootObjectType;
       }
   
  -    public void set(Object obj, Object value) throws MetadataException
  -    {
  -        writeValue(obj, value);
  -    }
  -
  -    public Object get(Object anObject) throws MetadataException
  -    {
  -        return readValue(anObject);
  -    }
  -
  -    private void writeValue(Object target, Object value)
  +    public void set(Object target, Object value) throws MetadataException
       {
  +        if(target == null) return;
           List propertyDescriptors = getPropertyGraph();
           int size = propertyDescriptors.size() - 1;
           PropertyDescriptor pd;
  @@ -117,7 +108,7 @@
           setValueFor(pd, target, value);
       }
   
  -    private Object readValue(Object target)
  +    public Object get(Object target) throws MetadataException
       {
           List propertyDescriptors = getPropertyGraph();
           for (int i = 0; i < propertyDescriptors.size(); i++)
  
  
  
  1.2       +3 -3      db-ojb/src/java/org/apache/ojb/broker/metadata/fieldaccess/PersistentFieldPrivilegedImplNew.java
  
  Index: PersistentFieldPrivilegedImplNew.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/fieldaccess/PersistentFieldPrivilegedImplNew.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PersistentFieldPrivilegedImplNew.java	25 Jun 2004 18:08:05 -0000	1.1
  +++ PersistentFieldPrivilegedImplNew.java	26 Jun 2004 23:51:37 -0000	1.2
  @@ -126,7 +126,7 @@
       private class SetAccessibleAction implements PrivilegedAction, Serializable
       {
           static final long serialVersionUID = 8152025069698028050L;
  -        Field current;
  +        transient Field current;
   
           public Object run()
           {
  @@ -138,7 +138,7 @@
       private class UnsetAccessibleAction implements PrivilegedAction, Serializable
       {
           static final long serialVersionUID = -2284913657454430305L;
  -        Field current;
  +        transient Field current;
   
           public Object run()
           {
  
  
  
  1.5       +122 -176  db-ojb/src/test/org/apache/ojb/broker/metadata/PersistentFieldTest.java
  
  Index: PersistentFieldTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/metadata/PersistentFieldTest.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PersistentFieldTest.java	26 Jun 2004 10:54:45 -0000	1.4
  +++ PersistentFieldTest.java	26 Jun 2004 23:51:37 -0000	1.5
  @@ -2,12 +2,14 @@
   
   import java.util.Collection;
   
  +import org.apache.commons.lang.SerializationUtils;
   import org.apache.commons.lang.builder.ToStringBuilder;
   import org.apache.commons.lang.builder.ToStringStyle;
   import org.apache.ojb.broker.metadata.fieldaccess.PersistentField;
   import org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldAutoProxyImpl;
   import org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDirectAccessImpl;
   import org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDirectAccessImplNew;
  +import org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDynaBeanAccessImpl;
   import org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldIntrospectorImpl;
   import org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldIntrospectorImplNew;
   import org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldPrivilegedImpl;
  @@ -50,7 +52,8 @@
           , PersistentFieldIntrospectorImplNew.class
           , PersistentFieldPrivilegedImpl.class
           , PersistentFieldPrivilegedImplNew.class
  -        , PersistentFieldAutoProxyImpl.class};
  +        , PersistentFieldAutoProxyImpl.class
  +        , PersistentFieldDynaBeanAccessImpl.class};
   
       public static void main(String[] args)
       {
  @@ -72,16 +75,20 @@
                   .getConfigurationFor(null)).setPersistentFieldClass(oldPFClass);
       }
   
  -    public void testDirectAccess() throws Exception
  +    private void runFieldTestsFor(Class targetClass, boolean supportJavaBeanNames) throws
Exception
       {
  -        Class targetClass = PersistentFieldDirectAccessImpl.class;
  -
           ((OjbConfiguration)OjbConfigurator.getInstance().getConfigurationFor(null)).setPersistentFieldClass(targetClass);
   
           PersistentField pfNM_Name = newInstance(targetClass, NestedMain.class, NESTED_MAIN_NAME);
           PersistentField pfNDD_RD = newInstance(targetClass, NestedMain.class, NESTED_DETAIL_DETAIL_REAL_DETAIL);
  -        // PersistentField pfND_MJB = newInstance(targetClass, NestedMain.class, NESTED_DETAIL_MORE_JAVA_BEAN);
  -        // PersistentField pfNE_Name = newInstance(targetClass, NestedMain.class, NESTED_ENTRY_NAME);
  +        PersistentField pfNDD_RDD = newInstance(targetClass, NestedMain.class, NESTED_DETAIL_DETAIL_REAL_DESCRIPTION);
  +        PersistentField pfND_MJB = null;
  +        PersistentField pfNE_Name = null;
  +        if(supportJavaBeanNames)
  +        {
  +            pfND_MJB = newInstance(targetClass, NestedMain.class, NESTED_DETAIL_MORE_JAVA_BEAN);
  +            pfNE_Name = newInstance(targetClass, NestedMain.class, NESTED_ENTRY_NAME);
  +        }
   
           // test getter
           NestedMain nm = createNestedObject();
  @@ -89,224 +96,160 @@
           assertEquals(NESTED_MAIN_NAME_VALUE, result);
           result = pfNDD_RD.get(nm);
           assertEquals(NESTED_DETAIL_DETAIL_REAL_DETAIL_VALUE, result);
  +        result = pfNDD_RDD.get(nm);
  +        assertEquals(NESTED_DETAIL_DETAIL_REAL_DESCRIPTION_VALUE, result);
  +
  +        if(supportJavaBeanNames)
  +        {
  +            result = pfND_MJB.get(nm);
  +            assertEquals(NESTED_DETAIL_MORE_JAVA_BEAN_VALUE, result);
  +            result = pfNE_Name.get(nm);
  +            assertEquals(NESTED_ENTRY_NAME_VALUE, result);
  +        }
   
           NestedMain newNM = new NestedMain();
           // test setter
           pfNM_Name.set(newNM, NESTED_MAIN_NAME_VALUE);
           pfNDD_RD.set(newNM, NESTED_DETAIL_DETAIL_REAL_DETAIL_VALUE);
  +        result = pfNDD_RDD.get(newNM);
  +        assertEquals(NESTED_DETAIL_DETAIL_REAL_DESCRIPTION_VALUE , result);
  +
           result = pfNM_Name.get(newNM);
           assertEquals(NESTED_MAIN_NAME_VALUE, result);
           result = pfNDD_RD.get(newNM);
           assertEquals(NESTED_DETAIL_DETAIL_REAL_DETAIL_VALUE , result);
   
  -    }
  -
  -    public void testDirectAccessNew() throws Exception
  -    {
  -        Class targetClass = PersistentFieldDirectAccessImplNew.class;
  -
  -        ((OjbConfiguration)OjbConfigurator.getInstance().getConfigurationFor(null)).setPersistentFieldClass(targetClass);
  -
  -        PersistentField pfNM_Name = newInstance(targetClass, NestedMain.class, NESTED_MAIN_NAME);
  -        PersistentField pfNDD_RD = newInstance(targetClass, NestedMain.class, NESTED_DETAIL_DETAIL_REAL_DETAIL);
  -        // PersistentField pfND_MJB = newInstance(targetClass, NestedMain.class, NESTED_DETAIL_MORE_JAVA_BEAN);
  -        // PersistentField pfNE_Name = newInstance(targetClass, NestedMain.class, NESTED_ENTRY_NAME);
  +        if(supportJavaBeanNames)
  +        {
  +            pfND_MJB.set(newNM, NESTED_DETAIL_MORE_JAVA_BEAN_VALUE);
  +            pfNE_Name.set(newNM, NESTED_ENTRY_NAME_VALUE);
  +            result = pfND_MJB.get(newNM);
  +            assertEquals(NESTED_DETAIL_MORE_JAVA_BEAN_VALUE, result);
  +            result = pfNE_Name.get(newNM);
  +            assertEquals(NESTED_ENTRY_NAME_VALUE, result);
  +        }
  +
  +        // serialize fields and test again
  +        pfNM_Name = (PersistentField) SerializationUtils.deserialize(SerializationUtils.serialize(pfNM_Name));
  +        pfNDD_RD = (PersistentField) SerializationUtils.deserialize(SerializationUtils.serialize(pfNDD_RD));
  +        pfNDD_RDD = (PersistentField) SerializationUtils.deserialize(SerializationUtils.serialize(pfNDD_RDD));
  +        if(supportJavaBeanNames)
  +        {
  +            pfND_MJB = (PersistentField) SerializationUtils.deserialize(SerializationUtils.serialize(pfND_MJB));
  +            pfNE_Name = (PersistentField) SerializationUtils.deserialize(SerializationUtils.serialize(pfNE_Name));
  +        }
   
           // test getter
  -        NestedMain nm = createNestedObject();
  -        Object result = pfNM_Name.get(nm);
  +        nm = createNestedObject();
  +        result = pfNM_Name.get(nm);
           assertEquals(NESTED_MAIN_NAME_VALUE, result);
           result = pfNDD_RD.get(nm);
           assertEquals(NESTED_DETAIL_DETAIL_REAL_DETAIL_VALUE, result);
  +        result = pfNDD_RDD.get(nm);
  +        assertEquals(NESTED_DETAIL_DETAIL_REAL_DESCRIPTION_VALUE, result);
   
  -        NestedMain newNM = new NestedMain();
  +        if(supportJavaBeanNames)
  +        {
  +            result = pfND_MJB.get(nm);
  +            assertEquals(NESTED_DETAIL_MORE_JAVA_BEAN_VALUE, result);
  +            result = pfNE_Name.get(nm);
  +            assertEquals(NESTED_ENTRY_NAME_VALUE, result);
  +        }
  +
  +        newNM = new NestedMain();
           // test setter
           pfNM_Name.set(newNM, NESTED_MAIN_NAME_VALUE);
           pfNDD_RD.set(newNM, NESTED_DETAIL_DETAIL_REAL_DETAIL_VALUE);
  +        result = pfNDD_RDD.get(newNM);
  +        assertEquals(NESTED_DETAIL_DETAIL_REAL_DESCRIPTION_VALUE , result);
  +
           result = pfNM_Name.get(newNM);
           assertEquals(NESTED_MAIN_NAME_VALUE, result);
           result = pfNDD_RD.get(newNM);
           assertEquals(NESTED_DETAIL_DETAIL_REAL_DETAIL_VALUE , result);
   
  +        if(supportJavaBeanNames)
  +        {
  +            pfND_MJB.set(newNM, NESTED_DETAIL_MORE_JAVA_BEAN_VALUE);
  +            pfNE_Name.set(newNM, NESTED_ENTRY_NAME_VALUE);
  +            result = pfND_MJB.get(newNM);
  +            assertEquals(NESTED_DETAIL_MORE_JAVA_BEAN_VALUE, result);
  +            result = pfNE_Name.get(newNM);
  +            assertEquals(NESTED_ENTRY_NAME_VALUE, result);
  +        }
  +    }
  +
  +    private void checkBoundaryConditions(Class targetClass) throws Exception
  +    {
  +        PersistentField pf = newInstance(targetClass, NestedMain.class, NESTED_MAIN_NAME);
  +        PersistentField pf_2 = newInstance(targetClass, NestedMain.class, NESTED_DETAIL_DETAIL_REAL_DETAIL);
  +        pf.get(null);
  +        pf.set(null, null);
  +        pf_2.get(null);
  +        pf_2.set(null, null);
  +        pf = newInstance(targetClass, NestedMain.class, NESTED_MAIN_NAME);
  +        pf_2 = newInstance(targetClass, NestedMain.class, NESTED_DETAIL_DETAIL_REAL_DETAIL);
  +        pf.get(null);
  +        pf.set(null, "kkddk");
  +        pf_2.get(null);
  +        pf_2.set(null, "gkfgfg");
       }
   
  -    public void testPrivileged() throws Exception
  +    public void testDirectAccess() throws Exception
       {
  -        Class targetClass = PersistentFieldPrivilegedImpl.class;
  -
  -        ((OjbConfiguration)OjbConfigurator.getInstance().getConfigurationFor(null)).setPersistentFieldClass(targetClass);
  -
  -        PersistentField pfNM_Name = newInstance(targetClass, NestedMain.class, NESTED_MAIN_NAME);
  -        PersistentField pfNDD_RD = newInstance(targetClass, NestedMain.class, NESTED_DETAIL_DETAIL_REAL_DETAIL);
  -        // PersistentField pfND_MJB = newInstance(targetClass, NestedMain.class, NESTED_DETAIL_MORE_JAVA_BEAN);
  -        // PersistentField pfNE_Name = newInstance(targetClass, NestedMain.class, NESTED_ENTRY_NAME);
  -
  -        // test getter
  -        NestedMain nm = createNestedObject();
  -        Object result = pfNM_Name.get(nm);
  -        assertEquals(NESTED_MAIN_NAME_VALUE, result);
  -        result = pfNDD_RD.get(nm);
  -        assertEquals(NESTED_DETAIL_DETAIL_REAL_DETAIL_VALUE, result);
  +        runFieldTestsFor(PersistentFieldDirectAccessImpl.class, false);
  +        checkBoundaryConditions(PersistentFieldDirectAccessImpl.class);
  +    }
   
  -        NestedMain newNM = new NestedMain();
  -        // test setter
  -        pfNM_Name.set(newNM, NESTED_MAIN_NAME_VALUE);
  -        pfNDD_RD.set(newNM, NESTED_DETAIL_DETAIL_REAL_DETAIL_VALUE);
  -        result = pfNM_Name.get(newNM);
  -        assertEquals(NESTED_MAIN_NAME_VALUE, result);
  -        result = pfNDD_RD.get(newNM);
  -        assertEquals(NESTED_DETAIL_DETAIL_REAL_DETAIL_VALUE , result);
  +    public void testDirectAccessNew() throws Exception
  +    {
  +        runFieldTestsFor(PersistentFieldDirectAccessImplNew.class, false);
  +        checkBoundaryConditions(PersistentFieldDirectAccessImplNew.class);
  +    }
   
  +    public void testPrivileged() throws Exception
  +    {
  +        runFieldTestsFor(PersistentFieldPrivilegedImpl.class, false);
  +        checkBoundaryConditions(PersistentFieldPrivilegedImpl.class);
       }
   
       public void testPrivilegedNew() throws Exception
       {
  -        Class targetClass = PersistentFieldPrivilegedImplNew.class;
  -
  -        ((OjbConfiguration)OjbConfigurator.getInstance().getConfigurationFor(null)).setPersistentFieldClass(targetClass);
  -
  -        PersistentField pfNM_Name = newInstance(targetClass, NestedMain.class, NESTED_MAIN_NAME);
  -        PersistentField pfNDD_RD = newInstance(targetClass, NestedMain.class, NESTED_DETAIL_DETAIL_REAL_DETAIL);
  -        // PersistentField pfND_MJB = newInstance(targetClass, NestedMain.class, NESTED_DETAIL_MORE_JAVA_BEAN);
  -        // PersistentField pfNE_Name = newInstance(targetClass, NestedMain.class, NESTED_ENTRY_NAME);
  -
  -        // test getter
  -        NestedMain nm = createNestedObject();
  -        Object result = pfNM_Name.get(nm);
  -        assertEquals(NESTED_MAIN_NAME_VALUE, result);
  -        result = pfNDD_RD.get(nm);
  -        assertEquals(NESTED_DETAIL_DETAIL_REAL_DETAIL_VALUE, result);
  -
  -        NestedMain newNM = new NestedMain();
  -        // test setter
  -        pfNM_Name.set(newNM, NESTED_MAIN_NAME_VALUE);
  -        pfNDD_RD.set(newNM, NESTED_DETAIL_DETAIL_REAL_DETAIL_VALUE);
  -        result = pfNM_Name.get(newNM);
  -        assertEquals(NESTED_MAIN_NAME_VALUE, result);
  -        result = pfNDD_RD.get(newNM);
  -        assertEquals(NESTED_DETAIL_DETAIL_REAL_DETAIL_VALUE , result);
  -
  +        runFieldTestsFor(PersistentFieldPrivilegedImplNew.class, false);
  +        checkBoundaryConditions(PersistentFieldPrivilegedImplNew.class);
       }
   
       public void testIntrospector() throws Exception
       {
  -        Class targetClass = PersistentFieldIntrospectorImpl.class;
  -
  -        ((OjbConfiguration)OjbConfigurator.getInstance().getConfigurationFor(null)).setPersistentFieldClass(targetClass);
  -
  -        PersistentField pfNM_Name = newInstance(targetClass, NestedMain.class, NESTED_MAIN_NAME);
  -        PersistentField pfNDD_RD = newInstance(targetClass, NestedMain.class, NESTED_DETAIL_DETAIL_REAL_DETAIL);
  -        PersistentField pfND_MJB = newInstance(targetClass, NestedMain.class, NESTED_DETAIL_MORE_JAVA_BEAN);
  -        PersistentField pfNE_Name = newInstance(targetClass, NestedMain.class, NESTED_ENTRY_NAME);
  -
  -        // test getter
  -        NestedMain nm = createNestedObject();
  -        Object result = pfNM_Name.get(nm);
  -        assertEquals(NESTED_MAIN_NAME_VALUE, result);
  -        result = pfNDD_RD.get(nm);
  -        assertEquals(NESTED_DETAIL_DETAIL_REAL_DETAIL_VALUE, result);
  -
  -        result = pfND_MJB.get(nm);
  -        assertEquals(NESTED_DETAIL_MORE_JAVA_BEAN_VALUE, result);
  -        result = pfNE_Name.get(nm);
  -        assertEquals(NESTED_ENTRY_NAME_VALUE, result);
  -
  -        NestedMain newNM = new NestedMain();
  -        // test setter
  -        pfNM_Name.set(newNM, NESTED_MAIN_NAME_VALUE);
  -        pfNDD_RD.set(newNM, NESTED_DETAIL_DETAIL_REAL_DETAIL_VALUE);
  -        pfND_MJB.set(newNM, NESTED_DETAIL_MORE_JAVA_BEAN_VALUE);
  -        pfNE_Name.set(newNM, NESTED_ENTRY_NAME_VALUE);
  -        result = pfNM_Name.get(newNM);
  -        assertEquals(NESTED_MAIN_NAME_VALUE, result);
  -        result = pfNDD_RD.get(newNM);
  -        assertEquals(NESTED_DETAIL_DETAIL_REAL_DETAIL_VALUE , result);
  -        result = pfND_MJB.get(newNM);
  -        assertEquals(NESTED_DETAIL_MORE_JAVA_BEAN_VALUE, result);
  -        result = pfNE_Name.get(newNM);
  -        assertEquals(NESTED_ENTRY_NAME_VALUE, result);
  +        runFieldTestsFor(PersistentFieldIntrospectorImpl.class, true);
  +        checkBoundaryConditions(PersistentFieldIntrospectorImpl.class);
       }
   
       public void testIntrospectorNew() throws Exception
       {
  -        Class targetClass = PersistentFieldIntrospectorImplNew.class;
  -
  -        ((OjbConfiguration)OjbConfigurator.getInstance().getConfigurationFor(null)).setPersistentFieldClass(targetClass);
  -
  -        PersistentField pfNM_Name = newInstance(targetClass, NestedMain.class, NESTED_MAIN_NAME);
  -        PersistentField pfNDD_RD = newInstance(targetClass, NestedMain.class, NESTED_DETAIL_DETAIL_REAL_DETAIL);
  -        PersistentField pfND_MJB = newInstance(targetClass, NestedMain.class, NESTED_DETAIL_MORE_JAVA_BEAN);
  -        PersistentField pfNE_Name = newInstance(targetClass, NestedMain.class, NESTED_ENTRY_NAME);
  -
  -        // test getter
  -        NestedMain nm = createNestedObject();
  -        Object result = pfNM_Name.get(nm);
  -        assertEquals(NESTED_MAIN_NAME_VALUE, result);
  -        result = pfNDD_RD.get(nm);
  -        assertEquals(NESTED_DETAIL_DETAIL_REAL_DETAIL_VALUE, result);
  -
  -        result = pfND_MJB.get(nm);
  -        assertEquals(NESTED_DETAIL_MORE_JAVA_BEAN_VALUE, result);
  -        result = pfNE_Name.get(nm);
  -        assertEquals(NESTED_ENTRY_NAME_VALUE, result);
  -
  -        NestedMain newNM = new NestedMain();
  -        // test setter
  -        pfNM_Name.set(newNM, NESTED_MAIN_NAME_VALUE);
  -        pfNDD_RD.set(newNM, NESTED_DETAIL_DETAIL_REAL_DETAIL_VALUE);
  -        pfND_MJB.set(newNM, NESTED_DETAIL_MORE_JAVA_BEAN_VALUE);
  -        pfNE_Name.set(newNM, NESTED_ENTRY_NAME_VALUE);
  -        result = pfNM_Name.get(newNM);
  -        assertEquals(NESTED_MAIN_NAME_VALUE, result);
  -        result = pfNDD_RD.get(newNM);
  -        assertEquals(NESTED_DETAIL_DETAIL_REAL_DETAIL_VALUE , result);
  -        result = pfND_MJB.get(newNM);
  -        assertEquals(NESTED_DETAIL_MORE_JAVA_BEAN_VALUE, result);
  -        result = pfNE_Name.get(newNM);
  -        assertEquals(NESTED_ENTRY_NAME_VALUE, result);
  +        runFieldTestsFor(PersistentFieldIntrospectorImplNew.class, true);
  +        checkBoundaryConditions(PersistentFieldIntrospectorImplNew.class);
       }
   
       public void testAutoProxy() throws Exception
       {
  -        Class targetClass = PersistentFieldAutoProxyImpl.class;
  -
  -        ((OjbConfiguration)OjbConfigurator.getInstance().getConfigurationFor(null)).setPersistentFieldClass(targetClass);
  -
  -        PersistentField pfNM_Name = newInstance(targetClass, NestedMain.class, NESTED_MAIN_NAME);
  -        PersistentField pfNDD_RD = newInstance(targetClass, NestedMain.class, NESTED_DETAIL_DETAIL_REAL_DETAIL);
  -        PersistentField pfND_MJB = newInstance(targetClass, NestedMain.class, NESTED_DETAIL_MORE_JAVA_BEAN);
  -        PersistentField pfNE_Name = newInstance(targetClass, NestedMain.class, NESTED_ENTRY_NAME);
  -
  -        // test getter
  -        NestedMain nm = createNestedObject();
  -        Object result = pfNM_Name.get(nm);
  -        assertEquals(NESTED_MAIN_NAME_VALUE, result);
  -        result = pfNDD_RD.get(nm);
  -        assertEquals(NESTED_DETAIL_DETAIL_REAL_DETAIL_VALUE, result);
  -
  -        result = pfND_MJB.get(nm);
  -        assertEquals(NESTED_DETAIL_MORE_JAVA_BEAN_VALUE, result);
  -        result = pfNE_Name.get(nm);
  -        assertEquals(NESTED_ENTRY_NAME_VALUE, result);
  -
  -        NestedMain newNM = new NestedMain();
  -        // test setter
  -        pfNM_Name.set(newNM, NESTED_MAIN_NAME_VALUE);
  -        pfNDD_RD.set(newNM, NESTED_DETAIL_DETAIL_REAL_DETAIL_VALUE);
  -        pfND_MJB.set(newNM, NESTED_DETAIL_MORE_JAVA_BEAN_VALUE);
  -        pfNE_Name.set(newNM, NESTED_ENTRY_NAME_VALUE);
  -        result = pfNM_Name.get(newNM);
  -        assertEquals(NESTED_MAIN_NAME_VALUE, result);
  -        result = pfNDD_RD.get(newNM);
  -        assertEquals(NESTED_DETAIL_DETAIL_REAL_DETAIL_VALUE , result);
  -        result = pfND_MJB.get(newNM);
  -        assertEquals(NESTED_DETAIL_MORE_JAVA_BEAN_VALUE, result);
  -        result = pfNE_Name.get(newNM);
  -        assertEquals(NESTED_ENTRY_NAME_VALUE, result);
  +        runFieldTestsFor(PersistentFieldAutoProxyImpl.class, true);
  +        checkBoundaryConditions(PersistentFieldAutoProxyImpl.class);
       }
   
  +//    public void testDynaBean() throws Exception
  +//    {
  +//        // TODO: need a test for dynaBean
  +//        if(ojbSkipKnownIssueProblem()) return;
  +//        // not implemented
  +//        throw new UnsupportedOperationException("Don't panic! Test only needs implementation");
  +//    }
   
   
  +
  +    //************************************************************************
  +    // helper methods
  +    //************************************************************************
       private NestedMain createNestedObject()
       {
           NestedEntry ne = new NestedEntry(NESTED_ENTRY_NAME_VALUE);
  @@ -346,6 +289,9 @@
   
       static String NESTED_DETAIL_DETAIL_REAL_DETAIL = "nestedDetail::nestedDetailDetail::realDetailName";
       static String NESTED_DETAIL_DETAIL_REAL_DETAIL_VALUE = "realDetailName_value";
  +
  +    static String NESTED_DETAIL_DETAIL_REAL_DESCRIPTION = "nestedDetail::nestedDetailDetail::realDetailDescription";
  +    static String NESTED_DETAIL_DETAIL_REAL_DESCRIPTION_VALUE = null;
   
       static String NESTED_ENTRY_NAME = "nestedEntry::name";
       static String NESTED_ENTRY_NAME_VALUE = "nestedEntryName_value";
  
  
  

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


Mime
View raw message