You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by lu...@apache.org on 2011/03/20 18:24:19 UTC

svn commit: r1083514 [10/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/ od...

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/correlation/PearsonsCorrelationTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/correlation/PearsonsCorrelationTest.java?rev=1083514&r1=1083513&r2=1083514&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/correlation/PearsonsCorrelationTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/correlation/PearsonsCorrelationTest.java Sun Mar 20 17:24:14 2011
@@ -22,10 +22,11 @@ import org.apache.commons.math.distribut
 import org.apache.commons.math.linear.RealMatrix;
 import org.apache.commons.math.linear.BlockRealMatrix;
 import org.apache.commons.math.util.FastMath;
+import org.junit.Assert;
+import org.junit.Test;
 
-import junit.framework.TestCase;
 
-public class PearsonsCorrelationTest extends TestCase {
+public class PearsonsCorrelationTest {
 
     protected final double[] longleyData = new double[] {
             60323,83.0,234289,2356,1590,107608,1947,
@@ -100,6 +101,7 @@ public class PearsonsCorrelationTest ext
     /**
      * Test Longley dataset against R.
      */
+    @Test
     public void testLongly() throws Exception {
         RealMatrix matrix = createRealMatrix(longleyData, 16, 7);
         PearsonsCorrelation corrInstance = new PearsonsCorrelation(matrix);
@@ -138,6 +140,7 @@ public class PearsonsCorrelationTest ext
     /**
      * Test R Swiss fertility dataset against R.
      */
+    @Test
     public void testSwissFertility() throws Exception {
          RealMatrix matrix = createRealMatrix(swissData, 47, 5);
          PearsonsCorrelation corrInstance = new PearsonsCorrelation(matrix);
@@ -165,6 +168,7 @@ public class PearsonsCorrelationTest ext
     /**
      * Test p-value near 0. JIRA: MATH-371
      */
+    @Test
     public void testPValueNearZero() throws Exception {
         /*
          * Create a dataset that has r -> 1, p -> 0 as dimension increases.
@@ -179,17 +183,18 @@ public class PearsonsCorrelationTest ext
             data[i][1] = i + 1/((double)i + 1);
         }
         PearsonsCorrelation corrInstance = new PearsonsCorrelation(data);
-        assertTrue(corrInstance.getCorrelationPValues().getEntry(0, 1) > 0);
+        Assert.assertTrue(corrInstance.getCorrelationPValues().getEntry(0, 1) > 0);
     }
     
 
     /**
      * Constant column
      */
+    @Test
     public void testConstant() {
         double[] noVariance = new double[] {1, 1, 1, 1};
         double[] values = new double[] {1, 2, 3, 4};
-        assertTrue(Double.isNaN(new PearsonsCorrelation().correlation(noVariance, values)));
+        Assert.assertTrue(Double.isNaN(new PearsonsCorrelation().correlation(noVariance, values)));
     }
 
 
@@ -197,19 +202,20 @@ public class PearsonsCorrelationTest ext
      * Insufficient data
      */
 
+    @Test
     public void testInsufficientData() {
         double[] one = new double[] {1};
         double[] two = new double[] {2};
         try {
             new PearsonsCorrelation().correlation(one, two);
-            fail("Expecting IllegalArgumentException");
+            Assert.fail("Expecting IllegalArgumentException");
         } catch (IllegalArgumentException ex) {
             // Expected
         }
         RealMatrix matrix = new BlockRealMatrix(new double[][] {{0},{1}});
         try {
             new PearsonsCorrelation(matrix);
-            fail("Expecting IllegalArgumentException");
+            Assert.fail("Expecting IllegalArgumentException");
         } catch (IllegalArgumentException ex) {
             // Expected
         }
@@ -219,6 +225,7 @@ public class PearsonsCorrelationTest ext
      * Verify that direct t-tests using standard error estimates are consistent
      * with reported p-values
      */
+    @Test
     public void testStdErrorConsistency() throws Exception {
         TDistribution tDistribution = new TDistributionImpl(45);
         RealMatrix matrix = createRealMatrix(swissData, 47, 5);
@@ -230,7 +237,7 @@ public class PearsonsCorrelationTest ext
             for (int j = 0; j < i; j++) {
                 double t = FastMath.abs(rValues.getEntry(i, j)) / stdErrors.getEntry(i, j);
                 double p = 2 * (1 - tDistribution.cumulativeProbability(t));
-                assertEquals(p, pValues.getEntry(i, j), 10E-15);
+                Assert.assertEquals(p, pValues.getEntry(i, j), 10E-15);
             }
         }
     }
@@ -239,6 +246,7 @@ public class PearsonsCorrelationTest ext
      * Verify that creating correlation from covariance gives same results as
      * direct computation from the original matrix
      */
+    @Test
     public void testCovarianceConsistency() throws Exception {
         RealMatrix matrix = createRealMatrix(longleyData, 16, 7);
         PearsonsCorrelation corrInstance = new PearsonsCorrelation(matrix);
@@ -262,13 +270,14 @@ public class PearsonsCorrelationTest ext
     }
 
 
+    @Test
     public void testConsistency() {
         RealMatrix matrix = createRealMatrix(longleyData, 16, 7);
         PearsonsCorrelation corrInstance = new PearsonsCorrelation(matrix);
         double[][] data = matrix.getData();
         double[] x = matrix.getColumn(0);
         double[] y = matrix.getColumn(1);
-        assertEquals(new PearsonsCorrelation().correlation(x, y),
+        Assert.assertEquals(new PearsonsCorrelation().correlation(x, y),
                 corrInstance.getCorrelationMatrix().getEntry(0, 1), Double.MIN_VALUE);
         TestUtils.assertEquals("Correlation matrix", corrInstance.getCorrelationMatrix(),
                 new PearsonsCorrelation().computeCorrelationMatrix(data), Double.MIN_VALUE);

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/correlation/SpearmansRankCorrelationTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/correlation/SpearmansRankCorrelationTest.java?rev=1083514&r1=1083513&r2=1083514&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/correlation/SpearmansRankCorrelationTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/correlation/SpearmansRankCorrelationTest.java Sun Mar 20 17:24:14 2011
@@ -19,6 +19,8 @@ package org.apache.commons.math.stat.cor
 import org.apache.commons.math.TestUtils;
 import org.apache.commons.math.linear.BlockRealMatrix;
 import org.apache.commons.math.linear.RealMatrix;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * Test cases for Spearman's rank correlation
@@ -28,20 +30,11 @@ import org.apache.commons.math.linear.Re
  */
 public class SpearmansRankCorrelationTest extends PearsonsCorrelationTest {
 
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-    }
-
-    @Override
-    protected void tearDown() throws Exception {
-        super.tearDown();
-    }
-
     /**
      * Test Longley dataset against R.
      */
     @Override
+    @Test
     public void testLongly() throws Exception {
         RealMatrix matrix = createRealMatrix(longleyData, 16, 7);
         SpearmansCorrelation corrInstance = new SpearmansCorrelation(matrix);
@@ -62,6 +55,7 @@ public class SpearmansRankCorrelationTes
     /**
      * Test R swiss fertility dataset.
      */
+    @Test
     public void testSwiss() throws Exception {
         RealMatrix matrix = createRealMatrix(swissData, 47, 5);
         SpearmansCorrelation corrInstance = new SpearmansCorrelation(matrix);
@@ -80,42 +74,45 @@ public class SpearmansRankCorrelationTes
      * Constant column
      */
     @Override
+    @Test
     public void testConstant() {
         double[] noVariance = new double[] {1, 1, 1, 1};
         double[] values = new double[] {1, 2, 3, 4};
-        assertTrue(Double.isNaN(new SpearmansCorrelation().correlation(noVariance, values)));
+        Assert.assertTrue(Double.isNaN(new SpearmansCorrelation().correlation(noVariance, values)));
     }
 
     /**
      * Insufficient data
      */
     @Override
+    @Test
     public void testInsufficientData() {
         double[] one = new double[] {1};
         double[] two = new double[] {2};
         try {
             new SpearmansCorrelation().correlation(one, two);
-            fail("Expecting IllegalArgumentException");
+            Assert.fail("Expecting IllegalArgumentException");
         } catch (IllegalArgumentException ex) {
             // Expected
         }
         RealMatrix matrix = new BlockRealMatrix(new double[][] {{0},{1}});
         try {
             new SpearmansCorrelation(matrix);
-            fail("Expecting IllegalArgumentException");
+            Assert.fail("Expecting IllegalArgumentException");
         } catch (IllegalArgumentException ex) {
             // Expected
         }
     }
 
     @Override
+    @Test
     public void testConsistency() {
         RealMatrix matrix = createRealMatrix(longleyData, 16, 7);
         SpearmansCorrelation corrInstance = new SpearmansCorrelation(matrix);
         double[][] data = matrix.getData();
         double[] x = matrix.getColumn(0);
         double[] y = matrix.getColumn(1);
-        assertEquals(new SpearmansCorrelation().correlation(x, y),
+        Assert.assertEquals(new SpearmansCorrelation().correlation(x, y),
                 corrInstance.getCorrelationMatrix().getEntry(0, 1), Double.MIN_VALUE);
         TestUtils.assertEquals("Correlation matrix", corrInstance.getCorrelationMatrix(),
                 new SpearmansCorrelation().computeCorrelationMatrix(data), Double.MIN_VALUE);
@@ -123,8 +120,10 @@ public class SpearmansRankCorrelationTes
 
     // Not relevant here
     @Override
+    @Test
     public void testStdErrorConsistency() throws Exception {}
     @Override
+    @Test
     public void testCovarianceConsistency() throws Exception {}
 
 }

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/data/CertifiedDataAbstractTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/data/CertifiedDataAbstractTest.java?rev=1083514&r1=1083513&r2=1083514&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/data/CertifiedDataAbstractTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/data/CertifiedDataAbstractTest.java Sun Mar 20 17:24:14 2011
@@ -26,16 +26,19 @@ import java.net.URL;
 import java.util.HashMap;
 import java.util.Map;
 
-import junit.framework.TestCase;
 
 import org.apache.commons.math.TestUtils;
 import org.apache.commons.math.stat.descriptive.DescriptiveStatistics;
 import org.apache.commons.math.stat.descriptive.SummaryStatistics;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
 
 /**
  * @version $Revision$ $Date$
  */
-public abstract class CertifiedDataAbstractTest extends TestCase {
+public abstract class CertifiedDataAbstractTest {
 
     private DescriptiveStatistics descriptives;
 
@@ -43,8 +46,8 @@ public abstract class CertifiedDataAbstr
 
     private Map<String, Double> certifiedValues;
 
-    @Override
-    protected void setUp() throws Exception {
+    @Before
+    public void setUp() throws IOException {
         descriptives = new DescriptiveStatistics();
         summaries = new SummaryStatistics();
         certifiedValues = new HashMap<String, Double>();
@@ -98,8 +101,8 @@ public abstract class CertifiedDataAbstr
         return 1.0e-5;
     }
 
-    @Override
-    protected void tearDown() throws Exception {
+    @After
+    public void tearDown() throws Exception {
         descriptives.clear();
         descriptives = null;
 
@@ -110,6 +113,7 @@ public abstract class CertifiedDataAbstr
         certifiedValues = null;
     }
 
+    @Test
     public void testCertifiedValues() {
         for (String name : certifiedValues.keySet()) {
             Double expectedValue = certifiedValues.get(name);
@@ -142,14 +146,14 @@ public abstract class CertifiedDataAbstr
             } else if (meth.getReturnType().equals(Long.TYPE)) {
                 return Double.valueOf(((Long) property).doubleValue());
             } else {
-                fail("wrong type: " + meth.getReturnType().getName());
+                Assert.fail("wrong type: " + meth.getReturnType().getName());
             }
         } catch (NoSuchMethodException nsme) {
             // ignored
         } catch (InvocationTargetException ite) {
-            fail(ite.getMessage());
+            Assert.fail(ite.getMessage());
         } catch (IllegalAccessException iae) {
-            fail(iae.getMessage());
+            Assert.fail(iae.getMessage());
         }
         return null;
     }

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/AbstractUnivariateStatisticTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/AbstractUnivariateStatisticTest.java?rev=1083514&r1=1083513&r2=1083514&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/AbstractUnivariateStatisticTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/AbstractUnivariateStatisticTest.java Sun Mar 20 17:24:14 2011
@@ -16,21 +16,18 @@
  */
 package org.apache.commons.math.stat.descriptive;
 
-import junit.framework.TestCase;
 
 import org.apache.commons.math.exception.MathIllegalArgumentException;
 import org.apache.commons.math.stat.descriptive.moment.Mean;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * Tests for AbstractUnivariateStatistic
  *
  * @version $Revision$ $Date$
  */
-public class AbstractUnivariateStatisticTest extends TestCase {
-
-    public AbstractUnivariateStatisticTest(String name) {
-        super(name);
-    }
+public class AbstractUnivariateStatisticTest {
 
     protected double[] testArray = {0, 1, 2, 3, 4, 5};
     protected double[] testWeightsArray = {0.3, 0.2, 1.3, 1.1, 1.0, 1.8};
@@ -39,64 +36,66 @@ public class AbstractUnivariateStatistic
     protected double[] singletonArray = {0};
     protected Mean testStatistic = new Mean();
 
+    @Test
     public void testTestPositive() {
         for (int j = 0; j < 6; j++) {
             for (int i = 1; i < (7 - j); i++) {
-                assertTrue(testStatistic.test(testArray, 0, i));
+                Assert.assertTrue(testStatistic.test(testArray, 0, i));
             }
         }
-        assertTrue(testStatistic.test(singletonArray, 0, 1));
-        assertTrue(testStatistic.test(singletonArray, 0, 0, true));
+        Assert.assertTrue(testStatistic.test(singletonArray, 0, 1));
+        Assert.assertTrue(testStatistic.test(singletonArray, 0, 0, true));
     }
 
+    @Test
     public void testTestNegative() {
-        assertFalse(testStatistic.test(singletonArray, 0, 0));
-        assertFalse(testStatistic.test(testArray, 0, 0));
+        Assert.assertFalse(testStatistic.test(singletonArray, 0, 0));
+        Assert.assertFalse(testStatistic.test(testArray, 0, 0));
         try {
             testStatistic.test(singletonArray, 2, 1);  // start past end
-            fail("Expecting MathIllegalArgumentException");
+            Assert.fail("Expecting MathIllegalArgumentException");
         } catch (MathIllegalArgumentException ex) {
             // expected
         }
         try {
             testStatistic.test(testArray, 0, 7);  // end past end
-            fail("Expecting MathIllegalArgumentException");
+            Assert.fail("Expecting MathIllegalArgumentException");
         } catch (MathIllegalArgumentException ex) {
             // expected
         }
         try {
             testStatistic.test(testArray, -1, 1);  // start negative
-            fail("Expecting MathIllegalArgumentException");
+            Assert.fail("Expecting MathIllegalArgumentException");
         } catch (MathIllegalArgumentException ex) {
             // expected
         }
         try {
             testStatistic.test(testArray, 0, -1);  // length negative
-            fail("Expecting MathIllegalArgumentException");
+            Assert.fail("Expecting MathIllegalArgumentException");
         } catch (MathIllegalArgumentException ex) {
             // expected
         }
         try {
             testStatistic.test(nullArray, 0, 1);  // null array
-            fail("Expecting MathIllegalArgumentException");
+            Assert.fail("Expecting MathIllegalArgumentException");
         } catch (MathIllegalArgumentException ex) {
             // expected
         }
         try {
             testStatistic.test(testArray, nullArray, 0, 1);  // null weights array
-            fail("Expecting MathIllegalArgumentException");
+            Assert.fail("Expecting MathIllegalArgumentException");
         } catch (MathIllegalArgumentException ex) {
             // expected
         }
         try {
             testStatistic.test(singletonArray, testWeightsArray, 0, 1);  // weights.length != value.length
-            fail("Expecting MathIllegalArgumentException");
+            Assert.fail("Expecting MathIllegalArgumentException");
         } catch (MathIllegalArgumentException ex) {
             // expected
         }
         try {
             testStatistic.test(testArray, testNegativeWeightsArray, 0, 6);  // can't have negative weights
-            fail("Expecting MathIllegalArgumentException");
+            Assert.fail("Expecting MathIllegalArgumentException");
         } catch (MathIllegalArgumentException ex) {
             // expected
         }

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/AggregateSummaryStatisticsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/AggregateSummaryStatisticsTest.java?rev=1083514&r1=1083513&r2=1083514&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/AggregateSummaryStatisticsTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/AggregateSummaryStatisticsTest.java Sun Mar 20 17:24:14 2011
@@ -20,47 +20,50 @@ package org.apache.commons.math.stat.des
 import java.util.ArrayList;
 import java.util.Collection;
 
-import junit.framework.TestCase;
 
 import org.apache.commons.math.TestUtils;
 import org.apache.commons.math.random.RandomData;
 import org.apache.commons.math.random.RandomDataImpl;
+import org.apache.commons.math.util.MathUtils;
+import org.junit.Assert;
+import org.junit.Test;
 
 
 /**
  * Test cases for {@link AggregateSummaryStatistics}
  *
  */
-public class AggregateSummaryStatisticsTest extends TestCase {
+public class AggregateSummaryStatisticsTest {
 
     /**
      * Tests the standard aggregation behavior
      */
+    @Test
     public void testAggregation() {
         AggregateSummaryStatistics aggregate = new AggregateSummaryStatistics();
         SummaryStatistics setOneStats = aggregate.createContributingStatistics();
         SummaryStatistics setTwoStats = aggregate.createContributingStatistics();
 
-        assertNotNull("The set one contributing stats are null", setOneStats);
-        assertNotNull("The set two contributing stats are null", setTwoStats);
-        assertNotSame("Contributing stats objects are the same", setOneStats, setTwoStats);
+        Assert.assertNotNull("The set one contributing stats are null", setOneStats);
+        Assert.assertNotNull("The set two contributing stats are null", setTwoStats);
+        Assert.assertNotSame("Contributing stats objects are the same", setOneStats, setTwoStats);
 
         setOneStats.addValue(2);
         setOneStats.addValue(3);
         setOneStats.addValue(5);
         setOneStats.addValue(7);
         setOneStats.addValue(11);
-        assertEquals("Wrong number of set one values", 5, setOneStats.getN());
-        assertEquals("Wrong sum of set one values", 28.0, setOneStats.getSum());
+        Assert.assertEquals("Wrong number of set one values", 5, setOneStats.getN());
+        Assert.assertTrue("Wrong sum of set one values", MathUtils.equals(28.0, setOneStats.getSum(), 1));
 
         setTwoStats.addValue(2);
         setTwoStats.addValue(4);
         setTwoStats.addValue(8);
-        assertEquals("Wrong number of set two values", 3, setTwoStats.getN());
-        assertEquals("Wrong sum of set two values", 14.0, setTwoStats.getSum());
+        Assert.assertEquals("Wrong number of set two values", 3, setTwoStats.getN());
+        Assert.assertTrue("Wrong sum of set two values", MathUtils.equals(14.0, setTwoStats.getSum(), 1));
 
-        assertEquals("Wrong number of aggregate values", 8, aggregate.getN());
-        assertEquals("Wrong aggregate sum", 42.0, aggregate.getSum());
+        Assert.assertEquals("Wrong number of aggregate values", 8, aggregate.getN());
+        Assert.assertTrue("Wrong aggregate sum", MathUtils.equals(42.0, aggregate.getSum(), 1));
     }
 
     /**
@@ -76,6 +79,7 @@ public class AggregateSummaryStatisticsT
      *     returned by a single SummaryStatistics instance that is provided
      *     the full dataset
      */
+    @Test
     public void testAggregationConsistency() throws Exception {
 
         // Generate a random sample and random partition
@@ -113,7 +117,7 @@ public class AggregateSummaryStatisticsT
          * as <totalStats>.
          *
          */
-        assertEquals(totalStats.getSummary(), aggregate.getSummary());
+        Assert.assertEquals(totalStats.getSummary(), aggregate.getSummary());
 
     }
 
@@ -126,6 +130,7 @@ public class AggregateSummaryStatisticsT
      *
      * @throws Exception
      */
+    @Test
     public void testAggregate() throws Exception {
 
         // Generate a random sample and random partition
@@ -158,6 +163,7 @@ public class AggregateSummaryStatisticsT
     }
 
 
+    @Test
     public void testAggregateDegenerate() throws Exception {
         double[] totalSample = {1, 2, 3, 4, 5};
         double[][] subSamples = {{1}, {2}, {3}, {4}, {5}};
@@ -186,6 +192,7 @@ public class AggregateSummaryStatisticsT
         assertEquals(totalStats.getSummary(), aggregatedStats, 10E-12);
     }
 
+    @Test
     public void testAggregateSpecialValues() throws Exception {
         double[] totalSample = {Double.POSITIVE_INFINITY, 2, 3, Double.NaN, 5};
         double[][] subSamples = {{Double.POSITIVE_INFINITY, 2}, {3}, {Double.NaN}, {5}};
@@ -223,7 +230,7 @@ public class AggregateSummaryStatisticsT
     protected static void assertEquals(StatisticalSummary expected, StatisticalSummary observed, double delta) {
         TestUtils.assertEquals(expected.getMax(), observed.getMax(), 0);
         TestUtils.assertEquals(expected.getMin(), observed.getMin(), 0);
-        assertEquals(expected.getN(), observed.getN());
+        Assert.assertEquals(expected.getN(), observed.getN());
         TestUtils.assertEquals(expected.getSum(), observed.getSum(), delta);
         TestUtils.assertEquals(expected.getMean(), observed.getMean(), delta);
         TestUtils.assertEquals(expected.getStandardDeviation(), observed.getStandardDeviation(), delta);

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/DescriptiveStatisticsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/DescriptiveStatisticsTest.java?rev=1083514&r1=1083513&r2=1083514&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/DescriptiveStatisticsTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/DescriptiveStatisticsTest.java Sun Mar 20 17:24:14 2011
@@ -15,10 +15,11 @@ package org.apache.commons.math.stat.des
 
 import java.util.Locale;
 
-import junit.framework.TestCase;
 
 import org.apache.commons.math.stat.descriptive.rank.Percentile;
 import org.apache.commons.math.util.MathUtils;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * Test cases for the DescriptiveStatistics class.
@@ -26,38 +27,37 @@ import org.apache.commons.math.util.Math
  * @version $Revision$ $Date: 2007-08-16 15:36:33 -0500 (Thu, 16 Aug
  *          2007) $
  */
-public class DescriptiveStatisticsTest extends TestCase {
-
-    public DescriptiveStatisticsTest(String name) {
-        super(name);
-    }
+public class DescriptiveStatisticsTest {
 
     protected DescriptiveStatistics createDescriptiveStatistics() {
         return new DescriptiveStatistics();
     }
 
+    @Test
     public void testSetterInjection() {
         DescriptiveStatistics stats = createDescriptiveStatistics();
         stats.addValue(1);
         stats.addValue(3);
-        assertEquals(2, stats.getMean(), 1E-10);
+        Assert.assertEquals(2, stats.getMean(), 1E-10);
         // Now lets try some new math
         stats.setMeanImpl(new deepMean());
-        assertEquals(42, stats.getMean(), 1E-10);
+        Assert.assertEquals(42, stats.getMean(), 1E-10);
     }
 
+    @Test
     public void testCopy() {
         DescriptiveStatistics stats = createDescriptiveStatistics();
         stats.addValue(1);
         stats.addValue(3);
         DescriptiveStatistics copy = new DescriptiveStatistics(stats);
-        assertEquals(2, copy.getMean(), 1E-10);
+        Assert.assertEquals(2, copy.getMean(), 1E-10);
         // Now lets try some new math
         stats.setMeanImpl(new deepMean());
         copy = stats.copy();
-        assertEquals(42, copy.getMean(), 1E-10);
+        Assert.assertEquals(42, copy.getMean(), 1E-10);
     }
 
+    @Test
     public void testWindowSize() {
         DescriptiveStatistics stats = createDescriptiveStatistics();
         stats.setWindowSize(300);
@@ -65,39 +65,41 @@ public class DescriptiveStatisticsTest e
             stats.addValue(i + 1);
         }
         int refSum = (100 * 101) / 2;
-        assertEquals(refSum / 100.0, stats.getMean(), 1E-10);
-        assertEquals(300, stats.getWindowSize());
+        Assert.assertEquals(refSum / 100.0, stats.getMean(), 1E-10);
+        Assert.assertEquals(300, stats.getWindowSize());
         try {
             stats.setWindowSize(-3);
-            fail("an exception should have been thrown");
+            Assert.fail("an exception should have been thrown");
         } catch (IllegalArgumentException iae) {
             // expected
         }
-        assertEquals(300, stats.getWindowSize());
+        Assert.assertEquals(300, stats.getWindowSize());
         stats.setWindowSize(50);
-        assertEquals(50, stats.getWindowSize());
+        Assert.assertEquals(50, stats.getWindowSize());
         int refSum2 = refSum - (50 * 51) / 2;
-        assertEquals(refSum2 / 50.0, stats.getMean(), 1E-10);
+        Assert.assertEquals(refSum2 / 50.0, stats.getMean(), 1E-10);
     }
 
+    @Test
     public void testGetValues() {
         DescriptiveStatistics stats = createDescriptiveStatistics();
         for (int i = 100; i > 0; --i) {
             stats.addValue(i);
         }
         int refSum = (100 * 101) / 2;
-        assertEquals(refSum / 100.0, stats.getMean(), 1E-10);
+        Assert.assertEquals(refSum / 100.0, stats.getMean(), 1E-10);
         double[] v = stats.getValues();
         for (int i = 0; i < v.length; ++i) {
-            assertEquals(100.0 - i, v[i], 1.0e-10);
+            Assert.assertEquals(100.0 - i, v[i], 1.0e-10);
         }
         double[] s = stats.getSortedValues();
         for (int i = 0; i < s.length; ++i) {
-            assertEquals(i + 1.0, s[i], 1.0e-10);
+            Assert.assertEquals(i + 1.0, s[i], 1.0e-10);
         }
-        assertEquals(12.0, stats.getElement(88), 1.0e-10);
+        Assert.assertEquals(12.0, stats.getElement(88), 1.0e-10);
     }
 
+    @Test
     public void testToString() {
         DescriptiveStatistics stats = createDescriptiveStatistics();
         stats.addValue(1);
@@ -105,7 +107,7 @@ public class DescriptiveStatisticsTest e
         stats.addValue(3);
         Locale d = Locale.getDefault();
         Locale.setDefault(Locale.US);
-        assertEquals("DescriptiveStatistics:\n" +
+        Assert.assertEquals("DescriptiveStatistics:\n" +
                      "n: 3\n" +
                      "min: 1.0\n" +
                      "max: 3.0\n" +
@@ -117,6 +119,7 @@ public class DescriptiveStatisticsTest e
         Locale.setDefault(d);
     }
 
+    @Test
     public void testShuffledStatistics() {
         // the purpose of this test is only to check the get/set methods
         // we are aware shuffling statistics like this is really not
@@ -140,42 +143,44 @@ public class DescriptiveStatisticsTest e
             shuffled.addValue(i);
         }
 
-        assertEquals(reference.getMean(),          shuffled.getGeometricMean(), 1.0e-10);
-        assertEquals(reference.getKurtosis(),      shuffled.getMean(),          1.0e-10);
-        assertEquals(reference.getSkewness(),      shuffled.getKurtosis(), 1.0e-10);
-        assertEquals(reference.getVariance(),      shuffled.getSkewness(), 1.0e-10);
-        assertEquals(reference.getMax(),           shuffled.getVariance(), 1.0e-10);
-        assertEquals(reference.getMin(),           shuffled.getMax(), 1.0e-10);
-        assertEquals(reference.getSum(),           shuffled.getMin(), 1.0e-10);
-        assertEquals(reference.getSumsq(),         shuffled.getSum(), 1.0e-10);
-        assertEquals(reference.getGeometricMean(), shuffled.getSumsq(), 1.0e-10);
+        Assert.assertEquals(reference.getMean(),          shuffled.getGeometricMean(), 1.0e-10);
+        Assert.assertEquals(reference.getKurtosis(),      shuffled.getMean(),          1.0e-10);
+        Assert.assertEquals(reference.getSkewness(),      shuffled.getKurtosis(), 1.0e-10);
+        Assert.assertEquals(reference.getVariance(),      shuffled.getSkewness(), 1.0e-10);
+        Assert.assertEquals(reference.getMax(),           shuffled.getVariance(), 1.0e-10);
+        Assert.assertEquals(reference.getMin(),           shuffled.getMax(), 1.0e-10);
+        Assert.assertEquals(reference.getSum(),           shuffled.getMin(), 1.0e-10);
+        Assert.assertEquals(reference.getSumsq(),         shuffled.getSum(), 1.0e-10);
+        Assert.assertEquals(reference.getGeometricMean(), shuffled.getSumsq(), 1.0e-10);
 
     }
 
+    @Test
     public void testPercentileSetter() throws Exception {
         DescriptiveStatistics stats = createDescriptiveStatistics();
         stats.addValue(1);
         stats.addValue(2);
         stats.addValue(3);
-        assertEquals(2, stats.getPercentile(50.0), 1E-10);
+        Assert.assertEquals(2, stats.getPercentile(50.0), 1E-10);
 
         // Inject wrapped Percentile impl
         stats.setPercentileImpl(new goodPercentile());
-        assertEquals(2, stats.getPercentile(50.0), 1E-10);
+        Assert.assertEquals(2, stats.getPercentile(50.0), 1E-10);
 
         // Try "new math" impl
         stats.setPercentileImpl(new subPercentile());
-        assertEquals(10.0, stats.getPercentile(10.0), 1E-10);
+        Assert.assertEquals(10.0, stats.getPercentile(10.0), 1E-10);
 
         // Try to set bad impl
         try {
             stats.setPercentileImpl(new badPercentile());
-            fail("Expecting IllegalArgumentException");
+            Assert.fail("Expecting IllegalArgumentException");
         } catch (IllegalArgumentException ex) {
             // expected
         }
     }
 
+    @Test
     public void test20090720() {
         DescriptiveStatistics descriptiveStatistics = new DescriptiveStatistics(100);
         for (int i = 0; i < 161; i++) {
@@ -183,9 +188,10 @@ public class DescriptiveStatisticsTest e
         }
         descriptiveStatistics.clear();
         descriptiveStatistics.addValue(1.2);
-        assertEquals(1, descriptiveStatistics.getN());
+        Assert.assertEquals(1, descriptiveStatistics.getN());
     }
 
+    @Test
     public void testRemoval() {
 
         final DescriptiveStatistics dstat = createDescriptiveStatistics();
@@ -208,11 +214,11 @@ public class DescriptiveStatisticsTest e
             dstat.addValue(i);
         }
 
-        assertTrue(MathUtils.equalsIncludingNaN(mean1, dstat.getMean()));
+        Assert.assertTrue(MathUtils.equalsIncludingNaN(mean1, dstat.getMean()));
         dstat.replaceMostRecentValue(0);
-        assertTrue(MathUtils.equalsIncludingNaN(mean2, dstat.getMean()));
+        Assert.assertTrue(MathUtils.equalsIncludingNaN(mean2, dstat.getMean()));
         dstat.removeMostRecentValue();
-        assertTrue(MathUtils.equalsIncludingNaN(mean3, dstat.getMean()));
+        Assert.assertTrue(MathUtils.equalsIncludingNaN(mean3, dstat.getMean()));
 
     }
 

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/InteractionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/InteractionTest.java?rev=1083514&r1=1083513&r2=1083514&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/InteractionTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/InteractionTest.java Sun Mar 20 17:24:14 2011
@@ -21,13 +21,14 @@ import org.apache.commons.math.stat.desc
 import org.apache.commons.math.stat.descriptive.moment.Mean;
 import org.apache.commons.math.stat.descriptive.moment.Skewness;
 import org.apache.commons.math.stat.descriptive.moment.Variance;
+import org.junit.Assert;
+import org.junit.Test;
 
-import junit.framework.TestCase;
 
 /**
  * @version $Revision$ $Date$
  */
-public class InteractionTest extends TestCase {
+public class InteractionTest {
 
     protected double mean = 12.40454545454550;
     protected double var = 10.00235930735930;
@@ -61,11 +62,7 @@ public class InteractionTest extends Tes
             9,
             12.3 };
 
-    public InteractionTest(String name) {
-        super(name);
-    }
-
-
+    @Test
     public void testInteraction() {
 
         FourthMoment m4 = new FourthMoment();
@@ -78,10 +75,10 @@ public class InteractionTest extends Tes
             m4.increment(testArray[i]);
         }
 
-        assertEquals(mean,m.getResult(),tolerance);
-        assertEquals(var,v.getResult(),tolerance);
-        assertEquals(skew ,s.getResult(),tolerance);
-        assertEquals(kurt,k.getResult(),tolerance);
+        Assert.assertEquals(mean,m.getResult(),tolerance);
+        Assert.assertEquals(var,v.getResult(),tolerance);
+        Assert.assertEquals(skew ,s.getResult(),tolerance);
+        Assert.assertEquals(kurt,k.getResult(),tolerance);
 
     }
 

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/ListUnivariateImplTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/ListUnivariateImplTest.java?rev=1083514&r1=1083513&r2=1083514&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/ListUnivariateImplTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/ListUnivariateImplTest.java Sun Mar 20 17:24:14 2011
@@ -19,10 +19,11 @@ package org.apache.commons.math.stat.des
 import java.util.ArrayList;
 import java.util.List;
 
-import junit.framework.TestCase;
 
 import org.apache.commons.math.TestUtils;
 import org.apache.commons.math.util.FastMath;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * Test cases for the {@link ListUnivariateImpl} class.
@@ -30,7 +31,7 @@ import org.apache.commons.math.util.Fast
  * @version $Revision$ $Date$
  */
 
-public final class ListUnivariateImplTest extends TestCase {
+public final class ListUnivariateImplTest {
 
     private double one = 1;
     private float two = 2;
@@ -46,49 +47,48 @@ public final class ListUnivariateImplTes
     private double max = 3;
     private double tolerance = 10E-15;
 
-    public ListUnivariateImplTest(String name) {
-        super(name);
-    }
-
     /** test stats */
+    @Test
     public void testStats() {
         List<Object> externalList = new ArrayList<Object>();
 
         DescriptiveStatistics u = new ListUnivariateImpl( externalList );
 
-        assertEquals("total count",0,u.getN(),tolerance);
+        Assert.assertEquals("total count",0,u.getN(),tolerance);
         u.addValue(one);
         u.addValue(two);
         u.addValue(two);
         u.addValue(three);
-        assertEquals("N",n,u.getN(),tolerance);
-        assertEquals("sum",sum,u.getSum(),tolerance);
-        assertEquals("sumsq",sumSq,u.getSumsq(),tolerance);
-        assertEquals("var",var,u.getVariance(),tolerance);
-        assertEquals("std",std,u.getStandardDeviation(),tolerance);
-        assertEquals("mean",mean,u.getMean(),tolerance);
-        assertEquals("min",min,u.getMin(),tolerance);
-        assertEquals("max",max,u.getMax(),tolerance);
+        Assert.assertEquals("N",n,u.getN(),tolerance);
+        Assert.assertEquals("sum",sum,u.getSum(),tolerance);
+        Assert.assertEquals("sumsq",sumSq,u.getSumsq(),tolerance);
+        Assert.assertEquals("var",var,u.getVariance(),tolerance);
+        Assert.assertEquals("std",std,u.getStandardDeviation(),tolerance);
+        Assert.assertEquals("mean",mean,u.getMean(),tolerance);
+        Assert.assertEquals("min",min,u.getMin(),tolerance);
+        Assert.assertEquals("max",max,u.getMax(),tolerance);
         u.clear();
-        assertEquals("total count",0,u.getN(),tolerance);
+        Assert.assertEquals("total count",0,u.getN(),tolerance);
     }
 
+    @Test
     public void testN0andN1Conditions() throws Exception {
         List<Object> list = new ArrayList<Object>();
 
         DescriptiveStatistics u = new ListUnivariateImpl( list );
 
-        assertTrue("Mean of n = 0 set should be NaN", Double.isNaN( u.getMean() ) );
-        assertTrue("Standard Deviation of n = 0 set should be NaN", Double.isNaN( u.getStandardDeviation() ) );
-        assertTrue("Variance of n = 0 set should be NaN", Double.isNaN(u.getVariance() ) );
+        Assert.assertTrue("Mean of n = 0 set should be NaN", Double.isNaN( u.getMean() ) );
+        Assert.assertTrue("Standard Deviation of n = 0 set should be NaN", Double.isNaN( u.getStandardDeviation() ) );
+        Assert.assertTrue("Variance of n = 0 set should be NaN", Double.isNaN(u.getVariance() ) );
 
         list.add( Double.valueOf(one));
 
-        assertTrue( "Mean of n = 1 set should be value of single item n1", u.getMean() == one);
-        assertTrue( "StdDev of n = 1 set should be zero, instead it is: " + u.getStandardDeviation(), u.getStandardDeviation() == 0);
-        assertTrue( "Variance of n = 1 set should be zero", u.getVariance() == 0);
+        Assert.assertTrue( "Mean of n = 1 set should be value of single item n1", u.getMean() == one);
+        Assert.assertTrue( "StdDev of n = 1 set should be zero, instead it is: " + u.getStandardDeviation(), u.getStandardDeviation() == 0);
+        Assert.assertTrue( "Variance of n = 1 set should be zero", u.getVariance() == 0);
     }
 
+    @Test
     public void testSkewAndKurtosis() {
         DescriptiveStatistics u = new DescriptiveStatistics();
 
@@ -98,12 +98,13 @@ public final class ListUnivariateImplTes
             u.addValue( testArray[i]);
         }
 
-        assertEquals("mean", 12.40455, u.getMean(), 0.0001);
-        assertEquals("variance", 10.00236, u.getVariance(), 0.0001);
-        assertEquals("skewness", 1.437424, u.getSkewness(), 0.0001);
-        assertEquals("kurtosis", 2.37719, u.getKurtosis(), 0.0001);
+        Assert.assertEquals("mean", 12.40455, u.getMean(), 0.0001);
+        Assert.assertEquals("variance", 10.00236, u.getVariance(), 0.0001);
+        Assert.assertEquals("skewness", 1.437424, u.getSkewness(), 0.0001);
+        Assert.assertEquals("kurtosis", 2.37719, u.getKurtosis(), 0.0001);
     }
 
+    @Test
     public void testProductAndGeometricMean() throws Exception {
         ListUnivariateImpl u = new ListUnivariateImpl(new ArrayList<Object>());
         u.setWindowSize(10);
@@ -113,7 +114,7 @@ public final class ListUnivariateImplTes
         u.addValue( 3.0 );
         u.addValue( 4.0 );
 
-        assertEquals( "Geometric mean not expected", 2.213364, u.getGeometricMean(), 0.00001 );
+        Assert.assertEquals( "Geometric mean not expected", 2.213364, u.getGeometricMean(), 0.00001 );
 
         // Now test rolling - StorelessDescriptiveStatistics should discount the contribution
         // of a discarded element
@@ -122,17 +123,18 @@ public final class ListUnivariateImplTes
         }
         // Values should be (2,3,4,5,6,7,8,9,10,11)
 
-        assertEquals( "Geometric mean not expected", 5.755931, u.getGeometricMean(), 0.00001 );
+        Assert.assertEquals( "Geometric mean not expected", 5.755931, u.getGeometricMean(), 0.00001 );
 
 
     }
 
     /** test stats */
+    @Test
     public void testSerialization() {
 
         DescriptiveStatistics u = new ListUnivariateImpl();
 
-        assertEquals("total count",0,u.getN(),tolerance);
+        Assert.assertEquals("total count",0,u.getN(),tolerance);
         u.addValue(one);
         u.addValue(two);
 
@@ -141,17 +143,17 @@ public final class ListUnivariateImplTes
         u2.addValue(two);
         u2.addValue(three);
 
-        assertEquals("N",n,u2.getN(),tolerance);
-        assertEquals("sum",sum,u2.getSum(),tolerance);
-        assertEquals("sumsq",sumSq,u2.getSumsq(),tolerance);
-        assertEquals("var",var,u2.getVariance(),tolerance);
-        assertEquals("std",std,u2.getStandardDeviation(),tolerance);
-        assertEquals("mean",mean,u2.getMean(),tolerance);
-        assertEquals("min",min,u2.getMin(),tolerance);
-        assertEquals("max",max,u2.getMax(),tolerance);
+        Assert.assertEquals("N",n,u2.getN(),tolerance);
+        Assert.assertEquals("sum",sum,u2.getSum(),tolerance);
+        Assert.assertEquals("sumsq",sumSq,u2.getSumsq(),tolerance);
+        Assert.assertEquals("var",var,u2.getVariance(),tolerance);
+        Assert.assertEquals("std",std,u2.getStandardDeviation(),tolerance);
+        Assert.assertEquals("mean",mean,u2.getMean(),tolerance);
+        Assert.assertEquals("min",min,u2.getMin(),tolerance);
+        Assert.assertEquals("max",max,u2.getMax(),tolerance);
 
         u2.clear();
-        assertEquals("total count",0,u2.getN(),tolerance);
+        Assert.assertEquals("total count",0,u2.getN(),tolerance);
     }
 }
 

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/MixedListUnivariateImplTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/MixedListUnivariateImplTest.java?rev=1083514&r1=1083513&r2=1083514&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/MixedListUnivariateImplTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/MixedListUnivariateImplTest.java Sun Mar 20 17:24:14 2011
@@ -20,11 +20,12 @@ import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.List;
 
-import junit.framework.TestCase;
 
 import org.apache.commons.math.util.FastMath;
 import org.apache.commons.math.util.NumberTransformer;
 import org.apache.commons.math.util.TransformerMap;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * Test cases for the {@link ListUnivariateImpl} class.
@@ -32,7 +33,7 @@ import org.apache.commons.math.util.Tran
  * @version $Revision$ $Date$
  */
 
-public final class MixedListUnivariateImplTest extends TestCase {
+public final class MixedListUnivariateImplTest {
     private double one = 1;
     private float two = 2;
     private int three = 3;
@@ -49,8 +50,7 @@ public final class MixedListUnivariateIm
 
     private TransformerMap transformers = new TransformerMap();
 
-    public MixedListUnivariateImplTest(String name) {
-        super(name);
+    public MixedListUnivariateImplTest() {
         transformers = new TransformerMap();
 
         transformers.putTransformer(Foo.class, new FooTransformer());
@@ -60,56 +60,59 @@ public final class MixedListUnivariateIm
     }
 
     /** test stats */
+    @Test
     public void testStats() {
         List<Object> externalList = new ArrayList<Object>();
 
         DescriptiveStatistics u = new ListUnivariateImpl(externalList,transformers);
 
-        assertEquals("total count", 0, u.getN(), tolerance);
+        Assert.assertEquals("total count", 0, u.getN(), tolerance);
         u.addValue(one);
         u.addValue(two);
         u.addValue(two);
         u.addValue(three);
-        assertEquals("N", n, u.getN(), tolerance);
-        assertEquals("sum", sum, u.getSum(), tolerance);
-        assertEquals("sumsq", sumSq, u.getSumsq(), tolerance);
-        assertEquals("var", var, u.getVariance(), tolerance);
-        assertEquals("std", std, u.getStandardDeviation(), tolerance);
-        assertEquals("mean", mean, u.getMean(), tolerance);
-        assertEquals("min", min, u.getMin(), tolerance);
-        assertEquals("max", max, u.getMax(), tolerance);
+        Assert.assertEquals("N", n, u.getN(), tolerance);
+        Assert.assertEquals("sum", sum, u.getSum(), tolerance);
+        Assert.assertEquals("sumsq", sumSq, u.getSumsq(), tolerance);
+        Assert.assertEquals("var", var, u.getVariance(), tolerance);
+        Assert.assertEquals("std", std, u.getStandardDeviation(), tolerance);
+        Assert.assertEquals("mean", mean, u.getMean(), tolerance);
+        Assert.assertEquals("min", min, u.getMin(), tolerance);
+        Assert.assertEquals("max", max, u.getMax(), tolerance);
         u.clear();
-        assertEquals("total count", 0, u.getN(), tolerance);
+        Assert.assertEquals("total count", 0, u.getN(), tolerance);
     }
 
+    @Test
     public void testN0andN1Conditions() throws Exception {
         DescriptiveStatistics u = new ListUnivariateImpl(new ArrayList<Object>(),transformers);
 
-        assertTrue(
+        Assert.assertTrue(
             "Mean of n = 0 set should be NaN",
             Double.isNaN(u.getMean()));
-        assertTrue(
+        Assert.assertTrue(
             "Standard Deviation of n = 0 set should be NaN",
             Double.isNaN(u.getStandardDeviation()));
-        assertTrue(
+        Assert.assertTrue(
             "Variance of n = 0 set should be NaN",
             Double.isNaN(u.getVariance()));
 
         u.addValue(one);
 
-        assertTrue(
+        Assert.assertTrue(
             "Mean of n = 1 set should be value of single item n1, instead it is " + u.getMean() ,
             u.getMean() == one);
 
-        assertTrue(
+        Assert.assertTrue(
             "StdDev of n = 1 set should be zero, instead it is: "
                 + u.getStandardDeviation(),
             u.getStandardDeviation() == 0);
-        assertTrue(
+        Assert.assertTrue(
             "Variance of n = 1 set should be zero",
             u.getVariance() == 0);
     }
 
+    @Test
     public void testSkewAndKurtosis() {
         ListUnivariateImpl u =
             new ListUnivariateImpl(new ArrayList<Object>(), transformers);
@@ -138,12 +141,13 @@ public final class MixedListUnivariateIm
         u.addObject("12.3");
 
 
-        assertEquals("mean", 12.40455, u.getMean(), 0.0001);
-        assertEquals("variance", 10.00236, u.getVariance(), 0.0001);
-        assertEquals("skewness", 1.437424, u.getSkewness(), 0.0001);
-        assertEquals("kurtosis", 2.37719, u.getKurtosis(), 0.0001);
+        Assert.assertEquals("mean", 12.40455, u.getMean(), 0.0001);
+        Assert.assertEquals("variance", 10.00236, u.getVariance(), 0.0001);
+        Assert.assertEquals("skewness", 1.437424, u.getSkewness(), 0.0001);
+        Assert.assertEquals("kurtosis", 2.37719, u.getKurtosis(), 0.0001);
     }
 
+    @Test
     public void testProductAndGeometricMean() throws Exception {
         ListUnivariateImpl u = new ListUnivariateImpl(new ArrayList<Object>(),transformers);
         u.setWindowSize(10);
@@ -153,7 +157,7 @@ public final class MixedListUnivariateIm
         u.addValue(3.0);
         u.addValue(4.0);
 
-        assertEquals(
+        Assert.assertEquals(
             "Geometric mean not expected",
             2.213364,
             u.getGeometricMean(),
@@ -165,7 +169,7 @@ public final class MixedListUnivariateIm
             u.addValue(i + 2);
         }
         // Values should be (2,3,4,5,6,7,8,9,10,11)
-        assertEquals(
+        Assert.assertEquals(
             "Geometric mean not expected",
             5.755931,
             u.getGeometricMean(),

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/StatisticalSummaryValuesTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/StatisticalSummaryValuesTest.java?rev=1083514&r1=1083513&r2=1083514&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/StatisticalSummaryValuesTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/StatisticalSummaryValuesTest.java Sun Mar 20 17:24:14 2011
@@ -19,22 +19,19 @@ package org.apache.commons.math.stat.des
 
 import java.util.Locale;
 
-import junit.framework.TestCase;
 
 import org.apache.commons.math.TestUtils;
+import org.junit.Assert;
+import org.junit.Test;
 /**
  * Test cases for the {@link StatisticalSummaryValues} class.
  *
  * @version $Revision$ $Date$
  */
 
-public final class StatisticalSummaryValuesTest extends TestCase {
-
-
-    public StatisticalSummaryValuesTest(String name) {
-        super(name);
-    }
+public final class StatisticalSummaryValuesTest {
 
+    @Test
     public void testSerialization() {
         StatisticalSummaryValues u = new StatisticalSummaryValues(1, 2, 3, 4, 5, 6);
         TestUtils.checkSerializedEquality(u);
@@ -42,24 +39,25 @@ public final class StatisticalSummaryVal
         verifyEquality(u, t);
     }
 
+    @Test
     public void testEqualsAndHashCode() {
         StatisticalSummaryValues u  = new StatisticalSummaryValues(1, 2, 3, 4, 5, 6);
         StatisticalSummaryValues t = null;
-        assertTrue("reflexive", u.equals(u));
-        assertFalse("non-null compared to null", u.equals(t));
-        assertFalse("wrong type", u.equals(Double.valueOf(0)));
+        Assert.assertTrue("reflexive", u.equals(u));
+        Assert.assertFalse("non-null compared to null", u.equals(t));
+        Assert.assertFalse("wrong type", u.equals(Double.valueOf(0)));
         t = new StatisticalSummaryValues(1, 2, 3, 4, 5, 6);
-        assertTrue("instances with same data should be equal", t.equals(u));
-        assertEquals("hash code", u.hashCode(), t.hashCode());
+        Assert.assertTrue("instances with same data should be equal", t.equals(u));
+        Assert.assertEquals("hash code", u.hashCode(), t.hashCode());
 
         u = new StatisticalSummaryValues(Double.NaN, 2, 3, 4, 5, 6);
         t = new StatisticalSummaryValues(1, Double.NaN, 3, 4, 5, 6);
-        assertFalse("instances based on different data should be different",
+        Assert.assertFalse("instances based on different data should be different",
                 (u.equals(t) ||t.equals(u)));
     }
 
     private void verifyEquality(StatisticalSummaryValues s, StatisticalSummaryValues u) {
-        assertEquals("N",s.getN(),u.getN());
+        Assert.assertEquals("N",s.getN(),u.getN());
         TestUtils.assertEquals("sum",s.getSum(),u.getSum(), 0);
         TestUtils.assertEquals("var",s.getVariance(),u.getVariance(), 0);
         TestUtils.assertEquals("std",s.getStandardDeviation(),u.getStandardDeviation(), 0);
@@ -68,11 +66,12 @@ public final class StatisticalSummaryVal
         TestUtils.assertEquals("max",s.getMax(),u.getMax(), 0);
     }
     
+    @Test
     public void testToString() {
         StatisticalSummaryValues u  = new StatisticalSummaryValues(4.5, 16, 10, 5, 4, 45);
         Locale d = Locale.getDefault();
         Locale.setDefault(Locale.US);
-        assertEquals("StatisticalSummaryValues:\n" +
+        Assert.assertEquals("StatisticalSummaryValues:\n" +
                      "n: 10\n" +
                      "min: 4.0\n" +
                      "max: 5.0\n" +

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/StorelessUnivariateStatisticAbstractTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/StorelessUnivariateStatisticAbstractTest.java?rev=1083514&r1=1083513&r2=1083514&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/StorelessUnivariateStatisticAbstractTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/StorelessUnivariateStatisticAbstractTest.java Sun Mar 20 17:24:14 2011
@@ -19,6 +19,8 @@ package org.apache.commons.math.stat.des
 import org.apache.commons.math.TestUtils;
 import org.apache.commons.math.stat.descriptive.moment.SecondMoment;
 import org.apache.commons.math.util.FastMath;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * Test cases for {@link StorelessUnivariateStatistic} classes.
@@ -27,10 +29,6 @@ import org.apache.commons.math.util.Fast
 public abstract class StorelessUnivariateStatisticAbstractTest
     extends UnivariateStatisticAbstractTest {
 
-    public StorelessUnivariateStatisticAbstractTest(String name) {
-        super(name);
-    }
-
     /** Small sample arrays */
     protected double[][] smallSamples = {{}, {1}, {1,2}, {1,2,3}, {1,2,3,4}};
 
@@ -45,6 +43,7 @@ public abstract class StorelessUnivariat
     /**
      *  Verifies that increment() and incrementAll work properly.
      */
+    @Test
     public void testIncrementation() throws Exception {
 
         StorelessUnivariateStatistic statistic =
@@ -55,28 +54,29 @@ public abstract class StorelessUnivariat
             statistic.increment(testArray[i]);
         }
 
-        assertEquals(expectedValue(), statistic.getResult(), getTolerance());
-        assertEquals(testArray.length, statistic.getN());
+        Assert.assertEquals(expectedValue(), statistic.getResult(), getTolerance());
+        Assert.assertEquals(testArray.length, statistic.getN());
 
         statistic.clear();
 
         // Add testArray all at once and check again
         statistic.incrementAll(testArray);
-        assertEquals(expectedValue(), statistic.getResult(), getTolerance());
-        assertEquals(testArray.length, statistic.getN());
+        Assert.assertEquals(expectedValue(), statistic.getResult(), getTolerance());
+        Assert.assertEquals(testArray.length, statistic.getN());
 
         statistic.clear();
 
         // Cleared
         checkClearValue(statistic);
-        assertEquals(0, statistic.getN());
+        Assert.assertEquals(0, statistic.getN());
 
     }
 
     protected void checkClearValue(StorelessUnivariateStatistic statistic){
-        assertTrue(Double.isNaN(statistic.getResult()));
+        Assert.assertTrue(Double.isNaN(statistic.getResult()));
     }
     
+    @Test
     public void testSerialization() throws Exception {
 
         StorelessUnivariateStatistic statistic =
@@ -94,7 +94,7 @@ public abstract class StorelessUnivariat
 
         TestUtils.checkSerializedEquality(statistic);
 
-        assertEquals(expectedValue(), statistic.getResult(), getTolerance());
+        Assert.assertEquals(expectedValue(), statistic.getResult(), getTolerance());
 
         statistic.clear();
 
@@ -102,59 +102,61 @@ public abstract class StorelessUnivariat
 
     }
 
+    @Test
     public void testEqualsAndHashCode() {
         StorelessUnivariateStatistic statistic =
             (StorelessUnivariateStatistic) getUnivariateStatistic();
         StorelessUnivariateStatistic statistic2 = null;
 
-        assertTrue("non-null, compared to null", !statistic.equals(statistic2));
-        assertTrue("reflexive, non-null", statistic.equals(statistic));
+        Assert.assertTrue("non-null, compared to null", !statistic.equals(statistic2));
+        Assert.assertTrue("reflexive, non-null", statistic.equals(statistic));
 
         int emptyHash = statistic.hashCode();
         statistic2 = (StorelessUnivariateStatistic) getUnivariateStatistic();
-        assertTrue("empty stats should be equal", statistic.equals(statistic2));
-        assertEquals("empty stats should have the same hashcode",
+        Assert.assertTrue("empty stats should be equal", statistic.equals(statistic2));
+        Assert.assertEquals("empty stats should have the same hashcode",
                 emptyHash, statistic2.hashCode());
 
         statistic.increment(1d);
-        assertTrue("reflexive, non-empty", statistic.equals(statistic));
-        assertTrue("non-empty, compared to empty", !statistic.equals(statistic2));
-        assertTrue("non-empty, compared to empty", !statistic2.equals(statistic));
-        assertTrue("non-empty stat should have different hashcode from empty stat",
+        Assert.assertTrue("reflexive, non-empty", statistic.equals(statistic));
+        Assert.assertTrue("non-empty, compared to empty", !statistic.equals(statistic2));
+        Assert.assertTrue("non-empty, compared to empty", !statistic2.equals(statistic));
+        Assert.assertTrue("non-empty stat should have different hashcode from empty stat",
                 statistic.hashCode() != emptyHash);
 
         statistic2.increment(1d);
-        assertTrue("stats with same data should be equal", statistic.equals(statistic2));
-        assertEquals("stats with same data should have the same hashcode",
+        Assert.assertTrue("stats with same data should be equal", statistic.equals(statistic2));
+        Assert.assertEquals("stats with same data should have the same hashcode",
                 statistic.hashCode(), statistic2.hashCode());
 
         statistic.increment(Double.POSITIVE_INFINITY);
-        assertTrue("stats with different n's should not be equal", !statistic2.equals(statistic));
-        assertTrue("stats with different n's should have different hashcodes",
+        Assert.assertTrue("stats with different n's should not be equal", !statistic2.equals(statistic));
+        Assert.assertTrue("stats with different n's should have different hashcodes",
                 statistic.hashCode() != statistic2.hashCode());
 
         statistic2.increment(Double.POSITIVE_INFINITY);
-        assertTrue("stats with same data should be equal", statistic.equals(statistic2));
-        assertEquals("stats with same data should have the same hashcode",
+        Assert.assertTrue("stats with same data should be equal", statistic.equals(statistic2));
+        Assert.assertEquals("stats with same data should have the same hashcode",
                 statistic.hashCode(), statistic2.hashCode());
 
         statistic.clear();
         statistic2.clear();
-        assertTrue("cleared stats should be equal", statistic.equals(statistic2));
-        assertEquals("cleared stats should have thashcode of empty stat",
+        Assert.assertTrue("cleared stats should be equal", statistic.equals(statistic2));
+        Assert.assertEquals("cleared stats should have thashcode of empty stat",
                 emptyHash, statistic2.hashCode());
-        assertEquals("cleared stats should have thashcode of empty stat",
+        Assert.assertEquals("cleared stats should have thashcode of empty stat",
                 emptyHash, statistic.hashCode());
 
     }
 
+    @Test
     public void testMomentSmallSamples() {
         UnivariateStatistic stat = getUnivariateStatistic();
         if (stat instanceof SecondMoment) {
             SecondMoment moment = (SecondMoment) getUnivariateStatistic();
-            assertTrue(Double.isNaN(moment.getResult()));
+            Assert.assertTrue(Double.isNaN(moment.getResult()));
             moment.increment(1d);
-            assertEquals(0d, moment.getResult(), 0);
+            Assert.assertEquals(0d, moment.getResult(), 0);
         }
     }
 
@@ -162,10 +164,11 @@ public abstract class StorelessUnivariat
      * Make sure that evaluate(double[]) and inrementAll(double[]),
      * getResult() give same results.
      */
+    @Test
     public void testConsistency() {
         StorelessUnivariateStatistic stat = (StorelessUnivariateStatistic) getUnivariateStatistic();
         stat.incrementAll(testArray);
-        assertEquals(stat.getResult(), stat.evaluate(testArray), getTolerance());
+        Assert.assertEquals(stat.getResult(), stat.evaluate(testArray), getTolerance());
         for (int i = 0; i < smallSamples.length; i++) {
             stat.clear();
             for (int j =0; j < smallSamples[i].length; j++) {
@@ -180,6 +183,7 @@ public abstract class StorelessUnivariat
      * incremented the same way.
      *
      */
+    @Test
     public void testCopyConsistency() {
 
         StorelessUnivariateStatistic master =
@@ -195,21 +199,22 @@ public abstract class StorelessUnivariat
         replica = master.copy();
 
         // Check same
-        assertTrue(replica.equals(master));
-        assertTrue(master.equals(replica));
+        Assert.assertTrue(replica.equals(master));
+        Assert.assertTrue(master.equals(replica));
 
         // Now add second part to both and check again
         master.incrementAll(testArray,
                 (int) index, (int) (testArray.length - index));
         replica.incrementAll(testArray,
                 (int) index, (int) (testArray.length - index));
-        assertTrue(replica.equals(master));
-        assertTrue(master.equals(replica));
+        Assert.assertTrue(replica.equals(master));
+        Assert.assertTrue(master.equals(replica));
     }
 
+    @Test
     public void testSerial() {
         StorelessUnivariateStatistic s =
             (StorelessUnivariateStatistic) getUnivariateStatistic();
-        assertEquals(s, TestUtils.serializeAndRecover(s));
+        Assert.assertEquals(s, TestUtils.serializeAndRecover(s));
     }
 }

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/SummaryStatisticsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/SummaryStatisticsTest.java?rev=1083514&r1=1083513&r2=1083514&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/SummaryStatisticsTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/SummaryStatisticsTest.java Sun Mar 20 17:24:14 2011
@@ -16,19 +16,20 @@
  */
 package org.apache.commons.math.stat.descriptive;
 
-import junit.framework.TestCase;
 
 import org.apache.commons.math.TestUtils;
 import org.apache.commons.math.stat.descriptive.moment.Mean;
 import org.apache.commons.math.stat.descriptive.summary.Sum;
 import org.apache.commons.math.util.FastMath;
+import org.junit.Assert;
+import org.junit.Test;
 /**
  * Test cases for the {@link SummaryStatistics} class.
  *
  * @version $Revision$ $Date$
  */
 
-public class SummaryStatisticsTest extends TestCase {
+public class SummaryStatisticsTest {
 
     private double one = 1;
     private float twoF = 2;
@@ -44,63 +45,62 @@ public class SummaryStatisticsTest exten
     private double max = 3;
     private double tolerance = 10E-15;
 
-    public SummaryStatisticsTest(String name) {
-        super(name);
-    }
-
     protected SummaryStatistics createSummaryStatistics() {
         return new SummaryStatistics();
     }
 
     /** test stats */
+    @Test
     public void testStats() {
         SummaryStatistics u = createSummaryStatistics();
-        assertEquals("total count",0,u.getN(),tolerance);
+        Assert.assertEquals("total count",0,u.getN(),tolerance);
         u.addValue(one);
         u.addValue(twoF);
         u.addValue(twoL);
         u.addValue(three);
-        assertEquals("N",n,u.getN(),tolerance);
-        assertEquals("sum",sum,u.getSum(),tolerance);
-        assertEquals("sumsq",sumSq,u.getSumsq(),tolerance);
-        assertEquals("var",var,u.getVariance(),tolerance);
-        assertEquals("std",std,u.getStandardDeviation(),tolerance);
-        assertEquals("mean",mean,u.getMean(),tolerance);
-        assertEquals("min",min,u.getMin(),tolerance);
-        assertEquals("max",max,u.getMax(),tolerance);
+        Assert.assertEquals("N",n,u.getN(),tolerance);
+        Assert.assertEquals("sum",sum,u.getSum(),tolerance);
+        Assert.assertEquals("sumsq",sumSq,u.getSumsq(),tolerance);
+        Assert.assertEquals("var",var,u.getVariance(),tolerance);
+        Assert.assertEquals("std",std,u.getStandardDeviation(),tolerance);
+        Assert.assertEquals("mean",mean,u.getMean(),tolerance);
+        Assert.assertEquals("min",min,u.getMin(),tolerance);
+        Assert.assertEquals("max",max,u.getMax(),tolerance);
         u.clear();
-        assertEquals("total count",0,u.getN(),tolerance);
+        Assert.assertEquals("total count",0,u.getN(),tolerance);
     }
 
+    @Test
     public void testN0andN1Conditions() throws Exception {
         SummaryStatistics u = createSummaryStatistics();
-        assertTrue("Mean of n = 0 set should be NaN",
+        Assert.assertTrue("Mean of n = 0 set should be NaN",
                 Double.isNaN( u.getMean() ) );
-        assertTrue("Standard Deviation of n = 0 set should be NaN",
+        Assert.assertTrue("Standard Deviation of n = 0 set should be NaN",
                 Double.isNaN( u.getStandardDeviation() ) );
-        assertTrue("Variance of n = 0 set should be NaN",
+        Assert.assertTrue("Variance of n = 0 set should be NaN",
                 Double.isNaN(u.getVariance() ) );
 
         /* n=1 */
         u.addValue(one);
-        assertTrue("mean should be one (n = 1)",
+        Assert.assertTrue("mean should be one (n = 1)",
                 u.getMean() == one);
-        assertTrue("geometric should be one (n = 1) instead it is " + u.getGeometricMean(),
+        Assert.assertTrue("geometric should be one (n = 1) instead it is " + u.getGeometricMean(),
                 u.getGeometricMean() == one);
-        assertTrue("Std should be zero (n = 1)",
+        Assert.assertTrue("Std should be zero (n = 1)",
                 u.getStandardDeviation() == 0.0);
-        assertTrue("variance should be zero (n = 1)",
+        Assert.assertTrue("variance should be zero (n = 1)",
                 u.getVariance() == 0.0);
 
         /* n=2 */
         u.addValue(twoF);
-        assertTrue("Std should not be zero (n = 2)",
+        Assert.assertTrue("Std should not be zero (n = 2)",
                 u.getStandardDeviation() != 0.0);
-        assertTrue("variance should not be zero (n = 2)",
+        Assert.assertTrue("variance should not be zero (n = 2)",
                 u.getVariance() != 0.0);
 
     }
 
+    @Test
     public void testProductAndGeometricMean() throws Exception {
         SummaryStatistics u = createSummaryStatistics();
         u.addValue( 1.0 );
@@ -108,38 +108,40 @@ public class SummaryStatisticsTest exten
         u.addValue( 3.0 );
         u.addValue( 4.0 );
 
-        assertEquals( "Geometric mean not expected", 2.213364,
+        Assert.assertEquals( "Geometric mean not expected", 2.213364,
                 u.getGeometricMean(), 0.00001 );
     }
 
+    @Test
     public void testNaNContracts() {
         SummaryStatistics u = createSummaryStatistics();
-        assertTrue("mean not NaN",Double.isNaN(u.getMean()));
-        assertTrue("min not NaN",Double.isNaN(u.getMin()));
-        assertTrue("std dev not NaN",Double.isNaN(u.getStandardDeviation()));
-        assertTrue("var not NaN",Double.isNaN(u.getVariance()));
-        assertTrue("geom mean not NaN",Double.isNaN(u.getGeometricMean()));
+        Assert.assertTrue("mean not NaN",Double.isNaN(u.getMean()));
+        Assert.assertTrue("min not NaN",Double.isNaN(u.getMin()));
+        Assert.assertTrue("std dev not NaN",Double.isNaN(u.getStandardDeviation()));
+        Assert.assertTrue("var not NaN",Double.isNaN(u.getVariance()));
+        Assert.assertTrue("geom mean not NaN",Double.isNaN(u.getGeometricMean()));
 
         u.addValue(1.0);
 
-        assertEquals( "mean not expected", 1.0,
+        Assert.assertEquals( "mean not expected", 1.0,
                 u.getMean(), Double.MIN_VALUE);
-        assertEquals( "variance not expected", 0.0,
+        Assert.assertEquals( "variance not expected", 0.0,
                 u.getVariance(), Double.MIN_VALUE);
-        assertEquals( "geometric mean not expected", 1.0,
+        Assert.assertEquals( "geometric mean not expected", 1.0,
                 u.getGeometricMean(), Double.MIN_VALUE);
 
         u.addValue(-1.0);
 
-        assertTrue("geom mean not NaN",Double.isNaN(u.getGeometricMean()));
+        Assert.assertTrue("geom mean not NaN",Double.isNaN(u.getGeometricMean()));
 
         u.addValue(0.0);
 
-        assertTrue("geom mean not NaN",Double.isNaN(u.getGeometricMean()));
+        Assert.assertTrue("geom mean not NaN",Double.isNaN(u.getGeometricMean()));
 
         //FiXME: test all other NaN contract specs
     }
 
+    @Test
     public void testGetSummary() {
         SummaryStatistics u = createSummaryStatistics();
         StatisticalSummary summary = u.getSummary();
@@ -155,6 +157,7 @@ public class SummaryStatisticsTest exten
         verifySummary(u, summary);
     }
 
+    @Test
     public void testSerialization() {
         SummaryStatistics u = createSummaryStatistics();
         // Empty test
@@ -178,26 +181,27 @@ public class SummaryStatisticsTest exten
 
     }
 
+    @Test
     public void testEqualsAndHashCode() {
         SummaryStatistics u = createSummaryStatistics();
         SummaryStatistics t = null;
         int emptyHash = u.hashCode();
-        assertTrue("reflexive", u.equals(u));
-        assertFalse("non-null compared to null", u.equals(t));
-        assertFalse("wrong type", u.equals(Double.valueOf(0)));
+        Assert.assertTrue("reflexive", u.equals(u));
+        Assert.assertFalse("non-null compared to null", u.equals(t));
+        Assert.assertFalse("wrong type", u.equals(Double.valueOf(0)));
         t = createSummaryStatistics();
-        assertTrue("empty instances should be equal", t.equals(u));
-        assertTrue("empty instances should be equal", u.equals(t));
-        assertEquals("empty hash code", emptyHash, t.hashCode());
+        Assert.assertTrue("empty instances should be equal", t.equals(u));
+        Assert.assertTrue("empty instances should be equal", u.equals(t));
+        Assert.assertEquals("empty hash code", emptyHash, t.hashCode());
 
         // Add some data to u
         u.addValue(2d);
         u.addValue(1d);
         u.addValue(3d);
         u.addValue(4d);
-        assertFalse("different n's should make instances not equal", t.equals(u));
-        assertFalse("different n's should make instances not equal", u.equals(t));
-        assertTrue("different n's should make hashcodes different",
+        Assert.assertFalse("different n's should make instances not equal", t.equals(u));
+        Assert.assertFalse("different n's should make instances not equal", u.equals(t));
+        Assert.assertTrue("different n's should make hashcodes different",
                 u.hashCode() != t.hashCode());
 
         //Add data in same order to t
@@ -205,20 +209,21 @@ public class SummaryStatisticsTest exten
         t.addValue(1d);
         t.addValue(3d);
         t.addValue(4d);
-        assertTrue("summaries based on same data should be equal", t.equals(u));
-        assertTrue("summaries based on same data should be equal", u.equals(t));
-        assertEquals("summaries based on same data should have same hashcodes",
+        Assert.assertTrue("summaries based on same data should be equal", t.equals(u));
+        Assert.assertTrue("summaries based on same data should be equal", u.equals(t));
+        Assert.assertEquals("summaries based on same data should have same hashcodes",
                 u.hashCode(), t.hashCode());
 
         // Clear and make sure summaries are indistinguishable from empty summary
         u.clear();
         t.clear();
-        assertTrue("empty instances should be equal", t.equals(u));
-        assertTrue("empty instances should be equal", u.equals(t));
-        assertEquals("empty hash code", emptyHash, t.hashCode());
-        assertEquals("empty hash code", emptyHash, u.hashCode());
+        Assert.assertTrue("empty instances should be equal", t.equals(u));
+        Assert.assertTrue("empty instances should be equal", u.equals(t));
+        Assert.assertEquals("empty hash code", emptyHash, t.hashCode());
+        Assert.assertEquals("empty hash code", emptyHash, u.hashCode());
     }
 
+    @Test
     public void testCopy() throws Exception {
         SummaryStatistics u = createSummaryStatistics();
         u.addValue(2d);
@@ -226,16 +231,16 @@ public class SummaryStatisticsTest exten
         u.addValue(3d);
         u.addValue(4d);
         SummaryStatistics v = new SummaryStatistics(u);
-        assertEquals(u, v);
-        assertEquals(v, u);
-        assertTrue(v.geoMean == v.getGeoMeanImpl());
-        assertTrue(v.mean == v.getMeanImpl());
-        assertTrue(v.min == v.getMinImpl());
-        assertTrue(v.max == v.getMaxImpl());
-        assertTrue(v.sum == v.getSumImpl());
-        assertTrue(v.sumsq == v.getSumsqImpl());
-        assertTrue(v.sumLog == v.getSumLogImpl());
-        assertTrue(v.variance == v.getVarianceImpl());
+        Assert.assertEquals(u, v);
+        Assert.assertEquals(v, u);
+        Assert.assertTrue(v.geoMean == v.getGeoMeanImpl());
+        Assert.assertTrue(v.mean == v.getMeanImpl());
+        Assert.assertTrue(v.min == v.getMinImpl());
+        Assert.assertTrue(v.max == v.getMaxImpl());
+        Assert.assertTrue(v.sum == v.getSumImpl());
+        Assert.assertTrue(v.sumsq == v.getSumsqImpl());
+        Assert.assertTrue(v.sumLog == v.getSumLogImpl());
+        Assert.assertTrue(v.variance == v.getVarianceImpl());
 
         // Make sure both behave the same with additional values added
         u.addValue(7d);
@@ -246,20 +251,20 @@ public class SummaryStatisticsTest exten
         v.addValue(9d);
         v.addValue(11d);
         v.addValue(23d);
-        assertEquals(u, v);
-        assertEquals(v, u);
+        Assert.assertEquals(u, v);
+        Assert.assertEquals(v, u);
 
         // Check implementation pointers are preserved
         u.clear();
         u.setSumImpl(new Sum());
         SummaryStatistics.copy(u,v);
-        assertEquals(u.sum, v.sum);
-        assertEquals(u.getSumImpl(), v.getSumImpl());
+        Assert.assertEquals(u.sum, v.sum);
+        Assert.assertEquals(u.getSumImpl(), v.getSumImpl());
 
     }
 
     private void verifySummary(SummaryStatistics u, StatisticalSummary s) {
-        assertEquals("N",s.getN(),u.getN());
+        Assert.assertEquals("N",s.getN(),u.getN());
         TestUtils.assertEquals("sum",s.getSum(),u.getSum(),tolerance);
         TestUtils.assertEquals("var",s.getVariance(),u.getVariance(),tolerance);
         TestUtils.assertEquals("std",s.getStandardDeviation(),u.getStandardDeviation(),tolerance);
@@ -268,30 +273,32 @@ public class SummaryStatisticsTest exten
         TestUtils.assertEquals("max",s.getMax(),u.getMax(),tolerance);
     }
 
+    @Test
     public void testSetterInjection() throws Exception {
         SummaryStatistics u = createSummaryStatistics();
         u.setMeanImpl(new Sum());
         u.setSumLogImpl(new Sum());
         u.addValue(1);
         u.addValue(3);
-        assertEquals(4, u.getMean(), 1E-14);
-        assertEquals(4, u.getSumOfLogs(), 1E-14);
-        assertEquals(FastMath.exp(2), u.getGeometricMean(), 1E-14);
+        Assert.assertEquals(4, u.getMean(), 1E-14);
+        Assert.assertEquals(4, u.getSumOfLogs(), 1E-14);
+        Assert.assertEquals(FastMath.exp(2), u.getGeometricMean(), 1E-14);
         u.clear();
         u.addValue(1);
         u.addValue(2);
-        assertEquals(3, u.getMean(), 1E-14);
+        Assert.assertEquals(3, u.getMean(), 1E-14);
         u.clear();
         u.setMeanImpl(new Mean()); // OK after clear
     }
 
+    @Test
     public void testSetterIllegalState() throws Exception {
         SummaryStatistics u = createSummaryStatistics();
         u.addValue(1);
         u.addValue(3);
         try {
             u.setMeanImpl(new Sum());
-            fail("Expecting IllegalStateException");
+            Assert.fail("Expecting IllegalStateException");
         } catch (IllegalStateException ex) {
             // expected
         }

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/SynchronizedDescriptiveStatisticsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/SynchronizedDescriptiveStatisticsTest.java?rev=1083514&r1=1083513&r2=1083514&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/SynchronizedDescriptiveStatisticsTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/SynchronizedDescriptiveStatisticsTest.java Sun Mar 20 17:24:14 2011
@@ -21,10 +21,6 @@ package org.apache.commons.math.stat.des
  */
 public final class SynchronizedDescriptiveStatisticsTest extends DescriptiveStatisticsTest {
 
-    public SynchronizedDescriptiveStatisticsTest(String name) {
-        super(name);
-    }
-
     @Override
     protected DescriptiveStatistics createDescriptiveStatistics() {
         return new SynchronizedDescriptiveStatistics();

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/SynchronizedSummaryStatisticsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/SynchronizedSummaryStatisticsTest.java?rev=1083514&r1=1083513&r2=1083514&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/SynchronizedSummaryStatisticsTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/SynchronizedSummaryStatisticsTest.java Sun Mar 20 17:24:14 2011
@@ -20,10 +20,6 @@ package org.apache.commons.math.stat.des
  */
 public final class SynchronizedSummaryStatisticsTest extends SummaryStatisticsTest {
 
-    public SynchronizedSummaryStatisticsTest(String name) {
-        super(name);
-    }
-
     @Override
     protected SummaryStatistics createSummaryStatistics() {
         return new SynchronizedSummaryStatistics();

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/UnivariateStatisticAbstractTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/UnivariateStatisticAbstractTest.java?rev=1083514&r1=1083513&r2=1083514&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/UnivariateStatisticAbstractTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/UnivariateStatisticAbstractTest.java Sun Mar 20 17:24:14 2011
@@ -19,18 +19,19 @@ package org.apache.commons.math.stat.des
 import java.util.ArrayList;
 import java.util.List;
 
-import junit.framework.TestCase;
 
 import org.apache.commons.math.TestUtils;
 import org.apache.commons.math.random.RandomData;
 import org.apache.commons.math.random.RandomDataImpl;
 import org.apache.commons.math.util.FastMath;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * Test cases for the {@link UnivariateStatistic} class.
  * @version $Revision$ $Date$
  */
-public abstract class UnivariateStatisticAbstractTest extends TestCase {
+public abstract class UnivariateStatisticAbstractTest {
 
     protected double mean = 12.404545454545455d;
     protected double geoMean = 12.070589161633011d;
@@ -83,11 +84,6 @@ public abstract class UnivariateStatisti
            1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,
            1.0,  1.0 };
 
-
-    public UnivariateStatisticAbstractTest(String name) {
-        super(name);
-    }
-
     public abstract UnivariateStatistic getUnivariateStatistic();
 
     public abstract double expectedValue();
@@ -96,17 +92,19 @@ public abstract class UnivariateStatisti
         return tolerance;
     }
 
+    @Test
     public void testEvaluation() throws Exception {
-        assertEquals(
+        Assert.assertEquals(
             expectedValue(),
             getUnivariateStatistic().evaluate(testArray),
             getTolerance());
     }
 
+    @Test
     public void testCopy() throws Exception {
         UnivariateStatistic original = getUnivariateStatistic();
         UnivariateStatistic copy = original.copy();
-        assertEquals(
+        Assert.assertEquals(
                 expectedValue(),
                 copy.evaluate(testArray),
                 getTolerance());
@@ -121,6 +119,7 @@ public abstract class UnivariateStatisti
      * in the repeating array.
      */
 
+    @Test
     public void testWeightedConsistency() throws Exception {
 
         // See if this statistic computes weighted statistics
@@ -173,7 +172,7 @@ public abstract class UnivariateStatisti
                 10E-14);
 
         // Check consistency of weighted evaluation methods
-        assertEquals(weightedStatistic.evaluate(values, weights, 0, values.length),
+        Assert.assertEquals(weightedStatistic.evaluate(values, weights, 0, values.length),
                 weightedStatistic.evaluate(values, weights), Double.MIN_VALUE);
 
     }

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/moment/FirstMomentTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/moment/FirstMomentTest.java?rev=1083514&r1=1083513&r2=1083514&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/moment/FirstMomentTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/moment/FirstMomentTest.java Sun Mar 20 17:24:14 2011
@@ -29,13 +29,6 @@ public class FirstMomentTest extends Sto
     protected FirstMoment stat;
 
     /**
-     * @param name
-     */
-    public FirstMomentTest(String name) {
-        super(name);
-    }
-
-    /**
      * @see org.apache.commons.math.stat.descriptive.UnivariateStatisticAbstractTest#getUnivariateStatistic()
      */
     @Override

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/moment/FourthMomentTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/moment/FourthMomentTest.java?rev=1083514&r1=1083513&r2=1083514&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/moment/FourthMomentTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/moment/FourthMomentTest.java Sun Mar 20 17:24:14 2011
@@ -29,13 +29,6 @@ public class FourthMomentTest extends St
     protected FourthMoment stat;
 
     /**
-     * @param name
-     */
-    public FourthMomentTest(String name) {
-        super(name);
-    }
-
-    /**
      * @see org.apache.commons.math.stat.descriptive.UnivariateStatisticAbstractTest#getUnivariateStatistic()
      */
     @Override

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/moment/GeometricMeanTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/moment/GeometricMeanTest.java?rev=1083514&r1=1083513&r2=1083514&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/moment/GeometricMeanTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/moment/GeometricMeanTest.java Sun Mar 20 17:24:14 2011
@@ -18,6 +18,8 @@ package org.apache.commons.math.stat.des
 
 import org.apache.commons.math.stat.descriptive.StorelessUnivariateStatisticAbstractTest;
 import org.apache.commons.math.stat.descriptive.UnivariateStatistic;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * Test cases for the {@link UnivariateStatistic} class.
@@ -28,13 +30,6 @@ public class GeometricMeanTest extends S
     protected GeometricMean stat;
 
     /**
-     * @param name
-     */
-    public GeometricMeanTest(String name) {
-        super(name);
-    }
-
-    /**
      * {@inheritDoc}
      */
     @Override
@@ -50,34 +45,35 @@ public class GeometricMeanTest extends S
         return this.geoMean;
     }
 
+    @Test
     public void testSpecialValues() {
         GeometricMean mean = new GeometricMean();
         // empty
-        assertTrue(Double.isNaN(mean.getResult()));
+        Assert.assertTrue(Double.isNaN(mean.getResult()));
 
         // finite data
         mean.increment(1d);
-        assertFalse(Double.isNaN(mean.getResult()));
+        Assert.assertFalse(Double.isNaN(mean.getResult()));
 
         // add 0 -- makes log sum blow to minus infinity, should make 0
         mean.increment(0d);
-        assertEquals(0d, mean.getResult(), 0);
+        Assert.assertEquals(0d, mean.getResult(), 0);
 
         // add positive infinity - note the minus infinity above
         mean.increment(Double.POSITIVE_INFINITY);
-        assertTrue(Double.isNaN(mean.getResult()));
+        Assert.assertTrue(Double.isNaN(mean.getResult()));
 
         // clear
         mean.clear();
-        assertTrue(Double.isNaN(mean.getResult()));
+        Assert.assertTrue(Double.isNaN(mean.getResult()));
 
         // positive infinity by itself
         mean.increment(Double.POSITIVE_INFINITY);
-        assertEquals(Double.POSITIVE_INFINITY, mean.getResult(), 0);
+        Assert.assertEquals(Double.POSITIVE_INFINITY, mean.getResult(), 0);
 
         // negative value -- should make NaN
         mean.increment(-2d);
-        assertTrue(Double.isNaN(mean.getResult()));
+        Assert.assertTrue(Double.isNaN(mean.getResult()));
     }
 
 }