[prev in list] [next in list] [prev in thread] [next in thread] 

List:       lucene-dev
Subject:    cvs commit: jakarta-lucene/src/test/org/apache/lucene/queryParser TestQueryParser.java
From:       otis () apache ! org
Date:       2002-07-18 14:17:42
[Download RAW message or body]

otis        2002/07/18 07:17:42

  Modified:    src/test/org/apache/lucene/queryParser TestQueryParser.java
  Log:
  - Added tests for QueryParser's setOperator functionality.
    All tests pass at this point.
  
  Revision  Changes    Path
  1.15      +32 -0     jakarta-lucene/src/test/org/apache/lucene/queryParser/TestQueryParser.java
  
  Index: TestQueryParser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/test/org/apache/lucene/queryParser/TestQueryParser.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- TestQueryParser.java	14 Jul 2002 17:51:53 -0000	1.14
  +++ TestQueryParser.java	18 Jul 2002 14:17:41 -0000	1.15
  @@ -137,6 +137,28 @@
   	}
       }
   
  +    public Query getQueryDOA(String query, Analyzer a)
  +	throws Exception
  +    {
  +	if (a == null)
  +	    a = new SimpleAnalyzer();
  +	QueryParser qp = new QueryParser("field", a);
  +	qp.setOperator(QueryParser.DEFAULT_OPERATOR_AND);
  +	return qp.parse(query);
  +    }
  +
  +    public void assertQueryEqualsDOA(String query, Analyzer a, String result)
  +	throws Exception
  +    {
  +	Query q = getQueryDOA(query, a);
  +	String s = q.toString("field");
  +	if (!s.equals(result))
  +	{
  +	    fail("Query /" + query + "/ yielded /" + s
  +		+ "/, expecting /" + result + "/");
  +	}
  +    }
  +
       public void testSimple() throws Exception {
   	assertQueryEquals("term term term", null, "term term term");
   	assertQueryEquals("türm term term", null, "türm term term");
  @@ -271,5 +293,15 @@
   	assertQueryEquals("\\\\", a, "\\\\");
   	assertQueryEquals("\\+blah", a, "\\+blah");
   	assertQueryEquals("\\(blah", a, "\\(blah");
  +    }
  +
  +    public void testSimpleDAO()
  +	throws Exception
  +    {
  +	assertQueryEqualsDOA("term term term", null, "+term +term +term");
  +	assertQueryEqualsDOA("term +term term", null, "+term +term +term");
  +	assertQueryEqualsDOA("term term +term", null, "+term +term +term");
  +	assertQueryEqualsDOA("term +term +term", null, "+term +term +term");
  +	assertQueryEqualsDOA("-term term term", null, "-term +term +term");
       }
   }
  
  
  

--
To unsubscribe, e-mail:   <mailto:lucene-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-dev-help@jakarta.apache.org>

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic