commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject svn commit: r1083514 [5/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/genetics/RandomKeyTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/genetics/RandomKeyTest.java?rev=1083514&r1=1083513&r2=1083514&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/genetics/RandomKeyTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/genetics/RandomKeyTest.java Sun Mar 20 17:24:14 2011
@@ -16,12 +16,12 @@
  */
 package org.apache.commons.math.genetics;
 
-import static org.junit.Assert.*;
 
 import java.util.Arrays;
 import java.util.Comparator;
 import java.util.List;
 
+import org.junit.Assert;
 import org.junit.Test;
 
 public class RandomKeyTest {
@@ -44,10 +44,10 @@ public class RandomKeyTest {
         DummyRandomKey drk4 = new DummyRandomKey(new Double[] {0.4, 0.25, 0.5, 0.8, 0.2});
         DummyRandomKey drk5 = new DummyRandomKey(new Double[] {0.4, 0.25, 0.5, 0.8, 0.2, 0.5});
 
-        assertTrue(drk1.isSame(drk2));
-        assertTrue(drk2.isSame(drk3));
-        assertFalse(drk3.isSame(drk4));
-        assertFalse(drk4.isSame(drk5));
+        Assert.assertTrue(drk1.isSame(drk2));
+        Assert.assertTrue(drk2.isSame(drk3));
+        Assert.assertFalse(drk3.isSame(drk4));
+        Assert.assertFalse(drk4.isSame(drk5));
     }
 
     @Test
@@ -55,11 +55,11 @@ public class RandomKeyTest {
         DummyRandomKey drk = new DummyRandomKey(new Double[] {0.4, 0.1, 0.5, 0.8, 0.2});
         List<String> decoded = drk.decode(Arrays.asList(new String[] {"a", "b", "c", "d", "e"}));
 
-        assertEquals("b", decoded.get(0));
-        assertEquals("e", decoded.get(1));
-        assertEquals("a", decoded.get(2));
-        assertEquals("c", decoded.get(3));
-        assertEquals("d", decoded.get(4));
+        Assert.assertEquals("b", decoded.get(0));
+        Assert.assertEquals("e", decoded.get(1));
+        Assert.assertEquals("a", decoded.get(2));
+        Assert.assertEquals("c", decoded.get(3));
+        Assert.assertEquals("d", decoded.get(4));
     }
 
     @Test
@@ -67,7 +67,7 @@ public class RandomKeyTest {
         // never generate an invalid one
         for (int i=0; i<10; i++) {
             DummyRandomKey drk = new DummyRandomKey(RandomKey.randomPermutation(20));
-            assertNotNull(drk);
+            Assert.assertNotNull(drk);
         }
     }
 
@@ -76,11 +76,11 @@ public class RandomKeyTest {
         DummyRandomKey drk = new DummyRandomKey(RandomKey.identityPermutation(5));
         List<String> decoded = drk.decode(Arrays.asList(new String[] {"a", "b", "c", "d", "e"}));
 
-        assertEquals("a", decoded.get(0));
-        assertEquals("b", decoded.get(1));
-        assertEquals("c", decoded.get(2));
-        assertEquals("d", decoded.get(3));
-        assertEquals("e", decoded.get(4));
+        Assert.assertEquals("a", decoded.get(0));
+        Assert.assertEquals("b", decoded.get(1));
+        Assert.assertEquals("c", decoded.get(2));
+        Assert.assertEquals("d", decoded.get(3));
+        Assert.assertEquals("e", decoded.get(4));
     }
 
     @Test
@@ -94,13 +94,13 @@ public class RandomKeyTest {
         });
         Double[] permArr = new Double[data.size()];
         permArr = permutation.toArray(permArr);
-        assertArrayEquals(new Double[] {0.6,0.0,0.4,0.8,0.2}, permArr);
+        Assert.assertArrayEquals(new Double[] {0.6,0.0,0.4,0.8,0.2}, permArr);
         List<String> decodedData = new DummyRandomKey(permutation).decode(data);
-        assertEquals("b", decodedData.get(0));
-        assertEquals("b", decodedData.get(1));
-        assertEquals("c", decodedData.get(2));
-        assertEquals("x", decodedData.get(3));
-        assertEquals("z", decodedData.get(4));
+        Assert.assertEquals("b", decodedData.get(0));
+        Assert.assertEquals("b", decodedData.get(1));
+        Assert.assertEquals("c", decodedData.get(2));
+        Assert.assertEquals("x", decodedData.get(3));
+        Assert.assertEquals("z", decodedData.get(4));
 
         permutation = RandomKey.comparatorPermutation(data, new Comparator<String>() {
             public int compare(String o1, String o2) {
@@ -109,13 +109,13 @@ public class RandomKeyTest {
         });
         permArr = new Double[data.size()];
         permArr = permutation.toArray(permArr);
-        assertArrayEquals(new Double[] {0.2,0.6,0.4,0.0,0.8}, permArr);
+        Assert.assertArrayEquals(new Double[] {0.2,0.6,0.4,0.0,0.8}, permArr);
         decodedData = new DummyRandomKey(permutation).decode(data);
-        assertEquals("z", decodedData.get(0));
-        assertEquals("x", decodedData.get(1));
-        assertEquals("c", decodedData.get(2));
-        assertEquals("b", decodedData.get(3));
-        assertEquals("b", decodedData.get(4));
+        Assert.assertEquals("z", decodedData.get(0));
+        Assert.assertEquals("x", decodedData.get(1));
+        Assert.assertEquals("c", decodedData.get(2));
+        Assert.assertEquals("b", decodedData.get(3));
+        Assert.assertEquals("b", decodedData.get(4));
     }
 
     @Test
@@ -126,18 +126,18 @@ public class RandomKeyTest {
         DummyRandomKey drk = new DummyRandomKey(RandomKey.inducedPermutation(origData, permutedData));
         List<String> decoded = drk.decode(origData);
 
-        assertEquals("d", decoded.get(0));
-        assertEquals("b", decoded.get(1));
-        assertEquals("c", decoded.get(2));
-        assertEquals("a", decoded.get(3));
-        assertEquals("d", decoded.get(4));
+        Assert.assertEquals("d", decoded.get(0));
+        Assert.assertEquals("b", decoded.get(1));
+        Assert.assertEquals("c", decoded.get(2));
+        Assert.assertEquals("a", decoded.get(3));
+        Assert.assertEquals("d", decoded.get(4));
 
         try {
             RandomKey.inducedPermutation(
                     Arrays.asList(new String[] {"a", "b", "c", "d", "d"}),
                     Arrays.asList(new String[] {"a", "b", "c", "d"})
             );
-            fail("Uncaught exception");
+            Assert.fail("Uncaught exception");
         } catch (IllegalArgumentException e) {
             // no-op
         }
@@ -146,7 +146,7 @@ public class RandomKeyTest {
                     Arrays.asList(new String[] {"a", "b", "c", "d", "d"}),
                     Arrays.asList(new String[] {"a", "b", "c", "d", "f"})
             );
-            fail("Uncaught exception");
+            Assert.fail("Uncaught exception");
         } catch (IllegalArgumentException e) {
             // no-op
         }
@@ -156,9 +156,9 @@ public class RandomKeyTest {
     public void testEqualRepr() {
         DummyRandomKey drk = new DummyRandomKey(new Double[] {0.2, 0.2, 0.5});
         List<String> decodedData = drk.decode(Arrays.asList(new String[] {"a", "b", "c"}));
-        assertEquals("a", decodedData.get(0));
-        assertEquals("b", decodedData.get(1));
-        assertEquals("c", decodedData.get(2));
+        Assert.assertEquals("a", decodedData.get(0));
+        Assert.assertEquals("b", decodedData.get(1));
+        Assert.assertEquals("c", decodedData.get(2));
     }
 
 }

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/genetics/TournamentSelectionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/genetics/TournamentSelectionTest.java?rev=1083514&r1=1083513&r2=1083514&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/genetics/TournamentSelectionTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/genetics/TournamentSelectionTest.java Sun Mar 20 17:24:14 2011
@@ -16,7 +16,7 @@
  */
 package org.apache.commons.math.genetics;
 
-import static org.junit.Assert.*;
+import org.junit.Assert;
 import org.junit.Test;
 
 public class TournamentSelectionTest {
@@ -35,8 +35,8 @@ public class TournamentSelectionTest {
         for (int i=0; i<20; i++) {
             ChromosomePair pair = ts.select(pop);
             // the worst chromosome should NEVER be selected
-            assertTrue(pair.getFirst().getFitness() > 0);
-            assertTrue(pair.getSecond().getFitness() > 0);
+            Assert.assertTrue(pair.getFirst().getFitness() > 0);
+            Assert.assertTrue(pair.getSecond().getFitness() > 0);
         }
     }
 

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/geometry/RotationOrderTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/geometry/RotationOrderTest.java?rev=1083514&r1=1083513&r2=1083514&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/geometry/RotationOrderTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/geometry/RotationOrderTest.java Sun Mar 20 17:24:14 2011
@@ -20,16 +20,13 @@ package org.apache.commons.math.geometry
 import java.lang.reflect.Field;
 
 import org.apache.commons.math.geometry.RotationOrder;
+import org.junit.Assert;
+import org.junit.Test;
 
-import junit.framework.*;
 
-public class RotationOrderTest
-  extends TestCase {
-
-  public RotationOrderTest(String name) {
-    super(name);
-  }
+public class RotationOrderTest {
 
+  @Test
   public void testName() {
 
     RotationOrder[] orders = {
@@ -40,7 +37,7 @@ public class RotationOrderTest
     };
 
     for (int i = 0; i < orders.length; ++i) {
-      assertEquals(getFieldName(orders[i]), orders[i].toString());
+      Assert.assertEquals(getFieldName(orders[i]), orders[i].toString());
     }
 
   }

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/geometry/RotationTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/geometry/RotationTest.java?rev=1083514&r1=1083513&r2=1083514&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/geometry/RotationTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/geometry/RotationTest.java Sun Mar 20 17:24:14 2011
@@ -24,16 +24,13 @@ import org.apache.commons.math.geometry.
 import org.apache.commons.math.geometry.Vector3D;
 import org.apache.commons.math.util.FastMath;
 import org.apache.commons.math.util.MathUtils;
+import org.junit.Assert;
+import org.junit.Test;
 
-import junit.framework.*;
 
-public class RotationTest
-  extends TestCase {
-
-  public RotationTest(String name) {
-    super(name);
-  }
+public class RotationTest {
 
+  @Test
   public void testIdentity() {
 
     Rotation r = Rotation.IDENTITY;
@@ -56,6 +53,7 @@ public class RotationTest
 
   }
 
+  @Test
   public void testAxisAngle() {
 
     Rotation r = new Rotation(new Vector3D(10, 10, 10), 2 * FastMath.PI / 3);
@@ -68,7 +66,7 @@ public class RotationTest
 
     try {
       new Rotation(new Vector3D(0, 0, 0), 2 * FastMath.PI / 3);
-      fail("an exception should have been thrown");
+      Assert.fail("an exception should have been thrown");
     } catch (ArithmeticException e) {
     }
 
@@ -84,15 +82,17 @@ public class RotationTest
 
   }
 
+  @Test
   public void testRevert() {
     Rotation r = new Rotation(0.001, 0.36, 0.48, 0.8, true);
     Rotation reverted = r.revert();
     checkRotation(r.applyTo(reverted), 1, 0, 0, 0);
     checkRotation(reverted.applyTo(r), 1, 0, 0, 0);
-    assertEquals(r.getAngle(), reverted.getAngle(), 1.0e-12);
-    assertEquals(-1, Vector3D.dotProduct(r.getAxis(), reverted.getAxis()), 1.0e-12);
+    Assert.assertEquals(r.getAngle(), reverted.getAngle(), 1.0e-12);
+    Assert.assertEquals(-1, Vector3D.dotProduct(r.getAxis(), reverted.getAxis()), 1.0e-12);
   }
 
+  @Test
   public void testVectorOnePair() {
 
     Vector3D u = new Vector3D(3, 2, 1);
@@ -104,13 +104,14 @@ public class RotationTest
 
     try {
         new Rotation(u, Vector3D.ZERO);
-        fail("an exception should have been thrown");
+        Assert.fail("an exception should have been thrown");
     } catch (IllegalArgumentException e) {
         // expected behavior
     }
 
   }
 
+  @Test
   public void testVectorTwoPairs() {
 
     Vector3D u1 = new Vector3D(3, 0, 0);
@@ -143,13 +144,14 @@ public class RotationTest
 
     try {
         new Rotation(u1, u2, Vector3D.ZERO, v2);
-        fail("an exception should have been thrown");
+        Assert.fail("an exception should have been thrown");
     } catch (IllegalArgumentException e) {
       // expected behavior
     }
 
   }
 
+  @Test
   public void testMatrix()
     throws NotARotationMatrixException {
 
@@ -158,7 +160,7 @@ public class RotationTest
                      { 0.0, 1.0, 0.0 },
                      { 1.0, 0.0, 0.0 }
                    }, 1.0e-7);
-      fail("Expecting NotARotationMatrixException");
+      Assert.fail("Expecting NotARotationMatrixException");
     } catch (NotARotationMatrixException nrme) {
       // expected behavior
     }
@@ -169,7 +171,7 @@ public class RotationTest
                      {  0.821760, -0.184320,  0.539200 },
                      { -0.354816,  0.574912,  0.737280 }
                    }, 1.0e-7);
-      fail("Expecting NotARotationMatrixException");
+      Assert.fail("Expecting NotARotationMatrixException");
     } catch (NotARotationMatrixException nrme) {
       // expected behavior
     }
@@ -180,7 +182,7 @@ public class RotationTest
                        { -0.4,  0.6,  0.7 },
                        {  0.8, -0.2,  0.5 }
                      }, 1.0e-15);
-        fail("Expecting NotARotationMatrixException");
+        Assert.fail("Expecting NotARotationMatrixException");
       } catch (NotARotationMatrixException nrme) {
         // expected behavior
       }
@@ -237,25 +239,25 @@ public class RotationTest
     double d21 = m2[2][1] - m3[2][1];
     double d22 = m2[2][2] - m3[2][2];
 
-    assertTrue(FastMath.abs(d00) < 6.0e-6);
-    assertTrue(FastMath.abs(d01) < 6.0e-6);
-    assertTrue(FastMath.abs(d02) < 6.0e-6);
-    assertTrue(FastMath.abs(d10) < 6.0e-6);
-    assertTrue(FastMath.abs(d11) < 6.0e-6);
-    assertTrue(FastMath.abs(d12) < 6.0e-6);
-    assertTrue(FastMath.abs(d20) < 6.0e-6);
-    assertTrue(FastMath.abs(d21) < 6.0e-6);
-    assertTrue(FastMath.abs(d22) < 6.0e-6);
-
-    assertTrue(FastMath.abs(d00) > 4.0e-7);
-    assertTrue(FastMath.abs(d01) > 4.0e-7);
-    assertTrue(FastMath.abs(d02) > 4.0e-7);
-    assertTrue(FastMath.abs(d10) > 4.0e-7);
-    assertTrue(FastMath.abs(d11) > 4.0e-7);
-    assertTrue(FastMath.abs(d12) > 4.0e-7);
-    assertTrue(FastMath.abs(d20) > 4.0e-7);
-    assertTrue(FastMath.abs(d21) > 4.0e-7);
-    assertTrue(FastMath.abs(d22) > 4.0e-7);
+    Assert.assertTrue(FastMath.abs(d00) < 6.0e-6);
+    Assert.assertTrue(FastMath.abs(d01) < 6.0e-6);
+    Assert.assertTrue(FastMath.abs(d02) < 6.0e-6);
+    Assert.assertTrue(FastMath.abs(d10) < 6.0e-6);
+    Assert.assertTrue(FastMath.abs(d11) < 6.0e-6);
+    Assert.assertTrue(FastMath.abs(d12) < 6.0e-6);
+    Assert.assertTrue(FastMath.abs(d20) < 6.0e-6);
+    Assert.assertTrue(FastMath.abs(d21) < 6.0e-6);
+    Assert.assertTrue(FastMath.abs(d22) < 6.0e-6);
+
+    Assert.assertTrue(FastMath.abs(d00) > 4.0e-7);
+    Assert.assertTrue(FastMath.abs(d01) > 4.0e-7);
+    Assert.assertTrue(FastMath.abs(d02) > 4.0e-7);
+    Assert.assertTrue(FastMath.abs(d10) > 4.0e-7);
+    Assert.assertTrue(FastMath.abs(d11) > 4.0e-7);
+    Assert.assertTrue(FastMath.abs(d12) > 4.0e-7);
+    Assert.assertTrue(FastMath.abs(d20) > 4.0e-7);
+    Assert.assertTrue(FastMath.abs(d21) > 4.0e-7);
+    Assert.assertTrue(FastMath.abs(d22) > 4.0e-7);
 
     for (int i = 0; i < 3; ++i) {
       for (int j = 0; j < 3; ++j) {
@@ -263,9 +265,9 @@ public class RotationTest
                      + m3[i][1] * m3[j][1]
                      + m3[i][2] * m3[j][2];
         if (i == j) {
-          assertTrue(FastMath.abs(m3tm3 - 1.0) < 1.0e-10);
+          Assert.assertTrue(FastMath.abs(m3tm3 - 1.0) < 1.0e-10);
         } else {
-          assertTrue(FastMath.abs(m3tm3) < 1.0e-10);
+          Assert.assertTrue(FastMath.abs(m3tm3) < 1.0e-10);
         }
       }
     }
@@ -288,13 +290,14 @@ public class RotationTest
                         { 0.0, 1.0, 0.0 },
                         { 1.0, 0.0, 0.0 } };
       r = new Rotation(m5, 1.0e-7);
-      fail("got " + r + ", should have caught an exception");
+      Assert.fail("got " + r + ", should have caught an exception");
     } catch (NotARotationMatrixException e) {
       // expected
     }
 
   }
 
+  @Test
   public void testAngles()
     throws CardanEulerSingularityException {
 
@@ -339,6 +342,7 @@ public class RotationTest
 
   }
 
+  @Test
   public void testSingularities() {
 
     RotationOrder[] CardanOrders = {
@@ -352,7 +356,7 @@ public class RotationTest
         Rotation r = new Rotation(CardanOrders[i], 0.1, singularCardanAngle[j], 0.3);
         try {
           r.getAngles(CardanOrders[i]);
-          fail("an exception should have been caught");
+          Assert.fail("an exception should have been caught");
         } catch (CardanEulerSingularityException cese) {
           // expected behavior
         }
@@ -370,7 +374,7 @@ public class RotationTest
         Rotation r = new Rotation(EulerOrders[i], 0.1, singularEulerAngle[j], 0.3);
         try {
           r.getAngles(EulerOrders[i]);
-          fail("an exception should have been caught");
+          Assert.fail("an exception should have been caught");
         } catch (CardanEulerSingularityException cese) {
           // expected behavior
         }
@@ -380,6 +384,7 @@ public class RotationTest
 
   }
 
+  @Test
   public void testQuaternion() {
 
     Rotation r1 = new Rotation(new Vector3D(2, -3, 5), 1.7);
@@ -401,6 +406,7 @@ public class RotationTest
 
   }
 
+  @Test
   public void testCompose() {
 
     Rotation r1 = new Rotation(new Vector3D(2, -3, 5), 1.7);
@@ -418,6 +424,7 @@ public class RotationTest
 
   }
 
+  @Test
   public void testComposeInverse() {
 
     Rotation r1 = new Rotation(new Vector3D(2, -3, 5), 1.7);
@@ -435,6 +442,7 @@ public class RotationTest
 
   }
 
+  @Test
   public void testApplyInverseTo() {
 
     Rotation r = new Rotation(new Vector3D(2, -3, 5), 1.7);
@@ -474,15 +482,15 @@ public class RotationTest
   }
 
   private void checkVector(Vector3D v1, Vector3D v2) {
-    assertTrue(v1.subtract(v2).getNorm() < 1.0e-10);
+    Assert.assertTrue(v1.subtract(v2).getNorm() < 1.0e-10);
   }
 
   private void checkAngle(double a1, double a2) {
-    assertEquals(a1, MathUtils.normalizeAngle(a2, a1), 1.0e-10);
+    Assert.assertEquals(a1, MathUtils.normalizeAngle(a2, a1), 1.0e-10);
   }
 
   private void checkRotation(Rotation r, double q0, double q1, double q2, double q3) {
-    assertEquals(0, Rotation.distance(r, new Rotation(q0, q1, q2, q3, false)), 1.0e-12);
+    Assert.assertEquals(0, Rotation.distance(r, new Rotation(q0, q1, q2, q3, false)), 1.0e-12);
   }
 
 }

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/AbstractRealVectorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/AbstractRealVectorTest.java?rev=1083514&r1=1083513&r2=1083514&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/AbstractRealVectorTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/AbstractRealVectorTest.java Sun Mar 20 17:24:14 2011
@@ -164,17 +164,16 @@ public class AbstractRealVectorTest {
         }
     }
 
-    private static void assertEquals(double[] d1, double[] d2) {
-        Assert.assertEquals(d1.length, d2.length);
-        for(int i=0; i<d1.length; i++) Assert.assertEquals(d1[i], d2[i], 0);
-    }
-
     @Test
     public void testMap() throws Exception {
         double[] vec1Squared = { 1d, 4d, 9d, 16d, 25d };
         RealVector v = new TestVectorImpl(vec1.clone());
         RealVector w = v.map(new UnivariateRealFunction() { public double value(double x) { return x * x; } });
-        assertEquals(vec1Squared, w.getData());
+        double[] d2 = w.getData();
+        Assert.assertEquals(vec1Squared.length, d2.length);
+        for(int i=0; i<vec1Squared.length; i++) {
+            Assert.assertEquals(vec1Squared[i], d2[i], 0);
+        }
     }
 
     @Test

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/ArrayFieldVectorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/ArrayFieldVectorTest.java?rev=1083514&r1=1083513&r2=1083514&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/ArrayFieldVectorTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/ArrayFieldVectorTest.java Sun Mar 20 17:24:14 2011
@@ -19,22 +19,22 @@ package org.apache.commons.math.linear;
 import java.io.Serializable;
 import java.lang.reflect.Array;
 
-import junit.framework.TestCase;
-
 import org.apache.commons.math.Field;
 import org.apache.commons.math.FieldElement;
 import org.apache.commons.math.TestUtils;
+import org.apache.commons.math.exception.MathIllegalArgumentException;
+import org.apache.commons.math.exception.OutOfRangeException;
 import org.apache.commons.math.fraction.Fraction;
 import org.apache.commons.math.fraction.FractionField;
-import org.apache.commons.math.exception.OutOfRangeException;
-import org.apache.commons.math.exception.MathIllegalArgumentException;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * Test cases for the {@link ArrayFieldVector} class.
  *
  * @version $Revision$ $Date$
  */
