1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.query.jpql.internal

File JPQLParserTest.java

 

Code metrics

0
12
3
1
63
27
3
0.25
4
3
1

Classes

Class Line # Actions
JPQLParserTest 24 12 0% 3 0
1.0100%
 

Contributing tests

This file is covered by 3 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.query.jpql.internal;
21   
22    import junit.framework.TestCase;
23   
 
24    public class JPQLParserTest extends TestCase
25    {
26    JPQLParser parser = new JPQLParser();
27   
 
28  1 toggle public void testStartSpeed() throws Exception
29    {
30    // heat up parser engine for more accuracy test timing
31    // this is needed because of much static data in the parser
32  1 parser.parse("select a from A as a");
33    }
34   
 
35  1 toggle public void testJPQL() throws Exception
36    {
37    // quotes
38  1 parser.parse("select a from A as a where a.f='str'");
39  1 parser.parse("select a from A as a where a.f=\"str\"");
40   
41    // order by
42  1 parser.parse("select doc from Document doc, doc.object(XWiki.XWikiGroups) as g order by g.number");
43  1 parser.parse("select doc from Document doc, doc.object(XWiki.XWikiGroups) as g order by g.number desc");
44  1 parser.parse("select doc from Document doc, doc.object(XWiki.XWikiGroups) as g order by g.number asc");
45   
46    // member of
47  1 parser.parse("select a from A as a where :param member of a.prop");
48   
49    // input parameters
50  1 parser.parse("select a from A as a where a.p = ?1 or :name = a.p or ?2 member of a.p or a.p like :qwe");
51    }
52   
 
53  1 toggle public void testXWQLExtensions() throws Exception
54    {
55    // object() in from clause
56  1 parser.parse("select doc from Document as doc, doc.object('XWiki.Test') as test where test.some=1");
57  1 parser.parse("select doc from Document as doc, doc.object(XWiki.Test) as test where test.some=1");
58   
59    // object() in where clause
60  1 parser.parse("select doc from Document as doc where doc.object('XWiki.Test').prop=1");
61  1 parser.parse("select doc from Document as doc where doc.object(XWiki.Test).prop=1");
62    }
63    }