topxiaoyong123 / jforum2

Automatically exported from code.google.com/p/jforum2
Other
0 stars 0 forks source link

LuceneSearchTestCase fails #32

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. checkout trunk (revision 177)
2. run LuceneSearchTestCase
3.

What is the expected output? What do you see instead?
Expectation is success. However 
LuceneSearchTestCase.testTwoDifferentForumsSearchOneExpectOneResult() fails 
with parsing error:

-------------------------------------------------------------------------------
Test set: net.jforum.search.LuceneSearchTestCase
-------------------------------------------------------------------------------
Tests run: 5, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.264 sec <<< 
FAILURE!
testTwoDifferentForumsSearchOneExpectOneResult(net.jforum.search.LuceneSearchTes
tCase)  Time elapsed: 0.008 sec  <<< ERROR!
net.jforum.exceptions.SearchException: 
org.apache.lucene.queryParser.ParseException: Cannot parse '+(forum.id:1) 
contents:()': Encountered " ")" ") "" at line 1, column 24.
Was expecting one of:
    <NOT> ...
    "+" ...
    "-" ...
    "(" ...
    "*" ...
    <QUOTED> ...
    <TERM> ...
    <PREFIXTERM> ...
    <WILDTERM> ...
    "[" ...
    "{" ...
    <NUMBER> ...
    <TERM> ...
    "*" ...

    at org.apache.lucene.queryParser.QueryParser.parse(QueryParser.java:211)
    at net.jforum.search.LuceneSearch.performSearch(LuceneSearch.java:147)
    at net.jforum.search.LuceneSearch.search(LuceneSearch.java:110)
    at net.jforum.search.LuceneSearchTestCase.testTwoDifferentForumsSearchOneExpectOneResult(LuceneSearchTestCase.java:208)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at junit.framework.TestCase.runTest(TestCase.java:168)
    at junit.framework.TestCase.runBare(TestCase.java:134)
    at junit.framework.TestResult$1.protect(TestResult.java:110)
    at junit.framework.TestResult.runProtected(TestResult.java:128)
    at junit.framework.TestResult.run(TestResult.java:113)
    at junit.framework.TestCase.run(TestCase.java:124)
    at junit.framework.TestSuite.runTest(TestSuite.java:243)
    at junit.framework.TestSuite.run(TestSuite.java:238)
    at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
    at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:35)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:146)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:97)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.maven.surefire.booter.ProviderFactory$ClassLoaderProxy.invoke(ProviderFactory.java:103)
    at $Proxy0.invoke(Unknown Source)
    at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:145)
    at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcess(SurefireStarter.java:87)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:69)

Original issue reported on code.google.com by peter.ri...@gmail.com on 24 Apr 2012 at 7:43

GoogleCodeExporter commented 9 years ago
The problem was likely caused by the introduction of  MatchType.RAW_KEYWORDS.

When there are no keywords the following search expression part is produced by 
LuceneSearch.filterByKeywords:

...contents:()...

It's refused by the parser. To avoid it, we should check the keywords and if 
there are not any of them then avoid appending "contents..." .

Original comment by peter.ri...@gmail.com on 24 Apr 2012 at 7:46

GoogleCodeExporter commented 9 years ago
This issue was updated by revision r179.

This fixes the failing testcase. Please review and close.

Original comment by peter.ri...@gmail.com on 24 Apr 2012 at 7:59

GoogleCodeExporter commented 9 years ago
Thank you~

Original comment by andow...@gmail.com on 24 May 2012 at 10:51