This project has retired. For details please refer to its Attic page.
TestParserExt xref

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   * http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.chemistry.opencmis.server.support.query;
20  
21  import org.apache.commons.logging.Log;
22  import org.apache.commons.logging.LogFactory;
23  import org.junit.After;
24  import org.junit.Before;
25  import org.junit.Test;
26  
27  public class TestParserExt extends AbstractParserTest {
28  
29      private static final Log log = LogFactory.getLog(TestParserStrict.class);
30  
31      @Before
32      public void setUp() throws Exception {
33          super.setUp(CmisQlStrictLexer.class, CmisQlExtParser.class, null);
34      }
35  
36      @Override
37      @After
38      public void tearDown() {
39          super.tearDown();
40      }
41  
42      @Test
43      public void test_predicate1() {
44          testParser("value_expression", "LOWER(foo)", "(FUNC LOWER (COL foo))");
45      }
46  
47      @Test
48      public void test_query1() {
49          testParser("query", "SELECT DISTINCT a, b, c FROM Document", "(SELECT DISTINCT (LIST (COL a) (COL b) (COL c)) (FROM (TABLE Document)))");
50      }
51  
52      @Test
53      public void test_query2() {
54          testParserOk("query",
55                  "SELECT Y.CLAIM_NUM, X.PROPERTY_ADDRESS, Y.DAMAGE_ESTIMATES " +
56                  "FROM POLICY AS X JOIN CLAIMS AS Y ON X.POLICY_NUM = Y.POLICY_NUM " +
57                  "    WHERE ( 100000 <= ANY Y.DAMAGE_ESTIMATES ) AND ( Y.CAUSE NOT LIKE '%Katrina%' )");
58      }
59  
60  
61      @Test
62      public void test_query3() {
63          testParserOk("query",
64                  "SELECT OBJECT_ID, SCORE() AS X, DESTINATION, DEPARTURE_DATES " +
65                  "FROM TRAVEL_BROCHURE " +
66                  "WHERE ( CONTAINS('CARIBBEAN CENTRAL AMERICA CRUISE TOUR') ) AND( '2010-1-1' < ANY DEPARTURE_DATES )");
67      }
68  }