Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3512977D3 for ; Thu, 1 Dec 2011 21:21:17 +0000 (UTC) Received: (qmail 2600 invoked by uid 500); 1 Dec 2011 21:21:16 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 2546 invoked by uid 500); 1 Dec 2011 21:21:16 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 2539 invoked by uid 99); 1 Dec 2011 21:21:16 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Dec 2011 21:21:16 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Dec 2011 21:21:11 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 039892388993 for ; Thu, 1 Dec 2011 21:20:50 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1209247 - in /commons/proper/math/trunk: ./ src/test/java/org/apache/commons/math/linear/ src/test/java/org/apache/commons/math/optimization/ src/test/java/org/apache/commons/math/random/ src/test/java/org/apache/commons/math/stat/regression/ Date: Thu, 01 Dec 2011 21:20:49 -0000 To: commits@commons.apache.org From: luc@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111201212050.039892388993@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: luc Date: Thu Dec 1 21:20:47 2011 New Revision: 1209247 URL: http://svn.apache.org/viewvc?rev=1209247&view=rev Log: Removed remnants of junit 3. Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/UnmodifiableRealVectorAbstractTest.java commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/BatteryNISTTest.java commons/proper/math/trunk/src/test/java/org/apache/commons/math/random/StableRandomGeneratorTest.java commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/regression/MillerUpdatingRegressionTest.java commons/proper/math/trunk/test-jar.xml Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/UnmodifiableRealVectorAbstractTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/UnmodifiableRealVectorAbstractTest.java?rev=1209247&r1=1209246&r2=1209247&view=diff ============================================================================== --- commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/UnmodifiableRealVectorAbstractTest.java (original) +++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/UnmodifiableRealVectorAbstractTest.java Thu Dec 1 21:20:47 2011 @@ -23,12 +23,11 @@ import java.util.HashSet; import java.util.Iterator; import java.util.Random; -import junit.framework.Assert; - import org.apache.commons.math.analysis.UnivariateFunction; import org.apache.commons.math.analysis.function.Sin; import org.apache.commons.math.exception.MathUnsupportedOperationException; import org.apache.commons.math.linear.RealVector.Entry; +import org.junit.Assert; import org.junit.Test; /** Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/BatteryNISTTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/BatteryNISTTest.java?rev=1209247&r1=1209246&r2=1209247&view=diff ============================================================================== --- commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/BatteryNISTTest.java (original) +++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/BatteryNISTTest.java Thu Dec 1 21:20:47 2011 @@ -16,7 +16,6 @@ package org.apache.commons.math.optimization; import java.util.Arrays; -import junit.framework.Assert; import org.apache.commons.math.MathRuntimeException; import org.apache.commons.math.TestUtils; import org.apache.commons.math.analysis.DifferentiableMultivariateFunction; @@ -29,6 +28,7 @@ import org.apache.commons.math.optimizat import org.apache.commons.math.optimization.general.ConjugateGradientFormula; import org.apache.commons.math.optimization.general.NonLinearConjugateGradientOptimizer; import org.apache.commons.math.util.FastMath; +import org.junit.Assert; import org.junit.Test; /** Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/random/StableRandomGeneratorTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/random/StableRandomGeneratorTest.java?rev=1209247&r1=1209246&r2=1209247&view=diff ============================================================================== --- commons/proper/math/trunk/src/test/java/org/apache/commons/math/random/StableRandomGeneratorTest.java (original) +++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/random/StableRandomGeneratorTest.java Thu Dec 1 21:20:47 2011 @@ -16,11 +16,11 @@ */ package org.apache.commons.math.random; -import junit.framework.TestCase; - import org.apache.commons.math.exception.OutOfRangeException; import org.apache.commons.math.stat.StatUtils; import org.apache.commons.math.stat.descriptive.DescriptiveStatistics; +import org.junit.Assert; +import org.junit.Test; /** * The class StableRandomGeneratorTest contains tests for the class @@ -28,26 +28,18 @@ import org.apache.commons.math.stat.desc * * @version $Revision$ */ -public class StableRandomGeneratorTest extends TestCase { +public class StableRandomGeneratorTest { private RandomGenerator rg = new Well19937c(100); private final static int sampleSize = 10000; /** - * Construct new test instance - * - * @param name the test name - */ - public StableRandomGeneratorTest(String name) { - super(name); - } - - /** * Run the double nextDouble() method test Due to leptokurtic property the * acceptance range is widened. * * TODO: verify that tolerance this wide is really OK */ + @Test public void testNextDouble() { StableRandomGenerator generator = new StableRandomGenerator(rg, 1.3, 0.1); @@ -55,12 +47,13 @@ public class StableRandomGeneratorTest e for (int i = 0; i < sample.length; ++i) { sample[i] = generator.nextNormalizedDouble(); } - assertEquals(0.0, StatUtils.mean(sample), 0.3); + Assert.assertEquals(0.0, StatUtils.mean(sample), 0.3); } /** * If alpha = 2, than it must be Gaussian distribution */ + @Test public void testGaussianCase() { StableRandomGenerator generator = new StableRandomGenerator(rg, 2d, 0.0); @@ -68,13 +61,14 @@ public class StableRandomGeneratorTest e for (int i = 0; i < sample.length; ++i) { sample[i] = generator.nextNormalizedDouble(); } - assertEquals(0.0, StatUtils.mean(sample), 0.02); - assertEquals(1.0, StatUtils.variance(sample), 0.02); + Assert.assertEquals(0.0, StatUtils.mean(sample), 0.02); + Assert.assertEquals(1.0, StatUtils.variance(sample), 0.02); } /** * If alpha = 1, than it must be Cauchy distribution */ + @Test public void testCauchyCase() { StableRandomGenerator generator = new StableRandomGenerator(rg, 1d, 0.0); DescriptiveStatistics summary = new DescriptiveStatistics(); @@ -86,49 +80,53 @@ public class StableRandomGeneratorTest e // Standard Cauchy distribution should have zero median and mode double median = summary.getPercentile(50); - assertEquals(0.0, median, 0.2); + Assert.assertEquals(0.0, median, 0.2); } /** * Input parameter range tests */ + @Test public void testAlphaRangeBelowZero() { try { new StableRandomGenerator(rg, -1.0, 0.0); - fail("Expected OutOfRangeException"); + Assert.fail("Expected OutOfRangeException"); } catch (OutOfRangeException e) { - assertEquals(-1.0, e.getArgument()); + Assert.assertEquals(-1.0, e.getArgument()); } } + @Test public void testAlphaRangeAboveTwo() { try { new StableRandomGenerator(rg, 3.0, 0.0); - fail("Expected OutOfRangeException"); + Assert.fail("Expected OutOfRangeException"); } catch (OutOfRangeException e) { - assertEquals(3.0, e.getArgument()); + Assert.assertEquals(3.0, e.getArgument()); } } + @Test public void testBetaRangeBelowMinusOne() { try { new StableRandomGenerator(rg, 1.0, -2.0); - fail("Expected OutOfRangeException"); + Assert.fail("Expected OutOfRangeException"); } catch (OutOfRangeException e) { - assertEquals(-2.0, e.getArgument()); + Assert.assertEquals(-2.0, e.getArgument()); } } + @Test public void testBetaRangeAboveOne() { try { new StableRandomGenerator(rg, 1.0, 2.0); - fail("Expected OutOfRangeException"); + Assert.fail("Expected OutOfRangeException"); } catch (OutOfRangeException e) { - assertEquals(2.0, e.getArgument()); + Assert.assertEquals(2.0, e.getArgument()); } } } \ No newline at end of file Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/regression/MillerUpdatingRegressionTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/regression/MillerUpdatingRegressionTest.java?rev=1209247&r1=1209246&r2=1209247&view=diff ============================================================================== --- commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/regression/MillerUpdatingRegressionTest.java (original) +++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/regression/MillerUpdatingRegressionTest.java Thu Dec 1 21:20:47 2011 @@ -16,14 +16,12 @@ */ package org.apache.commons.math.stat.regression; -import junit.framework.Assert; - import org.apache.commons.math.linear.RealMatrix; import org.apache.commons.math.stat.correlation.PearsonsCorrelation; import org.apache.commons.math.TestUtils; import org.apache.commons.math.util.FastMath; +import org.junit.Assert; import org.junit.Test; -import static org.junit.Assert.*; /** * MillerUpdatingRegression tests. @@ -51,11 +49,11 @@ public class MillerUpdatingRegressionTes public void testHasIntercept() { MillerUpdatingRegression instance = new MillerUpdatingRegression(10, false); if (instance.hasIntercept()) { - fail("Should not have intercept"); + Assert.fail("Should not have intercept"); } instance = new MillerUpdatingRegression(10, true); if (!instance.hasIntercept()) { - fail("Should have intercept"); + Assert.fail("Should have intercept"); } } @@ -76,14 +74,14 @@ public class MillerUpdatingRegressionTes } instance.addObservations(xAll, y); if (instance.getN() != xAll.length) { - fail("Number of observations not correct in bulk addition"); + Assert.fail("Number of observations not correct in bulk addition"); } instance.clear(); for (int i = 0; i < xAll.length; i++) { instance.addObservation(xAll[i], y[i]); } if (instance.getN() != xAll.length) { - fail("Number of observations not correct in drip addition"); + Assert.fail("Number of observations not correct in drip addition"); } return; } @@ -93,44 +91,44 @@ public class MillerUpdatingRegressionTes MillerUpdatingRegression instance = new MillerUpdatingRegression(3, true); try { instance.addObservation(new double[]{1.0}, 0.0); - fail("Should throw IllegalArgumentException"); + Assert.fail("Should throw IllegalArgumentException"); } catch (IllegalArgumentException iae) { } catch (Exception e) { - fail("Should throw IllegalArgumentException"); + Assert.fail("Should throw IllegalArgumentException"); } try { instance.addObservation(new double[]{1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}, 0.0); - fail("Should throw IllegalArgumentException"); + Assert.fail("Should throw IllegalArgumentException"); } catch (IllegalArgumentException iae) { } catch (Exception e) { - fail("Should throw IllegalArgumentException"); + Assert.fail("Should throw IllegalArgumentException"); } try { instance.addObservation(new double[]{1.0, 1.0, 1.0}, 0.0); } catch (Exception e) { - fail("Should throw IllegalArgumentException"); + Assert.fail("Should throw IllegalArgumentException"); } //now we try it without an intercept instance = new MillerUpdatingRegression(3, false); try { instance.addObservation(new double[]{1.0}, 0.0); - fail("Should throw IllegalArgumentException [NOINTERCEPT]"); + Assert.fail("Should throw IllegalArgumentException [NOINTERCEPT]"); } catch (IllegalArgumentException iae) { } catch (Exception e) { - fail("Should throw IllegalArgumentException [NOINTERCEPT]"); + Assert.fail("Should throw IllegalArgumentException [NOINTERCEPT]"); } try { instance.addObservation(new double[]{1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}, 0.0); - fail("Should throw IllegalArgumentException [NOINTERCEPT]"); + Assert.fail("Should throw IllegalArgumentException [NOINTERCEPT]"); } catch (IllegalArgumentException iae) { } catch (Exception e) { - fail("Should throw IllegalArgumentException [NOINTERCEPT]"); + Assert.fail("Should throw IllegalArgumentException [NOINTERCEPT]"); } try { instance.addObservation(new double[]{1.0, 1.0, 1.0}, 0.0); } catch (Exception e) { - fail("Should throw IllegalArgumentException [NOINTERCEPT]"); + Assert.fail("Should throw IllegalArgumentException [NOINTERCEPT]"); } } @@ -142,10 +140,10 @@ public class MillerUpdatingRegressionTes double[] y = {1.0}; instance.addObservations(tst, y); - fail("Should throw IllegalArgumentException"); + Assert.fail("Should throw IllegalArgumentException"); } catch (IllegalArgumentException iae) { } catch (Exception e) { - fail("Should throw IllegalArgumentException"); + Assert.fail("Should throw IllegalArgumentException"); } try { @@ -153,10 +151,10 @@ public class MillerUpdatingRegressionTes double[] y = {1.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0}; instance.addObservations(tst, y); - fail("Should throw IllegalArgumentException"); + Assert.fail("Should throw IllegalArgumentException"); } catch (IllegalArgumentException iae) { } catch (Exception e) { - fail("Should throw IllegalArgumentException"); + Assert.fail("Should throw IllegalArgumentException"); } } @@ -192,7 +190,7 @@ public class MillerUpdatingRegressionTes TestUtils.assertEquals(0.01552839, result.getMeanSquareError(), 1.0e-8); } catch (Exception e) { - fail("Should not throw exception but does"); + Assert.fail("Should not throw exception but does"); } } @@ -225,7 +223,7 @@ public class MillerUpdatingRegressionTes TestUtils.assertEquals(0.9883, result.getRSquared(), 1.0e-4); TestUtils.assertEquals(0.01552839, result.getMeanSquareError(), 1.0e-8); } catch (Exception e) { - fail("Should not throw exception but does"); + Assert.fail("Should not throw exception but does"); } } @@ -733,7 +731,7 @@ public class MillerUpdatingRegressionTes // instance.addObservations(x, y); // RegressionResults result = instance.regress(); // if (result == null) { -// fail("Null result...."); +// Assert.fail("Null result...."); // } // // instance.reorderRegressors(new int[]{3, 2}, 0); @@ -742,16 +740,16 @@ public class MillerUpdatingRegressionTes // double[] beta = result.getParameterEstimates(); // double[] betar = resultInverse.getParameterEstimates(); // if (Math.abs(beta[0] - betar[0]) > 1.0e-14) { -// fail("Parameters not correct after reorder (0,3)"); +// Assert.fail("Parameters not correct after reorder (0,3)"); // } // if (Math.abs(beta[1] - betar[1]) > 1.0e-14) { -// fail("Parameters not correct after reorder (1,2)"); +// Assert.fail("Parameters not correct after reorder (1,2)"); // } // if (Math.abs(beta[2] - betar[2]) > 1.0e-14) { -// fail("Parameters not correct after reorder (2,1)"); +// Assert.fail("Parameters not correct after reorder (2,1)"); // } // if (Math.abs(beta[3] - betar[3]) > 1.0e-14) { -// fail("Parameters not correct after reorder (3,0)"); +// Assert.fail("Parameters not correct after reorder (3,0)"); // } // } @@ -793,15 +791,15 @@ public class MillerUpdatingRegressionTes for (int i = 0; i < beta.length; i++) { if (Math.abs(beta[i] - betar[i]) > 1.0e-8) { - fail("Parameters not correctly estimated"); + Assert.fail("Parameters not correctly estimated"); } if (Math.abs(se[i] - ser[i]) > 1.0e-8) { - fail("Standard errors not correctly estimated"); + Assert.fail("Standard errors not correctly estimated"); } for (int j = 0; j < i; j++) { if (Math.abs(result.getCovarianceOfParameters(i, j) - resultRedundant.getCovarianceOfParameters(i, j)) > 1.0e-8) { - fail("Variance Covariance not correct"); + Assert.fail("Variance Covariance not correct"); } } } @@ -854,72 +852,72 @@ public class MillerUpdatingRegressionTes double[] ser = resultRedundant.getStdErrorOfEstimates(); if (Math.abs(beta[0] - betar[0]) > 1.0e-8) { - fail("Parameters not correct after reorder (0,3)"); + Assert.fail("Parameters not correct after reorder (0,3)"); } if (Math.abs(beta[1] - betar[2]) > 1.0e-8) { - fail("Parameters not correct after reorder (1,2)"); + Assert.fail("Parameters not correct after reorder (1,2)"); } if (Math.abs(beta[2] - betar[3]) > 1.0e-8) { - fail("Parameters not correct after reorder (2,1)"); + Assert.fail("Parameters not correct after reorder (2,1)"); } if (Math.abs(beta[3] - betar[5]) > 1.0e-8) { - fail("Parameters not correct after reorder (3,0)"); + Assert.fail("Parameters not correct after reorder (3,0)"); } if (Math.abs(se[0] - ser[0]) > 1.0e-8) { - fail("Se not correct after reorder (0,3)"); + Assert.fail("Se not correct after reorder (0,3)"); } if (Math.abs(se[1] - ser[2]) > 1.0e-8) { - fail("Se not correct after reorder (1,2)"); + Assert.fail("Se not correct after reorder (1,2)"); } if (Math.abs(se[2] - ser[3]) > 1.0e-8) { - fail("Se not correct after reorder (2,1)"); + Assert.fail("Se not correct after reorder (2,1)"); } if (Math.abs(se[3] - ser[5]) > 1.0e-8) { - fail("Se not correct after reorder (3,0)"); + Assert.fail("Se not correct after reorder (3,0)"); } if (Math.abs(result.getCovarianceOfParameters(0, 0) - resultRedundant.getCovarianceOfParameters(0, 0)) > 1.0e-8) { - fail("VCV not correct after reorder (0,0)"); + Assert.fail("VCV not correct after reorder (0,0)"); } if (Math.abs(result.getCovarianceOfParameters(0, 1) - resultRedundant.getCovarianceOfParameters(0, 2)) > 1.0e-8) { - fail("VCV not correct after reorder (0,1)<->(0,2)"); + Assert.fail("VCV not correct after reorder (0,1)<->(0,2)"); } if (Math.abs(result.getCovarianceOfParameters(0, 2) - resultRedundant.getCovarianceOfParameters(0, 3)) > 1.0e-8) { - fail("VCV not correct after reorder (0,2)<->(0,1)"); + Assert.fail("VCV not correct after reorder (0,2)<->(0,1)"); } if (Math.abs(result.getCovarianceOfParameters(0, 3) - resultRedundant.getCovarianceOfParameters(0, 5)) > 1.0e-8) { - fail("VCV not correct after reorder (0,3)<->(0,3)"); + Assert.fail("VCV not correct after reorder (0,3)<->(0,3)"); } if (Math.abs(result.getCovarianceOfParameters(1, 0) - resultRedundant.getCovarianceOfParameters(2, 0)) > 1.0e-8) { - fail("VCV not correct after reorder (1,0)<->(2,0)"); + Assert.fail("VCV not correct after reorder (1,0)<->(2,0)"); } if (Math.abs(result.getCovarianceOfParameters(1, 1) - resultRedundant.getCovarianceOfParameters(2, 2)) > 1.0e-8) { - fail("VCV not correct (1,1)<->(2,1)"); + Assert.fail("VCV not correct (1,1)<->(2,1)"); } if (Math.abs(result.getCovarianceOfParameters(1, 2) - resultRedundant.getCovarianceOfParameters(2, 3)) > 1.0e-8) { - fail("VCV not correct (1,2)<->(2,2)"); + Assert.fail("VCV not correct (1,2)<->(2,2)"); } if (Math.abs(result.getCovarianceOfParameters(2, 0) - resultRedundant.getCovarianceOfParameters(3, 0)) > 1.0e-8) { - fail("VCV not correct (2,0)<->(1,0)"); + Assert.fail("VCV not correct (2,0)<->(1,0)"); } if (Math.abs(result.getCovarianceOfParameters(2, 1) - resultRedundant.getCovarianceOfParameters(3, 2)) > 1.0e-8) { - fail("VCV not correct (2,1)<->(1,2)"); + Assert.fail("VCV not correct (2,1)<->(1,2)"); } if (Math.abs(result.getCovarianceOfParameters(3, 3) - resultRedundant.getCovarianceOfParameters(5, 5)) > 1.0e-8) { - fail("VCV not correct (3,3)<->(3,2)"); + Assert.fail("VCV not correct (3,3)<->(3,2)"); } TestUtils.assertEquals(result.getAdjustedRSquared(), resultRedundant.getAdjustedRSquared(), 1.0e-8); @@ -971,14 +969,14 @@ public class MillerUpdatingRegressionTes for (int i = 0; i < 4; i++) { for (int j = 0; j < i; j++) { if (Math.abs(pc[idx] - cp[off] / (diag[i] * diag[j])) > 1.0e-8) { - fail("Failed cross products... i = " + i + " j = " + j); + Assert.fail("Failed cross products... i = " + i + " j = " + j); } ++idx; ++off; } ++off; if (Math.abs(pc[i+off2] - yxcorr[ i] / (FastMath.sqrt(sumysq) * diag[i])) > 1.0e-8) { - fail("failed cross product i = " + i + " y"); + Assert.fail("Assert.failed cross product i = " + i + " y"); } } double[] pc2 = instance.getPartialCorrelations(1); @@ -988,14 +986,14 @@ public class MillerUpdatingRegressionTes for (int i = 1; i < 4; i++) { for (int j = 1; j < i; j++) { if (Math.abs(pc2[idx] - corr.getEntry(j, i)) > 1.0e-8) { - fail("Failed cross products... i = " + i + " j = " + j); + Assert.fail("Failed cross products... i = " + i + " j = " + j); } ++idx; } } double[] pc3 = instance.getPartialCorrelations(2); if (pc3 == null) { - fail("Should not be null"); + Assert.fail("Should not be null"); } return; } Modified: commons/proper/math/trunk/test-jar.xml URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/test-jar.xml?rev=1209247&r1=1209246&r2=1209247&view=diff ============================================================================== --- commons/proper/math/trunk/test-jar.xml (original) +++ commons/proper/math/trunk/test-jar.xml Thu Dec 1 21:20:47 2011 @@ -64,7 +64,7 @@ - +