commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject svn commit: r1083514 [6/15] - in /commons/proper/math/trunk/src/test/java/org/apache/commons/math: ./ analysis/integration/ analysis/interpolation/ analysis/polynomials/ analysis/solvers/ complex/ distribution/ fraction/ genetics/ geometry/ linear/ ode...
Date Sun, 20 Mar 2011 17:24:19 GMT
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SparseFieldVectorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SparseFieldVectorTest.java?rev=1083514&r1=1083513&r2=1083514&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SparseFieldVectorTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SparseFieldVectorTest.java Sun Mar 20 17:24:14 2011
@@ -21,15 +21,16 @@ import org.apache.commons.math.fraction.
 import org.apache.commons.math.fraction.FractionConversionException;
 import org.apache.commons.math.fraction.FractionField;
 import org.apache.commons.math.exception.MathIllegalArgumentException;
+import org.junit.Assert;
+import org.junit.Test;
 
-import junit.framework.TestCase;
 
 /**
  * Test cases for the {@link SparseFieldVector} class.
  *
  * @version $Revision$ $Date$
  */
-public class SparseFieldVectorTest extends TestCase {
+public class SparseFieldVectorTest {
 
     //
     protected Fraction[][] ma1 = {{new Fraction(1), new Fraction(2), new Fraction(3)}, {new Fraction(4), new Fraction(5), new Fraction(6)}, {new Fraction(7), new Fraction(8), new Fraction(9)}};
@@ -47,67 +48,69 @@ public class SparseFieldVectorTest exten
 
     protected FractionField field = FractionField.getInstance();
 
+    @Test
     public void testMapFunctions() throws FractionConversionException {
         SparseFieldVector<Fraction> v1 = new SparseFieldVector<Fraction>(field,vec1);
 
         //octave =  v1 .+ 2.0
         FieldVector<Fraction> v_mapAdd = v1.mapAdd(new Fraction(2));
         Fraction[] result_mapAdd = {new Fraction(3), new Fraction(4), new Fraction(5)};
-        assertEquals("compare vectors" ,result_mapAdd,v_mapAdd.getData());
+        Assert.assertEquals("compare vectors" ,result_mapAdd,v_mapAdd.getData());
 
         //octave =  v1 .+ 2.0
         FieldVector<Fraction> v_mapAddToSelf = v1.copy();
         v_mapAddToSelf.mapAddToSelf(new Fraction(2));
         Fraction[] result_mapAddToSelf = {new Fraction(3), new Fraction(4), new Fraction(5)};
-        assertEquals("compare vectors" ,result_mapAddToSelf,v_mapAddToSelf.getData());
+        Assert.assertEquals("compare vectors" ,result_mapAddToSelf,v_mapAddToSelf.getData());
 
         //octave =  v1 .- 2.0
         FieldVector<Fraction> v_mapSubtract = v1.mapSubtract(new Fraction(2));
         Fraction[] result_mapSubtract = {new Fraction(-1), new Fraction(0), new Fraction(1)};
-        assertEquals("compare vectors" ,result_mapSubtract,v_mapSubtract.getData());
+        Assert.assertEquals("compare vectors" ,result_mapSubtract,v_mapSubtract.getData());
 
         //octave =  v1 .- 2.0
         FieldVector<Fraction> v_mapSubtractToSelf = v1.copy();
         v_mapSubtractToSelf.mapSubtractToSelf(new Fraction(2));
         Fraction[] result_mapSubtractToSelf = {new Fraction(-1), new Fraction(0), new Fraction(1)};
-        assertEquals("compare vectors" ,result_mapSubtractToSelf,v_mapSubtractToSelf.getData());
+        Assert.assertEquals("compare vectors" ,result_mapSubtractToSelf,v_mapSubtractToSelf.getData());
 
         //octave =  v1 .* 2.0
         FieldVector<Fraction> v_mapMultiply = v1.mapMultiply(new Fraction(2));
         Fraction[] result_mapMultiply = {new Fraction(2), new Fraction(4), new Fraction(6)};
-        assertEquals("compare vectors" ,result_mapMultiply,v_mapMultiply.getData());
+        Assert.assertEquals("compare vectors" ,result_mapMultiply,v_mapMultiply.getData());
 
         //octave =  v1 .* 2.0
         FieldVector<Fraction> v_mapMultiplyToSelf = v1.copy();
         v_mapMultiplyToSelf.mapMultiplyToSelf(new Fraction(2));
         Fraction[] result_mapMultiplyToSelf = {new Fraction(2), new Fraction(4), new Fraction(6)};
-        assertEquals("compare vectors" ,result_mapMultiplyToSelf,v_mapMultiplyToSelf.getData());
+        Assert.assertEquals("compare vectors" ,result_mapMultiplyToSelf,v_mapMultiplyToSelf.getData());
 
         //octave =  v1 ./ 2.0
         FieldVector<Fraction> v_mapDivide = v1.mapDivide(new Fraction(2));
         Fraction[] result_mapDivide = {new Fraction(.5d), new Fraction(1), new Fraction(1.5d)};
-        assertEquals("compare vectors" ,result_mapDivide,v_mapDivide.getData());
+        Assert.assertEquals("compare vectors" ,result_mapDivide,v_mapDivide.getData());
 
         //octave =  v1 ./ 2.0
         FieldVector<Fraction> v_mapDivideToSelf = v1.copy();
         v_mapDivideToSelf.mapDivideToSelf(new Fraction(2));
         Fraction[] result_mapDivideToSelf = {new Fraction(.5d), new Fraction(1), new Fraction(1.5d)};
-        assertEquals("compare vectors" ,result_mapDivideToSelf,v_mapDivideToSelf.getData());
+        Assert.assertEquals("compare vectors" ,result_mapDivideToSelf,v_mapDivideToSelf.getData());
 
         //octave =  v1 .^-1
         FieldVector<Fraction> v_mapInv = v1.mapInv();
         Fraction[] result_mapInv = {new Fraction(1),new Fraction(0.5d),new Fraction(3.333333333333333e-01d)};
-        assertEquals("compare vectors" ,result_mapInv,v_mapInv.getData());
+        Assert.assertEquals("compare vectors" ,result_mapInv,v_mapInv.getData());
 
         //octave =  v1 .^-1
         FieldVector<Fraction> v_mapInvToSelf = v1.copy();
         v_mapInvToSelf.mapInvToSelf();
         Fraction[] result_mapInvToSelf = {new Fraction(1),new Fraction(0.5d),new Fraction(3.333333333333333e-01d)};
-        assertEquals("compare vectors" ,result_mapInvToSelf,v_mapInvToSelf.getData());
+        Assert.assertEquals("compare vectors" ,result_mapInvToSelf,v_mapInvToSelf.getData());
 
 
     }
 
+    @Test
     public void testBasicFunctions() throws FractionConversionException {
         SparseFieldVector<Fraction> v1 = new SparseFieldVector<Fraction>(field,vec1);
         SparseFieldVector<Fraction> v2 = new SparseFieldVector<Fraction>(field,vec2);
@@ -117,12 +120,12 @@ public class SparseFieldVectorTest exten
         //octave =  v1 + v2
         FieldVector<Fraction> v_add = v1.add(v2);
         Fraction[] result_add = {new Fraction(5), new Fraction(7), new Fraction(9)};
-        assertEquals("compare vect" ,v_add.getData(),result_add);
+        Assert.assertEquals("compare vect" ,v_add.getData(),result_add);
 
         SparseFieldVector<Fraction> vt2 = new SparseFieldVector<Fraction>(field,vec2);
         FieldVector<Fraction> v_add_i = v1.add(vt2);
         Fraction[] result_add_i = {new Fraction(5), new Fraction(7), new Fraction(9)};
-        assertEquals("compare vect" ,v_add_i.getData(),result_add_i);
+        Assert.assertEquals("compare vect" ,v_add_i.getData(),result_add_i);
 
         //octave =  v1 - v2
         SparseFieldVector<Fraction> v_subtract = v1.subtract(v2);
@@ -153,29 +156,30 @@ public class SparseFieldVectorTest exten
 
         // octave  dot(v1,v2)
         Fraction dot =  v1.dotProduct(v2);
-        assertEquals("compare val ",new Fraction(32), dot);
+        Assert.assertEquals("compare val ",new Fraction(32), dot);
 
         // octave  dot(v1,v2_t)
         Fraction dot_2 =  v1.dotProduct(v2_t);
-        assertEquals("compare val ",new Fraction(32), dot_2);
+        Assert.assertEquals("compare val ",new Fraction(32), dot_2);
 
         FieldMatrix<Fraction> m_outerProduct = v1.outerProduct(v2);
-        assertEquals("compare val ",new Fraction(4), m_outerProduct.getEntry(0,0));
+        Assert.assertEquals("compare val ",new Fraction(4), m_outerProduct.getEntry(0,0));
 
         FieldMatrix<Fraction> m_outerProduct_2 = v1.outerProduct(v2_t);
-        assertEquals("compare val ",new Fraction(4), m_outerProduct_2.getEntry(0,0));
+        Assert.assertEquals("compare val ",new Fraction(4), m_outerProduct_2.getEntry(0,0));
 
     }
 
 
+    @Test
     public void testMisc() {
         SparseFieldVector<Fraction> v1 = new SparseFieldVector<Fraction>(field,vec1);
 
         String out1 = v1.toString();
-        assertTrue("some output ",  out1.length()!=0);
+        Assert.assertTrue("some output ",  out1.length()!=0);
         try {
             v1.checkVectorDimensions(2);
-            fail("MathIllegalArgumentException expected");
+            Assert.fail("MathIllegalArgumentException expected");
         } catch (MathIllegalArgumentException ex) {
             // expected behavior
         }
@@ -183,33 +187,34 @@ public class SparseFieldVectorTest exten
 
     }
 
+    @Test
     public void testPredicates() {
 
         SparseFieldVector<Fraction> v = new SparseFieldVector<Fraction>(field, new Fraction[] { new Fraction(0), new Fraction(1), new Fraction(2) });
 
         v.setEntry(0, field.getZero());
-        assertEquals(v, new SparseFieldVector<Fraction>(field, new Fraction[] { new Fraction(0), new Fraction(1), new Fraction(2) }));
-        assertNotSame(v, new SparseFieldVector<Fraction>(field, new Fraction[] { new Fraction(0), new Fraction(1), new Fraction(2), new Fraction(3) }));
+        Assert.assertEquals(v, new SparseFieldVector<Fraction>(field, new Fraction[] { new Fraction(0), new Fraction(1), new Fraction(2) }));
+        Assert.assertNotSame(v, new SparseFieldVector<Fraction>(field, new Fraction[] { new Fraction(0), new Fraction(1), new Fraction(2), new Fraction(3) }));
 
     }
 
     /** verifies that two vectors are close (sup norm) */
     protected void assertEquals(String msg, Fraction[] m, Fraction[] n) {
         if (m.length != n.length) {
-            fail("vectors have different lengths");
+            Assert.fail("vectors have different lengths");
         }
         for (int i = 0; i < m.length; i++) {
-            assertEquals(msg + " " +  i + " elements differ", m[i],n[i]);
+            Assert.assertEquals(msg + " " +  i + " elements differ", m[i],n[i]);
         }
     }
 
     /** verifies that two vectors are close (sup norm) */
     protected void assertClose(String msg, Fraction[] m, Fraction[] n, double tolerance) {
         if (m.length != n.length) {
-            fail("vectors have different lengths");
+            Assert.fail("vectors have different lengths");
         }
         for (int i = 0; i < m.length; i++) {
-            assertEquals(msg + " " +  i + " elements differ", m[i].doubleValue(),n[i].doubleValue(), tolerance);
+            Assert.assertEquals(msg + " " +  i + " elements differ", m[i].doubleValue(),n[i].doubleValue(), tolerance);
         }
     }
 

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/ContinuousOutputModelTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/ContinuousOutputModelTest.java?rev=1083514&r1=1083513&r2=1083514&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/ContinuousOutputModelTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/ContinuousOutputModelTest.java Sun Mar 20 17:24:14 2011
@@ -17,7 +17,6 @@
 
 package org.apache.commons.math.ode;
 
-import junit.framework.*;
 import java.util.Random;
 
 import org.apache.commons.math.exception.MathUserException;
@@ -29,16 +28,19 @@ import org.apache.commons.math.ode.nonst
 import org.apache.commons.math.ode.sampling.DummyStepInterpolator;
 import org.apache.commons.math.ode.sampling.StepInterpolator;
 import org.apache.commons.math.util.FastMath;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
 
-public class ContinuousOutputModelTest
-  extends TestCase {
+public class ContinuousOutputModelTest {
 
-  public ContinuousOutputModelTest(String name) {
-    super(name);
+  public ContinuousOutputModelTest() {
     pb    = null;
     integ = null;
   }
 
+  @Test
   public void testBoundaries()
     throws MathUserException, IntegratorException {
     integ.addStepHandler(new ContinuousOutputModel());
@@ -51,6 +53,7 @@ public class ContinuousOutputModelTest
     cm.setInterpolatedTime(0.5 * (pb.getFinalTime() + pb.getInitialTime()));
   }
 
+  @Test
   public void testRandomAccess()
     throws MathUserException, IntegratorException {
 
@@ -76,10 +79,11 @@ public class ContinuousOutputModelTest
       }
     }
 
-    assertTrue(maxError < 1.0e-9);
+    Assert.assertTrue(maxError < 1.0e-9);
 
   }
 
+  @Test
   public void testModelsMerging()
     throws MathUserException, IntegratorException {
 
@@ -120,18 +124,19 @@ public class ContinuousOutputModelTest
       cm.append(cm1);
 
       // check circle
-      assertEquals(2.0 * FastMath.PI, cm.getInitialTime(), 1.0e-12);
-      assertEquals(0, cm.getFinalTime(), 1.0e-12);
-      assertEquals(cm.getFinalTime(), cm.getInterpolatedTime(), 1.0e-12);
+      Assert.assertEquals(2.0 * FastMath.PI, cm.getInitialTime(), 1.0e-12);
+      Assert.assertEquals(0, cm.getFinalTime(), 1.0e-12);
+      Assert.assertEquals(cm.getFinalTime(), cm.getInterpolatedTime(), 1.0e-12);
       for (double t = 0; t < 2.0 * FastMath.PI; t += 0.1) {
           cm.setInterpolatedTime(t);
           double[] y = cm.getInterpolatedState();
-          assertEquals(FastMath.cos(t), y[0], 1.0e-7);
-          assertEquals(FastMath.sin(t), y[1], 1.0e-7);
+          Assert.assertEquals(FastMath.cos(t), y[0], 1.0e-7);
+          Assert.assertEquals(FastMath.sin(t), y[1], 1.0e-7);
       }
 
   }
 
+  @Test
   public void testErrorConditions()
     throws MathUserException {
 
@@ -139,16 +144,16 @@ public class ContinuousOutputModelTest
       cm.handleStep(buildInterpolator(0, new double[] { 0.0, 1.0, -2.0 }, 1), true);
 
       // dimension mismatch
-      assertTrue(checkAppendError(cm, 1.0, new double[] { 0.0, 1.0 }, 2.0));
+      Assert.assertTrue(checkAppendError(cm, 1.0, new double[] { 0.0, 1.0 }, 2.0));
 
       // hole between time ranges
-      assertTrue(checkAppendError(cm, 10.0, new double[] { 0.0, 1.0, -2.0 }, 20.0));
+      Assert.assertTrue(checkAppendError(cm, 10.0, new double[] { 0.0, 1.0, -2.0 }, 20.0));
 
       // propagation direction mismatch
-      assertTrue(checkAppendError(cm, 1.0, new double[] { 0.0, 1.0, -2.0 }, 0.0));
+      Assert.assertTrue(checkAppendError(cm, 1.0, new double[] { 0.0, 1.0, -2.0 }, 0.0));
 
       // no errors
-      assertFalse(checkAppendError(cm, 1.0, new double[] { 0.0, 1.0, -2.0 }, 2.0));
+      Assert.assertFalse(checkAppendError(cm, 1.0, new double[] { 0.0, 1.0, -2.0 }, 2.0));
 
   }
 
@@ -174,10 +179,10 @@ public class ContinuousOutputModelTest
   }
 
   public void checkValue(double value, double reference) {
-    assertTrue(FastMath.abs(value - reference) < 1.0e-10);
+    Assert.assertTrue(FastMath.abs(value - reference) < 1.0e-10);
   }
 
-  @Override
+  @Before
   public void setUp() {
     pb = new TestProblem3(0.9);
     double minStep = 0;
@@ -185,7 +190,7 @@ public class ContinuousOutputModelTest
     integ = new DormandPrince54Integrator(minStep, maxStep, 1.0e-8, 1.0e-8);
   }
 
-  @Override
+  @After
   public void tearDown() {
     pb    = null;
     integ = null;

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/FirstOrderConverterTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/FirstOrderConverterTest.java?rev=1083514&r1=1083513&r2=1083514&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/FirstOrderConverterTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/FirstOrderConverterTest.java Sun Mar 20 17:24:14 2011
@@ -23,24 +23,22 @@ import org.apache.commons.math.ode.Integ
 import org.apache.commons.math.ode.SecondOrderDifferentialEquations;
 import org.apache.commons.math.ode.nonstiff.ClassicalRungeKuttaIntegrator;
 import org.apache.commons.math.util.FastMath;
+import org.junit.Assert;
+import org.junit.Test;
 
-import junit.framework.*;
 
-public class FirstOrderConverterTest
-  extends TestCase {
-
-  public FirstOrderConverterTest(String name) {
-    super(name);
-  }
+public class FirstOrderConverterTest {
 
+  @Test
   public void testDoubleDimension() {
     for (int i = 1; i < 10; ++i) {
       SecondOrderDifferentialEquations eqn2 = new Equations(i, 0.2);
       FirstOrderConverter eqn1 = new FirstOrderConverter(eqn2);
-      assertTrue(eqn1.getDimension() == (2 * eqn2.getDimension()));
+      Assert.assertTrue(eqn1.getDimension() == (2 * eqn2.getDimension()));
     }
   }
 
+  @Test
   public void testDecreasingSteps()
     throws MathUserException, IntegratorException {
 
@@ -51,25 +49,27 @@ public class FirstOrderConverterTest
       double error = integrateWithSpecifiedStep(4.0, 0.0, 1.0, step)
                    - FastMath.sin(4.0);
       if (i > 0) {
-        assertTrue(FastMath.abs(error) < FastMath.abs(previousError));
+        Assert.assertTrue(FastMath.abs(error) < FastMath.abs(previousError));
       }
       previousError = error;
 
     }
   }
 
+  @Test
   public void testSmallStep()
     throws MathUserException, IntegratorException {
     double error = integrateWithSpecifiedStep(4.0, 0.0, 1.0, 1.0e-4)
                    - FastMath.sin(4.0);
-    assertTrue(FastMath.abs(error) < 1.0e-10);
+    Assert.assertTrue(FastMath.abs(error) < 1.0e-10);
   }
 
+  @Test
   public void testBigStep()
     throws MathUserException, IntegratorException {
     double error = integrateWithSpecifiedStep(4.0, 0.0, 1.0, 0.5)
                    - FastMath.sin(4.0);
-    assertTrue(FastMath.abs(error) > 0.1);
+    Assert.assertTrue(FastMath.abs(error) > 0.1);
   }
 
   private static class Equations

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/events/EventStateTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/events/EventStateTest.java?rev=1083514&r1=1083513&r2=1083514&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/events/EventStateTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/events/EventStateTest.java Sun Mar 20 17:24:14 2011
@@ -17,12 +17,12 @@
 
 package org.apache.commons.math.ode.events;
 
-import junit.framework.Assert;
 
 import org.apache.commons.math.ConvergenceException;
 import org.apache.commons.math.exception.MathUserException;
 import org.apache.commons.math.ode.sampling.AbstractStepInterpolator;
 import org.apache.commons.math.ode.sampling.DummyStepInterpolator;
+import org.junit.Assert;
 import org.junit.Test;
 
 public class EventStateTest {

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/AdamsBashforthIntegratorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/AdamsBashforthIntegratorTest.java?rev=1083514&r1=1083513&r2=1083514&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/AdamsBashforthIntegratorTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/AdamsBashforthIntegratorTest.java Sun Mar 20 17:24:14 2011
@@ -17,8 +17,6 @@
 
 package org.apache.commons.math.ode.nonstiff;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
 
 import org.apache.commons.math.exception.MathUserException;
 import org.apache.commons.math.ode.FirstOrderIntegrator;
@@ -28,6 +26,7 @@ import org.apache.commons.math.ode.TestP
 import org.apache.commons.math.ode.TestProblem6;
 import org.apache.commons.math.ode.TestProblemHandler;
 import org.apache.commons.math.util.FastMath;
+import org.junit.Assert;
 import org.junit.Test;
 
 public class AdamsBashforthIntegratorTest {
@@ -86,13 +85,13 @@ public class AdamsBashforthIntegratorTes
             // the 31 and 36 factors are only valid for this test
             // and has been obtained from trial and error
             // there is no general relation between local and global errors
-            assertTrue(handler.getMaximalValueError() > (31.0 * scalAbsoluteTolerance));
-            assertTrue(handler.getMaximalValueError() < (36.0 * scalAbsoluteTolerance));
-            assertEquals(0, handler.getMaximalTimeError(), 1.0e-16);
+            Assert.assertTrue(handler.getMaximalValueError() > (31.0 * scalAbsoluteTolerance));
+            Assert.assertTrue(handler.getMaximalValueError() < (36.0 * scalAbsoluteTolerance));
+            Assert.assertEquals(0, handler.getMaximalTimeError(), 1.0e-16);
 
             int calls = pb.getCalls();
-            assertEquals(integ.getEvaluations(), calls);
-            assertTrue(calls <= previousCalls);
+            Assert.assertEquals(integ.getEvaluations(), calls);
+            Assert.assertTrue(calls <= previousCalls);
             previousCalls = calls;
 
         }
@@ -127,10 +126,10 @@ public class AdamsBashforthIntegratorTes
         integ.integrate(pb, pb.getInitialTime(), pb.getInitialState(),
                         pb.getFinalTime(), new double[pb.getDimension()]);
 
-        assertTrue(handler.getLastError() < 1.0e-8);
-        assertTrue(handler.getMaximalValueError() < 1.0e-8);
-        assertEquals(0, handler.getMaximalTimeError(), 1.0e-16);
-        assertEquals("Adams-Bashforth", integ.getName());
+        Assert.assertTrue(handler.getLastError() < 1.0e-8);
+        Assert.assertTrue(handler.getMaximalValueError() < 1.0e-8);
+        Assert.assertEquals(0, handler.getMaximalTimeError(), 1.0e-16);
+        Assert.assertEquals("Adams-Bashforth", integ.getName());
     }
 
     @Test
@@ -146,9 +145,9 @@ public class AdamsBashforthIntegratorTes
             integ.integrate(pb, pb.getInitialTime(), pb.getInitialState(),
                             pb.getFinalTime(), new double[pb.getDimension()]);
             if (nSteps < 4) {
-                assertTrue(integ.getEvaluations() > 150);
+                Assert.assertTrue(integ.getEvaluations() > 150);
             } else {
-                assertTrue(integ.getEvaluations() < 70);
+                Assert.assertTrue(integ.getEvaluations() < 70);
             }
         }
 

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/AdamsMoultonIntegratorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/AdamsMoultonIntegratorTest.java?rev=1083514&r1=1083513&r2=1083514&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/AdamsMoultonIntegratorTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/AdamsMoultonIntegratorTest.java Sun Mar 20 17:24:14 2011
@@ -17,8 +17,6 @@
 
 package org.apache.commons.math.ode.nonstiff;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
 
 import org.apache.commons.math.exception.MathUserException;
 import org.apache.commons.math.ode.FirstOrderIntegrator;
@@ -28,6 +26,7 @@ import org.apache.commons.math.ode.TestP
 import org.apache.commons.math.ode.TestProblem6;
 import org.apache.commons.math.ode.TestProblemHandler;
 import org.apache.commons.math.util.FastMath;
+import org.junit.Assert;
 import org.junit.Test;
 
 public class AdamsMoultonIntegratorTest {
@@ -86,13 +85,13 @@ public class AdamsMoultonIntegratorTest 
             // the 0.15 and 3.0 factors are only valid for this test
             // and has been obtained from trial and error
             // there is no general relation between local and global errors
-            assertTrue(handler.getMaximalValueError() > (0.15 * scalAbsoluteTolerance));
-            assertTrue(handler.getMaximalValueError() < (3.0 * scalAbsoluteTolerance));
-            assertEquals(0, handler.getMaximalTimeError(), 1.0e-16);
+            Assert.assertTrue(handler.getMaximalValueError() > (0.15 * scalAbsoluteTolerance));
+            Assert.assertTrue(handler.getMaximalValueError() < (3.0 * scalAbsoluteTolerance));
+            Assert.assertEquals(0, handler.getMaximalTimeError(), 1.0e-16);
 
             int calls = pb.getCalls();
-            assertEquals(integ.getEvaluations(), calls);
-            assertTrue(calls <= previousCalls);
+            Assert.assertEquals(integ.getEvaluations(), calls);
+            Assert.assertTrue(calls <= previousCalls);
             previousCalls = calls;
 
         }
@@ -127,10 +126,10 @@ public class AdamsMoultonIntegratorTest 
         integ.integrate(pb, pb.getInitialTime(), pb.getInitialState(),
                         pb.getFinalTime(), new double[pb.getDimension()]);
 
-        assertTrue(handler.getLastError() < 1.0e-9);
-        assertTrue(handler.getMaximalValueError() < 1.0e-9);
-        assertEquals(0, handler.getMaximalTimeError(), 1.0e-16);
-        assertEquals("Adams-Moulton", integ.getName());
+        Assert.assertTrue(handler.getLastError() < 1.0e-9);
+        Assert.assertTrue(handler.getMaximalValueError() < 1.0e-9);
+        Assert.assertEquals(0, handler.getMaximalTimeError(), 1.0e-16);
+        Assert.assertEquals("Adams-Moulton", integ.getName());
     }
 
     @Test
@@ -146,9 +145,9 @@ public class AdamsMoultonIntegratorTest 
             integ.integrate(pb, pb.getInitialTime(), pb.getInitialState(),
                             pb.getFinalTime(), new double[pb.getDimension()]);
             if (nSteps < 4) {
-                assertTrue(integ.getEvaluations() > 140);
+                Assert.assertTrue(integ.getEvaluations() > 140);
             } else {
-                assertTrue(integ.getEvaluations() < 90);
+                Assert.assertTrue(integ.getEvaluations() < 90);
             }
         }
 

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/ClassicalRungeKuttaIntegratorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/ClassicalRungeKuttaIntegratorTest.java?rev=1083514&r1=1083513&r2=1083514&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/ClassicalRungeKuttaIntegratorTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/ClassicalRungeKuttaIntegratorTest.java Sun Mar 20 17:24:14 2011
@@ -17,7 +17,6 @@
 
 package org.apache.commons.math.ode.nonstiff;
 
-import junit.framework.*;
 
 import org.apache.commons.math.exception.MathUserException;
 import org.apache.commons.math.ode.FirstOrderDifferentialEquations;
@@ -34,14 +33,12 @@ import org.apache.commons.math.ode.nonst
 import org.apache.commons.math.ode.sampling.StepHandler;
 import org.apache.commons.math.ode.sampling.StepInterpolator;
 import org.apache.commons.math.util.FastMath;
+import org.junit.Assert;
+import org.junit.Test;
 
-public class ClassicalRungeKuttaIntegratorTest
-  extends TestCase {
-
-  public ClassicalRungeKuttaIntegratorTest(String name) {
-    super(name);
-  }
+public class ClassicalRungeKuttaIntegratorTest {
 
+  @Test
   public void testMissedEndEvent() throws IntegratorException, MathUserException {
       final double   t0     = 1878250320.0000029;
       final double   tEvent = 1878250379.9999986;
@@ -95,15 +92,16 @@ public class ClassicalRungeKuttaIntegrat
 
   }
 
+  @Test
   public void testSanityChecks() {
     try  {
       TestProblem1 pb = new TestProblem1();
       new ClassicalRungeKuttaIntegrator(0.01).integrate(pb,
                                                         0.0, new double[pb.getDimension()+10],
                                                         1.0, new double[pb.getDimension()]);
-        fail("an exception should have been thrown");
+        Assert.fail("an exception should have been thrown");
     } catch(MathUserException de) {
-      fail("wrong exception caught");
+      Assert.fail("wrong exception caught");
     } catch(IntegratorException ie) {
     }
     try  {
@@ -111,9 +109,9 @@ public class ClassicalRungeKuttaIntegrat
         new ClassicalRungeKuttaIntegrator(0.01).integrate(pb,
                                                           0.0, new double[pb.getDimension()],
                                                           1.0, new double[pb.getDimension()+10]);
-          fail("an exception should have been thrown");
+          Assert.fail("an exception should have been thrown");
       } catch(MathUserException de) {
-        fail("wrong exception caught");
+        Assert.fail("wrong exception caught");
       } catch(IntegratorException ie) {
       }
     try  {
@@ -121,13 +119,14 @@ public class ClassicalRungeKuttaIntegrat
       new ClassicalRungeKuttaIntegrator(0.01).integrate(pb,
                                                         0.0, new double[pb.getDimension()],
                                                         0.0, new double[pb.getDimension()]);
-        fail("an exception should have been thrown");
+        Assert.fail("an exception should have been thrown");
     } catch(MathUserException de) {
-      fail("wrong exception caught");
+      Assert.fail("wrong exception caught");
     } catch(IntegratorException ie) {
     }
   }
 
+  @Test
   public void testDecreasingSteps()
     throws MathUserException, IntegratorException  {
 
@@ -149,33 +148,34 @@ public class ClassicalRungeKuttaIntegrat
           integ.addEventHandler(functions[l],
                                      Double.POSITIVE_INFINITY, 1.0e-6 * step, 1000);
         }
-        assertEquals(functions.length, integ.getEventHandlers().size());
+        Assert.assertEquals(functions.length, integ.getEventHandlers().size());
         double stopTime = integ.integrate(pb, pb.getInitialTime(), pb.getInitialState(),
                                           pb.getFinalTime(), new double[pb.getDimension()]);
         if (functions.length == 0) {
-            assertEquals(pb.getFinalTime(), stopTime, 1.0e-10);
+            Assert.assertEquals(pb.getFinalTime(), stopTime, 1.0e-10);
         }
 
         double error = handler.getMaximalValueError();
         if (i > 4) {
-          assertTrue(error < FastMath.abs(previousValueError));
+          Assert.assertTrue(error < FastMath.abs(previousValueError));
         }
         previousValueError = error;
 
         double timeError = handler.getMaximalTimeError();
         if (i > 4) {
-          assertTrue(timeError <= FastMath.abs(previousTimeError));
+          Assert.assertTrue(timeError <= FastMath.abs(previousTimeError));
         }
         previousTimeError = timeError;
 
         integ.clearEventHandlers();
-        assertEquals(0, integ.getEventHandlers().size());
+        Assert.assertEquals(0, integ.getEventHandlers().size());
       }
 
     }
 
   }
 
