You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by tn...@apache.org on 2015/04/26 22:12:02 UTC

[2/2] [math] [MATH-853] MathRuntimeException becomes the commons base class for all other exceptions.

[MATH-853] MathRuntimeException becomes the commons base class for all other exceptions.


Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/afcfbf57
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/afcfbf57
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/afcfbf57

Branch: refs/heads/master
Commit: afcfbf57b993aa96a3697e3869679894e8f460bd
Parents: 2f461bd
Author: Thomas Neidhart <th...@gmail.com>
Authored: Sun Apr 26 22:11:48 2015 +0200
Committer: Thomas Neidhart <th...@gmail.com>
Committed: Sun Apr 26 22:11:48 2015 +0200

----------------------------------------------------------------------
 src/changes/changes.xml                         |  5 ++
 .../math4/exception/ConvergenceException.java   |  3 +-
 .../exception/MathArithmeticException.java      | 33 +------
 .../exception/MathIllegalArgumentException.java | 30 +------
 .../exception/MathIllegalStateException.java    | 34 +-------
 .../math4/exception/MathParseException.java     | 11 +--
 .../math4/exception/MathRuntimeException.java   | 14 +++
 .../MathUnsupportedOperationException.java      | 30 +------
 .../regression/ModelSpecificationException.java |  3 +-
 .../FieldHermiteInterpolatorTest.java           |  3 +-
 .../interpolation/HermiteInterpolatorTest.java  |  3 +-
 .../commons/math4/complex/ComplexUtilsTest.java | 21 ++---
 .../commons/math4/fraction/BigFractionTest.java |  9 +-
 .../math4/genetics/BinaryChromosomeTest.java    |  3 +-
 .../commons/math4/genetics/RandomKeyTest.java   | 15 ++--
 .../math4/linear/Array2DRowRealMatrixTest.java  | 12 +--
 .../math4/linear/FieldMatrixImplTest.java       | 10 +--
 .../math4/linear/RealVectorAbstractTest.java    | 45 +++++++++-
 .../math4/ode/ContinuousOutputModelTest.java    |  8 +-
 .../math4/random/EmpiricalDistributionTest.java | 64 +++++++-------
 .../commons/math4/random/ValueServerTest.java   | 18 ++--
 .../commons/math4/stat/FrequencyTest.java       | 52 +++++------
 .../math4/stat/correlation/CovarianceTest.java  |  5 +-
 .../correlation/PearsonsCorrelationTest.java    |  9 +-
 .../SpearmansRankCorrelationTest.java           | 10 +--
 .../descriptive/DescriptiveStatisticsTest.java  |  7 +-
 .../MultivariateSummaryStatisticsTest.java      |  9 +-
 .../stat/descriptive/SummaryStatisticsTest.java | 53 ++++++------
 .../GLSMultipleLinearRegressionTest.java        | 57 ++++++------
 .../MillerUpdatingRegressionTest.java           | 75 ++++++++--------
 .../MultipleLinearRegressionAbstractTest.java   | 25 +++---
 .../OLSMultipleLinearRegressionTest.java        | 91 ++++++++++----------
 .../transform/FastCosineTransformerTest.java    | 17 ++--
 .../transform/FastHadamardTransformerTest.java  |  3 +-
 .../transform/FastSineTransformerTest.java      | 12 +--
 .../math4/util/ResizableDoubleArrayTest.java    | 25 +++---
 36 files changed, 397 insertions(+), 427 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index cdd6e9a..cc38aa8 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -54,6 +54,11 @@ If the output is not quite correct, check for invisible trailing spaces!
     </release>
 
     <release version="4.0" date="XXXX-XX-XX" description="">
