lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alessio Pace" <>
Subject Unit testing: Hits not implementing an interface and being final
Date Mon, 03 Jul 2006 13:11:21 GMT

I wanted just to share my issues with unit testing a component collaborating
with a Hits object.

The scenario is: I have a web page pagination component (say, it shows N
results per page) over the Hits results found in the Lucene index.

I want to test the pagination itselft, so I would like to provide it with a
stub or mock Hits implementation. The problem is that Hits does not
implement and interface, is final and has no public constructor (I am using
Lucene 1.4.3, but the latest 2.x seems to be the same, which prevents me
from subclassing it or mocking it (with EasyMock2 for example).

So my solution would be to change my component collaborator type from Hits
to a MyHits interface, which has a MyHitsImpl that works by delegation on a
concrete Hits object..

Any thoughts about it?

Best regards,

Alessio Pace.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message