+  @Test
   public void testSmallStep()
     throws MathUserException, IntegratorException {
 
@@ -188,12 +188,13 @@ public class ClassicalRungeKuttaIntegrat
     integ.integrate(pb, pb.getInitialTime(), pb.getInitialState(),
                     pb.getFinalTime(), new double[pb.getDimension()]);
 
-    assertTrue(handler.getLastError() < 2.0e-13);
-    assertTrue(handler.getMaximalValueError() < 4.0e-12);
-    assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
-    assertEquals("classical Runge-Kutta", integ.getName());
+    Assert.assertTrue(handler.getLastError() < 2.0e-13);
+    Assert.assertTrue(handler.getMaximalValueError() < 4.0e-12);
+    Assert.assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
+    Assert.assertEquals("classical Runge-Kutta", integ.getName());
   }
 
+  @Test
   public void testBigStep()
     throws MathUserException, IntegratorException {
 
@@ -206,12 +207,13 @@ public class ClassicalRungeKuttaIntegrat
     integ.integrate(pb, pb.getInitialTime(), pb.getInitialState(),
                     pb.getFinalTime(), new double[pb.getDimension()]);
 
-    assertTrue(handler.getLastError() > 0.0004);
-    assertTrue(handler.getMaximalValueError() > 0.005);
-    assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
+    Assert.assertTrue(handler.getLastError() > 0.0004);
+    Assert.assertTrue(handler.getMaximalValueError() > 0.005);
+    Assert.assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
 
   }
 
