----- "Gilles Sadowski" <gil...@harfang.homelinux.org> a écrit :
> On Mon, Apr 11, 2011 at 06:02:52PM -0000, l...@apache.org wrote: > > Author: luc > > Date: Mon Apr 11 18:02:52 2011 > > New Revision: 1091153 > > > > URL: http://svn.apache.org/viewvc?rev=1091153&view=rev > > Log: > > make sure the test runs correctly even in a non-US environment > > > > Modified: > > > commons/proper/math/trunk/src/test/java/org/apache/commons/math/exception/TooManyEvaluationsExceptionTest.java > > > > Modified: > 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=1091153&r1=1091152&r2=1091153&view=diff > > > ============================================================================== > > --- > commons/proper/math/trunk/src/test/java/org/apache/commons/math/exception/TooManyEvaluationsExceptionTest.java > (original) > > +++ > commons/proper/math/trunk/src/test/java/org/apache/commons/math/exception/TooManyEvaluationsExceptionTest.java > Mon Apr 11 18:02:52 2011 > > @@ -17,6 +17,7 @@ > > package org.apache.commons.math.exception; > > > > import java.text.MessageFormat; > > +import java.util.Locale; > > > > import org.junit.Assert; > > import org.junit.Test; > > @@ -32,9 +33,12 @@ public class TooManyEvaluationsException > > final int max = 12345; > > final TooManyEvaluationsException e = new > TooManyEvaluationsException(max); > > final String msg = e.getMessage(); > > + final MessageFormat usFormat = new MessageFormat("{0}", > Locale.US); > > Assert.assertTrue(msg, > > msg.matches(".*?" + > > - MessageFormat.format("{0}", > max) + > > + usFormat.format(new Object[] > {max}, > > + new > StringBuffer(), > > + null) + > > ".*")); > > } > > } > > > > > > Wouldn't it be nicer to just replace "getMessage()" with > "getLocalizedMessage()": > ---CUT--- > @Test > public void testMessage() { > final int max = 12345; > final TooManyEvaluationsException e = new > TooManyEvaluationsException(max); > final String msg = e.getLocalizedMessage(); > Assert.assertTrue(msg, > msg.matches(".*?" + > MessageFormat.format("{0}", max) > + > ".*")); > } > ---CUT--- > ? Sure! I have a tendency to always find find a difficult solution and miss the obvious one. Go for it. Luc > > Regards, > Gilles > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org > For additional commands, e-mail: dev-h...@commons.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org