I get errors in the tests. More inline: 

On Thu, 2002-05-02 at 06:23, Nicholas Wheeler wrote:
> I posted a question earlier about setByName and setByPeerName in the Base* 
> classes, and although it met with no response I am submitting this patch to 
> add that functionality. I have tested it partially at least, but I am 
> unsure of exactly how I am suppose to test it under "ant test" (something I 
> need to investigate further, but would love hints). I did run ant test with 
> mysql.profile, but I don't think that would test new methods.
> 
> 
> 
> ----
> 

> Index: ./src/java/org/apache/torque/om/BaseObject.java
> ===================================================================
> RCS file: 
>/home/cvspublic/jakarta-turbine-torque/src/java/org/apache/torque/om/BaseObject.java,v
> retrieving revision 1.11
> diff -u -r1.11 BaseObject.java
> --- ./src/java/org/apache/torque/om/BaseObject.java   30 Apr 2002 09:22:38 -0000     
> 1.11
> +++ ./src/java/org/apache/torque/om/BaseObject.java   2 May 2002 03:54:20 -0000
> @@ -337,6 +337,21 @@
>      }
>  

 You need to throw the TorqueException in the BaseObject.java methods.

>      /**
> +     * Sets the field specified by name to 
> +     * the value passed in.
> +     * Must be overridden if called.
> +     * BaseObject's implementation will throw an Error.
> +     *
> +     * @param field The name of the field to set.
> +     * @param value The new value for the field.
> +     *
> +     */
> +    public void setByName(String field, Object value)
> +    {
> +        throw new Error("BaseObject.setByName: " + NOT_IMPLEMENTED);
> +    }
> +
> +    /**
>       * Retrieves a field from the object by name passed in
>       * as a String.  Must be overridden if called.
>       * BaseObject's implementation will throw an Error.
> @@ -344,6 +359,21 @@
>      public Object getByPeerName(String name)
>      {
>          throw new Error("BaseObject.getByPeerName: " + NOT_IMPLEMENTED);
> +    }
> +
> +    /**
> +     * Sets the field specified by the Peer name to 
> +     * the value passed in.
> +     * Must be overridden if called.
> +     * BaseObject's implementation will throw an Error.
> +     *
> +     * @param field The name of the field to set.
> +     * @param value The new value for the field.
> +     *
> +     */
> +    public void setByPeerName(String field, Object value)
> +    {
> +        throw new Error("BaseObject.setByPeerName: " + NOT_IMPLEMENTED);
>      }
>  
>      /**
> Index: ./src/templates/om/Object.vm
> ===================================================================
> RCS file: /home/cvspublic/jakarta-turbine-torque/src/templates/om/Object.vm,v
> retrieving revision 1.28
> diff -u -r1.28 Object.vm
> --- ./src/templates/om/Object.vm      30 Apr 2002 23:49:48 -0000      1.28
> +++ ./src/templates/om/Object.vm      2 May 2002 03:54:21 -0000
> @@ -689,6 +689,46 @@
>      #end
>          return null;
>      }
> +
> +    /**
> +     * Sets a field by name passed in
> +     * as a String.  
> +     * throws a TorqueException
> +     */
> +    public void setByName(String name, Object obj) 
> +     throws TorqueException
> +    {
> +    #foreach ($col in $table.Columns)
> +      #set ( $cfc = $col.JavaName )
> +      #set ( $cup=$col.Name.toUpperCase() )
> +      #set ( $cjtype = $col.JavaNative )
> +        if (name.equals("${col.JavaName}"))
> +        {
> +      #if (!$col.isPrimitive())
> +             #if ( ($cjtype == "NumberKey")
> +               || ($cjtype == "StringKey")
> +               || ($cjtype == "DateKey") )
> +          // For ObjectKeys we need to check Object
> +           // to see if it's a String or an ObjectKey
> +          // so we can use the correct method
> +           if (obj instanceof $cjtype) 
> +           {
> +               set${cfc}(($cjtype)obj);
> +           } 
> +           else if (obj instanceof String) 
> +           {
> +               set${cfc}((String)obj);
> +           }

I don't know exactly how the above is supposed to work, but it does
generate errors during compilation of the tests.

> +             #else
> +          set${cfc}(($cjtype)obj);
> +             #end
> +     #else

Why is Number hardcoded here?

> +          set${cfc}(((Number)obj).${cjtype}Value());
> +      #end
> +       }
> +    #end
> +    }
> +

Similar comments for the other method as well.

john mcnally


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to