lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Uwe Schindler" <...@thetaphi.de>
Subject RE: [JENKINS] Lucene-Solr-trunk-Linux-Java8-64 - Build # 15 - Failure!
Date Sat, 14 Jul 2012 12:54:57 GMT
I like that, nice builder pattern *duck* ! (running away)

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: uwe@thetaphi.de


> -----Original Message-----
> From: dawid.weiss@gmail.com [mailto:dawid.weiss@gmail.com] On Behalf Of
> Dawid Weiss
> Sent: Saturday, July 14, 2012 2:44 PM
> To: dev@lucene.apache.org
> Subject: Re: [JENKINS] Lucene-Solr-trunk-Linux-Java8-64 - Build # 15 - Failure!
> 
> We use (and like) fest asserts. The syntax is nice but what's even nicer are
> formatted exception messages for arrays, maps, etc. so you get the idea what
> the mismatch was.
> 
> http://code.google.com/p/fest/
> 
> see fluid assertions; or here a new 2.x line of development:
> https://github.com/alexruiz/fest-assert-2.x/wiki
> 
> Dawid
> 
> On Sat, Jul 14, 2012 at 2:20 PM, Uwe Schindler <uwe@thetaphi.de> wrote:
> > Hi,
> >
> >
> >> "... tests doing Map.toString() and compare against a hardcoded
> >> String
> > (which
> >> is of course wrong for HashMaps or HashSets because order is undefined)."
> >>
> >> Map.toString sounds like a great operation to forbid in Solr/Lucene,
> > especially
> >> in tests. Although Map.toString is still helpful for debug/logging,
> >> what
> > would
> >> really be helpful are two things: 1) display the map sorted/ordered
> >> by
> > key, and
> >> 2) compare two maps for equality (build a map to compare against
> >> rather
> > than
> >> using a presumed toString value.) And, an "assertMapEquals" method as
> > well.
> >> Maybe even a "assertMapKeys" method that simply verifies that the
> >> keys of
> > a
> >> map are "equal" to a list of keys (set equality but not order.)
> >
> > assertMapEquals can be done with assertEquals easily, you just have to
> > pass a full map as comparison base:
> >
> >         assertEquals("map differs", new HashMap() {{
> > map.put(...);....}}, someMapToTest);
> >
> > For Sets it is much easier:
> >
> >         assertEquals("set differs", new
> > HashSet(Arrays.asList(<items>)), someSetToTest);
> >
> > The semantics of Map/Set.equals() (see interface docs) explicitely
> > specify that any type of Map or Set must compare against another one,
> > so you can compare a TreeMap against a HashMap for equality.
> >
> > If you want to compare by String and you only have a HashMap/HashSet,
> > the trick is:
> >
> >         assertEquals("map differs", "{items....}", new
> > TreeMap(someMapToTest));
> >
> > By that you enforce order (with cloning the map, but that's not a perf
> > problem in tests).
> >
> > Uwe
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org For
> > additional commands, e-mail: dev-help@lucene.apache.org
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org For additional
> commands, e-mail: dev-help@lucene.apache.org


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


Mime
View raw message