+      <action dev="tn" type="update" issue="MATH-853">
+        "MathRuntimeException" is now the base class for all commons-math
+        exceptions (except for "NullArgumentException" which extends
+        "NullPointerException").
+      </action>    
       <action dev="tn" type="fix" issue="MATH-1197">
         Computation of 2-sample Kolmogorov-Smirnov statistic in case of ties
         was not correct.

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/main/java/org/apache/commons/math4/exception/ConvergenceException.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/exception/ConvergenceException.java b/src/main/java/org/apache/commons/math4/exception/ConvergenceException.java
index f9b6207..6e63615 100644
--- a/src/main/java/org/apache/commons/math4/exception/ConvergenceException.java
+++ b/src/main/java/org/apache/commons/math4/exception/ConvergenceException.java
@@ -43,8 +43,7 @@ public class ConvergenceException extends MathIllegalStateException {
      * the error.
      * @param args Arguments.
      */
-    public ConvergenceException(Localizable pattern,
-                                Object ... args) {
+    public ConvergenceException(Localizable pattern, Object ... args) {
         getContext().addMessage(pattern, args);
     }
 }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/main/java/org/apache/commons/math4/exception/MathArithmeticException.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/exception/MathArithmeticException.java b/src/main/java/org/apache/commons/math4/exception/MathArithmeticException.java
index 7425bc5..a14a033 100644
--- a/src/main/java/org/apache/commons/math4/exception/MathArithmeticException.java
+++ b/src/main/java/org/apache/commons/math4/exception/MathArithmeticException.java
@@ -16,8 +16,6 @@
  */
 package org.apache.commons.math4.exception;
 
-import org.apache.commons.math4.exception.util.ExceptionContext;
-import org.apache.commons.math4.exception.util.ExceptionContextProvider;
 import org.apache.commons.math4.exception.util.Localizable;
 import org.apache.commons.math4.exception.util.LocalizedFormats;
 
@@ -29,19 +27,15 @@ import org.apache.commons.math4.exception.util.LocalizedFormats;
  *
  * @since 3.0
  */
-public class MathArithmeticException extends ArithmeticException
-    implements ExceptionContextProvider {
+public class MathArithmeticException extends MathRuntimeException {
     /** Serializable version Id. */
     private static final long serialVersionUID = -6024911025449780478L;
-    /** Context. */
-    private final ExceptionContext context;
 
     /**
      * Default constructor.
      */
     public MathArithmeticException() {
-        context = new ExceptionContext(this);
-        context.addMessage(LocalizedFormats.ARITHMETIC_EXCEPTION);
+        this(LocalizedFormats.ARITHMETIC_EXCEPTION);
     }
 
     /**
@@ -51,27 +45,8 @@ public class MathArithmeticException extends ArithmeticException
      * the error.
      * @param args Arguments.
      */
-    public MathArithmeticException(Localizable pattern,
-                                   Object ... args) {
-        context = new ExceptionContext(this);
-        context.addMessage(pattern, args);
+    public MathArithmeticException(Localizable pattern, Object ... args) {
+        super(pattern, args);
     }
 
-    /** {@inheritDoc} */
-    @Override
-    public ExceptionContext getContext() {
-        return context;
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public String getMessage() {
-        return context.getMessage();
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public String getLocalizedMessage() {
-        return context.getLocalizedMessage();
-    }
 }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/main/java/org/apache/commons/math4/exception/MathIllegalArgumentException.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/exception/MathIllegalArgumentException.java b/src/main/java/org/apache/commons/math4/exception/MathIllegalArgumentException.java
index efb7482..ea14f42 100644
--- a/src/main/java/org/apache/commons/math4/exception/MathIllegalArgumentException.java
+++ b/src/main/java/org/apache/commons/math4/exception/MathIllegalArgumentException.java
@@ -16,8 +16,6 @@
  */
 package org.apache.commons.math4.exception;
 
-import org.apache.commons.math4.exception.util.ExceptionContext;
-import org.apache.commons.math4.exception.util.ExceptionContextProvider;
 import org.apache.commons.math4.exception.util.Localizable;
 
 /**
@@ -28,38 +26,16 @@ import org.apache.commons.math4.exception.util.Localizable;
  *
  * @since 2.2
  */
-public class MathIllegalArgumentException extends IllegalArgumentException
-    implements ExceptionContextProvider {
+public class MathIllegalArgumentException extends MathRuntimeException {
     /** Serializable version Id. */
     private static final long serialVersionUID = -6024911025449780478L;
-    /** Context. */
-    private final ExceptionContext context;
 
     /**
      * @param pattern Message pattern explaining the cause of the error.
      * @param args Arguments.
      */
-    public MathIllegalArgumentException(Localizable pattern,
-                                        Object ... args) {
-        context = new ExceptionContext(this);
-        context.addMessage(pattern, args);
+    public MathIllegalArgumentException(Localizable pattern, Object ... args) {
+        super(pattern, args);
     }
 
-    /** {@inheritDoc} */
-    @Override
-    public ExceptionContext getContext() {
-        return context;
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public String getMessage() {
-        return context.getMessage();
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public String getLocalizedMessage() {
-        return context.getLocalizedMessage();
-    }
 }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/main/java/org/apache/commons/math4/exception/MathIllegalStateException.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/exception/MathIllegalStateException.java b/src/main/java/org/apache/commons/math4/exception/MathIllegalStateException.java
index 76bb280..b5acb9e 100644
--- a/src/main/java/org/apache/commons/math4/exception/MathIllegalStateException.java
+++ b/src/main/java/org/apache/commons/math4/exception/MathIllegalStateException.java
@@ -16,8 +16,6 @@
  */
 package org.apache.commons.math4.exception;
 
-import org.apache.commons.math4.exception.util.ExceptionContext;
-import org.apache.commons.math4.exception.util.ExceptionContextProvider;
 import org.apache.commons.math4.exception.util.Localizable;
 import org.apache.commons.math4.exception.util.LocalizedFormats;
 
@@ -28,12 +26,9 @@ import org.apache.commons.math4.exception.util.LocalizedFormats;
  *
  * @since 2.2
  */
-public class MathIllegalStateException extends IllegalStateException
-    implements ExceptionContextProvider {
+public class MathIllegalStateException extends MathRuntimeException {
     /** Serializable version Id. */
     private static final long serialVersionUID = -6024911025449780478L;
-    /** Context. */
-    private final ExceptionContext context;
 
     /**
      * Simple constructor.
@@ -41,10 +36,8 @@ public class MathIllegalStateException extends IllegalStateException
      * @param pattern Message pattern explaining the cause of the error.
      * @param args Arguments.
      */
-    public MathIllegalStateException(Localizable pattern,
-                                     Object ... args) {
-        context = new ExceptionContext(this);
-        context.addMessage(pattern, args);
+    public MathIllegalStateException(Localizable pattern, Object ... args) {
+        super(pattern, args);
     }
 
     /**
@@ -57,9 +50,7 @@ public class MathIllegalStateException extends IllegalStateException
     public MathIllegalStateException(Throwable cause,
                                      Localizable pattern,
                                      Object ... args) {
-        super(cause);
-        context = new ExceptionContext(this);
-        context.addMessage(pattern, args);
+        super(cause, pattern, args);
     }
 
     /**
@@ -69,21 +60,4 @@ public class MathIllegalStateException extends IllegalStateException
         this(LocalizedFormats.ILLEGAL_STATE);
     }
 
-    /** {@inheritDoc} */
-    @Override
-    public ExceptionContext getContext() {
-        return context;
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public String getMessage() {
-        return context.getMessage();
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public String getLocalizedMessage() {
-        return context.getLocalizedMessage();
-    }
 }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/main/java/org/apache/commons/math4/exception/MathParseException.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/exception/MathParseException.java b/src/main/java/org/apache/commons/math4/exception/MathParseException.java
index 0ef6a54..ac4819e 100644
--- a/src/main/java/org/apache/commons/math4/exception/MathParseException.java
+++ b/src/main/java/org/apache/commons/math4/exception/MathParseException.java
@@ -16,7 +16,6 @@
  */
 package org.apache.commons.math4.exception;
 
-import org.apache.commons.math4.exception.util.ExceptionContextProvider;
 import org.apache.commons.math4.exception.util.LocalizedFormats;
 
 /**
@@ -24,8 +23,7 @@ import org.apache.commons.math4.exception.util.LocalizedFormats;
  *
  * @since 2.2
  */
-public class MathParseException extends MathIllegalStateException
-    implements ExceptionContextProvider {
+public class MathParseException extends MathIllegalStateException {
     /** Serializable version Id. */
     private static final long serialVersionUID = -6024911025449780478L;
 
@@ -36,9 +34,7 @@ public class MathParseException extends MathIllegalStateException
      * @param type Class of the object supposedly represented by the
      * {@code wrong} string.
      */
-    public MathParseException(String wrong,
-                              int position,
-                              Class<?> type) {
+    public MathParseException(String wrong, int position, Class<?> type) {
         getContext().addMessage(LocalizedFormats.CANNOT_PARSE_AS_TYPE,
                                 wrong, Integer.valueOf(position), type.getName());
     }
@@ -48,8 +44,7 @@ public class MathParseException extends MathIllegalStateException
      * @param position Index, in the {@code wrong} string, that caused the
      * parsing to fail.
      */
-    public MathParseException(String wrong,
-                              int position) {
+    public MathParseException(String wrong, int position) {
         getContext().addMessage(LocalizedFormats.CANNOT_PARSE,
                                 wrong, Integer.valueOf(position));
     }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/main/java/org/apache/commons/math4/exception/MathRuntimeException.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/exception/MathRuntimeException.java b/src/main/java/org/apache/commons/math4/exception/MathRuntimeException.java
index 56fff8e..382af05 100644
--- a/src/main/java/org/apache/commons/math4/exception/MathRuntimeException.java
+++ b/src/main/java/org/apache/commons/math4/exception/MathRuntimeException.java
@@ -46,6 +46,20 @@ public class MathRuntimeException extends RuntimeException
         context.addMessage(pattern, args);
     }
 
+    /**
+     * @param cause Root cause.
+     * @param pattern Message pattern explaining the cause of the error.
+     * @param args Arguments.
+     * @since 4.0
+     */
+    public MathRuntimeException(Throwable cause,
+                                Localizable pattern,
+                                Object ... args) {
+        super(cause);
+        context = new ExceptionContext(this);
+        context.addMessage(pattern, args);
+    }
+
     /** {@inheritDoc} */
     @Override
     public ExceptionContext getContext() {

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/main/java/org/apache/commons/math4/exception/MathUnsupportedOperationException.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/exception/MathUnsupportedOperationException.java b/src/main/java/org/apache/commons/math4/exception/MathUnsupportedOperationException.java
index ad45b60..ede4a8f 100644
--- a/src/main/java/org/apache/commons/math4/exception/MathUnsupportedOperationException.java
+++ b/src/main/java/org/apache/commons/math4/exception/MathUnsupportedOperationException.java
@@ -16,8 +16,6 @@
  */
 package org.apache.commons.math4.exception;
 
-import org.apache.commons.math4.exception.util.ExceptionContext;
-import org.apache.commons.math4.exception.util.ExceptionContextProvider;
 import org.apache.commons.math4.exception.util.Localizable;
 import org.apache.commons.math4.exception.util.LocalizedFormats;
 
@@ -29,12 +27,9 @@ import org.apache.commons.math4.exception.util.LocalizedFormats;
  *
  * @since 2.2
  */
-public class MathUnsupportedOperationException extends UnsupportedOperationException
-    implements ExceptionContextProvider {
+public class MathUnsupportedOperationException extends MathRuntimeException {
     /** Serializable version Id. */
     private static final long serialVersionUID = -6024911025449780478L;
-    /** Context. */
-    private final ExceptionContext context;
 
     /**
      * Default constructor.
@@ -47,27 +42,8 @@ public class MathUnsupportedOperationException extends UnsupportedOperationExcep
      * the error.
      * @param args Arguments.
      */
-    public MathUnsupportedOperationException(Localizable pattern,
-                                             Object ... args) {
-        context = new ExceptionContext(this);
-        context.addMessage(pattern, args);
+    public MathUnsupportedOperationException(Localizable pattern, Object ... args) {
+        super(pattern, args);
     }
 
-    /** {@inheritDoc} */
-    @Override
-    public ExceptionContext getContext() {
-        return context;
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public String getMessage() {
-        return context.getMessage();
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public String getLocalizedMessage() {
-        return context.getLocalizedMessage();
-    }
 }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/main/java/org/apache/commons/math4/stat/regression/ModelSpecificationException.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/stat/regression/ModelSpecificationException.java b/src/main/java/org/apache/commons/math4/stat/regression/ModelSpecificationException.java
index 248234d..2607a5f 100644
--- a/src/main/java/org/apache/commons/math4/stat/regression/ModelSpecificationException.java
+++ b/src/main/java/org/apache/commons/math4/stat/regression/ModelSpecificationException.java
@@ -33,8 +33,7 @@ public class ModelSpecificationException extends MathIllegalArgumentException {
      *
      * @param args arguments.
      */
-    public ModelSpecificationException(Localizable pattern,
-                                        Object ... args) {
+    public ModelSpecificationException(Localizable pattern, Object ... args) {
         super(pattern, args);
     }
 }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/test/java/org/apache/commons/math4/analysis/interpolation/FieldHermiteInterpolatorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/analysis/interpolation/FieldHermiteInterpolatorTest.java b/src/test/java/org/apache/commons/math4/analysis/interpolation/FieldHermiteInterpolatorTest.java
index 0c3b27b..1e5b031 100644
--- a/src/test/java/org/apache/commons/math4/analysis/interpolation/FieldHermiteInterpolatorTest.java
+++ b/src/test/java/org/apache/commons/math4/analysis/interpolation/FieldHermiteInterpolatorTest.java
@@ -22,6 +22,7 @@ import org.apache.commons.math4.analysis.interpolation.FieldHermiteInterpolator;
 import org.apache.commons.math4.analysis.polynomials.PolynomialFunction;
 import org.apache.commons.math4.dfp.Dfp;
 import org.apache.commons.math4.dfp.DfpField;
+import org.apache.commons.math4.exception.MathIllegalArgumentException;
 import org.apache.commons.math4.exception.NoDataException;
 import org.apache.commons.math4.fraction.BigFraction;
 import org.apache.commons.math4.util.FastMath;
@@ -265,7 +266,7 @@ public class FieldHermiteInterpolatorTest {
         new FieldHermiteInterpolator<BigFraction>().derivatives(BigFraction.ZERO, 1);
     }
 
-    @Test(expected=IllegalArgumentException.class)
+    @Test(expected=MathIllegalArgumentException.class)
     public void testDuplicatedAbscissa() {
         FieldHermiteInterpolator<BigFraction> interpolator = new FieldHermiteInterpolator<BigFraction>();
         interpolator.addSamplePoint(new BigFraction(1), new BigFraction[] { new BigFraction(0) });

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/test/java/org/apache/commons/math4/analysis/interpolation/HermiteInterpolatorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/analysis/interpolation/HermiteInterpolatorTest.java b/src/test/java/org/apache/commons/math4/analysis/interpolation/HermiteInterpolatorTest.java
index 8dbb6ac..f07fa36 100644
--- a/src/test/java/org/apache/commons/math4/analysis/interpolation/HermiteInterpolatorTest.java
+++ b/src/test/java/org/apache/commons/math4/analysis/interpolation/HermiteInterpolatorTest.java
@@ -21,6 +21,7 @@ import java.util.Random;
 import org.apache.commons.math4.analysis.differentiation.DerivativeStructure;
 import org.apache.commons.math4.analysis.interpolation.HermiteInterpolator;
 import org.apache.commons.math4.analysis.polynomials.PolynomialFunction;
+import org.apache.commons.math4.exception.MathIllegalArgumentException;
 import org.apache.commons.math4.exception.NoDataException;
 import org.apache.commons.math4.util.FastMath;
 import org.junit.Assert;
@@ -234,7 +235,7 @@ public class HermiteInterpolatorTest {
         new HermiteInterpolator().value(0.0);
     }
 
-    @Test(expected=IllegalArgumentException.class)
+    @Test(expected=MathIllegalArgumentException.class)
     public void testDuplicatedAbscissa() {
         HermiteInterpolator interpolator = new HermiteInterpolator();
         interpolator.addSamplePoint(1.0, new double[] { 0.0 });

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/test/java/org/apache/commons/math4/complex/ComplexUtilsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/complex/ComplexUtilsTest.java b/src/test/java/org/apache/commons/math4/complex/ComplexUtilsTest.java
index 77c0d43..a0e9c6f 100644
--- a/src/test/java/org/apache/commons/math4/complex/ComplexUtilsTest.java
+++ b/src/test/java/org/apache/commons/math4/complex/ComplexUtilsTest.java
@@ -20,6 +20,7 @@ package org.apache.commons.math4.complex;
 import org.apache.commons.math4.TestUtils;
 import org.apache.commons.math4.complex.Complex;
 import org.apache.commons.math4.complex.ComplexUtils;
+import org.apache.commons.math4.exception.MathIllegalArgumentException;
 import org.apache.commons.math4.util.FastMath;
 import org.junit.Test;
 import org.junit.Assert;
@@ -28,16 +29,16 @@ import org.junit.Assert;
  */
 public class ComplexUtilsTest {
 
-    private double inf = Double.POSITIVE_INFINITY;
-    private double negInf = Double.NEGATIVE_INFINITY;
-    private double nan = Double.NaN;
-    private double pi = FastMath.PI;
+    private final double inf = Double.POSITIVE_INFINITY;
+    private final double negInf = Double.NEGATIVE_INFINITY;
+    private final double nan = Double.NaN;
+    private final double pi = FastMath.PI;
 
-    private Complex negInfInf = new Complex(negInf, inf);
-    private Complex infNegInf = new Complex(inf, negInf);
-    private Complex infInf = new Complex(inf, inf);
-    private Complex negInfNegInf = new Complex(negInf, negInf);
-    private Complex infNaN = new Complex(inf, nan);
+    private final Complex negInfInf = new Complex(negInf, inf);
+    private final Complex infNegInf = new Complex(inf, negInf);
+    private final Complex infInf = new Complex(inf, inf);
+    private final Complex negInfNegInf = new Complex(negInf, negInf);
+    private final Complex infNaN = new Complex(inf, nan);
 
     @Test
     public void testPolar2Complex() {
@@ -73,7 +74,7 @@ public class ComplexUtilsTest {
         return Complex.I.multiply(new Complex(theta, 0)).exp().multiply(new Complex(r, 0));
     }
 
-    @Test(expected=IllegalArgumentException.class)
+    @Test(expected=MathIllegalArgumentException.class)
     public void testPolar2ComplexIllegalModulus() {
         ComplexUtils.polar2Complex(-1, 0);
     }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/test/java/org/apache/commons/math4/fraction/BigFractionTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/fraction/BigFractionTest.java b/src/test/java/org/apache/commons/math4/fraction/BigFractionTest.java
index d921026..bba0cd4 100644
--- a/src/test/java/org/apache/commons/math4/fraction/BigFractionTest.java
+++ b/src/test/java/org/apache/commons/math4/fraction/BigFractionTest.java
@@ -22,6 +22,7 @@ import java.math.BigInteger;
 import org.apache.commons.math4.TestUtils;
 import org.apache.commons.math4.exception.ConvergenceException;
 import org.apache.commons.math4.exception.MathArithmeticException;
+import org.apache.commons.math4.exception.MathIllegalArgumentException;
 import org.apache.commons.math4.exception.NullArgumentException;
 import org.apache.commons.math4.exception.ZeroException;
 import org.apache.commons.math4.fraction.BigFraction;
@@ -156,9 +157,9 @@ public class BigFractionTest {
         assertFraction(8, 13, new BigFraction(0.6152, 99));
         assertFraction(510, 829, new BigFraction(0.6152, 999));
         assertFraction(769, 1250, new BigFraction(0.6152, 9999));
-        
+
         // MATH-996
-        assertFraction(1, 2, new BigFraction(0.5000000001, 10));        
+        assertFraction(1, 2, new BigFraction(0.5000000001, 10));
     }
 
     // MATH-1029
@@ -280,8 +281,8 @@ public class BigFractionTest {
         for (double v : new double[] { Double.NaN, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY}) {
             try {
                 new BigFraction(v);
-                Assert.fail("Expecting IllegalArgumentException");
-            } catch (IllegalArgumentException iae) {
+                Assert.fail("Expecting MathIllegalArgumentException");
+            } catch (MathIllegalArgumentException iae) {
                 // expected
             }
         }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/test/java/org/apache/commons/math4/genetics/BinaryChromosomeTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/genetics/BinaryChromosomeTest.java b/src/test/java/org/apache/commons/math4/genetics/BinaryChromosomeTest.java
index b846fde..4525fb4 100644
--- a/src/test/java/org/apache/commons/math4/genetics/BinaryChromosomeTest.java
+++ b/src/test/java/org/apache/commons/math4/genetics/BinaryChromosomeTest.java
@@ -17,6 +17,7 @@
 package org.apache.commons.math4.genetics;
 
 
+import org.apache.commons.math4.exception.MathIllegalArgumentException;
 import org.apache.commons.math4.genetics.BinaryChromosome;
 import org.apache.commons.math4.genetics.Chromosome;
 import org.junit.Assert;
@@ -35,7 +36,7 @@ public class BinaryChromosomeTest {
             try {
                 new DummyBinaryChromosome(repr);
                 Assert.fail("Exception not caught");
-            } catch (IllegalArgumentException e) {
+            } catch (MathIllegalArgumentException e) {
                 // Expected
             }
         }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/test/java/org/apache/commons/math4/genetics/RandomKeyTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/genetics/RandomKeyTest.java b/src/test/java/org/apache/commons/math4/genetics/RandomKeyTest.java
index 040edc9..e8ef32b 100644
--- a/src/test/java/org/apache/commons/math4/genetics/RandomKeyTest.java
+++ b/src/test/java/org/apache/commons/math4/genetics/RandomKeyTest.java
@@ -21,6 +21,7 @@ import java.util.Arrays;
 import java.util.Comparator;
 import java.util.List;
 
+import org.apache.commons.math4.exception.MathIllegalArgumentException;
 import org.apache.commons.math4.genetics.RandomKey;
 import org.junit.Assert;
 import org.junit.Test;
@@ -28,12 +29,12 @@ import org.junit.Test;
 @SuppressWarnings("boxing")
 public class RandomKeyTest {
 
-    @Test(expected=IllegalArgumentException.class)
+    @Test(expected=MathIllegalArgumentException.class)
     public void testConstructor1() {
         new DummyRandomKey(new Double[] {0.2, 0.3, 1.2});
     }
 
-    @Test(expected=IllegalArgumentException.class)
+    @Test(expected=MathIllegalArgumentException.class)
     public void testConstructor2() {
         new DummyRandomKey(new Double[] {0.2, 0.3, -0.2});
     }
@@ -63,8 +64,8 @@ public class RandomKeyTest {
         Assert.assertEquals("c", decoded.get(3));
         Assert.assertEquals("d", decoded.get(4));
     }
-    
-    @Test(expected=IllegalArgumentException.class)
+
+    @Test(expected=MathIllegalArgumentException.class)
     public void testInvalidRepresentation() {
         new DummyRandomKey(new Double[] {0.1, 0.1, 2d, 0.8, 0.2});
     }
@@ -95,6 +96,7 @@ public class RandomKeyTest {
         List<String> data = Arrays.asList(new String[] {"x", "b", "c", "z", "b"});
 
         List<Double> permutation = RandomKey.comparatorPermutation(data, new Comparator<String>() {
+            @Override
             public int compare(String o1, String o2) {
                 return o1.compareTo(o2);
             }
@@ -110,6 +112,7 @@ public class RandomKeyTest {
         Assert.assertEquals("z", decodedData.get(4));
 
         permutation = RandomKey.comparatorPermutation(data, new Comparator<String>() {
+            @Override
             public int compare(String o1, String o2) {
                 return o2.compareTo(o1);
             }
@@ -145,7 +148,7 @@ public class RandomKeyTest {
                     Arrays.asList(new String[] {"a", "b", "c", "d"})
             );
             Assert.fail("Uncaught exception");
-        } catch (IllegalArgumentException e) {
+        } catch (MathIllegalArgumentException e) {
             // no-op
         }
         try {
@@ -154,7 +157,7 @@ public class RandomKeyTest {
                     Arrays.asList(new String[] {"a", "b", "c", "d", "f"})
             );
             Assert.fail("Uncaught exception");
-        } catch (IllegalArgumentException e) {
+        } catch (MathIllegalArgumentException e) {
             // no-op
         }
     }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/test/java/org/apache/commons/math4/linear/Array2DRowRealMatrixTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/linear/Array2DRowRealMatrixTest.java b/src/test/java/org/apache/commons/math4/linear/Array2DRowRealMatrixTest.java
index 63300b4..147e80f 100644
--- a/src/test/java/org/apache/commons/math4/linear/Array2DRowRealMatrixTest.java
+++ b/src/test/java/org/apache/commons/math4/linear/Array2DRowRealMatrixTest.java
@@ -219,9 +219,9 @@ public final class Array2DRowRealMatrixTest {
 
     //Additional Test for Array2DRowRealMatrixTest.testMultiply
 
-    private double[][] d3 = new double[][] {{1,2,3,4},{5,6,7,8}};
-    private double[][] d4 = new double[][] {{1},{2},{3},{4}};
-    private double[][] d5 = new double[][] {{30},{70}};
+    private final double[][] d3 = new double[][] {{1,2,3,4},{5,6,7,8}};
+    private final double[][] d4 = new double[][] {{1},{2},{3},{4}};
+    private final double[][] d5 = new double[][] {{30},{70}};
 
     @Test
     public void testMultiply2() {
@@ -279,8 +279,8 @@ public final class Array2DRowRealMatrixTest {
 
         try {
             m.power(-1);
-            Assert.fail("Expecting IllegalArgumentException");
-        } catch (IllegalArgumentException ex) {
+            Assert.fail("Expecting MathIllegalArgumentException");
+        } catch (MathIllegalArgumentException ex) {
             // ignored
         }
     }
@@ -545,7 +545,7 @@ public final class Array2DRowRealMatrixTest {
         checkCopy(m, null,  1, 0, 2, 4, true);
         checkCopy(m, null, new int[] {},    new int[] { 0 }, true);
         checkCopy(m, null, new int[] { 0 }, new int[] { 4 }, true);
-        
+
         // rectangular check
         double[][] copy = new double[][] { { 0, 0, 0 }, { 0, 0 } };
         checkCopy(m, copy, 0, 1, 0, 2, true);

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/test/java/org/apache/commons/math4/linear/FieldMatrixImplTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/linear/FieldMatrixImplTest.java b/src/test/java/org/apache/commons/math4/linear/FieldMatrixImplTest.java
index 76f79f8..4fb5bf4 100644
--- a/src/test/java/org/apache/commons/math4/linear/FieldMatrixImplTest.java
+++ b/src/test/java/org/apache/commons/math4/linear/FieldMatrixImplTest.java
@@ -193,9 +193,9 @@ public final class FieldMatrixImplTest {
 
     //Additional Test for Array2DRowFieldMatrix<Fraction>Test.testMultiply
 
-    private Fraction[][] d3 = new Fraction[][] {{new Fraction(1),new Fraction(2),new Fraction(3),new Fraction(4)},{new Fraction(5),new Fraction(6),new Fraction(7),new Fraction(8)}};
-    private Fraction[][] d4 = new Fraction[][] {{new Fraction(1)},{new Fraction(2)},{new Fraction(3)},{new Fraction(4)}};
-    private Fraction[][] d5 = new Fraction[][] {{new Fraction(30)},{new Fraction(70)}};
+    private final Fraction[][] d3 = new Fraction[][] {{new Fraction(1),new Fraction(2),new Fraction(3),new Fraction(4)},{new Fraction(5),new Fraction(6),new Fraction(7),new Fraction(8)}};
+    private final Fraction[][] d4 = new Fraction[][] {{new Fraction(1)},{new Fraction(2)},{new Fraction(3)},{new Fraction(4)}};
+    private final Fraction[][] d5 = new Fraction[][] {{new Fraction(30)},{new Fraction(70)}};
 
     @Test
     public void testMultiply2() {
@@ -245,8 +245,8 @@ public final class FieldMatrixImplTest {
 
         try {
             m.power(-1);
-            Assert.fail("Expecting IllegalArgumentException");
-        } catch (IllegalArgumentException ex) {
+            Assert.fail("Expecting MathIllegalArgumentException");
+        } catch (MathIllegalArgumentException ex) {
             // ignored
         }
     }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/test/java/org/apache/commons/math4/linear/RealVectorAbstractTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/linear/RealVectorAbstractTest.java b/src/test/java/org/apache/commons/math4/linear/RealVectorAbstractTest.java
index b49301c..0324ffc 100644
--- a/src/test/java/org/apache/commons/math4/linear/RealVectorAbstractTest.java
+++ b/src/test/java/org/apache/commons/math4/linear/RealVectorAbstractTest.java
@@ -49,6 +49,7 @@ import org.apache.commons.math4.analysis.function.Tanh;
 import org.apache.commons.math4.analysis.function.Ulp;
 import org.apache.commons.math4.exception.DimensionMismatchException;
 import org.apache.commons.math4.exception.MathArithmeticException;
+import org.apache.commons.math4.exception.MathUnsupportedOperationException;
 import org.apache.commons.math4.exception.NotPositiveException;
 import org.apache.commons.math4.exception.NumberIsTooSmallException;
 import org.apache.commons.math4.exception.OutOfRangeException;
@@ -1061,12 +1062,12 @@ public abstract class RealVectorAbstractTest {
         }
     }
 
-    @Test(expected=ArithmeticException.class)
+    @Test(expected=MathArithmeticException.class)
     public void testUnitVectorNullVector() {
         doTestUnitVectorNullVector(false);
     }
 
-    @Test(expected=ArithmeticException.class)
+    @Test(expected=MathArithmeticException.class)
     public void testUnitizeNullVector() {
         doTestUnitVectorNullVector(true);
     }
@@ -1082,8 +1083,8 @@ public abstract class RealVectorAbstractTest {
             Assert.assertEquals("", values[i], e.getValue(), 0d);
             try {
                 it.remove();
-                Assert.fail("UnsupportedOperationException should have been thrown");
-            } catch (UnsupportedOperationException exc) {
+                Assert.fail("MathUnsupportedOperationException should have been thrown");
+            } catch (MathUnsupportedOperationException exc) {
                 // Expected behavior
             }
         }
@@ -1395,6 +1396,7 @@ public abstract class RealVectorAbstractTest {
 
             private int expectedIndex;
 
+            @Override
             public void visit(final int actualIndex, final double actualValue) {
                 Assert.assertEquals(expectedIndex, actualIndex);
                 Assert.assertEquals(Integer.toString(actualIndex),
@@ -1402,6 +1404,7 @@ public abstract class RealVectorAbstractTest {
                 ++expectedIndex;
             }
 
+            @Override
             public void start(final int actualSize, final int actualStart,
                               final int actualEnd) {
                 Assert.assertEquals(data.length, actualSize);
@@ -1410,6 +1413,7 @@ public abstract class RealVectorAbstractTest {
                 expectedIndex = 0;
             }
 
+            @Override
             public double end() {
                 return 0.0;
             }
@@ -1424,14 +1428,17 @@ public abstract class RealVectorAbstractTest {
         final RealVectorPreservingVisitor visitor;
         visitor = new RealVectorPreservingVisitor() {
 
+            @Override
             public void visit(int index, double value) {
                 // Do nothing
             }
 
+            @Override
             public void start(int dimension, int start, int end) {
                 // Do nothing
             }
 
+            @Override
             public double end() {
                 return 0.0;
             }
@@ -1482,6 +1489,7 @@ public abstract class RealVectorAbstractTest {
 
             private int expectedIndex;
 
+            @Override
             public void visit(final int actualIndex, final double actualValue) {
                 Assert.assertEquals(expectedIndex, actualIndex);
                 Assert.assertEquals(Integer.toString(actualIndex),
@@ -1489,6 +1497,7 @@ public abstract class RealVectorAbstractTest {
                 ++expectedIndex;
             }
 
+            @Override
             public void start(final int actualSize, final int actualStart,
                               final int actualEnd) {
                 Assert.assertEquals(data.length, actualSize);
@@ -1497,6 +1506,7 @@ public abstract class RealVectorAbstractTest {
                 expectedIndex = expectedStart;
             }
 
+            @Override
             public double end() {
                 return 0.0;
             }
@@ -1515,12 +1525,14 @@ public abstract class RealVectorAbstractTest {
         visitor = new RealVectorPreservingVisitor() {
             private final boolean[] visited = new boolean[data.length];
 
+            @Override
             public void visit(final int actualIndex, final double actualValue) {
                 visited[actualIndex] = true;
                 Assert.assertEquals(Integer.toString(actualIndex),
                                     data[actualIndex], actualValue, 0d);
             }
 
+            @Override
             public void start(final int actualSize, final int actualStart,
                               final int actualEnd) {
                 Assert.assertEquals(data.length, actualSize);
@@ -1529,6 +1541,7 @@ public abstract class RealVectorAbstractTest {
                 Arrays.fill(visited, false);
             }
 
+            @Override
             public double end() {
                 for (int i = 0; i < data.length; i++) {
                     Assert.assertTrue("entry " + i + "has not been visited",
@@ -1547,14 +1560,17 @@ public abstract class RealVectorAbstractTest {
         final RealVectorPreservingVisitor visitor;
         visitor = new RealVectorPreservingVisitor() {
 
+            @Override
             public void visit(int index, double value) {
                 // Do nothing
             }
 
+            @Override
             public void start(int dimension, int start, int end) {
                 // Do nothing
             }
 
+            @Override
             public double end() {
                 return 0.0;
             }
@@ -1604,12 +1620,14 @@ public abstract class RealVectorAbstractTest {
         visitor = new RealVectorPreservingVisitor() {
             private final boolean[] visited = new boolean[data.length];
 
+            @Override
             public void visit(final int actualIndex, final double actualValue) {
                 Assert.assertEquals(Integer.toString(actualIndex),
                                     data[actualIndex], actualValue, 0d);
                 visited[actualIndex] = true;
             }
 
+            @Override
             public void start(final int actualSize, final int actualStart,
                               final int actualEnd) {
                 Assert.assertEquals(data.length, actualSize);
@@ -1618,6 +1636,7 @@ public abstract class RealVectorAbstractTest {
                 Arrays.fill(visited, true);
             }
 
+            @Override
             public double end() {
                 for (int i = expectedStart; i <= expectedEnd; i++) {
                     Assert.assertTrue("entry " + i + "has not been visited",
@@ -1641,6 +1660,7 @@ public abstract class RealVectorAbstractTest {
 
             private int expectedIndex;
 
+            @Override
             public double visit(final int actualIndex, final double actualValue) {
                 Assert.assertEquals(expectedIndex, actualIndex);
                 Assert.assertEquals(Integer.toString(actualIndex),
@@ -1649,6 +1669,7 @@ public abstract class RealVectorAbstractTest {
                 return actualIndex + actualValue;
             }
 
+            @Override
             public void start(final int actualSize, final int actualStart,
                               final int actualEnd) {
                 Assert.assertEquals(data.length, actualSize);
@@ -1657,6 +1678,7 @@ public abstract class RealVectorAbstractTest {
                 expectedIndex = 0;
             }
 
+            @Override
             public double end() {
                 return 0.0;
             }
@@ -1674,14 +1696,17 @@ public abstract class RealVectorAbstractTest {
         final RealVectorChangingVisitor visitor;
         visitor = new RealVectorChangingVisitor() {
 
+            @Override
             public double visit(int index, double value) {
                 return 0.0;
             }
 
+            @Override
             public void start(int dimension, int start, int end) {
                 // Do nothing
             }
 
+            @Override
             public double end() {
                 return 0.0;
             }
@@ -1732,6 +1757,7 @@ public abstract class RealVectorAbstractTest {
 
             private int expectedIndex;
 
+            @Override
             public double visit(final int actualIndex, final double actualValue) {
                 Assert.assertEquals(expectedIndex, actualIndex);
                 Assert.assertEquals(Integer.toString(actualIndex),
@@ -1740,6 +1766,7 @@ public abstract class RealVectorAbstractTest {
                 return actualIndex + actualValue;
             }
 
+            @Override
             public void start(final int actualSize, final int actualStart,
                               final int actualEnd) {
                 Assert.assertEquals(data.length, actualSize);
@@ -1748,6 +1775,7 @@ public abstract class RealVectorAbstractTest {
                 expectedIndex = expectedStart;
             }
 
+            @Override
             public double end() {
                 return 0.0;
             }
@@ -1769,6 +1797,7 @@ public abstract class RealVectorAbstractTest {
         visitor = new RealVectorChangingVisitor() {
             private final boolean[] visited = new boolean[data.length];
 
+            @Override
             public double visit(final int actualIndex, final double actualValue) {
                 visited[actualIndex] = true;
                 Assert.assertEquals(Integer.toString(actualIndex),
@@ -1776,6 +1805,7 @@ public abstract class RealVectorAbstractTest {
                 return actualIndex + actualValue;
             }
 
+            @Override
             public void start(final int actualSize, final int actualStart,
                               final int actualEnd) {
                 Assert.assertEquals(data.length, actualSize);
@@ -1784,6 +1814,7 @@ public abstract class RealVectorAbstractTest {
                 Arrays.fill(visited, false);
             }
 
+            @Override
             public double end() {
                 for (int i = 0; i < data.length; i++) {
                     Assert.assertTrue("entry " + i + "has not been visited",
@@ -1805,14 +1836,17 @@ public abstract class RealVectorAbstractTest {
         final RealVectorChangingVisitor visitor;
         visitor = new RealVectorChangingVisitor() {
 
+            @Override
             public double visit(int index, double value) {
                 return 0.0;
             }
 
+            @Override
             public void start(int dimension, int start, int end) {
                 // Do nothing
             }
 
+            @Override
             public double end() {
                 return 0.0;
             }
@@ -1862,6 +1896,7 @@ public abstract class RealVectorAbstractTest {
         visitor = new RealVectorChangingVisitor() {
             private final boolean[] visited = new boolean[data.length];
 
+            @Override
             public double visit(final int actualIndex, final double actualValue) {
                 Assert.assertEquals(Integer.toString(actualIndex),
                                     data[actualIndex], actualValue, 0d);
@@ -1869,6 +1904,7 @@ public abstract class RealVectorAbstractTest {
                 return actualIndex + actualValue;
             }
 
+            @Override
             public void start(final int actualSize, final int actualStart,
                               final int actualEnd) {
                 Assert.assertEquals(data.length, actualSize);
@@ -1877,6 +1913,7 @@ public abstract class RealVectorAbstractTest {
                 Arrays.fill(visited, true);
             }
 
+            @Override
             public double end() {
                 for (int i = expectedStart; i <= expectedEnd; i++) {
                     Assert.assertTrue("entry " + i + "has not been visited",

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/test/java/org/apache/commons/math4/ode/ContinuousOutputModelTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/ode/ContinuousOutputModelTest.java b/src/test/java/org/apache/commons/math4/ode/ContinuousOutputModelTest.java
index b08ef1f..d9d2cb4 100644
--- a/src/test/java/org/apache/commons/math4/ode/ContinuousOutputModelTest.java
+++ b/src/test/java/org/apache/commons/math4/ode/ContinuousOutputModelTest.java
@@ -98,11 +98,13 @@ public class ContinuousOutputModelTest {
       // theoretical solution: y[0] = cos(t), y[1] = sin(t)
       FirstOrderDifferentialEquations problem =
           new FirstOrderDifferentialEquations() {
-              public void computeDerivatives(double t, double[] y, double[] dot) {
+              @Override
+            public void computeDerivatives(double t, double[] y, double[] dot) {
                   dot[0] = -y[1];
                   dot[1] =  y[0];
               }
-              public int getDimension() {
+              @Override
+            public int getDimension() {
                   return 2;
               }
           };
@@ -169,7 +171,7 @@ public class ContinuousOutputModelTest {
           ContinuousOutputModel otherCm = new ContinuousOutputModel();
           otherCm.handleStep(buildInterpolator(t0, y0, t1), true);
           cm.append(otherCm);
-      } catch(IllegalArgumentException iae) {
+      } catch(MathIllegalArgumentException iae) {
           return true; // there was an allowable error
       }
       return false; // no allowable error

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/test/java/org/apache/commons/math4/random/EmpiricalDistributionTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/random/EmpiricalDistributionTest.java b/src/test/java/org/apache/commons/math4/random/EmpiricalDistributionTest.java
index 6f38711..9633ff7 100644
--- a/src/test/java/org/apache/commons/math4/random/EmpiricalDistributionTest.java
+++ b/src/test/java/org/apache/commons/math4/random/EmpiricalDistributionTest.java
@@ -33,6 +33,7 @@ import org.apache.commons.math4.distribution.NormalDistribution;
 import org.apache.commons.math4.distribution.RealDistribution;
 import org.apache.commons.math4.distribution.RealDistributionAbstractTest;
 import org.apache.commons.math4.distribution.UniformRealDistribution;
+import org.apache.commons.math4.exception.MathIllegalStateException;
 import org.apache.commons.math4.exception.NullArgumentException;
 import org.apache.commons.math4.random.EmpiricalDistribution;
 import org.apache.commons.math4.random.RandomGenerator;
@@ -94,13 +95,13 @@ public final class EmpiricalDistributionTest extends RealDistributionAbstractTes
         // Load from a URL
         empiricalDistribution.load(url);
         checkDistribution();
-        
+
         // Load again from a file (also verifies idempotency of load)
         File file = new File(url.toURI());
         empiricalDistribution.load(file);
         checkDistribution();
     }
-    
+
     private void checkDistribution() {
         // testData File has 10000 values, with mean ~ 5.0, std dev ~ 1
         // Make sure that loaded distribution matches this
@@ -156,8 +157,8 @@ public final class EmpiricalDistributionTest extends RealDistributionAbstractTes
         try {
             empiricalDistribution.getNextValue();
             empiricalDistribution2.getNextValue();
-            Assert.fail("Expecting IllegalStateException");
-        } catch (IllegalStateException ex) {
+            Assert.fail("Expecting MathIllegalStateException");
+        } catch (MathIllegalStateException ex) {
             // expected
         }
     }
@@ -236,24 +237,24 @@ public final class EmpiricalDistributionTest extends RealDistributionAbstractTes
         TestUtils.assertEquals(expectedBinUpperBounds, dist.getUpperBounds(), tol);
         TestUtils.assertEquals(expectedGeneratorUpperBounds, dist.getGeneratorUpperBounds(), tol);
     }
-    
+
     @Test
     public void testGeneratorConfig() {
         double[] testData = {0, 1, 2, 3, 4};
         RandomGenerator generator = new RandomAdaptorTest.ConstantGenerator(0.5);
-        
+
         EmpiricalDistribution dist = new EmpiricalDistribution(5, generator);
         dist.load(testData);
         for (int i = 0; i < 5; i++) {
             Assert.assertEquals(2.0, dist.getNextValue(), 0d);
         }
-        
+
         // Verify no NPE with null generator argument
         dist = new EmpiricalDistribution(5, (RandomGenerator) null);
         dist.load(testData);
         dist.getNextValue();
     }
-    
+
     @Test
     public void testReSeed() throws Exception {
         empiricalDistribution.load(url);
@@ -301,9 +302,9 @@ public final class EmpiricalDistributionTest extends RealDistributionAbstractTes
         Assert.assertEquals("mean", 5.069831575018909, stats.getMean(), tolerance);
         Assert.assertEquals("std dev", 1.0173699343977738, stats.getStandardDeviation(), tolerance);
     }
-   
+
     //  Setup for distribution tests
-    
+
     @Override
     public RealDistribution makeDistribution() {
         // Create a uniform distribution on [0, 10,000]
@@ -315,10 +316,10 @@ public final class EmpiricalDistributionTest extends RealDistributionAbstractTes
         dist.load(sourceData);
         return dist;
     }
-    
+
     /** Uniform bin mass = 10/10001 == mass of all but the first bin */
     private final double binMass = 10d / (n + 1);
-    
+
     /** Mass of first bin = 11/10001 */
     private final double firstBinMass = 11d / (n + 1);
 
@@ -327,11 +328,11 @@ public final class EmpiricalDistributionTest extends RealDistributionAbstractTes
        final double[] testPoints = new double[] {9, 10, 15, 1000, 5004, 9999};
        return testPoints;
     }
-    
+
 
     @Override
     public double[] makeCumulativeTestValues() {
-        /* 
+        /*
          * Bins should be [0, 10], (10, 20], ..., (9990, 10000]
          * Kernels should be N(4.5, 3.02765), N(14.5, 3.02765)...
          * Each bin should have mass 10/10000 = .001
@@ -370,12 +371,12 @@ public final class EmpiricalDistributionTest extends RealDistributionAbstractTes
             final RealDistribution kernel = findKernel(lower, upper);
             final double withinBinKernelMass = kernel.probability(lower, upper);
             final double density = kernel.density(testPoints[i]);
-            densityValues[i] = density * (bin == 0 ? firstBinMass : binMass) / withinBinKernelMass;   
+            densityValues[i] = density * (bin == 0 ? firstBinMass : binMass) / withinBinKernelMass;
         }
         return densityValues;
     }
-    
-    /** 
+
+    /**
      * Modify test integration bounds from the default. Because the distribution
      * has discontinuities at bin boundaries, integrals spanning multiple bins
      * will face convergence problems.  Only test within-bin integrals and spans
@@ -389,6 +390,7 @@ public final class EmpiricalDistributionTest extends RealDistributionAbstractTes
         final BaseAbstractUnivariateIntegrator integrator =
             new IterativeLegendreGaussIntegrator(5, 1.0e-12, 1.0e-10);
         final UnivariateFunction d = new UnivariateFunction() {
+            @Override
             public double value(double x) {
                 return distribution.density(x);
             }
@@ -397,15 +399,15 @@ public final class EmpiricalDistributionTest extends RealDistributionAbstractTes
         final double[] upper = {5, 12, 1030, 5010, 10000};
         for (int i = 1; i < 5; i++) {
             Assert.assertEquals(
-                    distribution.probability( 
+                    distribution.probability(
                             lower[i], upper[i]),
                             integrator.integrate(
                                     1000000, // Triangle integrals are very slow to converge
                                     d, lower[i], upper[i]), tol);
         }
     }
-    
-    /** 
+
+    /**
      * MATH-984
      * Verify that sampled values do not go outside of the range of the data.
      */
@@ -429,7 +431,7 @@ public final class EmpiricalDistributionTest extends RealDistributionAbstractTes
             Assert.assertTrue(dev > 0);
         }
     }
-    
+
     /**
      * MATH-1203, MATH-1208
      */
@@ -448,7 +450,7 @@ public final class EmpiricalDistributionTest extends RealDistributionAbstractTes
         Assert.assertEquals(0.5, dist.cumulativeProbability(0.5), Double.MIN_VALUE);
         Assert.assertEquals(0.5, dist.cumulativeProbability(0.7), Double.MIN_VALUE);
     }
-    
+
     /**
      * Find the bin that x belongs (relative to {@link #makeDistribution()}).
      */
@@ -459,7 +461,7 @@ public final class EmpiricalDistributionTest extends RealDistributionAbstractTes
         // If x falls on a bin boundary, it is in the lower bin
         return FastMath.floor(x / 10) == x / 10 ? bin - 1 : bin;
     }
-    
+
     /**
      * Find the within-bin kernel for the bin with lower bound lower
      * and upper bound upper. All bins other than the first contain 10 points
@@ -471,10 +473,10 @@ public final class EmpiricalDistributionTest extends RealDistributionAbstractTes
         if (lower < 1) {
             return new NormalDistribution(5d, 3.3166247903554);
         } else {
-            return new NormalDistribution((upper + lower + 1) / 2d, 3.0276503540974917); 
+            return new NormalDistribution((upper + lower + 1) / 2d, 3.0276503540974917);
         }
     }
-    
+
     @Test
     public void testKernelOverrideConstant() {
         final EmpiricalDistribution dist = new ConstantKernelEmpiricalDistribution(5);
@@ -500,7 +502,7 @@ public final class EmpiricalDistributionTest extends RealDistributionAbstractTes
         Assert.assertEquals(8.0, dist.inverseCumulativeProbability(0.5), tol);
         Assert.assertEquals(8.0, dist.inverseCumulativeProbability(0.6), tol);
     }
-    
+
     @Test
     public void testKernelOverrideUniform() {
         final EmpiricalDistribution dist = new UniformKernelEmpiricalDistribution(5);
@@ -508,14 +510,14 @@ public final class EmpiricalDistributionTest extends RealDistributionAbstractTes
         dist.load(data);
         // Kernels are uniform distributions on [1,3], [4,6], [7,9], [10,12], [13,15]
         final double bounds[] = {3d, 6d, 9d, 12d};
-        final double tol = 10E-12; 
+        final double tol = 10E-12;
         for (int i = 0; i < 20; i++) {
             final double v = dist.sample();
             // Make sure v is not in the excluded range between bins - that is (bounds[i], bounds[i] + 1)
             for (int j = 0; j < bounds.length; j++) {
                 Assert.assertFalse(v > bounds[j] + tol && v < bounds[j] + 1 - tol);
             }
-        }   
+        }
         Assert.assertEquals(0.0, dist.cumulativeProbability(1), tol);
         Assert.assertEquals(0.1, dist.cumulativeProbability(2), tol);
         Assert.assertEquals(0.6, dist.cumulativeProbability(10), tol);
@@ -530,8 +532,8 @@ public final class EmpiricalDistributionTest extends RealDistributionAbstractTes
         Assert.assertEquals(8.0, dist.inverseCumulativeProbability(0.5), tol);
         Assert.assertEquals(9.0, dist.inverseCumulativeProbability(0.6), tol);
     }
-    
-    
+
+
     /**
      * Empirical distribution using a constant smoothing kernel.
      */
@@ -546,7 +548,7 @@ public final class EmpiricalDistributionTest extends RealDistributionAbstractTes
             return new ConstantRealDistribution(bStats.getMean());
         }
     }
-    
+
     /**
      * Empirical distribution using a uniform smoothing kernel.
      */

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/test/java/org/apache/commons/math4/random/ValueServerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/random/ValueServerTest.java b/src/test/java/org/apache/commons/math4/random/ValueServerTest.java
index 43d3554..f9c63ef 100644
--- a/src/test/java/org/apache/commons/math4/random/ValueServerTest.java
+++ b/src/test/java/org/apache/commons/math4/random/ValueServerTest.java
@@ -38,7 +38,7 @@ import org.junit.runner.RunWith;
 @RunWith(RetryRunner.class)
 public final class ValueServerTest {
 
-    private ValueServer vs = new ValueServer(new Well19937c(100));
+    private final ValueServer vs = new ValueServer(new Well19937c(100));
 
     @Before
     public void setUp() {
@@ -78,12 +78,12 @@ public final class ValueServerTest {
         Assert.assertEquals("std dev", 1.0173699343977738, stats.getStandardDeviation(),
             tolerance);
     }
-    
+
     /**
      * Verify that when provided with fixed seeds, stochastic modes
      * generate fixed sequences.  Verifies the fix for MATH-654.
      */
-    @Test 
+    @Test
     public void testFixedSeed() throws Exception {
         ValueServer valueServer = new ValueServer();
         URL url = getClass().getResource("testData.txt");
@@ -94,7 +94,7 @@ public final class ValueServerTest {
         checkFixedSeed(valueServer, ValueServer.GAUSSIAN_MODE);
         checkFixedSeed(valueServer, ValueServer.UNIFORM_MODE);
     }
-    
+
     /**
      * Do the check for {@link #testFixedSeed()}
      * @param mode ValueServer mode
@@ -110,7 +110,7 @@ public final class ValueServerTest {
         for (int i = 0; i < 100; i++) {
             values[1][i] = valueServer.getNext();
         }
-        Assert.assertTrue(Arrays.equals(values[0], values[1])); 
+        Assert.assertTrue(Arrays.equals(values[0], values[1]));
     }
 
     /**
@@ -121,8 +121,8 @@ public final class ValueServerTest {
     public void testNextDigestFail() throws Exception {
         try {
             vs.getNext();
-            Assert.fail("Expecting IllegalStateException");
-        } catch (IllegalStateException ex) {}
+            Assert.fail("Expecting MathIllegalStateException");
+        } catch (MathIllegalStateException ex) {}
     }
 
     @Test
@@ -203,8 +203,8 @@ public final class ValueServerTest {
         try {
             vs.setMode(1000);
             vs.getNext();
-            Assert.fail("bad mode, expecting IllegalStateException");
-        } catch (IllegalStateException ex) {
+            Assert.fail("bad mode, expecting MathIllegalStateException");
+        } catch (MathIllegalStateException ex) {
             // ignored
         }
     }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/test/java/org/apache/commons/math4/stat/FrequencyTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/stat/FrequencyTest.java b/src/test/java/org/apache/commons/math4/stat/FrequencyTest.java
index ae1a4d9..444c57a 100644
--- a/src/test/java/org/apache/commons/math4/stat/FrequencyTest.java
+++ b/src/test/java/org/apache/commons/math4/stat/FrequencyTest.java
@@ -159,14 +159,14 @@ public final class FrequencyTest {
         f.addValue(bChar);
         try {
             f.addValue(aString);
-            Assert.fail("Expecting IllegalArgumentException");
-        } catch (IllegalArgumentException ex) {
+            Assert.fail("Expecting MathIllegalArgumentException");
+        } catch (MathIllegalArgumentException ex) {
             // expected
         }
         try {
             f.addValue(2);
-            Assert.fail("Expecting IllegalArgumentException");
-        } catch (IllegalArgumentException ex) {
+            Assert.fail("Expecting MathIllegalArgumentException");
+        } catch (MathIllegalArgumentException ex) {
             // expected
         }
         Assert.assertEquals("a pct",0.5,f.getPct(aChar),TOLERANCE);
@@ -254,7 +254,7 @@ public final class FrequencyTest {
         Assert.assertEquals("Integer 1 cumPct", 0.5, f.getCumPct(1), TOLERANCE);
         Assert.assertEquals("Integer 1 cumPct", 0.5, f.getCumPct(Long.valueOf(1)), TOLERANCE);
         Assert.assertEquals("Integer 1 cumPct", 0.5, f.getCumPct(Integer.valueOf(1)), TOLERANCE);
-        
+
         f.incrementValue(ONE, -2);
         f.incrementValue(THREE, 5);
 
@@ -264,7 +264,7 @@ public final class FrequencyTest {
         Iterator<?> it = f.valuesIterator();
         while (it.hasNext()) {
             Assert.assertTrue(it.next() instanceof Long);
-        }        
+        }
     }
 
     @Test
@@ -275,7 +275,7 @@ public final class FrequencyTest {
         f.addValue(TWO);
         Assert.assertEquals(f, TestUtils.serializeAndRecover(f));
     }
-    
+
     @Test
     public void testGetUniqueCount() {
         Assert.assertEquals(0, f.getUniqueCount());
@@ -286,7 +286,7 @@ public final class FrequencyTest {
         f.addValue(TWO);
         Assert.assertEquals(2, f.getUniqueCount());
     }
-    
+
     @Test
     public void testIncrement() {
         Assert.assertEquals(0, f.getUniqueCount());
@@ -295,34 +295,34 @@ public final class FrequencyTest {
 
         f.incrementValue(ONE_LONG, 4);
         Assert.assertEquals(5, f.getCount(ONE_LONG));
-        
+
         f.incrementValue(ONE_LONG, -5);
         Assert.assertEquals(0, f.getCount(ONE_LONG));
-        
+
         try {
             f.incrementValue(CHAR_A, 1);
-            Assert.fail("Expecting IllegalArgumentException");
-        } catch (IllegalArgumentException ex) {
+            Assert.fail("Expecting MathIllegalArgumentException");
+        } catch (MathIllegalArgumentException ex) {
             // expected
         }
 
         f = new Frequency();
         f.incrementValue(CHAR_A, 2);
-        
+
         Assert.assertEquals(2, f.getCount(CHAR_A));
 
         try {
             f.incrementValue(ONE, 1);
-            Assert.fail("Expecting IllegalArgumentException");
-        } catch (IllegalArgumentException ex) {
+            Assert.fail("Expecting MathIllegalArgumentException");
+        } catch (MathIllegalArgumentException ex) {
             // expected
         }
-        
+
         f.incrementValue(CHAR_A, 3);
         Assert.assertEquals(5, f.getCount(CHAR_A));
 
     }
-    
+
     @Test
     public void testMerge() {
         Assert.assertEquals(0, f.getUniqueCount());
@@ -330,7 +330,7 @@ public final class FrequencyTest {
         f.addValue(TWO_LONG);
         f.addValue(ONE);
         f.addValue(TWO);
-        
+
         Assert.assertEquals(2, f.getUniqueCount());
         Assert.assertEquals(2, f.getCount(ONE));
         Assert.assertEquals(2, f.getCount(TWO));
@@ -345,18 +345,18 @@ public final class FrequencyTest {
         Assert.assertEquals(2, g.getCount(THREE));
 
         f.merge(g);
-        
+
         Assert.assertEquals(3, f.getUniqueCount());
         Assert.assertEquals(3, f.getCount(ONE));
         Assert.assertEquals(2, f.getCount(TWO));
-        Assert.assertEquals(2, f.getCount(THREE));        
+        Assert.assertEquals(2, f.getCount(THREE));
     }
-    
+
     @Test
     public void testMergeCollection() {
         Assert.assertEquals(0, f.getUniqueCount());
         f.addValue(ONE_LONG);
-        
+
         Assert.assertEquals(1, f.getUniqueCount());
         Assert.assertEquals(1, f.getCount(ONE));
         Assert.assertEquals(0, f.getCount(TWO));
@@ -366,18 +366,18 @@ public final class FrequencyTest {
 
         Frequency h = new Frequency();
         h.addValue(THREE_LONG);
-        
+
         List<Frequency> coll = new ArrayList<Frequency>();
         coll.add(g);
         coll.add(h);
         f.merge(coll);
-        
+
         Assert.assertEquals(3, f.getUniqueCount());
         Assert.assertEquals(1, f.getCount(ONE));
         Assert.assertEquals(1, f.getCount(TWO));
-        Assert.assertEquals(1, f.getCount(THREE));        
+        Assert.assertEquals(1, f.getCount(THREE));
     }
-    
+
     @Test
     public void testMode() {
         List<Comparable<?>> mode;

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/test/java/org/apache/commons/math4/stat/correlation/CovarianceTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/stat/correlation/CovarianceTest.java b/src/test/java/org/apache/commons/math4/stat/correlation/CovarianceTest.java
index f0c6fbe..de67cff 100644
--- a/src/test/java/org/apache/commons/math4/stat/correlation/CovarianceTest.java
+++ b/src/test/java/org/apache/commons/math4/stat/correlation/CovarianceTest.java
@@ -17,6 +17,7 @@
 package org.apache.commons.math4.stat.correlation;
 
 import org.apache.commons.math4.TestUtils;
+import org.apache.commons.math4.exception.MathIllegalArgumentException;
 import org.apache.commons.math4.exception.NotStrictlyPositiveException;
 import org.apache.commons.math4.linear.Array2DRowRealMatrix;
 import org.apache.commons.math4.linear.RealMatrix;
@@ -183,8 +184,8 @@ public class CovarianceTest {
         double[] two = new double[] {2};
         try {
             new Covariance().covariance(one, two, false);
-            Assert.fail("Expecting IllegalArgumentException");
-        } catch (IllegalArgumentException ex) {
+            Assert.fail("Expecting MathIllegalArgumentException");
+        } catch (MathIllegalArgumentException ex) {
             // Expected
         }
         try {

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/test/java/org/apache/commons/math4/stat/correlation/PearsonsCorrelationTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/stat/correlation/PearsonsCorrelationTest.java b/src/test/java/org/apache/commons/math4/stat/correlation/PearsonsCorrelationTest.java
index d36513b..c4c0211 100644
--- a/src/test/java/org/apache/commons/math4/stat/correlation/PearsonsCorrelationTest.java
+++ b/src/test/java/org/apache/commons/math4/stat/correlation/PearsonsCorrelationTest.java
@@ -18,6 +18,7 @@ package org.apache.commons.math4.stat.correlation;
 
 import org.apache.commons.math4.TestUtils;
 import org.apache.commons.math4.distribution.TDistribution;
+import org.apache.commons.math4.exception.MathIllegalArgumentException;
 import org.apache.commons.math4.linear.BlockRealMatrix;
 import org.apache.commons.math4.linear.RealMatrix;
 import org.apache.commons.math4.stat.correlation.Covariance;
@@ -210,15 +211,15 @@ public class PearsonsCorrelationTest {
         double[] two = new double[] {2};
         try {
             new PearsonsCorrelation().correlation(one, two);
-            Assert.fail("Expecting IllegalArgumentException");
-        } catch (IllegalArgumentException ex) {
+            Assert.fail("Expecting MathIllegalArgumentException");
+        } catch (MathIllegalArgumentException ex) {
             // Expected
         }
         RealMatrix matrix = new BlockRealMatrix(new double[][] {{0},{1}});
         try {
             new PearsonsCorrelation(matrix);
-            Assert.fail("Expecting IllegalArgumentException");
-        } catch (IllegalArgumentException ex) {
+            Assert.fail("Expecting MathIllegalArgumentException");
+        } catch (MathIllegalArgumentException ex) {
             // Expected
         }
     }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/test/java/org/apache/commons/math4/stat/correlation/SpearmansRankCorrelationTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/stat/correlation/SpearmansRankCorrelationTest.java b/src/test/java/org/apache/commons/math4/stat/correlation/SpearmansRankCorrelationTest.java
index fbccc29..20cacd9 100644
--- a/src/test/java/org/apache/commons/math4/stat/correlation/SpearmansRankCorrelationTest.java
+++ b/src/test/java/org/apache/commons/math4/stat/correlation/SpearmansRankCorrelationTest.java
@@ -95,15 +95,15 @@ public class SpearmansRankCorrelationTest extends PearsonsCorrelationTest {
         double[] two = new double[] {2};
         try {
             new SpearmansCorrelation().correlation(one, two);
-            Assert.fail("Expecting IllegalArgumentException");
-        } catch (IllegalArgumentException ex) {
+            Assert.fail("Expecting MathIllegalArgumentException");
+        } catch (MathIllegalArgumentException ex) {
             // Expected
         }
         RealMatrix matrix = new BlockRealMatrix(new double[][] {{0},{1}});
         try {
             new SpearmansCorrelation(matrix);
-            Assert.fail("Expecting IllegalArgumentException");
-        } catch (IllegalArgumentException ex) {
+            Assert.fail("Expecting MathIllegalArgumentException");
+        } catch (MathIllegalArgumentException ex) {
             // Expected
         }
     }
@@ -149,7 +149,7 @@ public class SpearmansRankCorrelationTest extends PearsonsCorrelationTest {
         // compute correlation
         NaturalRanking ranking = new NaturalRanking(NaNStrategy.REMOVED);
         SpearmansCorrelation spearman = new SpearmansCorrelation(matrix, ranking);
-        
+
         Assert.assertEquals(0.5, spearman.getCorrelationMatrix().getEntry(0, 1), Double.MIN_VALUE);
     }
 

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/test/java/org/apache/commons/math4/stat/descriptive/DescriptiveStatisticsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/stat/descriptive/DescriptiveStatisticsTest.java b/src/test/java/org/apache/commons/math4/stat/descriptive/DescriptiveStatisticsTest.java
index 5f25f88..e11e171 100644
--- a/src/test/java/org/apache/commons/math4/stat/descriptive/DescriptiveStatisticsTest.java
+++ b/src/test/java/org/apache/commons/math4/stat/descriptive/DescriptiveStatisticsTest.java
@@ -16,6 +16,7 @@ package org.apache.commons.math4.stat.descriptive;
 import java.util.Locale;
 
 import org.apache.commons.math4.TestUtils;
+import org.apache.commons.math4.exception.MathIllegalArgumentException;
 import org.apache.commons.math4.stat.descriptive.DescriptiveStatistics;
 import org.apache.commons.math4.stat.descriptive.SummaryStatistics;
 import org.apache.commons.math4.stat.descriptive.UnivariateStatistic;
@@ -77,7 +78,7 @@ public class DescriptiveStatisticsTest {
         try {
             stats.setWindowSize(-3);
             Assert.fail("an exception should have been thrown");
-        } catch (IllegalArgumentException iae) {
+        } catch (MathIllegalArgumentException iae) {
             // expected
         }
         Assert.assertEquals(300, stats.getWindowSize());
@@ -197,8 +198,8 @@ public class DescriptiveStatisticsTest {
         // Try to set bad impl
         try {
             stats.setPercentileImpl(new badPercentile());
-            Assert.fail("Expecting IllegalArgumentException");
-        } catch (IllegalArgumentException ex) {
+            Assert.fail("Expecting MathIllegalArgumentException");
+        } catch (MathIllegalArgumentException ex) {
             // expected
         }
     }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/test/java/org/apache/commons/math4/stat/descriptive/MultivariateSummaryStatisticsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/stat/descriptive/MultivariateSummaryStatisticsTest.java b/src/test/java/org/apache/commons/math4/stat/descriptive/MultivariateSummaryStatisticsTest.java
index c9d8c37..d198644 100644
--- a/src/test/java/org/apache/commons/math4/stat/descriptive/MultivariateSummaryStatisticsTest.java
+++ b/src/test/java/org/apache/commons/math4/stat/descriptive/MultivariateSummaryStatisticsTest.java
@@ -21,6 +21,7 @@ import java.util.Locale;
 
 import org.apache.commons.math4.TestUtils;
 import org.apache.commons.math4.exception.DimensionMismatchException;
+import org.apache.commons.math4.exception.MathIllegalStateException;
 import org.apache.commons.math4.stat.descriptive.MultivariateSummaryStatistics;
 import org.apache.commons.math4.stat.descriptive.StorelessUnivariateStatistic;
 import org.apache.commons.math4.stat.descriptive.moment.Mean;
@@ -71,11 +72,9 @@ public class MultivariateSummaryStatisticsTest {
         u.addValue(new double[] { 1, 2 });
         u.addValue(new double[] { 3, 4 });
         try {
-            u.setMeanImpl(new StorelessUnivariateStatistic[] {
-                            new sumMean(), new sumMean()
-                          });
-            Assert.fail("Expecting IllegalStateException");
-        } catch (IllegalStateException ex) {
+            u.setMeanImpl(new StorelessUnivariateStatistic[] { new sumMean(), new sumMean() });
+            Assert.fail("Expecting MathIllegalStateException");
+        } catch (MathIllegalStateException ex) {
             // expected
         }
     }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/test/java/org/apache/commons/math4/stat/descriptive/SummaryStatisticsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/stat/descriptive/SummaryStatisticsTest.java b/src/test/java/org/apache/commons/math4/stat/descriptive/SummaryStatisticsTest.java
index d546ca3..bdf1f38 100644
--- a/src/test/java/org/apache/commons/math4/stat/descriptive/SummaryStatisticsTest.java
+++ b/src/test/java/org/apache/commons/math4/stat/descriptive/SummaryStatisticsTest.java
@@ -18,6 +18,7 @@ package org.apache.commons.math4.stat.descriptive;
 
 
 import org.apache.commons.math4.TestUtils;
+import org.apache.commons.math4.exception.MathIllegalStateException;
 import org.apache.commons.math4.stat.descriptive.StatisticalSummary;
 import org.apache.commons.math4.stat.descriptive.SummaryStatistics;
 import org.apache.commons.math4.stat.descriptive.moment.GeometricMean;
@@ -32,20 +33,20 @@ import org.junit.Test;
  */
 public class SummaryStatisticsTest {
 
-    private double one = 1;
-    private float twoF = 2;
-    private long twoL = 2;
-    private int three = 3;
-    private double mean = 2;
-    private double sumSq = 18;
-    private double sum = 8;
-    private double var = 0.666666666666666666667;
-    private double popVar = 0.5;
-    private double std = FastMath.sqrt(var);
-    private double n = 4;
-    private double min = 1;
-    private double max = 3;
-    private double tolerance = 10E-15;
+    private final double one = 1;
+    private final float twoF = 2;
+    private final long twoL = 2;
+    private final int three = 3;
+    private final double mean = 2;
+    private final double sumSq = 18;
+    private final double sum = 8;
+    private final double var = 0.666666666666666666667;
+    private final double popVar = 0.5;
+    private final double std = FastMath.sqrt(var);
+    private final double n = 4;
+    private final double min = 1;
+    private final double max = 3;
+    private final double tolerance = 10E-15;
 
     protected SummaryStatistics createSummaryStatistics() {
         return new SummaryStatistics();
@@ -292,12 +293,12 @@ public class SummaryStatisticsTest {
         u.addValue(3);
         try {
             u.setMeanImpl(new Sum());
-            Assert.fail("Expecting IllegalStateException");
-        } catch (IllegalStateException ex) {
+            Assert.fail("Expecting MathIllegalStateException");
+        } catch (MathIllegalStateException ex) {
             // expected
         }
     }
-    
+
     @Test
     public void testQuadraticMean() {
         final double[] values = { 1.2, 3.4, 5.6, 7.89 };
@@ -315,7 +316,7 @@ public class SummaryStatisticsTest {
 
         Assert.assertEquals(expected, stats.getQuadraticMean(), Math.ulp(expected));
     }
-    
+
     /**
      * JIRA: MATH-691
      */
@@ -327,31 +328,31 @@ public class SummaryStatisticsTest {
         for(double i : scores) {
           stats.addValue(i);
         }
-        Assert.assertEquals((new Variance(false)).evaluate(scores),stats.getVariance(), 0); 
+        Assert.assertEquals((new Variance(false)).evaluate(scores),stats.getVariance(), 0);
     }
-    
+
     @Test
     public void testOverrideMeanWithMathClass() {
         double[] scores = {1, 2, 3, 4};
         SummaryStatistics stats = new SummaryStatistics();
-        stats.setMeanImpl(new Mean()); 
+        stats.setMeanImpl(new Mean());
         for(double i : scores) {
           stats.addValue(i);
         }
-        Assert.assertEquals((new Mean()).evaluate(scores),stats.getMean(), 0); 
+        Assert.assertEquals((new Mean()).evaluate(scores),stats.getMean(), 0);
     }
-    
+
     @Test
     public void testOverrideGeoMeanWithMathClass() {
         double[] scores = {1, 2, 3, 4};
         SummaryStatistics stats = new SummaryStatistics();
-        stats.setGeoMeanImpl(new GeometricMean()); 
+        stats.setGeoMeanImpl(new GeometricMean());
         for(double i : scores) {
           stats.addValue(i);
         }
-        Assert.assertEquals((new GeometricMean()).evaluate(scores),stats.getGeometricMean(), 0); 
+        Assert.assertEquals((new GeometricMean()).evaluate(scores),stats.getGeometricMean(), 0);
     }
-    
+
     @Test
     public void testToString() {
         SummaryStatistics u = createSummaryStatistics();