commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From luc.maison...@free.fr
Subject Re: svn commit: r1091153 - /commons/proper/math/trunk/src/test/java/org/apache/commons/math/exception/TooManyEvaluationsExceptionTest.java
Date Tue, 12 Apr 2011 07:16:47 GMT

----- "Gilles Sadowski" <gilles@harfang.homelinux.org> a écrit :

> On Mon, Apr 11, 2011 at 06:02:52PM -0000, luc@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-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message