You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by je...@apache.org on 2011/07/04 22:06:01 UTC

svn commit: r1142786 [2/2] - in /chemistry/opencmis/trunk/chemistry-opencmis-server: chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/ chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/op...

Added: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/test/java/org/apache/chemistry/opencmis/server/support/query/TestParserTextSearch.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/test/java/org/apache/chemistry/opencmis/server/support/query/TestParserTextSearch.java?rev=1142786&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/test/java/org/apache/chemistry/opencmis/server/support/query/TestParserTextSearch.java (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/test/java/org/apache/chemistry/opencmis/server/support/query/TestParserTextSearch.java Mon Jul  4 20:05:59 2011
@@ -0,0 +1,510 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.chemistry.opencmis.server.support.query;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestParserTextSearch extends AbstractParserTest{
+
+    //private static final Log log = LogFactory.getLog(TestParserTextSearch.class);
+
+    @Before
+    public void setUp() {
+        super.setUp(TextSearchLexer.class, TextSearchParser.class, null);
+    }
+
+    @Override
+    @After
+    public void tearDown() {
+        super.tearDown();
+    }
+
+    // full text search parser
+    //    OR:
+    //    <<
+    //    OR
+    //    >> OK
+    @Test
+    public void testOR1() {
+      testLexerOk("OR", "OR");
+    }
+    
+    //
+    //    TEXT_SEARCH_WORD_LIT:
+    //    <<
+    //    abc
+    //    >> OK
+    @Test
+    public void testTEXT_SEARCH_WORD_LIT2() {
+      testLexerOk("TEXT_SEARCH_WORD_LIT", "abc");
+    }
+    
+    //
+    //    <<
+    //    "ab c"
+    //    >> FAIL
+    @Test
+    public void testTEXT_SEARCH_WORD_LIT3() {
+        testLexerFail("TEXT_SEARCH_WORD_LIT", "\"ab c\"");
+    }
+    
+    //
+    //    <<
+    //    "'abc'" 
+    //    >> FAIL
+    @Test
+    public void testTEXT_SEARCH_WORD_LIT4() {
+        testLexerFail("TEXT_SEARCH_WORD_LIT", "\"\'abc\'\"");
+    }
+    
+    //
+    //    <<
+    //    "ab\'c"
+    //    >> OK
+    @Test
+    public void testTEXT_SEARCH_WORD_LIT5() {
+        testLexerOk("TEXT_SEARCH_WORD_LIT", "\"ab\\'c\"");
+    }
+    
+    //
+    //    <<
+    //    "ab\\c"
+    //    >> OK
+    @Test
+    public void testTEXT_SEARCH_WORD_LIT6() {
+      testLexerOk("TEXT_SEARCH_WORD_LIT", "\"ab\\\\c\"");
+    }
+    
+    //
+    //    /*
+    //    <<
+    //    ab''c
+    //    >> OK
+    //    */
+    /*
+     * double quotes not supported in text search
+     */
+    /*
+    @Test
+    public void testTEXT_SEARCH_WORD_LIT7() {
+      testLexerOk("TEXT_SEARCH_WORD_LIT", "ab''c");
+    }
+    */
+    
+    //
+    //    phrase:
+    //
+    //    <<
+    //    \'abc\'
+    //    >> FAIL
+    @Test
+    public void testPhrase1() {
+        testParserFail("phrase", "\\'abc\\'");
+    }
+    
+    //
+    //    <<
+    //    "abc"
+    //    >> FAIL
+    @Test
+    public void testPhrase2() {
+        testParserFail("phrase", "\"abc\"");
+    }
+    
+    //
+    //    <<
+    //    'abc'
+    //    >> OK
+    @Test
+    public void testPhrase3() {
+      testParserOk("phrase", "'abc'");
+    }
+    
+    //
+    //    <<
+    //    'abc def'
+    //    >> OK
+    @Test
+    public void testPhrase4() {
+      testParserOk("phrase", "'abc def'");
+    }
+    
+    //
+    //    <<
+    //    'ab\-c'
+    //    >> OK
+    @Test
+    public void testPhrase5() {
+      testParserOk("phrase", "'ab\\-c'");
+    }
+    
+    //
+    //    <<
+    //    'ab\\c'
+    //    >> OK
+    @Test
+    public void testPhrase6() {
+      testParserOk("phrase", "'ab\\\\c'");
+    }
+    
+    //
+    //    <<
+    //    'ab\c'
+    //    >> FAIL
+    @Test
+    public void testPhrase7() {
+        testParserFail("phrase", "'ab\\c'");
+    }
+    
+    //
+    //    <<
+    //    'ab\\\c'
+    //    >> FAIL
+    @Test
+    public void testPhrase8() {
+        testParserFail("phrase", "'ab\\\\\\c'");
+    }
+    
+    //
+    //    <<
+    //    'ab\'c'
+    //    >> OK
+    @Test
+    public void testPhrase9() {
+      testParserOk("phrase", "'ab\\'c'");
+    }
+    
+    //
+    //    <<
+    //    'abc def'
+    //    >> OK
+    @Test
+    public void testPhrase10() {
+      testParserOk("phrase", "'abc def'");
+    }
+    
+    //
+    //    <<
+    //    '\'abc\''
+    //    >> OK
+    @Test
+    public void testPhrase11() {
+      testParserOk("phrase", "'\\'abc\\''");
+    }
+    
+    //
+    //    <<
+    //    'abc AND def'
+    //    >> OK
+    @Test
+    public void testPhrase12() {
+      testParserOk("phrase", "'abc AND def'");
+    }
+    
+    //
+    //    << 
+    //    'AND'
+    //    >> OK
+    @Test
+    public void testPhrase13() {
+      testParserOk("phrase", "'AND'");
+    }
+    
+    //
+    //    word:
+    //
+    //    << 
+    //    abc
+    //    >> OK
+    @Test
+    public void testWord1() {
+      testParserOk("word", "abc");
+    }
+    
+    //
+    //    << 
+    //    312#+!&abc
+    //    >> OK
+    @Test
+    public void testWord2() {
+      testParserOk("word", "312#+!&abc");
+    }
+    
+    //
+    //    << 
+    //    \'abc\'
+    //    >> OK
+    @Test
+    public void testWord3() {
+      testParserOk("word", "\\'abc\\'");
+    }
+    
+    //
+    //    << 
+    //    'abc'
+    //    >> FAIL
+    @Test
+    public void testWord4() {
+        testParserFail("word", "'abc'");
+    }    
+    
+    //
+    //    <<
+    //    ab\-c
+    //    >> OK
+    @Test
+    public void testWord6() {
+        testParserOk("word", "ab\\-c");
+    }
+    
+    //
+    //    <<
+    //    ab\\c
+    //    >> OK
+    @Test
+    public void testWord7() {
+        testParserOk("word", "ab\\\\c");
+    }
+    
+    //
+    //    <<
+    //    ab\'c
+    //    >> OK
+    @Test
+    public void testWord8() {
+        testParserOk("word", "ab\\'c");
+    }
+    
+    //
+    //    <<
+    //    OR
+    //    >> FAIL
+    @Test
+    public void testWord9() {
+        testParserFail("word", "OR");
+    }
+    
+    //
+    //    <<
+    //    AND
+    //    >> FAIL
+    @Test
+    public void testWord10() {
+        testParserFail("word", "AND");
+    }
+    
+    //
+    //
+    //    term:
+    //
+    //    <<
+    //    -abc
+    //    >> OK
+    @Test
+    public void testWord11() {
+      testParserOk("term", "-abc");
+    }
+    
+    //
+    //    <<
+    //    abc
+    //    >> OK
+    @Test
+    public void testWord12() {
+      testParserOk("term", "abc");
+    }
+    
+    //
+    //    <<
+    //    'abc def'
+    //    >> OK
+    @Test
+    public void testWord13() {
+      testParserOk("term", "'abc def'");
+    }
+    
+    //
+    //    <<
+    //    -'abc def'
+    //    >> OK
+    @Test
+    public void testWord14() {
+      testParserOk("term", "-'abc def'");
+    }
+    
+    //
+    //    conjunct:
+    //
+    //    <<
+    //    abc def
+    //    >> OK
+    @Test
+    public void testConjunct1() {
+      testParserOk("conjunct", "abc def");
+    }
+    
+    //
+    //    <<
+    //    abc AND def
+    //    >> OK
+    @Test
+    public void testConjunct2() {
+      testParserOk("conjunct", "abc AND def");
+    }
+    
+    //
+    //    <<
+    //    abc AND def ghi John\'s
+    //    >> OK
+    @Test
+    public void testConjunct3() {
+      testParserOk("conjunct", "abc AND def ghi John\\'s");
+    }
+    
+    //
+    //    text_search_expression:
+    //
+    //    <<
+    //    cat mouse dog
+    //    >> OK
+    @Test
+    public void testTextSearchExpression1() {
+      testParserOk("text_search_expression", "cat mouse dog");
+    }
+    
+    //
+    //    <<
+    //    cat AND mouse AND dog
+    //    >> OK
+    @Test
+    public void testTextSearchExpression2() {
+      testParserOk("text_search_expression", "cat AND mouse AND dog");
+    }
+    
+    //
+    //    <<
+    //    cat OR mouse OR dog
+    //    >> OK
+    @Test
+    public void testTextSearchExpression3() {
+      testParserOk("text_search_expression", "cat OR mouse OR dog");
+    }
+    
+    //
+    //    <<
+    //    cat mouse OR dog
+    //    >> OK
+    @Test
+    public void testTextSearchExpression4() {
+      testParserOk("text_search_expression", "cat mouse OR dog");
+    }
+    
+    //
+    //    <<
+    //    cat AND mouse OR dog AND John\'s
+    //    >> OK
+    @Test
+    public void testTextSearchExpression5() {
+      testParserOk("text_search_expression", "cat AND mouse OR dog AND John\\'s");
+    }
+    
+    //
+    //    <<
+    //    'cat AND mouse'
+    //    >> OK
+    @Test
+    public void testTextSearchExpression6() {
+      testParserOk("text_search_expression", "'cat AND mouse'");
+    }
+    
+    //
+    //    <<
+    //    'text search expression'
+    //    >> OK
+    @Test
+    public void testTextSearchExpression7() {
+      testParserOk("text_search_expression", "'text search expression'");
+    }
+    
+    //
+    //    <<
+    //    'John\'s presentation'
+    //    >> OK
+    @Test
+    public void testTextSearchExpression8() {
+      testParserOk("text_search_expression", "'John\\'s presentation'");
+    }
+    
+    //
+    //    <<
+    //    'John\\'s presentation'
+    //    >> FAIL
+    @Test
+    public void testTextSearchExpression9() {
+        testParserFail("text_search_expression", "'John\\\\'s presentation'");
+    }
+    
+    //
+    //    <<
+    //    A\-1
+    //    >> OK
+    @Test
+    public void testTextSearchExpression10() {
+      testParserOk("text_search_expression", "A\\-1");
+    }
+    
+    //
+    //    <<
+    //    'c:\\My Documents'
+    //    >> OK
+    @Test
+    public void testTextSearchExpression11() {
+      testParserOk("text_search_expression", "'c:\\\\My Documents'");
+    }
+    
+    //
+    //    <<
+    //    'c:\\\My Documents'
+    //    >> FAIL
+    @Test
+    public void testTextSearchExpression13() {
+        testParserFail("text_search_expression", "'c:\\\\\\My Documents'");
+    }
+    
+    //
+    //    <<
+    //    'c:\My Documents'
+    //    >> FAIL
+    @Test
+    public void testTextSearchExpression14() {
+      testParserFail("text_search_expression", "'c:\\My Documents'");
+    }
+    
+    //
+    //    <<
+    //    c:\My Documents
+    //    >> FAIL
+    @Test
+    public void testTextSearchExpression15() {
+      testParserFail("text_search_expression", "c:\\My Documents");
+    }
+    
+}