You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Ujjwala Kulkarni <uj...@bea.com> on 2003/07/23 01:17:58 UTC

Posssible bug in Betwixt alpha

Hi , 

I guess , when user calls method beanReader.parse(file) , the  ‘update’ of class org.apache.commons.betwixt.expression.MethodUpdater  gets called. 

I observed that if the data types are java.util.Date , int the attributes are not getting converted to the required data type and hence I get the InvalidArgumentExcetion as the default attribute type passed is ‘String’ 

If the date is java.sql.Date then there is no problem but if it is java.util.Date type then I get this exception. One possible cause is that these data types do not have constructors accepting String as only argument. 

e.g java.util.Date  has deprecated new Date(String) constructor. 

And the Interger can not be converted to int like  new int(String)  the code 

 “newValue = ConvertUtils.convert( (String) newValue, valueType );”  will always fail to convert to int or java.util.Date. 

I modified MethodUpdater and the log file I got. And added following statements 

                System.out.println(" UJ -  "+valueType);
                System.out.println(" UJ dest-  "+newValue.getClass());

And  pasting the log I got shows that the type conversion is not working properly. 

_______________________________
 
 UJ in update method
 UJ -  class java.lang.String
 UJ dest-  class java.lang.String
 UJ in update method
 UJ -  class java.lang.String
 UJ dest-  class java.lang.String
 UJ in update method
 UJ -  class java.lang.String
 UJ dest-  class java.lang.String
 UJ in update method
 UJ -  int
 UJ dest-  class java.lang.Integer
Jul 22, 2003 3:46:01 PM org.apache.commons.betwixt.expression.MethodUpdater update
WARNING: Cannot call setter method: addNumber on bean: [com.bea.it.cib.test.CustomerBean: ID=null, name=James] with type: com.bea.it.cib.test.CustomerBean as parameter should be of type: int but is: java.lang.Integer
 UJ in update method
 UJ -  int
 UJ dest-  class java.lang.Integer
Jul 22, 2003 3:46:01 PM org.apache.commons.betwixt.expression.MethodUpdater update
WARNING: Cannot call setter method: addNumber on bean: [com.bea.it.cib.test.CustomerBean: ID=null, name=James] with type: com.bea.it.cib.test.CustomerBean as parameter should be of type: int but is: java.lang.Integer
 UJ in update method
 UJ -  int
 UJ dest-  class java.lang.Integer
Jul 22, 2003 3:46:01 PM org.apache.commons.betwixt.expression.MethodUpdater update
WARNING: Cannot call setter method: addNumber on bean: [com.bea.it.cib.test.CustomerBean: ID=null, name=James] with type: com.bea.it.cib.test.CustomerBean as parameter should be of type: int but is: java.lang.Integer
 UJ in update method
 UJ -  class java.lang.String
 UJ dest-  class java.lang.String
 UJ in update method
 UJ -  class java.lang.String
 UJ dest-  class java.lang.String
 UJ in update method
 UJ -  class java.util.Date
 UJ dest-  class java.lang.String
Jul 22, 2003 3:46:02 PM org.apache.commons.betwixt.expression.MethodUpdater update
WARNING: Cannot call setter method: setDate on bean: [com.bea.it.cib.test.CustomerBean: ID=null, name=James] with type: com.bea.it.cib.test.CustomerBean as parameter should be of type: java.util.Date but is: java.lang.String
 UJ in update method
 UJ -  class java.sql.Time
 UJ dest-  class java.sql.Time
 UJ in update method
 UJ -  class java.sql.Timestamp
 UJ dest-  class java.sql.Timestamp
 UJ in update method
 UJ -  class java.math.BigDecimal
 UJ dest-  class java.math.BigDecimal
 UJ in update method
 UJ -  class java.math.BigInteger
 UJ dest-  class java.math.BigInteger
File read ..null
Process terminated with exit code 0
_______________________________


Thanks 
Ujjwala