commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pste...@apache.org
Subject cvs commit: jakarta-commons/math/src/test/org/apache/commons/math/util BeanTransformer.java BeanTransformerTest.java DefaultTransformerTest.java
Date Mon, 16 Feb 2004 07:04:04 GMT
psteitz     2004/02/15 23:04:04

  Modified:    math/src/test/org/apache/commons/math/util
                        BeanTransformer.java BeanTransformerTest.java
                        DefaultTransformerTest.java
  Log:
  Fixed logic in bean transformer tests to match API.
  
  Revision  Changes    Path
  1.3       +3 -2      jakarta-commons/math/src/test/org/apache/commons/math/util/BeanTransformer.java
  
  Index: BeanTransformer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/math/src/test/org/apache/commons/math/util/BeanTransformer.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BeanTransformer.java	29 Jan 2004 00:48:59 -0000	1.2
  +++ BeanTransformer.java	16 Feb 2004 07:04:03 -0000	1.3
  @@ -55,6 +55,7 @@
   
   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.
  @@ -104,7 +105,7 @@
        */
       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) {
  
  
  
  1.8       +6 -24     jakarta-commons/math/src/test/org/apache/commons/math/util/BeanTransformerTest.java
  
  Index: BeanTransformerTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/math/src/test/org/apache/commons/math/util/BeanTransformerTest.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- BeanTransformerTest.java	29 Jan 2004 00:48:59 -0000	1.7
  +++ BeanTransformerTest.java	16 Feb 2004 07:04:04 -0000	1.8
  @@ -97,20 +97,18 @@
       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;
  @@ -126,22 +124,6 @@
       /**
        * 
        */
  -    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);
  -    }
  -    
  -    /**
  -     * 
  -     */
       public void testTransformInvalidType(){
           BeanTransformer b = new BeanTransformer("y");
           TestBean target = new TestBean();
  @@ -152,7 +134,7 @@
   				// TODO Auto-generated catch block
   				e.printStackTrace();
   			}
  -            fail();
  +            fail("Expecting ClassCastException");
           } catch(ClassCastException ex){
               // success
           }
  
  
  
  1.8       +7 -9      jakarta-commons/math/src/test/org/apache/commons/math/util/DefaultTransformerTest.java
  
  Index: DefaultTransformerTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/math/src/test/org/apache/commons/math/util/DefaultTransformerTest.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- DefaultTransformerTest.java	29 Jan 2004 00:48:59 -0000	1.7
  +++ DefaultTransformerTest.java	16 Feb 2004 07:04:04 -0000	1.8
  @@ -84,13 +84,12 @@
        * 
        */
       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 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
   		}
       }
   }
  
  
  

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


Mime
View raw message