+  @Test
   public void testBackward()
     throws MathUserException, IntegratorException {
 
@@ -224,12 +226,13 @@ public class ClassicalRungeKuttaIntegrat
     integ.integrate(pb, pb.getInitialTime(), pb.getInitialState(),
                     pb.getFinalTime(), new double[pb.getDimension()]);
 
-    assertTrue(handler.getLastError() < 5.0e-10);
-    assertTrue(handler.getMaximalValueError() < 7.0e-10);
-    assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
-    assertEquals("classical Runge-Kutta", integ.getName());
+    Assert.assertTrue(handler.getLastError() < 5.0e-10);
+    Assert.assertTrue(handler.getMaximalValueError() < 7.0e-10);
+    Assert.assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
+    Assert.assertEquals("classical Runge-Kutta", integ.getName());
   }
 
+  @Test
   public void testKepler()
     throws MathUserException, IntegratorException {
 
@@ -269,13 +272,14 @@ public class ClassicalRungeKuttaIntegrat
         // even with more than 1000 evaluations per period,
         // RK4 is not able to integrate such an eccentric
         // orbit with a good accuracy
-        assertTrue(maxError > 0.005);
+        Assert.assertTrue(maxError > 0.005);
       }
     }
     private double maxError = 0;
     private TestProblem3 pb;
   }
 
+  @Test
   public void testStepSize()
     throws MathUserException, IntegratorException {
       final double step = 1.23456;
@@ -283,7 +287,7 @@ public class ClassicalRungeKuttaIntegrat
       integ.addStepHandler(new StepHandler() {
           public void handleStep(StepInterpolator interpolator, boolean isLast) {
               if (! isLast) {
-                  assertEquals(step,
+                  Assert.assertEquals(step,
                                interpolator.getCurrentTime() - interpolator.getPreviousTime(),
                                1.0e-12);
               }

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/ClassicalRungeKuttaStepInterpolatorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/ClassicalRungeKuttaStepInterpolatorTest.java?rev=1083514&r1=1083513&r2=1083514&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/ClassicalRungeKuttaStepInterpolatorTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/ClassicalRungeKuttaStepInterpolatorTest.java Sun Mar 20 17:24:14 2011
@@ -17,7 +17,6 @@
 
 package org.apache.commons.math.ode.nonstiff;
 
-import static org.junit.Assert.assertTrue;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
@@ -32,6 +31,7 @@ import org.apache.commons.math.ode.Integ
 import org.apache.commons.math.ode.TestProblem3;
 import org.apache.commons.math.ode.sampling.StepHandler;
 import org.apache.commons.math.ode.sampling.StepInterpolatorTestUtils;
+import org.junit.Assert;
 import org.junit.Test;
 
 public class ClassicalRungeKuttaStepInterpolatorTest {
@@ -64,8 +64,8 @@ public class ClassicalRungeKuttaStepInte
         oos.writeObject(handler);
     }
 
-    assertTrue(bos.size () > 753000);
-    assertTrue(bos.size () < 754000);
+    Assert.assertTrue(bos.size () > 753000);
+    Assert.assertTrue(bos.size () < 754000);
 
     ByteArrayInputStream  bis = new ByteArrayInputStream(bos.toByteArray());
     ObjectInputStream     ois = new ObjectInputStream(bis);
@@ -87,7 +87,7 @@ public class ClassicalRungeKuttaStepInte
       }
     }
 
-    assertTrue(maxError > 0.005);
+    Assert.assertTrue(maxError > 0.005);
 
   }
 

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/DormandPrince54IntegratorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/DormandPrince54IntegratorTest.java?rev=1083514&r1=1083513&r2=1083514&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/DormandPrince54IntegratorTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/DormandPrince54IntegratorTest.java Sun Mar 20 17:24:14 2011
@@ -32,16 +32,13 @@ import org.apache.commons.math.ode.nonst
 import org.apache.commons.math.ode.sampling.StepHandler;
 import org.apache.commons.math.ode.sampling.StepInterpolator;
 import org.apache.commons.math.util.FastMath;
+import org.junit.Assert;
+import org.junit.Test;
 
-import junit.framework.*;
 
-public class DormandPrince54IntegratorTest
-  extends TestCase {
-
-  public DormandPrince54IntegratorTest(String name) {
-    super(name);
-  }
+public class DormandPrince54IntegratorTest {
 
+  @Test
   public void testDimensionCheck() {
     try  {
       TestProblem1 pb = new TestProblem1();
@@ -50,13 +47,14 @@ public class DormandPrince54IntegratorTe
       integrator.integrate(pb,
                            0.0, new double[pb.getDimension()+10],
                            1.0, new double[pb.getDimension()+10]);
-      fail("an exception should have been thrown");
+      Assert.fail("an exception should have been thrown");
     } catch(MathUserException de) {
-      fail("wrong exception caught");
+      Assert.fail("wrong exception caught");
     } catch(IntegratorException ie) {
     }
   }
 
+  @Test
   public void testMinStep() {
 
     try {
@@ -74,14 +72,15 @@ public class DormandPrince54IntegratorTe
       integ.integrate(pb,
                       pb.getInitialTime(), pb.getInitialState(),
                       pb.getFinalTime(), new double[pb.getDimension()]);
-      fail("an exception should have been thrown");
+      Assert.fail("an exception should have been thrown");
     } catch(MathUserException de) {
-      fail("wrong exception caught");
+      Assert.fail("wrong exception caught");
     } catch(IntegratorException ie) {
     }
 
   }
 
+  @Test
   public void testSmallLastStep()
     throws MathUserException, IntegratorException {
 
@@ -102,11 +101,12 @@ public class DormandPrince54IntegratorTe
     integ.integrate(pb,
                     pb.getInitialTime(), pb.getInitialState(),
                     pb.getFinalTime(), new double[pb.getDimension()]);
-    assertTrue(handler.wasLastSeen());
-    assertEquals("Dormand-Prince 5(4)", integ.getName());
+    Assert.assertTrue(handler.wasLastSeen());
+    Assert.assertEquals("Dormand-Prince 5(4)", integ.getName());
 
   }
 
+  @Test
   public void testBackward()
       throws MathUserException, IntegratorException {
 
@@ -124,10 +124,10 @@ public class DormandPrince54IntegratorTe
       integ.integrate(pb, pb.getInitialTime(), pb.getInitialState(),
                       pb.getFinalTime(), new double[pb.getDimension()]);
 
-      assertTrue(handler.getLastError() < 2.0e-7);
-      assertTrue(handler.getMaximalValueError() < 2.0e-7);
-      assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
-      assertEquals("Dormand-Prince 5(4)", integ.getName());
+      Assert.assertTrue(handler.getLastError() < 2.0e-7);
+      Assert.assertTrue(handler.getMaximalValueError() < 2.0e-7);
+      Assert.assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
+      Assert.assertEquals("Dormand-Prince 5(4)", integ.getName());
   }
 
   private static class DP54SmallLastHandler implements StepHandler {
@@ -148,7 +148,7 @@ public class DormandPrince54IntegratorTe
       if (isLast) {
         lastSeen = true;
         double h = interpolator.getCurrentTime() - interpolator.getPreviousTime();
-        assertTrue(FastMath.abs(h) < minStep);
+        Assert.assertTrue(FastMath.abs(h) < minStep);
       }
     }
 
@@ -161,6 +161,7 @@ public class DormandPrince54IntegratorTe
 
   }
 
+  @Test
   public void testIncreasingTolerance()
     throws MathUserException, IntegratorException {
 
@@ -183,25 +184,26 @@ public class DormandPrince54IntegratorTe
       integ.integrate(pb,
                       pb.getInitialTime(), pb.getInitialState(),
                       pb.getFinalTime(), new double[pb.getDimension()]);
-      assertEquals(0.8, integ.getSafety(), 1.0e-12);
-      assertEquals(5.0, integ.getMaxGrowth(), 1.0e-12);
-      assertEquals(0.3, integ.getMinReduction(), 1.0e-12);
+      Assert.assertEquals(0.8, integ.getSafety(), 1.0e-12);
+      Assert.assertEquals(5.0, integ.getMaxGrowth(), 1.0e-12);
+      Assert.assertEquals(0.3, integ.getMinReduction(), 1.0e-12);
 
       // the 0.7 factor is only valid for this test
       // and has been obtained from trial and error
       // there is no general relation between local and global errors
-      assertTrue(handler.getMaximalValueError() < (0.7 * scalAbsoluteTolerance));
-      assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
+      Assert.assertTrue(handler.getMaximalValueError() < (0.7 * scalAbsoluteTolerance));
+      Assert.assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
 
       int calls = pb.getCalls();
-      assertEquals(integ.getEvaluations(), calls);
-      assertTrue(calls <= previousCalls);
+      Assert.assertEquals(integ.getEvaluations(), calls);
+      Assert.assertTrue(calls <= previousCalls);
       previousCalls = calls;
 
     }
 
   }
 
+  @Test
   public void testEvents()
     throws MathUserException, IntegratorException {
 
@@ -222,19 +224,20 @@ public class DormandPrince54IntegratorTe
       integ.addEventHandler(functions[l],
                                  Double.POSITIVE_INFINITY, convergence, 1000);
     }
-    assertEquals(functions.length, integ.getEventHandlers().size());
+    Assert.assertEquals(functions.length, integ.getEventHandlers().size());
     integ.integrate(pb,
                     pb.getInitialTime(), pb.getInitialState(),
                     pb.getFinalTime(), new double[pb.getDimension()]);
 
-    assertTrue(handler.getMaximalValueError() < 5.0e-6);
-    assertEquals(0, handler.getMaximalTimeError(), convergence);
-    assertEquals(12.0, handler.getLastTime(), convergence);
+    Assert.assertTrue(handler.getMaximalValueError() < 5.0e-6);
+    Assert.assertEquals(0, handler.getMaximalTimeError(), convergence);
+    Assert.assertEquals(12.0, handler.getLastTime(), convergence);
     integ.clearEventHandlers();
-    assertEquals(0, integ.getEventHandlers().size());
+    Assert.assertEquals(0, integ.getEventHandlers().size());
 
   }
 
+  @Test
   public void testKepler()
     throws MathUserException, IntegratorException {
 
@@ -252,11 +255,12 @@ public class DormandPrince54IntegratorTe
                     pb.getInitialTime(), pb.getInitialState(),
                     pb.getFinalTime(), new double[pb.getDimension()]);
 
-    assertEquals(integ.getEvaluations(), pb.getCalls());
-    assertTrue(pb.getCalls() < 2800);
+    Assert.assertEquals(integ.getEvaluations(), pb.getCalls());
+    Assert.assertTrue(pb.getCalls() < 2800);
 
   }
 
