Author: erans
Date: Thu Apr 7 14:33:08 2011
New Revision: 1089891
URL: http://svn.apache.org/viewvc?rev=1089891&view=rev
Log:
Wrong chaining of constructors made the interesting message (indicating the
maximal
count) disappear.
Added:
commons/proper/math/trunk/src/test/java/org/apache/commons/math/exception/TooManyEvaluationsExceptionTest.java
(with props)
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MaxCountExceededException.java
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MaxCountExceededException.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MaxCountExceededException.java?rev=1089891&r1=1089890&r2=1089891&view=diff
==============================================================================
---
commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MaxCountExceededException.java
(original)
+++
commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MaxCountExceededException.java
Thu Apr 7 14:33:08 2011
@@ -39,7 +39,8 @@ public class MaxCountExceededException e
* @param max Maximum.
*/
public MaxCountExceededException(Number max) {
- this(LocalizedFormats.MAX_COUNT_EXCEEDED, max);
+ super(LocalizedFormats.MAX_COUNT_EXCEEDED, max);
+ this.max = max;
}
/**
* Construct the exception with a specific context.
@@ -51,8 +52,8 @@ public class MaxCountExceededException e
public MaxCountExceededException(Localizable specific,
Number max,
Object ... args) {
- super(specific, max, args);
- this.max = max;
+ this(max);
+ addMessage(specific, max, args);
}
/**
Added:
commons/proper/math/trunk/src/test/java/org/apache/commons/math/exception/TooManyEvaluationsExceptionTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/exception/TooManyEvaluationsExceptionTest.java?rev=1089891&view=auto
==============================================================================
---
commons/proper/math/trunk/src/test/java/org/apache/commons/math/exception/TooManyEvaluationsExceptionTest.java
(added)
+++
commons/proper/math/trunk/src/test/java/org/apache/commons/math/exception/TooManyEvaluationsExceptionTest.java
Thu Apr 7 14:33:08 2011
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.math.exception;
+
+import java.text.MessageFormat;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Test for {@link MaxCountExceededException}.
+ *
+ * @version $Revision$ $Date$
+ */
+public class TooManyEvaluationsExceptionTest {
+ @Test
+ public void testMessage() {
+ final int max = 12345;
+ final TooManyEvaluationsException e = new
TooManyEvaluationsException(max);
+ final String msg = e.getMessage();
+ Assert.assertTrue(msg,
+ msg.matches(".*?" +
+ MessageFormat.format("{0}", max) +
+ ".*"));
+ }
+}
Propchange:
commons/proper/math/trunk/src/test/java/org/apache/commons/math/exception/TooManyEvaluationsExceptionTest.java
------------------------------------------------------------------------------
svn:eol-style = native