lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ehatc...@apache.org
Subject cvs commit: jakarta-lucene/src/test/org/apache/lucene/queryParser TestQueryParser.java
Date Wed, 26 Nov 2003 11:03:30 GMT
ehatcher    2003/11/26 03:03:30

  Modified:    src/test/org/apache/lucene/queryParser TestQueryParser.java
  Log:
  new QueryParser tests
  
  Revision  Changes    Path
  1.23      +50 -2     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.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- TestQueryParser.java	30 Sep 2003 04:41:02 -0000	1.22
  +++ TestQueryParser.java	26 Nov 2003 11:03:30 -0000	1.23
  @@ -79,8 +79,6 @@
   
   /**
    * Tests QueryParser.
  - *
  - * @version $Id$
    */
   public class TestQueryParser extends TestCase {
   
  @@ -138,6 +136,12 @@
       }
     }
   
  +  private int originalMaxClauses;
  +
  +  public void setUp() {
  +    originalMaxClauses = BooleanQuery.getMaxClauseCount();
  +  }
  +
     public QueryParser getParser(Analyzer a) throws Exception {
       if (a == null)
         a = new SimpleAnalyzer();
  @@ -356,6 +360,25 @@
       assertQueryEquals("\\\\", a, "\\\\");
       assertQueryEquals("\\+blah", a, "\\+blah");
       assertQueryEquals("\\(blah", a, "\\(blah");
  +
  +    assertQueryEquals("\\-blah", a, "\\-blah");
  +    assertQueryEquals("\\!blah", a, "\\!blah");
  +    assertQueryEquals("\\{blah", a, "\\{blah");
  +    assertQueryEquals("\\}blah", a, "\\}blah");
  +    assertQueryEquals("\\:blah", a, "\\:blah");
  +    assertQueryEquals("\\^blah", a, "\\^blah");
  +    assertQueryEquals("\\[blah", a, "\\[blah");
  +    assertQueryEquals("\\]blah", a, "\\]blah");
  +    assertQueryEquals("\\\"blah", a, "\\\"blah");
  +    assertQueryEquals("\\(blah", a, "\\(blah");
  +    assertQueryEquals("\\)blah", a, "\\)blah");
  +    assertQueryEquals("\\~blah", a, "\\~blah");
  +    assertQueryEquals("\\*blah", a, "\\*blah");
  +    assertQueryEquals("\\?blah", a, "\\?blah");
  +    assertQueryEquals("foo \\&& bar", a, "foo \\&& bar");
  +    assertQueryEquals("foo \\|| bar", a, "foo \\|| bar");
  +    assertQueryEquals("foo \\AND bar", a, "foo \\AND bar");
  +
     }
   
     public void testSimpleDAO()
  @@ -381,6 +404,17 @@
       assertEquals(q.getBoost(), (float) 2.0, (float) 0.5);
       q = qp.parse("\"on\"^1.0");
       assertNotNull(q);
  +
  +    q = QueryParser.parse("the^3", "field", new StandardAnalyzer());
  +    assertNotNull(q);
  +  }
  +
  +  public void testException() throws Exception {
  +    try {
  +      assertQueryEquals("\"some phrase", null, "abc");
  +      fail("ParseException expected, not thrown");
  +    } catch (ParseException expected) {
  +    }
     }
   
     public void testCustomQueryParserWildcard() {
  @@ -399,6 +433,20 @@
         return;
       }
       fail("Fuzzy queries should not be allowed");
  +  }
  +
  +  public void testBooleanQuery() throws Exception {
  +    BooleanQuery.setMaxClauseCount(2);
  +    try {
  +      QueryParser.parse("one two three", "field", new WhitespaceAnalyzer());
  +      fail("ParseException expected due to too many boolean clauses");
  +    } catch (ParseException expected) {
  +      // too many boolean clauses, so ParseException is expected
  +    }
  +  }
  +
  +  public void tearDown() {
  +    BooleanQuery.setMaxClauseCount(originalMaxClauses);
     }
   
   }
  
  
  

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


Mime
View raw message