+  @Test
   public void testVariableSteps()
     throws MathUserException, IntegratorException {
 
@@ -272,7 +276,7 @@ public class DormandPrince54IntegratorTe
     integ.addStepHandler(new VariableHandler());
     double stopTime = integ.integrate(pb, pb.getInitialTime(), pb.getInitialState(),
                                       pb.getFinalTime(), new double[pb.getDimension()]);
-    assertEquals(pb.getFinalTime(), stopTime, 1.0e-10);
+    Assert.assertEquals(pb.getFinalTime(), stopTime, 1.0e-10);
   }
 
   private static class KeplerHandler implements StepHandler {
@@ -309,8 +313,8 @@ public class DormandPrince54IntegratorTe
         }
       }
       if (isLast) {
-        assertTrue(maxError < 7.0e-10);
-        assertTrue(nbSteps < 400);
+        Assert.assertTrue(maxError < 7.0e-10);
+        Assert.assertTrue(nbSteps < 400);
       }
     }
     private int nbSteps;
@@ -351,8 +355,8 @@ public class DormandPrince54IntegratorTe
       }
 
       if (isLast) {
-        assertTrue(minStep < (1.0 / 450.0));
-        assertTrue(maxStep > (1.0 / 4.2));
+        Assert.assertTrue(minStep < (1.0 / 450.0));
+        Assert.assertTrue(maxStep > (1.0 / 4.2));
       }
     }
     private boolean firstTime;

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/DormandPrince54StepInterpolatorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/DormandPrince54StepInterpolatorTest.java?rev=1083514&r1=1083513&r2=1083514&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/DormandPrince54StepInterpolatorTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/DormandPrince54StepInterpolatorTest.java Sun Mar 20 17:24:14 2011
@@ -17,8 +17,6 @@
 
 package org.apache.commons.math.ode.nonstiff;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
@@ -35,6 +33,7 @@ import org.apache.commons.math.ode.sampl
 import org.apache.commons.math.ode.sampling.StepInterpolator;
 import org.apache.commons.math.ode.sampling.StepInterpolatorTestUtils;
 import org.apache.commons.math.util.FastMath;
+import org.junit.Assert;
 import org.junit.Test;
 
 public class DormandPrince54StepInterpolatorTest {
@@ -77,8 +76,8 @@ public class DormandPrince54StepInterpol
         oos.writeObject(handler);
     }
 
-    assertTrue(bos.size () > 126000);
-    assertTrue(bos.size () < 127000);
+    Assert.assertTrue(bos.size () > 126000);
+    Assert.assertTrue(bos.size () < 127000);
 
     ByteArrayInputStream  bis = new ByteArrayInputStream(bos.toByteArray());
     ObjectInputStream     ois = new ObjectInputStream(bis);
@@ -100,7 +99,7 @@ public class DormandPrince54StepInterpol
       }
     }
 
-    assertTrue(maxError < 7.0e-10);
+    Assert.assertTrue(maxError < 7.0e-10);
 
   }
 
@@ -122,18 +121,18 @@ public class DormandPrince54StepInterpol
               double tA = cloned.getPreviousTime();
               double tB = cloned.getCurrentTime();
               double halfStep = FastMath.abs(tB - tA) / 2;
-              assertEquals(interpolator.getPreviousTime(), tA, 1.0e-12);
-              assertEquals(interpolator.getCurrentTime(), tB, 1.0e-12);
+              Assert.assertEquals(interpolator.getPreviousTime(), tA, 1.0e-12);
+              Assert.assertEquals(interpolator.getCurrentTime(), tB, 1.0e-12);
               for (int i = 0; i < 10; ++i) {
                   double t = (i * tB + (9 - i) * tA) / 9;
                   interpolator.setInterpolatedTime(t);
-                  assertTrue(FastMath.abs(cloned.getInterpolatedTime() - t) > (halfStep / 10));
+                  Assert.assertTrue(FastMath.abs(cloned.getInterpolatedTime() - t) > (halfStep / 10));
                   cloned.setInterpolatedTime(t);
-                  assertEquals(t, cloned.getInterpolatedTime(), 1.0e-12);
+                  Assert.assertEquals(t, cloned.getInterpolatedTime(), 1.0e-12);
                   double[] referenceState = interpolator.getInterpolatedState();
                   double[] cloneState     = cloned.getInterpolatedState();
                   for (int j = 0; j < referenceState.length; ++j) {
-                      assertEquals(referenceState[j], cloneState[j], 1.0e-12);
+                      Assert.assertEquals(referenceState[j], cloneState[j], 1.0e-12);
                   }
               }
           }

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/DormandPrince853IntegratorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/DormandPrince853IntegratorTest.java?rev=1083514&r1=1083513&r2=1083514&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/DormandPrince853IntegratorTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/DormandPrince853IntegratorTest.java Sun Mar 20 17:24:14 2011
@@ -32,16 +32,13 @@ import org.apache.commons.math.ode.sampl
 import org.apache.commons.math.ode.sampling.StepHandler;
 import org.apache.commons.math.ode.sampling.StepInterpolator;
 import org.apache.commons.math.util.FastMath;
+import org.junit.Assert;
+import org.junit.Test;
 
-import junit.framework.*;
 
-public class DormandPrince853IntegratorTest
-  extends TestCase {
-
-  public DormandPrince853IntegratorTest(String name) {
-    super(name);
-  }
+public class DormandPrince853IntegratorTest {
 
+  @Test
   public void testMissedEndEvent() throws IntegratorException, MathUserException {
       final double   t0     = 1878250320.0000029;
       final double   tEvent = 1878250379.9999986;
@@ -98,6 +95,7 @@ public class DormandPrince853IntegratorT
 
   }
 
+  @Test
   public void testDimensionCheck() {
     try  {
       TestProblem1 pb = new TestProblem1();
@@ -106,13 +104,14 @@ public class DormandPrince853IntegratorT
       integrator.integrate(pb,
                            0.0, new double[pb.getDimension()+10],
                            1.0, new double[pb.getDimension()+10]);
-      fail("an exception should have been thrown");
+      Assert.fail("an exception should have been thrown");
     } catch(MathUserException de) {
-      fail("wrong exception caught");
+      Assert.fail("wrong exception caught");
     } catch(IntegratorException ie) {
     }
   }
 
+  @Test
   public void testNullIntervalCheck() {
     try  {
       TestProblem1 pb = new TestProblem1();
@@ -121,13 +120,14 @@ public class DormandPrince853IntegratorT
       integrator.integrate(pb,
                            0.0, new double[pb.getDimension()],
                            0.0, new double[pb.getDimension()]);
-      fail("an exception should have been thrown");
+      Assert.fail("an exception should have been thrown");
     } catch(MathUserException de) {
-      fail("wrong exception caught");
+      Assert.fail("wrong exception caught");
     } catch(IntegratorException ie) {
     }
   }
 
+  @Test
   public void testMinStep() {
 
     try {
@@ -145,14 +145,15 @@ public class DormandPrince853IntegratorT
       integ.integrate(pb,
                       pb.getInitialTime(), pb.getInitialState(),
                       pb.getFinalTime(), new double[pb.getDimension()]);
-      fail("an exception should have been thrown");
+      Assert.fail("an exception should have been thrown");
     } catch(MathUserException de) {
-      fail("wrong exception caught");
+      Assert.fail("wrong exception caught");
     } catch(IntegratorException ie) {
     }
 
   }
 
+  @Test
   public void testIncreasingTolerance()
     throws MathUserException, IntegratorException {
 
@@ -176,18 +177,19 @@ public class DormandPrince853IntegratorT
       // the 1.3 factor is only valid for this test
       // and has been obtained from trial and error
       // there is no general relation between local and global errors
-      assertTrue(handler.getMaximalValueError() < (1.3 * scalAbsoluteTolerance));
-      assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
+      Assert.assertTrue(handler.getMaximalValueError() < (1.3 * scalAbsoluteTolerance));
+      Assert.assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
 
       int calls = pb.getCalls();
-      assertEquals(integ.getEvaluations(), calls);
-      assertTrue(calls <= previousCalls);
+      Assert.assertEquals(integ.getEvaluations(), calls);
+      Assert.assertTrue(calls <= previousCalls);
       previousCalls = calls;
 
     }
 
   }
 
+  @Test
   public void testBackward()
       throws MathUserException, IntegratorException {
 
@@ -205,12 +207,13 @@ public class DormandPrince853IntegratorT
       integ.integrate(pb, pb.getInitialTime(), pb.getInitialState(),
                       pb.getFinalTime(), new double[pb.getDimension()]);
 
-      assertTrue(handler.getLastError() < 1.1e-7);
-      assertTrue(handler.getMaximalValueError() < 1.1e-7);
-      assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
-      assertEquals("Dormand-Prince 8 (5, 3)", integ.getName());
+      Assert.assertTrue(handler.getLastError() < 1.1e-7);
+      Assert.assertTrue(handler.getMaximalValueError() < 1.1e-7);
+      Assert.assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
+      Assert.assertEquals("Dormand-Prince 8 (5, 3)", integ.getName());
   }
 
+  @Test
   public void testEvents()
     throws MathUserException, IntegratorException {
 
@@ -231,19 +234,20 @@ public class DormandPrince853IntegratorT
       integ.addEventHandler(functions[l],
                                  Double.POSITIVE_INFINITY, convergence, 1000);
     }
-    assertEquals(functions.length, integ.getEventHandlers().size());
+    Assert.assertEquals(functions.length, integ.getEventHandlers().size());
     integ.integrate(pb,
                     pb.getInitialTime(), pb.getInitialState(),
                     pb.getFinalTime(), new double[pb.getDimension()]);
 
-    assertEquals(0, handler.getMaximalValueError(), 1.1e-7);
-    assertEquals(0, handler.getMaximalTimeError(), convergence);
-    assertEquals(12.0, handler.getLastTime(), convergence);
+    Assert.assertEquals(0, handler.getMaximalValueError(), 1.1e-7);
+    Assert.assertEquals(0, handler.getMaximalTimeError(), convergence);
+    Assert.assertEquals(12.0, handler.getLastTime(), convergence);
     integ.clearEventHandlers();
-    assertEquals(0, integ.getEventHandlers().size());
+    Assert.assertEquals(0, integ.getEventHandlers().size());
 
   }
 
+  @Test
   public void testKepler()
     throws MathUserException, IntegratorException {
 
@@ -261,11 +265,12 @@ public class DormandPrince853IntegratorT
                     pb.getInitialTime(), pb.getInitialState(),
                     pb.getFinalTime(), new double[pb.getDimension()]);
 
-    assertEquals(integ.getEvaluations(), pb.getCalls());
-    assertTrue(pb.getCalls() < 3300);
+    Assert.assertEquals(integ.getEvaluations(), pb.getCalls());
+    Assert.assertTrue(pb.getCalls() < 3300);
 
   }
 
+  @Test
   public void testVariableSteps()
     throws MathUserException, IntegratorException {
 
@@ -282,10 +287,11 @@ public class DormandPrince853IntegratorT
     double stopTime = integ.integrate(pb,
                                       pb.getInitialTime(), pb.getInitialState(),
                                       pb.getFinalTime(), new double[pb.getDimension()]);
-    assertEquals(pb.getFinalTime(), stopTime, 1.0e-10);
-    assertEquals("Dormand-Prince 8 (5, 3)", integ.getName());
+    Assert.assertEquals(pb.getFinalTime(), stopTime, 1.0e-10);
+    Assert.assertEquals("Dormand-Prince 8 (5, 3)", integ.getName());
   }
 
+  @Test
   public void testNoDenseOutput()
     throws MathUserException, IntegratorException {
     TestProblem1 pb1 = new TestProblem1();
@@ -303,19 +309,20 @@ public class DormandPrince853IntegratorT
                     pb1.getInitialTime(), pb1.getInitialState(),
                     pb1.getFinalTime(), new double[pb1.getDimension()]);
     int callsWithoutDenseOutput = pb1.getCalls();
-    assertEquals(integ.getEvaluations(), callsWithoutDenseOutput);
+    Assert.assertEquals(integ.getEvaluations(), callsWithoutDenseOutput);
 
     integ.addStepHandler(new InterpolatingStepHandler());
     integ.integrate(pb2,
                     pb2.getInitialTime(), pb2.getInitialState(),
                     pb2.getFinalTime(), new double[pb2.getDimension()]);
     int callsWithDenseOutput = pb2.getCalls();
-    assertEquals(integ.getEvaluations(), callsWithDenseOutput);
+    Assert.assertEquals(integ.getEvaluations(), callsWithDenseOutput);
 
-    assertTrue(callsWithDenseOutput > callsWithoutDenseOutput);
+    Assert.assertTrue(callsWithDenseOutput > callsWithoutDenseOutput);
 
   }
 
+  @Test
   public void testUnstableDerivative()
   throws MathUserException, IntegratorException {
     final StepProblem stepProblem = new StepProblem(0.0, 1.0, 2.0);
@@ -324,7 +331,7 @@ public class DormandPrince853IntegratorT
     integ.addEventHandler(stepProblem, 1.0, 1.0e-12, 1000);
     double[] y = { Double.NaN };
     integ.integrate(stepProblem, 0.0, new double[] { 0.0 }, 10.0, y);
-    assertEquals(8.0, y[0], 1.0e-12);
+    Assert.assertEquals(8.0, y[0], 1.0e-12);
   }
 
   private static class KeplerHandler implements StepHandler {
@@ -361,8 +368,8 @@ public class DormandPrince853IntegratorT
         }
       }
       if (isLast) {
-        assertTrue(maxError < 2.4e-10);
-        assertTrue(nbSteps < 150);
+        Assert.assertTrue(maxError < 2.4e-10);
+        Assert.assertTrue(nbSteps < 150);
       }
     }
     private int nbSteps;
@@ -401,8 +408,8 @@ public class DormandPrince853IntegratorT
       }
 
       if (isLast) {
-        assertTrue(minStep < (1.0 / 100.0));
-        assertTrue(maxStep > (1.0 / 2.0));
+        Assert.assertTrue(minStep < (1.0 / 100.0));
+        Assert.assertTrue(maxStep > (1.0 / 2.0));
       }
     }
     private boolean firstTime = true;

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/DormandPrince853StepInterpolatorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/DormandPrince853StepInterpolatorTest.java?rev=1083514&r1=1083513&r2=1083514&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/DormandPrince853StepInterpolatorTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/DormandPrince853StepInterpolatorTest.java Sun Mar 20 17:24:14 2011
@@ -17,8 +17,6 @@
 
 package org.apache.commons.math.ode.nonstiff;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
@@ -35,6 +33,7 @@ import org.apache.commons.math.ode.sampl
 import org.apache.commons.math.ode.sampling.StepInterpolator;
 import org.apache.commons.math.ode.sampling.StepInterpolatorTestUtils;
 import org.apache.commons.math.util.FastMath;
+import org.junit.Assert;
 import org.junit.Test;
 
 public class DormandPrince853StepInterpolatorTest {
@@ -77,8 +76,8 @@ public class DormandPrince853StepInterpo
         oos.writeObject(handler);
     }
 
-    assertTrue(bos.size () > 88000);
-    assertTrue(bos.size () < 89000);
+    Assert.assertTrue(bos.size () > 88000);
+    Assert.assertTrue(bos.size () < 89000);
 
     ByteArrayInputStream  bis = new ByteArrayInputStream(bos.toByteArray());
     ObjectInputStream     ois = new ObjectInputStream(bis);
@@ -100,7 +99,7 @@ public class DormandPrince853StepInterpo
       }
     }
 
-    assertTrue(maxError < 2.4e-10);
+    Assert.assertTrue(maxError < 2.4e-10);
 
   }
 
@@ -122,18 +121,18 @@ public class DormandPrince853StepInterpo
             double tA = cloned.getPreviousTime();
             double tB = cloned.getCurrentTime();
             double halfStep = FastMath.abs(tB - tA) / 2;
-            assertEquals(interpolator.getPreviousTime(), tA, 1.0e-12);
-            assertEquals(interpolator.getCurrentTime(), tB, 1.0e-12);
+            Assert.assertEquals(interpolator.getPreviousTime(), tA, 1.0e-12);
+            Assert.assertEquals(interpolator.getCurrentTime(), tB, 1.0e-12);
             for (int i = 0; i < 10; ++i) {
                 double t = (i * tB + (9 - i) * tA) / 9;
                 interpolator.setInterpolatedTime(t);
-                assertTrue(FastMath.abs(cloned.getInterpolatedTime() - t) > (halfStep / 10));
+                Assert.assertTrue(FastMath.abs(cloned.getInterpolatedTime() - t) > (halfStep / 10));
                 cloned.setInterpolatedTime(t);
-                assertEquals(t, cloned.getInterpolatedTime(), 1.0e-12);
+                Assert.assertEquals(t, cloned.getInterpolatedTime(), 1.0e-12);
                 double[] referenceState = interpolator.getInterpolatedState();
                 double[] cloneState     = cloned.getInterpolatedState();
                 for (int j = 0; j < referenceState.length; ++j) {
-                    assertEquals(referenceState[j], cloneState[j], 1.0e-12);
+                    Assert.assertEquals(referenceState[j], cloneState[j], 1.0e-12);
                 }
             }
         }

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/EulerIntegratorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/EulerIntegratorTest.java?rev=1083514&r1=1083513&r2=1083514&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/EulerIntegratorTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/EulerIntegratorTest.java Sun Mar 20 17:24:14 2011
@@ -17,7 +17,6 @@
 
 package org.apache.commons.math.ode.nonstiff;
 
-import junit.framework.*;
 
 import org.apache.commons.math.exception.MathUserException;
 import org.apache.commons.math.ode.FirstOrderDifferentialEquations;
@@ -33,27 +32,26 @@ import org.apache.commons.math.ode.nonst
 import org.apache.commons.math.ode.sampling.StepHandler;
 import org.apache.commons.math.ode.sampling.StepInterpolator;
 import org.apache.commons.math.util.FastMath;
+import org.junit.Assert;
+import org.junit.Test;
 
-public class EulerIntegratorTest
-  extends TestCase {
-
-  public EulerIntegratorTest(String name) {
-    super(name);
-  }
+public class EulerIntegratorTest {
 
+  @Test
   public void testDimensionCheck() {
     try  {
       TestProblem1 pb = new TestProblem1();
       new EulerIntegrator(0.01).integrate(pb,
                                           0.0, new double[pb.getDimension()+10],
                                           1.0, new double[pb.getDimension()+10]);
-        fail("an exception should have been thrown");
+        Assert.fail("an exception should have been thrown");
     } catch(MathUserException de) {
-      fail("wrong exception caught");
+      Assert.fail("wrong exception caught");
     } catch(IntegratorException ie) {
     }
   }
 
+  @Test
   public void testDecreasingSteps()
     throws MathUserException, IntegratorException {
 
@@ -78,18 +76,18 @@ public class EulerIntegratorTest
         double stopTime = integ.integrate(pb, pb.getInitialTime(), pb.getInitialState(),
                                           pb.getFinalTime(), new double[pb.getDimension()]);
         if (functions.length == 0) {
-            assertEquals(pb.getFinalTime(), stopTime, 1.0e-10);
+            Assert.assertEquals(pb.getFinalTime(), stopTime, 1.0e-10);
         }
 
         double valueError = handler.getMaximalValueError();
         if (i > 4) {
-          assertTrue(valueError < FastMath.abs(previousValueError));
+          Assert.assertTrue(valueError < FastMath.abs(previousValueError));
         }
         previousValueError = valueError;
 
         double timeError = handler.getMaximalTimeError();
         if (i > 4) {
-          assertTrue(timeError <= FastMath.abs(previousTimeError));
+          Assert.assertTrue(timeError <= FastMath.abs(previousTimeError));
         }
         previousTimeError = timeError;
 
@@ -99,6 +97,7 @@ public class EulerIntegratorTest
 
   }
 
+  @Test
   public void testSmallStep()
     throws MathUserException, IntegratorException {
 
@@ -112,13 +111,14 @@ public class EulerIntegratorTest
                     pb.getInitialTime(), pb.getInitialState(),
                     pb.getFinalTime(), new double[pb.getDimension()]);
 
-   assertTrue(handler.getLastError() < 2.0e-4);
-   assertTrue(handler.getMaximalValueError() < 1.0e-3);
-   assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
-   assertEquals("Euler", integ.getName());
+   Assert.assertTrue(handler.getLastError() < 2.0e-4);
+   Assert.assertTrue(handler.getMaximalValueError() < 1.0e-3);
+   Assert.assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
+   Assert.assertEquals("Euler", integ.getName());
 
   }
 
+  @Test
   public void testBigStep()
     throws MathUserException, IntegratorException {
 
@@ -132,12 +132,13 @@ public class EulerIntegratorTest
                     pb.getInitialTime(), pb.getInitialState(),
                     pb.getFinalTime(), new double[pb.getDimension()]);
 
-    assertTrue(handler.getLastError() > 0.01);
-    assertTrue(handler.getMaximalValueError() > 0.2);
-    assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
+    Assert.assertTrue(handler.getLastError() > 0.01);
+    Assert.assertTrue(handler.getMaximalValueError() > 0.2);
+    Assert.assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
 
   }
 
+  @Test
   public void testBackward()
       throws MathUserException, IntegratorException {
 
@@ -150,12 +151,13 @@ public class EulerIntegratorTest
       integ.integrate(pb, pb.getInitialTime(), pb.getInitialState(),
                       pb.getFinalTime(), new double[pb.getDimension()]);
 
-      assertTrue(handler.getLastError() < 0.45);
-      assertTrue(handler.getMaximalValueError() < 0.45);
-      assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
-      assertEquals("Euler", integ.getName());
+      Assert.assertTrue(handler.getLastError() < 0.45);
+      Assert.assertTrue(handler.getMaximalValueError() < 0.45);
+      Assert.assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
+      Assert.assertEquals("Euler", integ.getName());
   }
 
