diff --git a/src/test/org/apache/commons/math/util/BeanTransformer.java b/src/test/org/apache/commons/math/util/BeanTransformer.java index 1f3c6632b..134ffd522 100644 --- a/src/test/org/apache/commons/math/util/BeanTransformer.java +++ b/src/test/org/apache/commons/math/util/BeanTransformer.java @@ -55,10 +55,11 @@ package org.apache.commons.math.util; import java.lang.reflect.InvocationTargetException; import org.apache.commons.math.MathException; +import org.apache.commons.beanutils.PropertyUtils; /** * Uses PropertyUtils to map a Bean getter to a double value. - * @version $Revision: 1.2 $ $Date: 2004/01/29 00:48:59 $ + * @version $Revision: 1.3 $ $Date: 2004/02/16 07:04:03 $ */ public class BeanTransformer implements NumberTransformer { @@ -104,7 +105,7 @@ public class BeanTransformer implements NumberTransformer { */ public double transform(final Object o) throws MathException { try { - return ((Number) org.apache.commons.beanutils.PropertyUtils.getProperty(o, getPropertyName())).doubleValue(); + return ((Number) PropertyUtils.getProperty(o, getPropertyName())).doubleValue(); } catch (IllegalAccessException e) { throw new MathException("IllegalAccessException in Transformation: " + e.getMessage(), e); } catch (InvocationTargetException e) { diff --git a/src/test/org/apache/commons/math/util/BeanTransformerTest.java b/src/test/org/apache/commons/math/util/BeanTransformerTest.java index a482153d9..f9a9a9190 100644 --- a/src/test/org/apache/commons/math/util/BeanTransformerTest.java +++ b/src/test/org/apache/commons/math/util/BeanTransformerTest.java @@ -60,7 +60,7 @@ import org.apache.commons.math.TestUtils; import junit.framework.TestCase; /** - * @version $Revision: 1.7 $ $Date: 2004/01/29 00:48:59 $ + * @version $Revision: 1.8 $ $Date: 2004/02/16 07:04:04 $ */ public class BeanTransformerTest extends TestCase { @@ -97,20 +97,18 @@ public class BeanTransformerTest extends TestCase { public void testTransformNoSuchMethod(){ BeanTransformer b = new BeanTransformer("z"); TestBean target = new TestBean(); - double value = Double.NaN; try { - value = b.transform(target); + b.transform(target); + fail("Expecting MathException"); } catch (MathException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + // expected } - TestUtils.assertEquals(Double.NaN, value, 1.0e-2); } /** * */ - public void testTransform(){ + public void testTransform() { BeanTransformer b = new BeanTransformer("x"); TestBean target = new TestBean(); double value = Double.NaN; @@ -123,22 +121,6 @@ public class BeanTransformerTest extends TestCase { TestUtils.assertEquals(1.0, value, 1.0e-2); } - /** - * - */ - public void testTransformInvocationError(){ - BeanTransformer b = new BeanTransformer("z"); - TestBean target = new TestBean(); - double value = Double.NaN; - try { - value = b.transform(target); - } catch (MathException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - TestUtils.assertEquals(Double.NaN, value, 1.0e-2); - } - /** * */ @@ -152,7 +134,7 @@ public class BeanTransformerTest extends TestCase { // TODO Auto-generated catch block e.printStackTrace(); } - fail(); + fail("Expecting ClassCastException"); } catch(ClassCastException ex){ // success } diff --git a/src/test/org/apache/commons/math/util/DefaultTransformerTest.java b/src/test/org/apache/commons/math/util/DefaultTransformerTest.java index 2cdba5fdf..2fdc324e4 100644 --- a/src/test/org/apache/commons/math/util/DefaultTransformerTest.java +++ b/src/test/org/apache/commons/math/util/DefaultTransformerTest.java @@ -62,7 +62,7 @@ import org.apache.commons.math.TestUtils; import junit.framework.TestCase; /** - * @version $Revision: 1.7 $ $Date: 2004/01/29 00:48:59 $ + * @version $Revision: 1.8 $ $Date: 2004/02/16 07:04:04 $ */ public class DefaultTransformerTest extends TestCase { /** @@ -84,13 +84,12 @@ public class DefaultTransformerTest extends TestCase { * */ public void testTransformNull(){ - double expected = Double.NaN; DefaultTransformer t = new DefaultTransformer(); try { - TestUtils.assertEquals(expected, t.transform(null), 1.0e-4); + t.transform(null); + fail("Expection MathException"); } catch (MathException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + // expected } } @@ -143,14 +142,13 @@ public class DefaultTransformerTest extends TestCase { * */ public void testTransformObject(){ - double expected = Double.NaN; Boolean input = Boolean.TRUE; DefaultTransformer t = new DefaultTransformer(); try { - TestUtils.assertEquals(expected, t.transform(input), 1.0e-4); + t.transform(input); + fail("Expecting MathException"); } catch (MathException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + // expected } } }