-public class ArrayFieldVectorTest extends TestCase {
+public class ArrayFieldVectorTest {
 
     //
     protected Fraction[][] ma1 = {
@@ -254,77 +254,79 @@ public class ArrayFieldVectorTest extend
 
     }
 
+    @Test
     public void testConstructors() {
 
         ArrayFieldVector<Fraction> v0 = new ArrayFieldVector<Fraction>(FractionField.getInstance());
-        assertEquals(0, v0.getDimension());
+        Assert.assertEquals(0, v0.getDimension());
 
         ArrayFieldVector<Fraction> v1 = new ArrayFieldVector<Fraction>(FractionField.getInstance(), 7);
-        assertEquals(7, v1.getDimension());
-        assertEquals(new Fraction(0), v1.getEntry(6));
+        Assert.assertEquals(7, v1.getDimension());
+        Assert.assertEquals(new Fraction(0), v1.getEntry(6));
 
         ArrayFieldVector<Fraction> v2 = new ArrayFieldVector<Fraction>(5, new Fraction(123, 100));
-        assertEquals(5, v2.getDimension());
-        assertEquals(new Fraction(123, 100), v2.getEntry(4));
+        Assert.assertEquals(5, v2.getDimension());
+        Assert.assertEquals(new Fraction(123, 100), v2.getEntry(4));
 
         ArrayFieldVector<Fraction> v3 = new ArrayFieldVector<Fraction>(vec1);
-        assertEquals(3, v3.getDimension());
-        assertEquals(new Fraction(2), v3.getEntry(1));
+        Assert.assertEquals(3, v3.getDimension());
+        Assert.assertEquals(new Fraction(2), v3.getEntry(1));
 
         ArrayFieldVector<Fraction> v4 = new ArrayFieldVector<Fraction>(vec4, 3, 2);
-        assertEquals(2, v4.getDimension());
-        assertEquals(new Fraction(4), v4.getEntry(0));
+        Assert.assertEquals(2, v4.getDimension());
+        Assert.assertEquals(new Fraction(4), v4.getEntry(0));
         try {
             new ArrayFieldVector<Fraction>(vec4, 8, 3);
-            fail("MathIllegalArgumentException expected");
+            Assert.fail("MathIllegalArgumentException expected");
         } catch (MathIllegalArgumentException ex) {
             // expected behavior
         }
 
         FieldVector<Fraction> v5_i = new ArrayFieldVector<Fraction>(dvec1);
-        assertEquals(9, v5_i.getDimension());
-        assertEquals(new Fraction(9), v5_i.getEntry(8));
+        Assert.assertEquals(9, v5_i.getDimension());
+        Assert.assertEquals(new Fraction(9), v5_i.getEntry(8));
 
         ArrayFieldVector<Fraction> v5 = new ArrayFieldVector<Fraction>(dvec1);
-        assertEquals(9, v5.getDimension());
-        assertEquals(new Fraction(9), v5.getEntry(8));
+        Assert.assertEquals(9, v5.getDimension());
+        Assert.assertEquals(new Fraction(9), v5.getEntry(8));
 
         ArrayFieldVector<Fraction> v6 = new ArrayFieldVector<Fraction>(dvec1, 3, 2);
-        assertEquals(2, v6.getDimension());
-        assertEquals(new Fraction(4), v6.getEntry(0));
+        Assert.assertEquals(2, v6.getDimension());
+        Assert.assertEquals(new Fraction(4), v6.getEntry(0));
         try {
             new ArrayFieldVector<Fraction>(dvec1, 8, 3);
-            fail("MathIllegalArgumentException expected");
+            Assert.fail("MathIllegalArgumentException expected");
         } catch (MathIllegalArgumentException ex) {
             // expected behavior
         }
 
         ArrayFieldVector<Fraction> v7 = new ArrayFieldVector<Fraction>(v1);
-        assertEquals(7, v7.getDimension());
-        assertEquals(new Fraction(0), v7.getEntry(6));
+        Assert.assertEquals(7, v7.getDimension());
+        Assert.assertEquals(new Fraction(0), v7.getEntry(6));
 
         FieldVectorTestImpl<Fraction> v7_i = new FieldVectorTestImpl<Fraction>(vec1);
 
         ArrayFieldVector<Fraction> v7_2 = new ArrayFieldVector<Fraction>(v7_i);
-        assertEquals(3, v7_2.getDimension());
-        assertEquals(new Fraction(2), v7_2.getEntry(1));
+        Assert.assertEquals(3, v7_2.getDimension());
+        Assert.assertEquals(new Fraction(2), v7_2.getEntry(1));
 
         ArrayFieldVector<Fraction> v8 = new ArrayFieldVector<Fraction>(v1, true);
-        assertEquals(7, v8.getDimension());
-        assertEquals(new Fraction(0), v8.getEntry(6));
-        assertNotSame("testData not same object ", v1.data, v8.data);
+        Assert.assertEquals(7, v8.getDimension());
+        Assert.assertEquals(new Fraction(0), v8.getEntry(6));
+        Assert.assertNotSame("testData not same object ", v1.data, v8.data);
 
         ArrayFieldVector<Fraction> v8_2 = new ArrayFieldVector<Fraction>(v1, false);
-        assertEquals(7, v8_2.getDimension());
-        assertEquals(new Fraction(0), v8_2.getEntry(6));
-        assertEquals(v1.data, v8_2.data);
+        Assert.assertEquals(7, v8_2.getDimension());
+        Assert.assertEquals(new Fraction(0), v8_2.getEntry(6));
+        Assert.assertArrayEquals(v1.data, v8_2.data);
 
         ArrayFieldVector<Fraction> v9 = new ArrayFieldVector<Fraction>(v1, v3);
-        assertEquals(10, v9.getDimension());
-        assertEquals(new Fraction(1), v9.getEntry(7));
+        Assert.assertEquals(10, v9.getDimension());
+        Assert.assertEquals(new Fraction(1), v9.getEntry(7));
 
     }
 
+    @Test
     public void testDataInOut() {
 
         ArrayFieldVector<Fraction> v1 = new ArrayFieldVector<Fraction>(vec1);
@@ -333,84 +335,84 @@ public class ArrayFieldVectorTest extend
         FieldVectorTestImpl<Fraction> v2_t = new FieldVectorTestImpl<Fraction>(vec2);
 
         FieldVector<Fraction> v_append_1 = v1.append(v2);
-        assertEquals(6, v_append_1.getDimension());
-        assertEquals(new Fraction(4), v_append_1.getEntry(3));
+        Assert.assertEquals(6, v_append_1.getDimension());
+        Assert.assertEquals(new Fraction(4), v_append_1.getEntry(3));
 
         FieldVector<Fraction> v_append_2 = v1.append(new Fraction(2));
-        assertEquals(4, v_append_2.getDimension());
-        assertEquals(new Fraction(2), v_append_2.getEntry(3));
+        Assert.assertEquals(4, v_append_2.getDimension());
+        Assert.assertEquals(new Fraction(2), v_append_2.getEntry(3));
 
         FieldVector<Fraction> v_append_3 = v1.append(vec2);
-        assertEquals(6, v_append_3.getDimension());
-        assertEquals(new Fraction(4), v_append_3.getEntry(3));
+        Assert.assertEquals(6, v_append_3.getDimension());
+        Assert.assertEquals(new Fraction(4), v_append_3.getEntry(3));
 
         FieldVector<Fraction> v_append_4 = v1.append(v2_t);
-        assertEquals(6, v_append_4.getDimension());
-        assertEquals(new Fraction(4), v_append_4.getEntry(3));
+        Assert.assertEquals(6, v_append_4.getDimension());
+        Assert.assertEquals(new Fraction(4), v_append_4.getEntry(3));
 
         FieldVector<Fraction> v_copy = v1.copy();
-        assertEquals(3, v_copy.getDimension());
-        assertNotSame("testData not same object ", v1.data, v_copy.getData());
+        Assert.assertEquals(3, v_copy.getDimension());
+        Assert.assertNotSame("testData not same object ", v1.data, v_copy.getData());
 
         Fraction[] a_frac = v1.toArray();
-        assertEquals(3, a_frac.length);
-        assertNotSame("testData not same object ", v1.data, a_frac);
+        Assert.assertEquals(3, a_frac.length);
+        Assert.assertNotSame("testData not same object ", v1.data, a_frac);
 
 
 //      ArrayFieldVector<Fraction> vout4 = (ArrayFieldVector<Fraction>) v1.clone();
-//      assertEquals(3, vout4.getDimension());
-//      assertEquals(v1.data, vout4.data);
+//      Assert.assertEquals(3, vout4.getDimension());
+//      Assert.assertEquals(v1.data, vout4.data);
 
 
         FieldVector<Fraction> vout5 = v4.getSubVector(3, 3);
-        assertEquals(3, vout5.getDimension());
-        assertEquals(new Fraction(5), vout5.getEntry(1));
+        Assert.assertEquals(3, vout5.getDimension());
+        Assert.assertEquals(new Fraction(5), vout5.getEntry(1));
         try {
             v4.getSubVector(3, 7);
-            fail("OutOfRangeException expected");
+            Assert.fail("OutOfRangeException expected");
         } catch (OutOfRangeException ex) {
             // expected behavior
         }
 
         ArrayFieldVector<Fraction> v_set1 = (ArrayFieldVector<Fraction>) v1.copy();
         v_set1.setEntry(1, new Fraction(11));
-        assertEquals(new Fraction(11), v_set1.getEntry(1));
+        Assert.assertEquals(new Fraction(11), v_set1.getEntry(1));
         try {
             v_set1.setEntry(3, new Fraction(11));
-            fail("OutOfRangeException expected");
+            Assert.fail("OutOfRangeException expected");
         } catch (OutOfRangeException ex) {
             // expected behavior
         }
 
         ArrayFieldVector<Fraction> v_set2 = (ArrayFieldVector<Fraction>) v4.copy();
         v_set2.set(3, v1);
-        assertEquals(new Fraction(1), v_set2.getEntry(3));
-        assertEquals(new Fraction(7), v_set2.getEntry(6));
+        Assert.assertEquals(new Fraction(1), v_set2.getEntry(3));
+        Assert.assertEquals(new Fraction(7), v_set2.getEntry(6));
         try {
             v_set2.set(7, v1);
-            fail("OutOfRangeException expected");
+            Assert.fail("OutOfRangeException expected");
         } catch (OutOfRangeException ex) {
             // expected behavior
         }
 
         ArrayFieldVector<Fraction> v_set3 = (ArrayFieldVector<Fraction>) v1.copy();
         v_set3.set(new Fraction(13));
-        assertEquals(new Fraction(13), v_set3.getEntry(2));
+        Assert.assertEquals(new Fraction(13), v_set3.getEntry(2));
 
         try {
             v_set3.getEntry(23);
-            fail("ArrayIndexOutOfBoundsException expected");
+            Assert.fail("ArrayIndexOutOfBoundsException expected");
         } catch (ArrayIndexOutOfBoundsException ex) {
             // expected behavior
         }
 
         ArrayFieldVector<Fraction> v_set4 = (ArrayFieldVector<Fraction>) v4.copy();
         v_set4.setSubVector(3, v2_t);
-        assertEquals(new Fraction(4), v_set4.getEntry(3));
-        assertEquals(new Fraction(7), v_set4.getEntry(6));
+        Assert.assertEquals(new Fraction(4), v_set4.getEntry(3));
+        Assert.assertEquals(new Fraction(7), v_set4.getEntry(6));
         try {
             v_set4.setSubVector(7, v2_t);
-            fail("OutOfRangeException expected");
+            Assert.fail("OutOfRangeException expected");
         } catch (OutOfRangeException ex) {
             // expected behavior
         }
@@ -418,12 +420,13 @@ public class ArrayFieldVectorTest extend
 
         ArrayFieldVector<Fraction> vout10 = (ArrayFieldVector<Fraction>) v1.copy();
         ArrayFieldVector<Fraction> vout10_2 = (ArrayFieldVector<Fraction>) v1.copy();
-        assertEquals(vout10, vout10_2);
+        Assert.assertEquals(vout10, vout10_2);
         vout10_2.setEntry(0, new Fraction(11, 10));
-        assertNotSame(vout10, vout10_2);
+        Assert.assertNotSame(vout10, vout10_2);
 
     }
 
+    @Test
     public void testMapFunctions() {
         ArrayFieldVector<Fraction> v1 = new ArrayFieldVector<Fraction>(vec1);
 
@@ -484,6 +487,7 @@ public class ArrayFieldVectorTest extend
 
     }
 
+    @Test
     public void testBasicFunctions() {
         ArrayFieldVector<Fraction> v1 = new ArrayFieldVector<Fraction>(vec1);
         ArrayFieldVector<Fraction> v2 = new ArrayFieldVector<Fraction>(vec2);
@@ -530,17 +534,17 @@ public class ArrayFieldVectorTest extend
 
         // 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));
 
         ArrayFieldVector<Fraction> v_projection = v1.projection(v2);
         Fraction[] result_projection = {new Fraction(128, 77), new Fraction(160, 77), new Fraction(192, 77)};
@@ -552,82 +556,85 @@ public class ArrayFieldVectorTest extend
 
     }
 
+    @Test
     public void testMisc() {
         ArrayFieldVector<Fraction> v1 = new ArrayFieldVector<Fraction>(vec1);
         ArrayFieldVector<Fraction> v4 = new ArrayFieldVector<Fraction>(vec4);
         FieldVector<Fraction> v4_2 = new ArrayFieldVector<Fraction>(vec4);
 
         String out1 = v1.toString();
-        assertTrue("some output ",  out1.length()!=0);
+        Assert.assertTrue("some output ",  out1.length()!=0);
         /*
          Fraction[] dout1 = v1.copyOut();
-        assertEquals(3, dout1.length);
+        Assert.assertEquals(3, dout1.length);
         assertNotSame("testData not same object ", v1.data, dout1);
          */
         try {
             v1.checkVectorDimensions(2);
-            fail("MathIllegalArgumentException expected");
+            Assert.fail("MathIllegalArgumentException expected");
         } catch (MathIllegalArgumentException ex) {
             // expected behavior
         }
 
        try {
             v1.checkVectorDimensions(v4);
-            fail("MathIllegalArgumentException expected");
+            Assert.fail("MathIllegalArgumentException expected");
         } catch (MathIllegalArgumentException ex) {
             // expected behavior
         }
 
         try {
             v1.checkVectorDimensions(v4_2);
-            fail("MathIllegalArgumentException expected");
+            Assert.fail("MathIllegalArgumentException expected");
         } catch (MathIllegalArgumentException ex) {
             // expected behavior
         }
 
     }
 
+    @Test
     public void testSerial()  {
         ArrayFieldVector<Fraction> v = new ArrayFieldVector<Fraction>(vec1);
-        assertEquals(v,TestUtils.serializeAndRecover(v));
+        Assert.assertEquals(v,TestUtils.serializeAndRecover(v));
     }
 
+    @Test
     public void testZeroVectors() {
 
         // when the field is not specified, array cannot be empty
         try {
             new ArrayFieldVector<Fraction>(new Fraction[0]);
-            fail("MathIllegalArgumentException expected");
+            Assert.fail("MathIllegalArgumentException expected");
         } catch (MathIllegalArgumentException ex) {
             // expected behavior
         }
         try {
             new ArrayFieldVector<Fraction>(new Fraction[0], true);
-            fail("MathIllegalArgumentException expected");
+            Assert.fail("MathIllegalArgumentException expected");
         } catch (MathIllegalArgumentException ex) {
             // expected behavior
         }
         try {
             new ArrayFieldVector<Fraction>(new Fraction[0], false);
-            fail("MathIllegalArgumentException expected");
+            Assert.fail("MathIllegalArgumentException expected");
         } catch (MathIllegalArgumentException ex) {
             // expected behavior
         }
 
         // when the field is specified, array can be empty
-        assertEquals(0, new ArrayFieldVector<Fraction>(FractionField.getInstance(), new Fraction[0]).getDimension());
-        assertEquals(0, new ArrayFieldVector<Fraction>(FractionField.getInstance(), new Fraction[0], true).getDimension());
-        assertEquals(0, new ArrayFieldVector<Fraction>(FractionField.getInstance(), new Fraction[0], false).getDimension());
+        Assert.assertEquals(0, new ArrayFieldVector<Fraction>(FractionField.getInstance(), new Fraction[0]).getDimension());
+        Assert.assertEquals(0, new ArrayFieldVector<Fraction>(FractionField.getInstance(), new Fraction[0], true).getDimension());
+        Assert.assertEquals(0, new ArrayFieldVector<Fraction>(FractionField.getInstance(), new Fraction[0], false).getDimension());
 
     }
 
     /** verifies that two vectors are equals */
     protected void checkArray(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]);
         }
     }
 

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/CholeskySolverTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/CholeskySolverTest.java?rev=1083514&r1=1083513&r2=1083514&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/CholeskySolverTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/CholeskySolverTest.java Sun Mar 20 17:24:14 2011
@@ -18,10 +18,11 @@
 package org.apache.commons.math.linear;
 
 import org.apache.commons.math.exception.MathIllegalArgumentException;
