lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mike Hogan">
Subject Re: [subscriptions] Please make org.apache.lucene.index.IndexWriter non-final
Date Sun, 05 Oct 2003 14:02:32 GMT

> The static parse method is simply for convenience.... it does nothing
> that you couldn't do by instantiating an instance of QueryParser and
> calling the instance 'parse' method.  In fact, its more flexible to use
> QueryParser as an instance than through the static method.
> So, you already have what you're requesting with QueryParser.
> What exactly are you unit testing and how?  I have a feeling if you
> give us more details of what you're trying to accomplish we could help.

I am trying to unit test this:

    public int search(final String query, int beginIndex, final int
endIndex, final List collector) throws SearchService.Exception {
        int numHits = 0;
        try {
            final Searcher searcher = new IndexSearcher(INDEX_FILE_PATH);
            final Analyzer analyzer = new StandardAnalyzer();
            final Query q = QueryParser.parse(query, "contents", analyzer);
            final Hits hits =;
            numHits = hits.length();
            while (beginIndex <= endIndex && beginIndex < numHits) {
                final Document doc = hits.doc(beginIndex++);
        } catch (java.lang.Exception e) {
            throw new SearchService.Exception("Exception performing Lucene
        return numHits;

So sometimes I want QueryParser.parse() to throw an exception, sometimes not
etc etc - the usual mock stuff.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message