On Friday, August 1, 2003, at 09:22 AM, Vladimir Djuzhev wrote:
  We are developing a large corporate site, and decided to
  integrate Lucene as search engine. Everything goes fine,
  until we go into writing unit tests.

Have you tried using RAMDirectory rather than FSDirectory for your index during testing?


  We heavily use Mocks for unit tests. It would be especially
  useful for Lucene since any test performing indexing over
  real data would take unappropriate time.

Yup, I use mocks myself.


    // dozen: unlinked version of Crawler for tests
    public static class MockedCrawler extends Crawler {

        public MockedCrawler(String baseIndexDir, List indexers) {
            super(baseIndexDir, indexers);
        }


I'd recommend you do a bit of inversion here, and have the outside world control the implementation of Directory that is used. In production, use FSDirectory. In testing use RAMDirectory. Refactoring is par for the course here, and will likely imply changes to your code - but that is what doing mock is all about - better design while testing too! :)

  May I ask Lucene development team to remove final modifiers from
  the code? ;)

I disagree with this request, even to the point of -1. If you can show a use case of where extensions are necessary beyond testing then it would be considered, but I suspect you can refactor your code to use a RAMDirectory for testing purposes.


Erik


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to