+  @Test
   public void testStepSize()
     throws MathUserException, IntegratorException {
       final double step = 1.23456;
@@ -163,7 +165,7 @@ public class EulerIntegratorTest
       integ.addStepHandler(new StepHandler() {
         public void handleStep(StepInterpolator interpolator, boolean isLast) {
             if (! isLast) {
-                assertEquals(step,
+                Assert.assertEquals(step,
                              interpolator.getCurrentTime() - interpolator.getPreviousTime(),
                              1.0e-12);
             }

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/EulerStepInterpolatorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/EulerStepInterpolatorTest.java?rev=1083514&r1=1083513&r2=1083514&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/EulerStepInterpolatorTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/EulerStepInterpolatorTest.java Sun Mar 20 17:24:14 2011
@@ -17,7 +17,6 @@
 
 package org.apache.commons.math.ode.nonstiff;
 
-import static org.junit.Assert.assertTrue;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
@@ -34,6 +33,7 @@ import org.apache.commons.math.ode.TestP
 import org.apache.commons.math.ode.sampling.StepHandler;
 import org.apache.commons.math.ode.sampling.StepInterpolatorTestUtils;
 import org.apache.commons.math.util.FastMath;
+import org.junit.Assert;
 import org.junit.Test;
 
 public class EulerStepInterpolatorTest {
@@ -51,7 +51,7 @@ public class EulerStepInterpolatorTest {
 
     double[] result = interpolator.getInterpolatedState();
     for (int i = 0; i < result.length; ++i) {
-      assertTrue(FastMath.abs(result[i] - y[i]) < 1.0e-10);
+      Assert.assertTrue(FastMath.abs(result[i] - y[i]) < 1.0e-10);
     }
 
   }
@@ -82,13 +82,13 @@ public class EulerStepInterpolatorTest {
     interpolator.setInterpolatedTime(interpolator.getPreviousTime());
     double[] result = interpolator.getInterpolatedState();
     for (int i = 0; i < result.length; ++i) {
-      assertTrue(FastMath.abs(result[i] - y0[i]) < 1.0e-10);
+      Assert.assertTrue(FastMath.abs(result[i] - y0[i]) < 1.0e-10);
     }
 
     interpolator.setInterpolatedTime(interpolator.getCurrentTime());
     result = interpolator.getInterpolatedState();
     for (int i = 0; i < result.length; ++i) {
-      assertTrue(FastMath.abs(result[i] - y[i]) < 1.0e-10);
+      Assert.assertTrue(FastMath.abs(result[i] - y[i]) < 1.0e-10);
     }
 
   }
@@ -107,15 +107,15 @@ public class EulerStepInterpolatorTest {
 
     interpolator.setInterpolatedTime(0.1);
     double[] result = interpolator.getInterpolatedState();
-    assertTrue(FastMath.abs(result[0] - 0.1) < 1.0e-10);
-    assertTrue(FastMath.abs(result[1] - 1.2) < 1.0e-10);
-    assertTrue(FastMath.abs(result[2] + 2.2) < 1.0e-10);
+    Assert.assertTrue(FastMath.abs(result[0] - 0.1) < 1.0e-10);
+    Assert.assertTrue(FastMath.abs(result[1] - 1.2) < 1.0e-10);
+    Assert.assertTrue(FastMath.abs(result[2] + 2.2) < 1.0e-10);
 
     interpolator.setInterpolatedTime(0.5);
     result = interpolator.getInterpolatedState();
-    assertTrue(FastMath.abs(result[0] - 0.5) < 1.0e-10);
-    assertTrue(FastMath.abs(result[1] - 2.0) < 1.0e-10);
-    assertTrue(FastMath.abs(result[2] + 3.0) < 1.0e-10);
+    Assert.assertTrue(FastMath.abs(result[0] - 0.5) < 1.0e-10);
+    Assert.assertTrue(FastMath.abs(result[1] - 2.0) < 1.0e-10);
+    Assert.assertTrue(FastMath.abs(result[2] + 3.0) < 1.0e-10);
 
   }
 
@@ -166,7 +166,7 @@ public class EulerStepInterpolatorTest {
         maxError = error;
       }
     }
-    assertTrue(maxError < 0.001);
+    Assert.assertTrue(maxError < 0.001);
 
   }
 

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/GillIntegratorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/GillIntegratorTest.java?rev=1083514&r1=1083513&r2=1083514&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/GillIntegratorTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/GillIntegratorTest.java Sun Mar 20 17:24:14 2011
@@ -17,7 +17,6 @@
 
 package org.apache.commons.math.ode.nonstiff;
 
-import junit.framework.*;
 
 import org.apache.commons.math.exception.MathUserException;
 import org.apache.commons.math.ode.FirstOrderDifferentialEquations;
@@ -34,27 +33,26 @@ import org.apache.commons.math.ode.nonst
 import org.apache.commons.math.ode.sampling.StepHandler;
 import org.apache.commons.math.ode.sampling.StepInterpolator;
 import org.apache.commons.math.util.FastMath;
+import org.junit.Assert;
+import org.junit.Test;
 
-public class GillIntegratorTest
-  extends TestCase {
-
-  public GillIntegratorTest(String name) {
-    super(name);
-  }
+public class GillIntegratorTest {
 
+  @Test
   public void testDimensionCheck() {
     try  {
       TestProblem1 pb = new TestProblem1();
       new GillIntegrator(0.01).integrate(pb,
                                          0.0, new double[pb.getDimension()+10],
                                          1.0, new double[pb.getDimension()+10]);
-        fail("an exception should have been thrown");
+        Assert.fail("an exception should have been thrown");
     } catch(MathUserException de) {
-      fail("wrong exception caught");
+      Assert.fail("wrong exception caught");
     } catch(IntegratorException ie) {
     }
   }
 
+  @Test
   public void testDecreasingSteps()
     throws MathUserException, IntegratorException  {
 
@@ -79,18 +77,18 @@ public class GillIntegratorTest
         double stopTime = integ.integrate(pb, pb.getInitialTime(), pb.getInitialState(),
                                           pb.getFinalTime(), new double[pb.getDimension()]);
         if (functions.length == 0) {
-            assertEquals(pb.getFinalTime(), stopTime, 1.0e-10);
+            Assert.assertEquals(pb.getFinalTime(), stopTime, 1.0e-10);
         }
 
         double valueError = handler.getMaximalValueError();
         if (i > 5) {
-          assertTrue(valueError < FastMath.abs(previousValueError));
+          Assert.assertTrue(valueError < FastMath.abs(previousValueError));
         }
         previousValueError = valueError;
 
         double timeError = handler.getMaximalTimeError();
         if (i > 5) {
-          assertTrue(timeError <= FastMath.abs(previousTimeError));
+          Assert.assertTrue(timeError <= FastMath.abs(previousTimeError));
         }
         previousTimeError = timeError;
 
@@ -100,6 +98,7 @@ public class GillIntegratorTest
 
   }
 
+  @Test
   public void testSmallStep()
     throws MathUserException, IntegratorException {
 
@@ -112,13 +111,14 @@ public class GillIntegratorTest
     integ.integrate(pb, pb.getInitialTime(), pb.getInitialState(),
                     pb.getFinalTime(), new double[pb.getDimension()]);
 
-    assertTrue(handler.getLastError() < 2.0e-13);
-    assertTrue(handler.getMaximalValueError() < 4.0e-12);
-    assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
-    assertEquals("Gill", integ.getName());
+    Assert.assertTrue(handler.getLastError() < 2.0e-13);
+    Assert.assertTrue(handler.getMaximalValueError() < 4.0e-12);
+    Assert.assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
+    Assert.assertEquals("Gill", integ.getName());
 
   }
 
+  @Test
   public void testBigStep()
     throws MathUserException, IntegratorException {
 
@@ -131,12 +131,13 @@ public class GillIntegratorTest
     integ.integrate(pb, pb.getInitialTime(), pb.getInitialState(),
                     pb.getFinalTime(), new double[pb.getDimension()]);
 
-    assertTrue(handler.getLastError() > 0.0004);
-    assertTrue(handler.getMaximalValueError() > 0.005);
-    assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
+    Assert.assertTrue(handler.getLastError() > 0.0004);
+    Assert.assertTrue(handler.getMaximalValueError() > 0.005);
+    Assert.assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
 
   }
 
+  @Test
   public void testBackward()
       throws MathUserException, IntegratorException {
 
@@ -149,12 +150,13 @@ public class GillIntegratorTest
       integ.integrate(pb, pb.getInitialTime(), pb.getInitialState(),
                       pb.getFinalTime(), new double[pb.getDimension()]);
 
-      assertTrue(handler.getLastError() < 5.0e-10);
-      assertTrue(handler.getMaximalValueError() < 7.0e-10);
-      assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
-      assertEquals("Gill", integ.getName());
+      Assert.assertTrue(handler.getLastError() < 5.0e-10);
+      Assert.assertTrue(handler.getMaximalValueError() < 7.0e-10);
+      Assert.assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
+      Assert.assertEquals("Gill", integ.getName());
   }
 
+  @Test
   public void testKepler()
     throws MathUserException, IntegratorException {
 
@@ -168,6 +170,7 @@ public class GillIntegratorTest
                     pb.getFinalTime(), new double[pb.getDimension()]);
   }
 
+  @Test
   public void testUnstableDerivative()
   throws MathUserException, IntegratorException {
     final StepProblem stepProblem = new StepProblem(0.0, 1.0, 2.0);
@@ -175,7 +178,7 @@ public class GillIntegratorTest
     integ.addEventHandler(stepProblem, 1.0, 1.0e-12, 1000);
     double[] y = { Double.NaN };
     integ.integrate(stepProblem, 0.0, new double[] { 0.0 }, 10.0, y);
-    assertEquals(8.0, y[0], 1.0e-12);
+    Assert.assertEquals(8.0, y[0], 1.0e-12);
   }
 
   private static class KeplerStepHandler implements StepHandler {
@@ -204,13 +207,14 @@ public class GillIntegratorTest
         // even with more than 1000 evaluations per period,
         // RK4 is not able to integrate such an eccentric
         // orbit with a good accuracy
-        assertTrue(maxError > 0.001);
+        Assert.assertTrue(maxError > 0.001);
       }
     }
     private double maxError;
     private TestProblem3 pb;
   }
 
+  @Test
   public void testStepSize()
     throws MathUserException, IntegratorException {
       final double step = 1.23456;
@@ -218,7 +222,7 @@ public class GillIntegratorTest
       integ.addStepHandler(new StepHandler() {
           public void handleStep(StepInterpolator interpolator, boolean isLast) {
               if (! isLast) {
-                  assertEquals(step,
+                  Assert.assertEquals(step,
                                interpolator.getCurrentTime() - interpolator.getPreviousTime(),
                                1.0e-12);
               }

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/GillStepInterpolatorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/GillStepInterpolatorTest.java?rev=1083514&r1=1083513&r2=1083514&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/GillStepInterpolatorTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/GillStepInterpolatorTest.java Sun Mar 20 17:24:14 2011
@@ -17,7 +17,6 @@
 
 package org.apache.commons.math.ode.nonstiff;
 
-import static org.junit.Assert.assertTrue;
 
 import java.util.Random;
 import java.io.ByteArrayOutputStream;
@@ -33,6 +32,7 @@ import org.apache.commons.math.ode.TestP
 import org.apache.commons.math.ode.nonstiff.GillIntegrator;
 import org.apache.commons.math.ode.sampling.StepHandler;
 import org.apache.commons.math.ode.sampling.StepInterpolatorTestUtils;
+import org.junit.Assert;
 import org.junit.Test;
 
 public class GillStepInterpolatorTest {
@@ -65,8 +65,8 @@ public class GillStepInterpolatorTest {
         oos.writeObject(handler);
     }
 
-    assertTrue(bos.size () > 753000);
-    assertTrue(bos.size () < 754000);
+    Assert.assertTrue(bos.size () > 753000);
+    Assert.assertTrue(bos.size () < 754000);
 
     ByteArrayInputStream  bis = new ByteArrayInputStream(bos.toByteArray());
     ObjectInputStream     ois = new ObjectInputStream(bis);
@@ -88,7 +88,7 @@ public class GillStepInterpolatorTest {
       }
     }
 
-    assertTrue(maxError < 0.003);
+    Assert.assertTrue(maxError < 0.003);
 
   }
 

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerIntegratorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerIntegratorTest.java?rev=1083514&r1=1083513&r2=1083514&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerIntegratorTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerIntegratorTest.java Sun Mar 20 17:24:14 2011
@@ -31,16 +31,13 @@ import org.apache.commons.math.ode.nonst
 import org.apache.commons.math.ode.sampling.StepHandler;
 import org.apache.commons.math.ode.sampling.StepInterpolator;
 import org.apache.commons.math.util.FastMath;
+import org.junit.Assert;
+import org.junit.Test;
 
-import junit.framework.*;
 
-public class GraggBulirschStoerIntegratorTest
-  extends TestCase {
-
-  public GraggBulirschStoerIntegratorTest(String name) {
-    super(name);
-  }
+public class GraggBulirschStoerIntegratorTest {
 
+  @Test
   public void testDimensionCheck() {
     try  {
       TestProblem1 pb = new TestProblem1();
@@ -49,13 +46,14 @@ public class GraggBulirschStoerIntegrato
       integrator.integrate(pb,
                            0.0, new double[pb.getDimension()+10],
                            1.0, new double[pb.getDimension()+10]);
-      fail("an exception should have been thrown");
+      Assert.fail("an exception should have been thrown");
     } catch(MathUserException de) {
-      fail("wrong exception caught");
+      Assert.fail("wrong exception caught");
     } catch(IntegratorException ie) {
     }
   }
 
+  @Test
   public void testNullIntervalCheck() {
     try  {
       TestProblem1 pb = new TestProblem1();
@@ -64,13 +62,14 @@ public class GraggBulirschStoerIntegrato
       integrator.integrate(pb,
                            0.0, new double[pb.getDimension()],
                            0.0, new double[pb.getDimension()]);
-      fail("an exception should have been thrown");
+      Assert.fail("an exception should have been thrown");
     } catch(MathUserException de) {
-      fail("wrong exception caught");
+      Assert.fail("wrong exception caught");
     } catch(IntegratorException ie) {
     }
   }
 
+  @Test
   public void testMinStep() {
 
     try {
@@ -88,14 +87,15 @@ public class GraggBulirschStoerIntegrato
       integ.integrate(pb,
                       pb.getInitialTime(), pb.getInitialState(),
                       pb.getFinalTime(), new double[pb.getDimension()]);
-      fail("an exception should have been thrown");
+      Assert.fail("an exception should have been thrown");
     } catch(MathUserException de) {
-      fail("wrong exception caught");
+      Assert.fail("wrong exception caught");
     } catch(IntegratorException ie) {
     }
 
   }
 
+  @Test
   public void testBackward()
       throws MathUserException, IntegratorException {
 
@@ -113,12 +113,13 @@ public class GraggBulirschStoerIntegrato
       integ.integrate(pb, pb.getInitialTime(), pb.getInitialState(),
                       pb.getFinalTime(), new double[pb.getDimension()]);
 
-      assertTrue(handler.getLastError() < 7.5e-9);
-      assertTrue(handler.getMaximalValueError() < 8.1e-9);
-      assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
-      assertEquals("Gragg-Bulirsch-Stoer", integ.getName());
+      Assert.assertTrue(handler.getLastError() < 7.5e-9);
+      Assert.assertTrue(handler.getMaximalValueError() < 8.1e-9);
+      Assert.assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
+      Assert.assertEquals("Gragg-Bulirsch-Stoer", integ.getName());
   }
 
+  @Test
   public void testIncreasingTolerance()
     throws MathUserException, IntegratorException {
 
@@ -143,19 +144,20 @@ public class GraggBulirschStoerIntegrato
       // and have been obtained from trial and error
       // there is no general relation between local and global errors
       double ratio =  handler.getMaximalValueError() / absTolerance;
-      assertTrue(ratio < 2.4);
-      assertTrue(ratio > 0.02);
-      assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
+      Assert.assertTrue(ratio < 2.4);
+      Assert.assertTrue(ratio > 0.02);
+      Assert.assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
 
       int calls = pb.getCalls();
-      assertEquals(integ.getEvaluations(), calls);
-      assertTrue(calls <= previousCalls);
+      Assert.assertEquals(integ.getEvaluations(), calls);
+      Assert.assertTrue(calls <= previousCalls);
       previousCalls = calls;
 
     }
 
   }
 
+  @Test
   public void testIntegratorControls()
   throws MathUserException, IntegratorException {
 
@@ -168,19 +170,19 @@ public class GraggBulirschStoerIntegrato
 
     // stability control
     integ.setStabilityCheck(true, 2, 1, 0.99);
-    assertTrue(errorWithDefaultSettings < getMaxError(integ, pb));
+    Assert.assertTrue(errorWithDefaultSettings < getMaxError(integ, pb));
     integ.setStabilityCheck(true, -1, -1, -1);
 
     integ.setStepsizeControl(0.5, 0.99, 0.1, 2.5);
-    assertTrue(errorWithDefaultSettings < getMaxError(integ, pb));
+    Assert.assertTrue(errorWithDefaultSettings < getMaxError(integ, pb));
     integ.setStepsizeControl(-1, -1, -1, -1);
 
     integ.setOrderControl(10, 0.7, 0.95);
-    assertTrue(errorWithDefaultSettings < getMaxError(integ, pb));
+    Assert.assertTrue(errorWithDefaultSettings < getMaxError(integ, pb));
     integ.setOrderControl(-1, -1, -1);
 
     integ.setInterpolationControl(true, 3);
-    assertTrue(errorWithDefaultSettings < getMaxError(integ, pb));
+    Assert.assertTrue(errorWithDefaultSettings < getMaxError(integ, pb));
     integ.setInterpolationControl(true, -1);
 
   }
@@ -195,6 +197,7 @@ public class GraggBulirschStoerIntegrato
       return handler.getMaximalValueError();
   }
 
+  @Test
   public void testEvents()
     throws MathUserException, IntegratorException {
 
@@ -214,19 +217,20 @@ public class GraggBulirschStoerIntegrato
     for (int l = 0; l < functions.length; ++l) {
       integ.addEventHandler(functions[l], Double.POSITIVE_INFINITY, convergence, 1000);
     }
-    assertEquals(functions.length, integ.getEventHandlers().size());
+    Assert.assertEquals(functions.length, integ.getEventHandlers().size());
     integ.integrate(pb,
                     pb.getInitialTime(), pb.getInitialState(),
                     pb.getFinalTime(), new double[pb.getDimension()]);
 
-    assertTrue(handler.getMaximalValueError() < 5.0e-8);
-    assertEquals(0, handler.getMaximalTimeError(), convergence);
-    assertEquals(12.0, handler.getLastTime(), convergence);
+    Assert.assertTrue(handler.getMaximalValueError() < 5.0e-8);
+    Assert.assertEquals(0, handler.getMaximalTimeError(), convergence);
+    Assert.assertEquals(12.0, handler.getLastTime(), convergence);
     integ.clearEventHandlers();
-    assertEquals(0, integ.getEventHandlers().size());
+    Assert.assertEquals(0, integ.getEventHandlers().size());
 
   }
 
+  @Test
   public void testKepler()
     throws MathUserException, IntegratorException {
 
@@ -244,11 +248,12 @@ public class GraggBulirschStoerIntegrato
                     pb.getInitialTime(), pb.getInitialState(),
                     pb.getFinalTime(), new double[pb.getDimension()]);
 
-    assertEquals(integ.getEvaluations(), pb.getCalls());
-    assertTrue(pb.getCalls() < 2150);
+    Assert.assertEquals(integ.getEvaluations(), pb.getCalls());
+    Assert.assertTrue(pb.getCalls() < 2150);
 
   }
 
+  @Test
   public void testVariableSteps()
     throws MathUserException, IntegratorException {
 
@@ -264,10 +269,11 @@ public class GraggBulirschStoerIntegrato
     double stopTime = integ.integrate(pb,
                                       pb.getInitialTime(), pb.getInitialState(),
                                       pb.getFinalTime(), new double[pb.getDimension()]);
-    assertEquals(pb.getFinalTime(), stopTime, 1.0e-10);
-    assertEquals("Gragg-Bulirsch-Stoer", integ.getName());
+    Assert.assertEquals(pb.getFinalTime(), stopTime, 1.0e-10);
+    Assert.assertEquals("Gragg-Bulirsch-Stoer", integ.getName());
   }
 
+  @Test
   public void testUnstableDerivative()
     throws MathUserException, IntegratorException {
     final StepProblem stepProblem = new StepProblem(0.0, 1.0, 2.0);
@@ -276,7 +282,7 @@ public class GraggBulirschStoerIntegrato
     integ.addEventHandler(stepProblem, 1.0, 1.0e-12, 1000);
     double[] y = { Double.NaN };
     integ.integrate(stepProblem, 0.0, new double[] { 0.0 }, 10.0, y);
-    assertEquals(8.0, y[0], 1.0e-12);
+    Assert.assertEquals(8.0, y[0], 1.0e-12);
   }
 
   private static class KeplerStepHandler implements StepHandler {
@@ -313,8 +319,8 @@ public class GraggBulirschStoerIntegrato
         }
       }
       if (isLast) {
-        assertTrue(maxError < 2.7e-6);
-        assertTrue(nbSteps < 80);
+        Assert.assertTrue(maxError < 2.7e-6);
+        Assert.assertTrue(nbSteps < 80);
       }
     }
     private int nbSteps;
@@ -353,8 +359,8 @@ public class GraggBulirschStoerIntegrato
       }
 
       if (isLast) {
-        assertTrue(minStep < 8.2e-3);
-        assertTrue(maxStep > 1.7);
+        Assert.assertTrue(minStep < 8.2e-3);
+        Assert.assertTrue(maxStep > 1.7);
       }
     }
     private boolean firstTime;



Mime
View raw message