Wrong chaining of constructors made the interesting message (indicating the maximal
count) disappear. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1089891 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3c3c66c84f
commit
a3c552e324
|
@ -39,7 +39,8 @@ public class MaxCountExceededException extends MathIllegalStateException {
|
|||
* @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 extends MathIllegalStateException {
|
|||
public MaxCountExceededException(Localizable specific,
|
||||
Number max,
|
||||
Object ... args) {
|
||||
super(specific, max, args);
|
||||
this.max = max;
|
||||
this(max);
|
||||
addMessage(specific, max, args);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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) +
|
||||
".*"));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue