Erik, > 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 = searcher.search(q); numHits = hits.length(); while (beginIndex <= endIndex && beginIndex < numHits) { final Document doc = hits.doc(beginIndex++); collector.add(doc.get("id")); } } catch (java.lang.Exception e) { throw new SearchService.Exception("Exception performing Lucene search",e); } return numHits; } So sometimes I want QueryParser.parse() to throw an exception, sometimes not etc etc - the usual mock stuff. Cheers, Mike --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]