+import org.junit.Assert;
+import org.junit.Test;
 
-import junit.framework.TestCase;
 
-public class CholeskySolverTest extends TestCase {
+public class CholeskySolverTest {
 
     private double[][] testData = new double[][] {
             {  1,  2,   4,   7,  11 },
@@ -31,36 +32,34 @@ public class CholeskySolverTest extends 
             { 11, 58, 182, 430, 855 }
     };
 
-    public CholeskySolverTest(String name) {
-        super(name);
-    }
-
     /** test solve dimension errors */
+    @Test
     public void testSolveDimensionErrors() {
         DecompositionSolver solver =
             new CholeskyDecompositionImpl(MatrixUtils.createRealMatrix(testData)).getSolver();
         RealMatrix b = MatrixUtils.createRealMatrix(new double[2][2]);
         try {
             solver.solve(b);
-            fail("an exception should have been thrown");
+            Assert.fail("an exception should have been thrown");
         } catch (MathIllegalArgumentException iae) {
             // expected behavior
         }
         try {
             solver.solve(b.getColumn(0));
-            fail("an exception should have been thrown");
+            Assert.fail("an exception should have been thrown");
         } catch (MathIllegalArgumentException iae) {
             // expected behavior
         }
         try {
             solver.solve(new ArrayRealVectorTest.RealVectorTestImpl(b.getColumn(0)));
-            fail("an exception should have been thrown");
+            Assert.fail("an exception should have been thrown");
         } catch (MathIllegalArgumentException iae) {
             // expected behavior
         }
     }
 
     /** test solve */
+    @Test
     public void testSolve() {
         DecompositionSolver solver =
             new CholeskyDecompositionImpl(MatrixUtils.createRealMatrix(testData)).getSolver();
@@ -80,18 +79,18 @@ public class CholeskySolverTest extends 
         });
 
         // using RealMatrix
-        assertEquals(0, solver.solve(b).subtract(xRef).getNorm(), 1.0e-13);
+        Assert.assertEquals(0, solver.solve(b).subtract(xRef).getNorm(), 1.0e-13);
 
         // using double[]
         for (int i = 0; i < b.getColumnDimension(); ++i) {
-            assertEquals(0,
+            Assert.assertEquals(0,
                          new ArrayRealVector(solver.solve(b.getColumn(i))).subtract(xRef.getColumnVector(i)).getNorm(),
                          1.0e-13);
         }
 
         // using ArrayRealVector
         for (int i = 0; i < b.getColumnDimension(); ++i) {
-            assertEquals(0,
+            Assert.assertEquals(0,
                          solver.solve(b.getColumnVector(i)).subtract(xRef.getColumnVector(i)).getNorm(),
                          1.0e-13);
         }
@@ -100,7 +99,7 @@ public class CholeskySolverTest extends 
         for (int i = 0; i < b.getColumnDimension(); ++i) {
             ArrayRealVectorTest.RealVectorTestImpl v =
                 new ArrayRealVectorTest.RealVectorTestImpl(b.getColumn(i));
-            assertEquals(0,
+            Assert.assertEquals(0,
                          solver.solve(v).subtract(xRef.getColumnVector(i)).getNorm(),
                          1.0e-13);
         }
@@ -108,8 +107,9 @@ public class CholeskySolverTest extends 
     }
 
     /** test determinant */
+    @Test
     public void testDeterminant() {
-        assertEquals(7290000.0, getDeterminant(MatrixUtils.createRealMatrix(testData)), 1.0e-15);
+        Assert.assertEquals(7290000.0, getDeterminant(MatrixUtils.createRealMatrix(testData)), 1.0e-15);
     }
 
     private double getDeterminant(RealMatrix m) {

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/EigenDecompositionImplTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/EigenDecompositionImplTest.java?rev=1083514&r1=1083513&r2=1083514&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/EigenDecompositionImplTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/EigenDecompositionImplTest.java Sun Mar 20 17:24:14 2011
@@ -20,27 +20,28 @@ package org.apache.commons.math.linear;
 import java.util.Arrays;
 import java.util.Random;
 
-import junit.framework.TestCase;
 
 import org.apache.commons.math.util.FastMath;
 import org.apache.commons.math.util.MathUtils;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
 
-public class EigenDecompositionImplTest extends TestCase {
+public class EigenDecompositionImplTest {
 
     private double[] refValues;
     private RealMatrix matrix;
 
-    public EigenDecompositionImplTest(String name) {
-        super(name);
-    }
-
+    @Test
     public void testDimension1() {
         RealMatrix matrix =
             MatrixUtils.createRealMatrix(new double[][] { { 1.5 } });
         EigenDecomposition ed = new EigenDecompositionImpl(matrix, MathUtils.SAFE_MIN);
-        assertEquals(1.5, ed.getRealEigenvalue(0), 1.0e-15);
+        Assert.assertEquals(1.5, ed.getRealEigenvalue(0), 1.0e-15);
     }
 
+    @Test
     public void testDimension2() {
         RealMatrix matrix =
             MatrixUtils.createRealMatrix(new double[][] {
@@ -48,10 +49,11 @@ public class EigenDecompositionImplTest 
                     { 12.0, 66.0 }
             });
         EigenDecomposition ed = new EigenDecompositionImpl(matrix, MathUtils.SAFE_MIN);
-        assertEquals(75.0, ed.getRealEigenvalue(0), 1.0e-15);
-        assertEquals(50.0, ed.getRealEigenvalue(1), 1.0e-15);
+        Assert.assertEquals(75.0, ed.getRealEigenvalue(0), 1.0e-15);
+        Assert.assertEquals(50.0, ed.getRealEigenvalue(1), 1.0e-15);
     }
 
+    @Test
     public void testDimension3() {
         RealMatrix matrix =
             MatrixUtils.createRealMatrix(new double[][] {
@@ -60,11 +62,12 @@ public class EigenDecompositionImplTest 
                                    { -16560.0,  7920.0,  17300.0 }
                                });
         EigenDecomposition ed = new EigenDecompositionImpl(matrix, MathUtils.SAFE_MIN);
-        assertEquals(50000.0, ed.getRealEigenvalue(0), 3.0e-11);
-        assertEquals(12500.0, ed.getRealEigenvalue(1), 3.0e-11);
-        assertEquals( 3125.0, ed.getRealEigenvalue(2), 3.0e-11);
+        Assert.assertEquals(50000.0, ed.getRealEigenvalue(0), 3.0e-11);
+        Assert.assertEquals(12500.0, ed.getRealEigenvalue(1), 3.0e-11);
+        Assert.assertEquals( 3125.0, ed.getRealEigenvalue(2), 3.0e-11);
     }
 
+    @Test
     public void testDimension3MultipleRoot() {
         RealMatrix matrix =
             MatrixUtils.createRealMatrix(new double[][] {
@@ -73,11 +76,12 @@ public class EigenDecompositionImplTest 
                     { 15,   30,   45 }
             });
         EigenDecomposition ed = new EigenDecompositionImpl(matrix, MathUtils.SAFE_MIN);
-        assertEquals(70.0, ed.getRealEigenvalue(0), 3.0e-11);
-        assertEquals(0.0,  ed.getRealEigenvalue(1), 3.0e-11);
-        assertEquals(0.0,  ed.getRealEigenvalue(2), 3.0e-11);
+        Assert.assertEquals(70.0, ed.getRealEigenvalue(0), 3.0e-11);
+        Assert.assertEquals(0.0,  ed.getRealEigenvalue(1), 3.0e-11);
+        Assert.assertEquals(0.0,  ed.getRealEigenvalue(2), 3.0e-11);
     }
 
+    @Test
     public void testDimension4WithSplit() {
         RealMatrix matrix =
             MatrixUtils.createRealMatrix(new double[][] {
@@ -87,12 +91,13 @@ public class EigenDecompositionImplTest 
                                    {  0.000,  0.000, -0.048,  0.136 }
                                });
         EigenDecomposition ed = new EigenDecompositionImpl(matrix, MathUtils.SAFE_MIN);
-        assertEquals(1.0, ed.getRealEigenvalue(0), 1.0e-15);
-        assertEquals(0.4, ed.getRealEigenvalue(1), 1.0e-15);
-        assertEquals(0.2, ed.getRealEigenvalue(2), 1.0e-15);
-        assertEquals(0.1, ed.getRealEigenvalue(3), 1.0e-15);
+        Assert.assertEquals(1.0, ed.getRealEigenvalue(0), 1.0e-15);
+        Assert.assertEquals(0.4, ed.getRealEigenvalue(1), 1.0e-15);
+        Assert.assertEquals(0.2, ed.getRealEigenvalue(2), 1.0e-15);
+        Assert.assertEquals(0.1, ed.getRealEigenvalue(3), 1.0e-15);
     }
 
+    @Test
     public void testDimension4WithoutSplit() {
         RealMatrix matrix =
             MatrixUtils.createRealMatrix(new double[][] {
@@ -102,13 +107,14 @@ public class EigenDecompositionImplTest 
                                    { -0.2976,  0.1152, -0.1344,  0.3872 }
                                });
         EigenDecomposition ed = new EigenDecompositionImpl(matrix, MathUtils.SAFE_MIN);
-        assertEquals(1.0, ed.getRealEigenvalue(0), 1.0e-15);
-        assertEquals(0.4, ed.getRealEigenvalue(1), 1.0e-15);
-        assertEquals(0.2, ed.getRealEigenvalue(2), 1.0e-15);
-        assertEquals(0.1, ed.getRealEigenvalue(3), 1.0e-15);
+        Assert.assertEquals(1.0, ed.getRealEigenvalue(0), 1.0e-15);
+        Assert.assertEquals(0.4, ed.getRealEigenvalue(1), 1.0e-15);
+        Assert.assertEquals(0.2, ed.getRealEigenvalue(2), 1.0e-15);
+        Assert.assertEquals(0.1, ed.getRealEigenvalue(3), 1.0e-15);
     }
 
     // the following test triggered an ArrayIndexOutOfBoundsException in commons-math 2.0
+    @Test
     public void testMath308() {
 
         double[] mainTridiagonal = {
@@ -136,12 +142,13 @@ public class EigenDecompositionImplTest 
 
         double[] eigenValues = decomposition.getRealEigenvalues();
         for (int i = 0; i < refEigenValues.length; ++i) {
-            assertEquals(refEigenValues[i], eigenValues[i], 1.0e-5);
-            assertEquals(0, refEigenVectors[i].subtract(decomposition.getEigenvector(i)).getNorm(), 2.0e-7);
+            Assert.assertEquals(refEigenValues[i], eigenValues[i], 1.0e-5);
+            Assert.assertEquals(0, refEigenVectors[i].subtract(decomposition.getEigenvector(i)).getNorm(), 2.0e-7);
         }
 
     }
 
+    @Test
     public void testMathpbx02() {
 
         double[] mainTridiagonal = {
@@ -178,16 +185,17 @@ public class EigenDecompositionImplTest 
 
         double[] eigenValues = decomposition.getRealEigenvalues();
         for (int i = 0; i < refEigenValues.length; ++i) {
-            assertEquals(refEigenValues[i], eigenValues[i], 1.0e-3);
+            Assert.assertEquals(refEigenValues[i], eigenValues[i], 1.0e-3);
             if (refEigenVectors[i].dotProduct(decomposition.getEigenvector(i)) < 0) {
-                assertEquals(0, refEigenVectors[i].add(decomposition.getEigenvector(i)).getNorm(), 1.0e-5);
+                Assert.assertEquals(0, refEigenVectors[i].add(decomposition.getEigenvector(i)).getNorm(), 1.0e-5);
             } else {
-                assertEquals(0, refEigenVectors[i].subtract(decomposition.getEigenvector(i)).getNorm(), 1.0e-5);
+                Assert.assertEquals(0, refEigenVectors[i].subtract(decomposition.getEigenvector(i)).getNorm(), 1.0e-5);
             }
         }
 
     }
 
+    @Test
     public void testMathpbx03() {
 
         double[] mainTridiagonal = {
@@ -222,17 +230,18 @@ public class EigenDecompositionImplTest 
 
         double[] eigenValues = decomposition.getRealEigenvalues();
         for (int i = 0; i < refEigenValues.length; ++i) {
-            assertEquals(refEigenValues[i], eigenValues[i], 1.0e-4);
+            Assert.assertEquals(refEigenValues[i], eigenValues[i], 1.0e-4);
             if (refEigenVectors[i].dotProduct(decomposition.getEigenvector(i)) < 0) {
-                assertEquals(0, refEigenVectors[i].add(decomposition.getEigenvector(i)).getNorm(), 1.0e-5);
+                Assert.assertEquals(0, refEigenVectors[i].add(decomposition.getEigenvector(i)).getNorm(), 1.0e-5);
             } else {
-                assertEquals(0, refEigenVectors[i].subtract(decomposition.getEigenvector(i)).getNorm(), 1.0e-5);
+                Assert.assertEquals(0, refEigenVectors[i].subtract(decomposition.getEigenvector(i)).getNorm(), 1.0e-5);
             }
         }
 
     }
 
     /** test a matrix already in tridiagonal form. */
+    @Test
     public void testTridiagonal() {
         Random r = new Random(4366663527842l);
         double[] ref = new double[30];
@@ -251,36 +260,39 @@ public class EigenDecompositionImplTest 
                                        t.getSecondaryDiagonalRef(),
                                        MathUtils.SAFE_MIN);
         double[] eigenValues = ed.getRealEigenvalues();
-        assertEquals(ref.length, eigenValues.length);
+        Assert.assertEquals(ref.length, eigenValues.length);
         for (int i = 0; i < ref.length; ++i) {
-            assertEquals(ref[ref.length - i - 1], eigenValues[i], 2.0e-14);
+            Assert.assertEquals(ref[ref.length - i - 1], eigenValues[i], 2.0e-14);
         }
 
     }
 
     /** test dimensions */
+    @Test
     public void testDimensions() {
         final int m = matrix.getRowDimension();
         EigenDecomposition ed = new EigenDecompositionImpl(matrix, MathUtils.SAFE_MIN);
-        assertEquals(m, ed.getV().getRowDimension());
-        assertEquals(m, ed.getV().getColumnDimension());
-        assertEquals(m, ed.getD().getColumnDimension());
-        assertEquals(m, ed.getD().getColumnDimension());
-        assertEquals(m, ed.getVT().getRowDimension());
-        assertEquals(m, ed.getVT().getColumnDimension());
+        Assert.assertEquals(m, ed.getV().getRowDimension());
+        Assert.assertEquals(m, ed.getV().getColumnDimension());
+        Assert.assertEquals(m, ed.getD().getColumnDimension());
+        Assert.assertEquals(m, ed.getD().getColumnDimension());
+        Assert.assertEquals(m, ed.getVT().getRowDimension());
+        Assert.assertEquals(m, ed.getVT().getColumnDimension());
     }
 
     /** test eigenvalues */
+    @Test
     public void testEigenvalues() {
         EigenDecomposition ed = new EigenDecompositionImpl(matrix, MathUtils.SAFE_MIN);
         double[] eigenValues = ed.getRealEigenvalues();
-        assertEquals(refValues.length, eigenValues.length);
+        Assert.assertEquals(refValues.length, eigenValues.length);
         for (int i = 0; i < refValues.length; ++i) {
-            assertEquals(refValues[i], eigenValues[i], 3.0e-15);
+            Assert.assertEquals(refValues[i], eigenValues[i], 3.0e-15);
         }
     }
 
     /** test eigenvalues for a big matrix. */
+    @Test
     public void testBigMatrix() {
         Random r = new Random(17748333525117l);
         double[] bigValues = new double[200];
@@ -291,55 +303,60 @@ public class EigenDecompositionImplTest 
         EigenDecomposition ed =
             new EigenDecompositionImpl(createTestMatrix(r, bigValues), MathUtils.SAFE_MIN);
         double[] eigenValues = ed.getRealEigenvalues();
-        assertEquals(bigValues.length, eigenValues.length);
+        Assert.assertEquals(bigValues.length, eigenValues.length);
         for (int i = 0; i < bigValues.length; ++i) {
-            assertEquals(bigValues[bigValues.length - i - 1], eigenValues[i], 2.0e-14);
+            Assert.assertEquals(bigValues[bigValues.length - i - 1], eigenValues[i], 2.0e-14);
         }
     }
 
     /** test eigenvectors */
+    @Test
     public void testEigenvectors() {
         EigenDecomposition ed = new EigenDecompositionImpl(matrix, MathUtils.SAFE_MIN);
         for (int i = 0; i < matrix.getRowDimension(); ++i) {
             double lambda = ed.getRealEigenvalue(i);
             RealVector v  = ed.getEigenvector(i);
             RealVector mV = matrix.operate(v);
-            assertEquals(0, mV.subtract(v.mapMultiplyToSelf(lambda)).getNorm(), 1.0e-13);
+            Assert.assertEquals(0, mV.subtract(v.mapMultiplyToSelf(lambda)).getNorm(), 1.0e-13);
         }
     }
 
     /** test A = VDVt */
+    @Test
     public void testAEqualVDVt() {
         EigenDecomposition ed = new EigenDecompositionImpl(matrix, MathUtils.SAFE_MIN);
         RealMatrix v  = ed.getV();
         RealMatrix d  = ed.getD();
         RealMatrix vT = ed.getVT();
         double norm = v.multiply(d).multiply(vT).subtract(matrix).getNorm();
-        assertEquals(0, norm, 6.0e-13);
+        Assert.assertEquals(0, norm, 6.0e-13);
     }
 
     /** test that V is orthogonal */
+    @Test
     public void testVOrthogonal() {
         RealMatrix v = new EigenDecompositionImpl(matrix, MathUtils.SAFE_MIN).getV();
         RealMatrix vTv = v.transpose().multiply(v);
         RealMatrix id  = MatrixUtils.createRealIdentityMatrix(vTv.getRowDimension());
-        assertEquals(0, vTv.subtract(id).getNorm(), 2.0e-13);
+        Assert.assertEquals(0, vTv.subtract(id).getNorm(), 2.0e-13);
     }
 
     /** test diagonal matrix */
+    @Test
     public void testDiagonal() {
         double[] diagonal = new double[] { -3.0, -2.0, 2.0, 5.0 };
         RealMatrix m = createDiagonalMatrix(diagonal, diagonal.length, diagonal.length);
         EigenDecomposition ed = new EigenDecompositionImpl(m, MathUtils.SAFE_MIN);
-        assertEquals(diagonal[0], ed.getRealEigenvalue(3), 2.0e-15);
-        assertEquals(diagonal[1], ed.getRealEigenvalue(2), 2.0e-15);
-        assertEquals(diagonal[2], ed.getRealEigenvalue(1), 2.0e-15);
-        assertEquals(diagonal[3], ed.getRealEigenvalue(0), 2.0e-15);
+        Assert.assertEquals(diagonal[0], ed.getRealEigenvalue(3), 2.0e-15);
+        Assert.assertEquals(diagonal[1], ed.getRealEigenvalue(2), 2.0e-15);
+        Assert.assertEquals(diagonal[2], ed.getRealEigenvalue(1), 2.0e-15);
+        Assert.assertEquals(diagonal[3], ed.getRealEigenvalue(0), 2.0e-15);
     }
 
     /**
      * Matrix with eigenvalues {8, -1, -1}
      */
+    @Test
     public void testRepeatedEigenvalue() {
         RealMatrix repeated = MatrixUtils.createRealMatrix(new double[][] {
                 {3,  2,  4},
@@ -354,6 +371,7 @@ public class EigenDecompositionImplTest 
     /**
      * Matrix with eigenvalues {2, 0, 12}
      */
+    @Test
     public void testDistinctEigenvalues() {
         RealMatrix distinct = MatrixUtils.createRealMatrix(new double[][] {
                 {3, 1, -4},
@@ -370,6 +388,7 @@ public class EigenDecompositionImplTest 
     /**
      * Verifies operation on indefinite matrix
      */
+    @Test
     public void testZeroDivide() {
         RealMatrix indefinite = MatrixUtils.createRealMatrix(new double [][] {
                 { 0.0, 1.0, -1.0 },
@@ -394,8 +413,8 @@ public class EigenDecompositionImplTest 
             EigenDecomposition ed, double tolerance) {
         double[] observed = ed.getRealEigenvalues();
         for (int i = 0; i < observed.length; i++) {
-            assertTrue(isIncludedValue(observed[i], targetValues, tolerance));
-            assertTrue(isIncludedValue(targetValues[i], observed, tolerance));
+            Assert.assertTrue(isIncludedValue(observed[i], targetValues, tolerance));
+            Assert.assertTrue(isIncludedValue(targetValues[i], observed, tolerance));
         }
     }
 
@@ -424,7 +443,7 @@ public class EigenDecompositionImplTest 
      */
     protected void checkEigenVector(double[] eigenVector,
             EigenDecomposition ed, double tolerance) {
-        assertTrue(isIncludedColumn(eigenVector, ed.getV(), tolerance));
+        Assert.assertTrue(isIncludedColumn(eigenVector, ed.getV(), tolerance));
     }
 
     /**
@@ -457,7 +476,7 @@ public class EigenDecompositionImplTest 
         return found;
     }
 
-    @Override
+    @Before
     public void setUp() {
         refValues = new double[] {
                 2.003, 2.002, 2.001, 1.001, 1.000, 0.001
@@ -465,7 +484,7 @@ public class EigenDecompositionImplTest 
         matrix = createTestMatrix(new Random(35992629946426l), refValues);
     }
 
-    @Override
+    @After
     public void tearDown() {
         refValues = null;
         matrix    = null;

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/MatrixUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/MatrixUtilsTest.java?rev=1083514&r1=1083513&r2=1083514&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/MatrixUtilsTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/MatrixUtilsTest.java Sun Mar 20 17:24:14 2011
@@ -18,7 +18,6 @@ package org.apache.commons.math.linear;
 
 import java.math.BigDecimal;
 
-import junit.framework.TestCase;
 
 import org.apache.commons.math.fraction.BigFraction;
 import org.apache.commons.math.fraction.Fraction;
@@ -27,6 +26,8 @@ import org.apache.commons.math.fraction.
 import org.apache.commons.math.exception.NullArgumentException;
 import org.apache.commons.math.exception.NotStrictlyPositiveException;
 import org.apache.commons.math.exception.MathIllegalArgumentException;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * Test cases for the {@link MatrixUtils} class.
@@ -34,7 +35,7 @@ import org.apache.commons.math.exception
  * @version $Revision$ $Date$
  */
 
-public final class MatrixUtilsTest extends TestCase {
+public final class MatrixUtilsTest {
 
     protected double[][] testData = { {1d,2d,3d}, {2d,5d,3d}, {1d,0d,8d} };
     protected double[][] nullMatrix = null;
@@ -64,127 +65,128 @@ public final class MatrixUtilsTest exten
     protected Fraction[][] fractionColMatrix =
         {{new Fraction(0)},{new Fraction(4)},{new Fraction(6)}};
 
-    public MatrixUtilsTest(String name) {
-        super(name);
-    }
-
-
+    @Test
     public void testCreateRealMatrix() {
-        assertEquals(new BlockRealMatrix(testData),
+        Assert.assertEquals(new BlockRealMatrix(testData),
                 MatrixUtils.createRealMatrix(testData));
         try {
             MatrixUtils.createRealMatrix(new double[][] {{1}, {1,2}});  // ragged
-            fail("Expecting MathIllegalArgumentException");
+            Assert.fail("Expecting MathIllegalArgumentException");
         } catch (MathIllegalArgumentException ex) {
             // expected
         }
         try {
             MatrixUtils.createRealMatrix(new double[][] {{}, {}});  // no columns
-            fail("Expecting MathIllegalArgumentException");
+            Assert.fail("Expecting MathIllegalArgumentException");
         } catch (MathIllegalArgumentException ex) {
             // expected
         }
         try {
             MatrixUtils.createRealMatrix(null);  // null
-            fail("Expecting NullArgumentException");
+            Assert.fail("Expecting NullArgumentException");
         } catch (NullArgumentException ex) {
             // expected
         }
     }
 
+    @Test
     public void testcreateFieldMatrix() {
-        assertEquals(new Array2DRowFieldMatrix<Fraction>(asFraction(testData)),
+        Assert.assertEquals(new Array2DRowFieldMatrix<Fraction>(asFraction(testData)),
                      MatrixUtils.createFieldMatrix(asFraction(testData)));
-        assertEquals(new Array2DRowFieldMatrix<Fraction>(fractionColMatrix),
+        Assert.assertEquals(new Array2DRowFieldMatrix<Fraction>(fractionColMatrix),
                      MatrixUtils.createFieldMatrix(fractionColMatrix));
         try {
             MatrixUtils.createFieldMatrix(asFraction(new double[][] {{1}, {1,2}}));  // ragged
-            fail("Expecting MathIllegalArgumentException");
+            Assert.fail("Expecting MathIllegalArgumentException");
         } catch (MathIllegalArgumentException ex) {
             // expected
         }
         try {
             MatrixUtils.createFieldMatrix(asFraction(new double[][] {{}, {}}));  // no columns
-            fail("Expecting MathIllegalArgumentException");
+            Assert.fail("Expecting MathIllegalArgumentException");
         } catch (MathIllegalArgumentException ex) {
             // expected
         }
         try {
             MatrixUtils.createFieldMatrix((Fraction[][])null);  // null
-            fail("Expecting NullArgumentException");
+            Assert.fail("Expecting NullArgumentException");
         } catch (NullArgumentException ex) {
             // expected
         }
     }
 
+    @Test
     public void testCreateRowRealMatrix() {
-        assertEquals(MatrixUtils.createRowRealMatrix(row),
+        Assert.assertEquals(MatrixUtils.createRowRealMatrix(row),
                      new BlockRealMatrix(rowMatrix));
         try {
             MatrixUtils.createRowRealMatrix(new double[] {});  // empty
-            fail("Expecting NotStrictlyPositiveException");
+            Assert.fail("Expecting NotStrictlyPositiveException");
         } catch (NotStrictlyPositiveException ex) {
             // expected
         }
         try {
             MatrixUtils.createRowRealMatrix(null);  // null
-            fail("Expecting NullArgumentException");
+            Assert.fail("Expecting NullArgumentException");
         } catch (NullArgumentException ex) {
             // expected
         }
     }
 
+    @Test
     public void testCreateRowFieldMatrix() {
-        assertEquals(MatrixUtils.createRowFieldMatrix(asFraction(row)),
+        Assert.assertEquals(MatrixUtils.createRowFieldMatrix(asFraction(row)),
                      new Array2DRowFieldMatrix<Fraction>(asFraction(rowMatrix)));
-        assertEquals(MatrixUtils.createRowFieldMatrix(fractionRow),
+        Assert.assertEquals(MatrixUtils.createRowFieldMatrix(fractionRow),
                      new Array2DRowFieldMatrix<Fraction>(fractionRowMatrix));
         try {
             MatrixUtils.createRowFieldMatrix(new Fraction[] {});  // empty
-            fail("Expecting MathIllegalArgumentException");
+            Assert.fail("Expecting MathIllegalArgumentException");
         } catch (MathIllegalArgumentException ex) {
             // expected
         }
         try {
             MatrixUtils.createRowFieldMatrix((Fraction[]) null);  // null
-            fail("Expecting NullArgumentException");
+            Assert.fail("Expecting NullArgumentException");
         } catch (NullArgumentException ex) {
             // expected
         }
     }
 
+    @Test
     public void testCreateColumnRealMatrix() {
-        assertEquals(MatrixUtils.createColumnRealMatrix(col),
+        Assert.assertEquals(MatrixUtils.createColumnRealMatrix(col),
                      new BlockRealMatrix(colMatrix));
         try {
             MatrixUtils.createColumnRealMatrix(new double[] {});  // empty
-            fail("Expecting MathIllegalArgumentException");
+            Assert.fail("Expecting MathIllegalArgumentException");
         } catch (MathIllegalArgumentException ex) {
             // expected
         }
         try {
             MatrixUtils.createColumnRealMatrix(null);  // null
-            fail("Expecting NullArgumentException");
+            Assert.fail("Expecting NullArgumentException");
         } catch (NullArgumentException ex) {
             // expected
         }
     }
 
+    @Test
     public void testCreateColumnFieldMatrix() {
-        assertEquals(MatrixUtils.createColumnFieldMatrix(asFraction(col)),
+        Assert.assertEquals(MatrixUtils.createColumnFieldMatrix(asFraction(col)),
                      new Array2DRowFieldMatrix<Fraction>(asFraction(colMatrix)));
-        assertEquals(MatrixUtils.createColumnFieldMatrix(fractionCol),
+        Assert.assertEquals(MatrixUtils.createColumnFieldMatrix(fractionCol),
                      new Array2DRowFieldMatrix<Fraction>(fractionColMatrix));
 
         try {
             MatrixUtils.createColumnFieldMatrix(new Fraction[] {});  // empty
-            fail("Expecting MathIllegalArgumentException");
+            Assert.fail("Expecting MathIllegalArgumentException");
         } catch (MathIllegalArgumentException ex) {
             // expected
         }
         try {
             MatrixUtils.createColumnFieldMatrix((Fraction[]) null);  // null
-            fail("Expecting NullArgumentException");
+            Assert.fail("Expecting NullArgumentException");
         } catch (NullArgumentException ex) {
             // expected
         }
@@ -197,21 +199,22 @@ public final class MatrixUtilsTest exten
         for (int i = 0; i < m.getRowDimension(); i++) {
             for (int j =0; j < m.getColumnDimension(); j++) {
                 if (i == j) {
-                    assertEquals(m.getEntry(i, j), 1d, 0);
+                    Assert.assertEquals(m.getEntry(i, j), 1d, 0);
                 } else {
-                    assertEquals(m.getEntry(i, j), 0d, 0);
+                    Assert.assertEquals(m.getEntry(i, j), 0d, 0);
                 }
             }
         }
     }
 
+    @Test
     public void testCreateIdentityMatrix() {
         checkIdentityMatrix(MatrixUtils.createRealIdentityMatrix(3));
         checkIdentityMatrix(MatrixUtils.createRealIdentityMatrix(2));
         checkIdentityMatrix(MatrixUtils.createRealIdentityMatrix(1));
         try {
             MatrixUtils.createRealIdentityMatrix(0);
-            fail("Expecting MathIllegalArgumentException");
+            Assert.fail("Expecting MathIllegalArgumentException");
         } catch (MathIllegalArgumentException ex) {
             // expected
         }
@@ -224,26 +227,28 @@ public final class MatrixUtilsTest exten
         for (int i = 0; i < m.getRowDimension(); i++) {
             for (int j =0; j < m.getColumnDimension(); j++) {
                 if (i == j) {
-                    assertEquals(m.getEntry(i, j), Fraction.ONE);
+                    Assert.assertEquals(m.getEntry(i, j), Fraction.ONE);
                 } else {
-                    assertEquals(m.getEntry(i, j), Fraction.ZERO);
+                    Assert.assertEquals(m.getEntry(i, j), Fraction.ZERO);
                 }
             }
         }
     }
 
+    @Test
     public void testcreateFieldIdentityMatrix() {
         checkIdentityFieldMatrix(MatrixUtils.createFieldIdentityMatrix(FractionField.getInstance(), 3));
         checkIdentityFieldMatrix(MatrixUtils.createFieldIdentityMatrix(FractionField.getInstance(), 2));
         checkIdentityFieldMatrix(MatrixUtils.createFieldIdentityMatrix(FractionField.getInstance(), 1));
         try {
             MatrixUtils.createRealIdentityMatrix(0);
-            fail("Expecting MathIllegalArgumentException");
+            Assert.fail("Expecting MathIllegalArgumentException");
         } catch (MathIllegalArgumentException ex) {
             // expected
         }
     }
 
+    @Test
     public void testBigFractionConverter() {
         BigFraction[][] bfData = {
                 { new BigFraction(1), new BigFraction(2), new BigFraction(3) },
@@ -253,9 +258,10 @@ public final class MatrixUtilsTest exten
         FieldMatrix<BigFraction> m = new Array2DRowFieldMatrix<BigFraction>(bfData, false);
         RealMatrix converted = MatrixUtils.bigFractionMatrixToRealMatrix(m);
         RealMatrix reference = new Array2DRowRealMatrix(testData, false);
-        assertEquals(0.0, converted.subtract(reference).getNorm(), 0.0);
+        Assert.assertEquals(0.0, converted.subtract(reference).getNorm(), 0.0);
     }
 
+    @Test
     public void testFractionConverter() {
         Fraction[][] fData = {
                 { new Fraction(1), new Fraction(2), new Fraction(3) },
@@ -265,7 +271,7 @@ public final class MatrixUtilsTest exten
         FieldMatrix<Fraction> m = new Array2DRowFieldMatrix<Fraction>(fData, false);
         RealMatrix converted = MatrixUtils.fractionMatrixToRealMatrix(m);
         RealMatrix reference = new Array2DRowRealMatrix(testData, false);
-        assertEquals(0.0, converted.subtract(reference).getNorm(), 0.0);
+        Assert.assertEquals(0.0, converted.subtract(reference).getNorm(), 0.0);
     }
 
     public static final Fraction[][] asFraction(double[][] data) {
@@ -280,7 +286,7 @@ public final class MatrixUtilsTest exten
                 d[i] = dI;
             }
         } catch (FractionConversionException fce) {
-            fail(fce.getMessage());
+            Assert.fail(fce.getMessage());
         }
         return d;
     }
@@ -292,7 +298,7 @@ public final class MatrixUtilsTest exten
                 d[i] = new Fraction(data[i]);
             }
         } catch (FractionConversionException fce) {
-            fail(fce.getMessage());
+            Assert.fail(fce.getMessage());
         }
         return d;
     }

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/QRDecompositionImplTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/QRDecompositionImplTest.java?rev=1083514&r1=1083513&r2=1083514&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/QRDecompositionImplTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/QRDecompositionImplTest.java Sun Mar 20 17:24:14 2011
@@ -20,10 +20,11 @@ package org.apache.commons.math.linear;
 import java.util.Random;
 
 import org.apache.commons.math.exception.MathUserException;
+import org.junit.Assert;
+import org.junit.Test;
 
-import junit.framework.TestCase;
 
-public class QRDecompositionImplTest extends TestCase {
+public class QRDecompositionImplTest {
     double[][] testData3x3NonSingular = {
             { 12, -51, 4 },
             { 6, 167, -68 },
@@ -49,12 +50,9 @@ public class QRDecompositionImplTest ext
 
     private static final double normTolerance = 10e-14;
 
-    public QRDecompositionImplTest(String name) {
-        super(name);
-    }
-
     /** test dimensions 
      * @throws MathUserException */
+    @Test
     public void testDimensions() throws MathUserException {
         checkDimension(MatrixUtils.createRealMatrix(testData3x3NonSingular));
 
@@ -74,14 +72,15 @@ public class QRDecompositionImplTest ext
         int rows = m.getRowDimension();
         int columns = m.getColumnDimension();
         QRDecomposition qr = new QRDecompositionImpl(m);
-        assertEquals(rows,    qr.getQ().getRowDimension());
-        assertEquals(rows,    qr.getQ().getColumnDimension());
-        assertEquals(rows,    qr.getR().getRowDimension());
-        assertEquals(columns, qr.getR().getColumnDimension());
+        Assert.assertEquals(rows,    qr.getQ().getRowDimension());
+        Assert.assertEquals(rows,    qr.getQ().getColumnDimension());
+        Assert.assertEquals(rows,    qr.getR().getRowDimension());
+        Assert.assertEquals(columns, qr.getR().getColumnDimension());
     }
 
     /** test A = QR 
      * @throws MathUserException */
+    @Test
     public void testAEqualQR() throws MathUserException {
         checkAEqualQR(MatrixUtils.createRealMatrix(testData3x3NonSingular));
 
@@ -103,11 +102,12 @@ public class QRDecompositionImplTest ext
     private void checkAEqualQR(RealMatrix m) {
         QRDecomposition qr = new QRDecompositionImpl(m);
         double norm = qr.getQ().multiply(qr.getR()).subtract(m).getNorm();
-        assertEquals(0, norm, normTolerance);
+        Assert.assertEquals(0, norm, normTolerance);
     }
 
     /** test the orthogonality of Q 
      * @throws MathUserException */
+    @Test
     public void testQOrthogonal() throws MathUserException {
         checkQOrthogonal(MatrixUtils.createRealMatrix(testData3x3NonSingular));
 
@@ -130,10 +130,11 @@ public class QRDecompositionImplTest ext
         QRDecomposition qr = new QRDecompositionImpl(m);
         RealMatrix eye = MatrixUtils.createRealIdentityMatrix(m.getRowDimension());
         double norm = qr.getQT().multiply(qr.getQ()).subtract(eye).getNorm();
-        assertEquals(0, norm, normTolerance);
+        Assert.assertEquals(0, norm, normTolerance);
     }
 
     /** test that R is upper triangular */
+    @Test
     public void testRUpperTriangular() throws MathUserException {
         RealMatrix matrix = MatrixUtils.createRealMatrix(testData3x3NonSingular);
         checkUpperTriangular(new QRDecompositionImpl(matrix).getR());
@@ -163,7 +164,7 @@ public class QRDecompositionImplTest ext
             @Override
             public void visit(int row, int column, double value) {
                 if (column < row) {
-                    assertEquals(0.0, value, entryTolerance);
+                    Assert.assertEquals(0.0, value, entryTolerance);
                 }
             }
         });
@@ -171,6 +172,7 @@ public class QRDecompositionImplTest ext
 
     /** test that H is trapezoidal 
      * @throws MathUserException */
+    @Test
     public void testHTrapezoidal() throws MathUserException {
         RealMatrix matrix = MatrixUtils.createRealMatrix(testData3x3NonSingular);
         checkTrapezoidal(new QRDecompositionImpl(matrix).getH());
@@ -200,12 +202,13 @@ public class QRDecompositionImplTest ext
             @Override
             public void visit(int row, int column, double value) {
                 if (column > row) {
-                    assertEquals(0.0, value, entryTolerance);
+                    Assert.assertEquals(0.0, value, entryTolerance);
                 }
             }
         });
     }
     /** test matrices values */
+    @Test
     public void testMatricesValues() {
         QRDecomposition qr =
             new QRDecompositionImpl(MatrixUtils.createRealMatrix(testData3x3NonSingular));
@@ -227,18 +230,18 @@ public class QRDecompositionImplTest ext
 
         // check values against known references
         RealMatrix q = qr.getQ();
-        assertEquals(0, q.subtract(qRef).getNorm(), 1.0e-13);
+        Assert.assertEquals(0, q.subtract(qRef).getNorm(), 1.0e-13);
         RealMatrix qT = qr.getQT();
-        assertEquals(0, qT.subtract(qRef.transpose()).getNorm(), 1.0e-13);
+        Assert.assertEquals(0, qT.subtract(qRef.transpose()).getNorm(), 1.0e-13);
         RealMatrix r = qr.getR();
-        assertEquals(0, r.subtract(rRef).getNorm(), 1.0e-13);
+        Assert.assertEquals(0, r.subtract(rRef).getNorm(), 1.0e-13);
         RealMatrix h = qr.getH();
-        assertEquals(0, h.subtract(hRef).getNorm(), 1.0e-13);
+        Assert.assertEquals(0, h.subtract(hRef).getNorm(), 1.0e-13);
 
         // check the same cached instance is returned the second time
-        assertTrue(q == qr.getQ());
-        assertTrue(r == qr.getR());
-        assertTrue(h == qr.getH());
+        Assert.assertTrue(q == qr.getQ());
+        Assert.assertTrue(r == qr.getR());
+        Assert.assertTrue(h == qr.getH());
 
     }
 

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SingularValueDecompositionImplTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SingularValueDecompositionImplTest.java?rev=1083514&r1=1083513&r2=1083514&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SingularValueDecompositionImplTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SingularValueDecompositionImplTest.java Sun Mar 20 17:24:14 2011
@@ -19,9 +19,11 @@ package org.apache.commons.math.linear;
 
 import java.util.Random;
 
-import junit.framework.TestCase;
+import org.junit.Assert;
+import org.junit.Test;
 
-public class SingularValueDecompositionImplTest extends TestCase {
+
+public class SingularValueDecompositionImplTest {
 
     private double[][] testSquare = {
             { 24.0 / 25.0, 43.0 / 25.0 },
@@ -37,10 +39,7 @@ public class SingularValueDecompositionI
 
     private static final double normTolerance = 10e-14;
 
-    public SingularValueDecompositionImplTest(String name) {
-        super(name);
-    }
-
+    @Test
     public void testMoreRows() {
         final double[] singularValues = { 123.456, 2.3, 1.001, 0.999 };
         final int rows    = singularValues.length + 2;
@@ -49,12 +48,13 @@ public class SingularValueDecompositionI
         SingularValueDecomposition svd =
             new SingularValueDecompositionImpl(createTestMatrix(r, rows, columns, singularValues));
         double[] computedSV = svd.getSingularValues();
-        assertEquals(singularValues.length, computedSV.length);
+        Assert.assertEquals(singularValues.length, computedSV.length);
         for (int i = 0; i < singularValues.length; ++i) {
-            assertEquals(singularValues[i], computedSV[i], 1.0e-10);
+            Assert.assertEquals(singularValues[i], computedSV[i], 1.0e-10);
         }
     }
 
+    @Test
     public void testMoreColumns() {
         final double[] singularValues = { 123.456, 2.3, 1.001, 0.999 };
         final int rows    = singularValues.length;
@@ -63,28 +63,30 @@ public class SingularValueDecompositionI
         SingularValueDecomposition svd =
             new SingularValueDecompositionImpl(createTestMatrix(r, rows, columns, singularValues));
         double[] computedSV = svd.getSingularValues();
-        assertEquals(singularValues.length, computedSV.length);
+        Assert.assertEquals(singularValues.length, computedSV.length);
         for (int i = 0; i < singularValues.length; ++i) {
-            assertEquals(singularValues[i], computedSV[i], 1.0e-10);
+            Assert.assertEquals(singularValues[i], computedSV[i], 1.0e-10);
         }
     }
 
     /** test dimensions */
+    @Test
     public void testDimensions() {
         RealMatrix matrix = MatrixUtils.createRealMatrix(testSquare);
         final int m = matrix.getRowDimension();
         final int n = matrix.getColumnDimension();
         SingularValueDecomposition svd = new SingularValueDecompositionImpl(matrix);
-        assertEquals(m, svd.getU().getRowDimension());
-        assertEquals(m, svd.getU().getColumnDimension());
-        assertEquals(m, svd.getS().getColumnDimension());
-        assertEquals(n, svd.getS().getColumnDimension());
-        assertEquals(n, svd.getV().getRowDimension());
-        assertEquals(n, svd.getV().getColumnDimension());
+        Assert.assertEquals(m, svd.getU().getRowDimension());
+        Assert.assertEquals(m, svd.getU().getColumnDimension());
+        Assert.assertEquals(m, svd.getS().getColumnDimension());
+        Assert.assertEquals(n, svd.getS().getColumnDimension());
+        Assert.assertEquals(n, svd.getV().getRowDimension());
+        Assert.assertEquals(n, svd.getV().getColumnDimension());
 
     }
 
     /** Test based on a dimension 4 Hadamard matrix. */
+    @Test
     public void testHadamard() {
         RealMatrix matrix = new Array2DRowRealMatrix(new double[][] {
                 {15.0 / 2.0,  5.0 / 2.0,  9.0 / 2.0,  3.0 / 2.0 },
@@ -93,10 +95,10 @@ public class SingularValueDecompositionI
                 { 3.0 / 2.0,  9.0 / 2.0,  5.0 / 2.0, 15.0 / 2.0 }
         }, false);
         SingularValueDecomposition svd = new SingularValueDecompositionImpl(matrix);
-        assertEquals(16.0, svd.getSingularValues()[0], 1.0e-14);
-        assertEquals( 8.0, svd.getSingularValues()[1], 1.0e-14);
-        assertEquals( 4.0, svd.getSingularValues()[2], 1.0e-14);
-        assertEquals( 2.0, svd.getSingularValues()[3], 1.0e-14);
+        Assert.assertEquals(16.0, svd.getSingularValues()[0], 1.0e-14);
+        Assert.assertEquals( 8.0, svd.getSingularValues()[1], 1.0e-14);
+        Assert.assertEquals( 4.0, svd.getSingularValues()[2], 1.0e-14);
+        Assert.assertEquals( 2.0, svd.getSingularValues()[3], 1.0e-14);
 
         RealMatrix fullCovariance = new Array2DRowRealMatrix(new double[][] {
                 {  85.0 / 1024, -51.0 / 1024, -75.0 / 1024,  45.0 / 1024 },
@@ -104,7 +106,7 @@ public class SingularValueDecompositionI
                 { -75.0 / 1024,  45.0 / 1024,  85.0 / 1024, -51.0 / 1024 },
                 {  45.0 / 1024, -75.0 / 1024, -51.0 / 1024,  85.0 / 1024 }
         }, false);
-        assertEquals(0.0,
+        Assert.assertEquals(0.0,
                      fullCovariance.subtract(svd.getCovariance(0.0)).getNorm(),
                      1.0e-14);
 
@@ -114,13 +116,14 @@ public class SingularValueDecompositionI
                 {   5.0 / 1024,  -3.0 / 1024,   5.0 / 1024,  -3.0 / 1024 },
                 {  -3.0 / 1024,   5.0 / 1024,  -3.0 / 1024,   5.0 / 1024 }
         }, false);
-        assertEquals(0.0,
+        Assert.assertEquals(0.0,
                      halfCovariance.subtract(svd.getCovariance(6.0)).getNorm(),
                      1.0e-14);
 
     }
 
     /** test A = USVt */
+    @Test
     public void testAEqualUSVt() {
         checkAEqualUSVt(MatrixUtils.createRealMatrix(testSquare));
         checkAEqualUSVt(MatrixUtils.createRealMatrix(testNonSquare));
@@ -133,11 +136,12 @@ public class SingularValueDecompositionI
         RealMatrix s = svd.getS();
         RealMatrix v = svd.getV();
         double norm = u.multiply(s).multiply(v.transpose()).subtract(matrix).getNorm();
-        assertEquals(0, norm, normTolerance);
+        Assert.assertEquals(0, norm, normTolerance);
 
     }
 
     /** test that U is orthogonal */
+    @Test
     public void testUOrthogonal() {
         checkOrthogonal(new SingularValueDecompositionImpl(MatrixUtils.createRealMatrix(testSquare)).getU());
         checkOrthogonal(new SingularValueDecompositionImpl(MatrixUtils.createRealMatrix(testNonSquare)).getU());
@@ -145,6 +149,7 @@ public class SingularValueDecompositionI
     }
 
     /** test that V is orthogonal */
+    @Test
     public void testVOrthogonal() {
         checkOrthogonal(new SingularValueDecompositionImpl(MatrixUtils.createRealMatrix(testSquare)).getV());
         checkOrthogonal(new SingularValueDecompositionImpl(MatrixUtils.createRealMatrix(testNonSquare)).getV());
@@ -154,10 +159,11 @@ public class SingularValueDecompositionI
     public void checkOrthogonal(final RealMatrix m) {
         RealMatrix mTm = m.transpose().multiply(m);
         RealMatrix id  = MatrixUtils.createRealIdentityMatrix(mTm.getRowDimension());
-        assertEquals(0, mTm.subtract(id).getNorm(), normTolerance);
+        Assert.assertEquals(0, mTm.subtract(id).getNorm(), normTolerance);
     }
 
     /** test matrices values */
+    @Test
     public void testMatricesValues1() {
        SingularValueDecomposition svd =
             new SingularValueDecompositionImpl(MatrixUtils.createRealMatrix(testSquare));
@@ -176,16 +182,16 @@ public class SingularValueDecompositionI
 
         // check values against known references
         RealMatrix u = svd.getU();
-        assertEquals(0, u.subtract(uRef).getNorm(), normTolerance);
+        Assert.assertEquals(0, u.subtract(uRef).getNorm(), normTolerance);
         RealMatrix s = svd.getS();
-        assertEquals(0, s.subtract(sRef).getNorm(), normTolerance);
+        Assert.assertEquals(0, s.subtract(sRef).getNorm(), normTolerance);
         RealMatrix v = svd.getV();
-        assertEquals(0, v.subtract(vRef).getNorm(), normTolerance);
+        Assert.assertEquals(0, v.subtract(vRef).getNorm(), normTolerance);
 
         // check the same cached instance is returned the second time
-        assertTrue(u == svd.getU());
-        assertTrue(s == svd.getS());
-        assertTrue(v == svd.getV());
+        Assert.assertTrue(u == svd.getU());
+        Assert.assertTrue(s == svd.getS());
+        Assert.assertTrue(v == svd.getV());
 
     }
 
@@ -215,25 +221,26 @@ public class SingularValueDecompositionI
         SingularValueDecomposition svd =
             new SingularValueDecompositionImpl(MatrixUtils.createRealMatrix(testNonSquare));
         RealMatrix u = svd.getU();
-        assertEquals(0, u.subtract(uRef).getNorm(), normTolerance);
+        Assert.assertEquals(0, u.subtract(uRef).getNorm(), normTolerance);
         RealMatrix s = svd.getS();
-        assertEquals(0, s.subtract(sRef).getNorm(), normTolerance);
+        Assert.assertEquals(0, s.subtract(sRef).getNorm(), normTolerance);
         RealMatrix v = svd.getV();
-        assertEquals(0, v.subtract(vRef).getNorm(), normTolerance);
+        Assert.assertEquals(0, v.subtract(vRef).getNorm(), normTolerance);
 
         // check the same cached instance is returned the second time
-        assertTrue(u == svd.getU());
-        assertTrue(s == svd.getS());
-        assertTrue(v == svd.getV());
+        Assert.assertTrue(u == svd.getU());
+        Assert.assertTrue(s == svd.getS());
+        Assert.assertTrue(v == svd.getV());
 
     }
 
     /** test condition number */
+    @Test
     public void testConditionNumber() {
         SingularValueDecompositionImpl svd =
             new SingularValueDecompositionImpl(MatrixUtils.createRealMatrix(testSquare));
         // replace 1.0e-15 with 1.5e-15
-        assertEquals(3.0, svd.getConditionNumber(), 1.5e-15);
+        Assert.assertEquals(3.0, svd.getConditionNumber(), 1.5e-15);
     }
 
     private RealMatrix createTestMatrix(final Random r, final int rows, final int columns,

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SparseFieldMatrixTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SparseFieldMatrixTest.java?rev=1083514&r1=1083513&r2=1083514&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SparseFieldMatrixTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SparseFieldMatrixTest.java Sun Mar 20 17:24:14 2011
@@ -579,6 +579,7 @@ public class SparseFieldMatrixTest {
     }
 
     /* Disable for now
+    @Test
     public void testToString() {
         SparseFieldMatrix<Fraction> m = createSparseMatrix(testData);
         Assert.assertEquals("SparseFieldMatrix<Fraction>{{1.0,2.0,3.0},{2.0,5.0,3.0},{1.0,0.0,8.0}}",



Mime
View raw message