mdiggory 2004/06/01 15:15:51 Modified: math/src/test/org/apache/commons/math/stat/data CertifiedDataAbstractTest.java Log: Removing Dependency on BeanUtils Revision Changes Path 1.3 +24 -4 jakarta-commons/math/src/test/org/apache/commons/math/stat/data/CertifiedDataAbstractTest.java Index: CertifiedDataAbstractTest.java =================================================================== RCS file: /home/cvs/jakarta-commons/math/src/test/org/apache/commons/math/stat/data/CertifiedDataAbstractTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- CertifiedDataAbstractTest.java 12 Apr 2004 02:27:50 -0000 1.2 +++ CertifiedDataAbstractTest.java 1 Jun 2004 22:15:51 -0000 1.3 @@ -16,15 +16,18 @@ package org.apache.commons.math.stat.data; +import java.beans.Expression; +import java.beans.PropertyDescriptor; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; +import java.lang.reflect.Method; import java.net.URL; import java.util.HashMap; import java.util.Iterator; import java.util.Map; -import org.apache.commons.beanutils.PropertyUtils; +//import org.apache.commons.beanutils.PropertyUtils; import org.apache.commons.lang.StringUtils; import org.apache.commons.math.TestUtils; import org.apache.commons.math.stat.univariate.DescriptiveStatistics; @@ -115,18 +118,35 @@ String name = iter.next().toString(); Double expectedValue = (Double)certifiedValues.get(name); try { - Double summariesValue = (Double)PropertyUtils.getProperty(summaries, name); + Double summariesValue = (Double)this.getProperty(summaries, name); TestUtils.assertEquals("summary value for " + name + " is incorrect.", summariesValue.doubleValue(), expectedValue.doubleValue(), getMaximumAbsoluteError()); } catch (Exception ex) { } try { - Double descriptivesValue = (Double)PropertyUtils.getProperty(descriptives, name); + Double descriptivesValue = (Double)this.getProperty(descriptives, name); TestUtils.assertEquals("descriptive value for " + name + " is incorrect.", descriptivesValue.doubleValue(), expectedValue.doubleValue(), getMaximumAbsoluteError()); } catch (Exception ex) { } } } + + + protected Object getProperty(Object bean, String name){ + + // Get the value of prop + String prop = "get" + name.substring(0,1).toUpperCase() + name.substring(1); + + Expression expr = new Expression(bean, prop, new Object[0]); + try { + expr.execute(); + return expr.getValue(); + } catch (Exception e) { + e.printStackTrace(); + } + + return null; + } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]