jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1302927 [4/4] - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/query/ main/java/org/apache/jackrabbit/oak/query/ast/ main/java/org/apache/jackrabbit/oak/query/index/ test/java/org/apache/jackrabbit/oak/ test/jav...
Date Tue, 20 Mar 2012 15:05:06 GMT
Added: jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/queryTest.txt
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/queryTest.txt?rev=1302927&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/queryTest.txt
(added)
+++ jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/queryTest.txt
Tue Mar 20 15:05:04 2012
@@ -0,0 +1,176 @@
+# Syntax:
+# * lines starting with "#" are remarks.
+# * lines starting with "select" are queries, followed by expected results and an empty line
+# * lines starting with "explain" are followed by expected query plan and an empty line
+# * all other lines are are committed into the microkernel (line by line)
+# * new tests are typically be added on top, after the syntax docs
+# * use ascii character only
+
++ "test": { "jcr:resource": {}, "resource": { "x" : {}}}
+
+explain select * from [nt:base] as b where ischildnode(b, '/test')
+nt:base AS b /* traverse "/test/*" */
+
+explain select * from [nt:base] as b where isdescendantnode(b, '/test')
+nt:base AS b /* traverse "/test//*" */
+
+select * from [nt:base] as b where ischildnode(b, '/test')
+/test/jcr:resource
+/test/resource
+
+select * from [nt:base] as b where issamenode(b, '/test')
+/test
+
+select * from [nt:base] where name() = 'resource'
+/test/resource
+
+select * from [nt:base] as b where localname(b) = 'resource'
+/test/jcr:resource
+/test/resource
+
+select * from [nt:base] as x where isdescendantnode(x, '/')
+/
+/test
+/test/jcr:resource
+/test/resource
+/test/resource/x
+
+- "test"
+
++ "parents": { "p0": {"id": "0"}, "p1": {"id": "1"}, "p2": {"id": "2"}}
++ "children": { "c1": {"p": "1"}, "c2": {"p": "1"}, "c3": {"p": "2"}, "c4": {"p": "3"}}
+
+select * from [nt:base] as p where p.[jcr:path] = '/parents'
+/parents
+
+select * from [nt:base] as p inner join [nt:base] as p2 on ischildnode(p2, p) where p.[jcr:path]
= '/'
+/, /parents
+/, /children
+
+select * from [nt:base] as p inner join [nt:base] as p2 on isdescendantnode(p2, p) where
p.[jcr:path] = '/parents'
+/parents, /parents/p0
+/parents, /parents/p1
+/parents, /parents/p2
+
+select * from [nt:base] as p inner join [nt:base] as p2 on issamenode(p2, p) where p.[jcr:path]
= '/parents'
+/parents, /parents
+
+select id from [nt:base] where id is not null
+0
+1
+2
+
+select id from [nt:base] where id is not null order by id desc
+2
+1
+0
+
+select * from [nt:base] as c right outer join [nt:base] as p on p.id = c.p where p.id is
not null
+null, /parents/p0
+/children/c1, /parents/p1
+/children/c2, /parents/p1
+/children/c3, /parents/p2
+
+select * from [nt:base] as p left outer join [nt:base] as c on p.id = c.p where p.id is not
null
+/parents/p0, null
+/parents/p1, /children/c1
+/parents/p1, /children/c2
+/parents/p2, /children/c3
+
+select * from [nt:base] as p left outer join [nt:base] as c on p.id = c.p where p.id is not
null and c.p is null
+/parents/p0, null
+
+select * from [nt:base] as p left outer join [nt:base] as c on p.id = c.p where p.id is not
null and c.p is not null
+/parents/p1, /children/c1
+/parents/p1, /children/c2
+/parents/p2, /children/c3
+
+select * from [nt:base] as p inner join [nt:base] as c on p.id = c.p
+/parents/p1, /children/c1
+/parents/p1, /children/c2
+/parents/p2, /children/c3
+
+explain select * from [nt:base] as p inner join [nt:base] as c on p.id = c.p
+nt:base AS p /* traverse "//*" */ INNER JOIN nt:base AS c /* traverse "//*" */
+
+- "parents"
+- "children"
+
++ "test": { "hello": { "x": "1" }, "world": { "x": "2" } }
++ "test2": { "id":"1", "x": "2" }
+
+select * from [nt:base]
+/
+/test
+/test/hello
+/test/world
+/test2
+
+select * from [nt:base] where id = '1'
+/test2
+
+select * from [nt:base] where id = '1' and x = '2'
+/test2
+
+select * from [nt:base] where id = '1' or x = '2'
+/test/world
+/test2
+
+select * from [nt:base] where not (id = '1' or x = '2')
+/
+/test
+/test/hello
+
+select * from [nt:base] where x is null
+/
+/test
+
+- "test"
+- "test2"
+
++ "test": { "name": "hello" }
++ "test2": { "name": "World!" }
++ "test3": { "name": "Hallo" }
++ "test4": { "name": "10%" }
++ "test5": { "name": "10 percent" }
+
+select name from [nt:base] order by upper(name)
+10 percent
+10%
+Hallo
+hello
+World!
+null
+
+select * from [nt:base] where length(name) = 5
+/test
+/test3
+
+select * from [nt:base] where upper(name) = 'HELLO'
+/test
+
+select * from [nt:base] where lower(name) = 'world!'
+/test2
+
+select * from [nt:base] where name like 'W%'
+/test2
+
+select * from [nt:base] where name like '%o_%'
+/test2
+
+select * from [nt:base] where name like '__llo'
+/test
+/test3
+
+select * from [nt:base] where upper(name) like 'H_LLO'
+/test
+/test3
+
+select * from [nt:base] where upper(name) like 'H\_LLO'
+
+select * from [nt:base] where upper(name) like '10%'
+/test4
+/test5
+
+select * from [nt:base] where upper(name) like '10\%'
+/test4

Added: jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/queryXpathTest.txt
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/queryXpathTest.txt?rev=1302927&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/queryXpathTest.txt
(added)
+++ jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/queryXpathTest.txt
Tue Mar 20 15:05:04 2012
@@ -0,0 +1,106 @@
+# Syntax:
+# * lines starting with "#" are remarks.
+# * lines starting with "xpath" are xpath queries, followed by expected sql2 query
+# * use ascii character only
+
+xpath //*
+select * from [nt:base]
+
+xpath //element(*, my:type)
+select * from [my:type]
+
+xpath //element(*, my:type)/@my:title
+select [my:title] from [my:type]
+
+xpath //element(*, my:type)/(@my:title | @my:text)
+select [my:title], [my:text] from [my:type]
+
+xpath /jcr:root/nodes//element(*, my:type)
+select * from [my:type] where [jcr:path] like '/nodes' or [jcr:path] like '/nodes/%'
+
+xpath /jcr:root/some/element(nodes, my:type)
+select * from [my:type] where [jcr:path] like '/some/nodes'
+
+xpath /jcr:root/some/nodes/element(*, my:type)
+select * from [my:type] where [jcr:path] like '/some/nodes/%' and not [jcr:path] like '/some/nodes/%/'
+
+xpath /jcr:root/some/nodes//element(*, my:type)
+select * from [my:type] where [jcr:path] like '/some/nodes' or [jcr:path] like '/some/nodes/%'
+
+xpath //element(*, my:type)[@my:title = 'JSR 170']
+select * from [my:type] where [my:title] = 'JSR 170'
+
+xpath //element(*, my:type)[jcr:like(@title,'%Java%')]
+select * from [my:type] where [title] like '%Java%'
+
+xpath //element(*, my:type)[jcr:contains(., 'JSR 170')]
+select * from [my:type] where contains(*, 'JSR 170')
+
+xpath //element(*, my:type)[@my:title]
+select * from [my:type] where [my:title] is not null
+
+xpath //element(*, my:type)[not(@my:title)]
+select * from [my:type] where [my:title] is null
+
+xpath //element(*, my:type)[@my:value < -1.0]
+select * from [my:type] where [my:value] < -1.0
+
+xpath //element(*, my:type)[@my:value > +10123123123]
+select * from [my:type] where [my:value] > 10123123123
+
+xpath //element(*, my:type)[@my:value <= 10.3e-3]
+select * from [my:type] where [my:value] <= 10.3e-3
+
+xpath //element(*, my:type)[@my:value >= 0e3]
+select * from [my:type] where [my:value] >= 0e3
+
+xpath //element(*, my:type)[@my:value <> 'Joe''s Caffee']
+select * from [my:type] where [my:value] <> 'Joe''s Caffee'
+
+xpath //element(*, my:type)[(not(@my:title) and @my:subject)]
+select * from [my:type] where ([my:title] is null and [my:subject] is not null)
+
+xpath //element(*, my:type)[not(@my:title) or @my:subject]
+select * from [my:type] where [my:title] is null or [my:subject] is not null
+
+xpath //element(*, my:type)[not(@my:value > 0 and @my:value < 100)]
+select * from [my:type] where not([my:value] > 0 and [my:value] < 100)
+
+xpath //element(*, my:type) order by @jcr:lastModified
+select * from [my:type] order by [jcr:lastModified]
+
+xpath //element(*, my:type) order by @my:date descending, @my:title ascending
+select * from [my:type] order by [my:date] desc, [my:title]
+
+xpath //element(*, my:type)[jcr:contains(., 'jcr')] order by jcr:score() descending
+select * from [my:type] where contains(*, 'jcr') order by score() desc
+
+xpath //element(*, my:type)[jcr:contains(@my:title, 'jcr')] order by jcr:score() descending
+select * from [my:type] where contains([my:title], 'jcr') order by score() desc
+
+xpath invalid/query
+invalid: Query: invalid(*)/query; expected: <end>
+
+xpath //element(*, my:type)[@my:value = -'x']
+invalid: Query: //element(*, my:type)[@my:value = -'x'(*)]
+
+xpath //element(-1, my:type)
+invalid: Query: //element(-(*)1, my:type); expected: identifier
+
+xpath //element(*, my:type)[not @my:title]
+invalid: Query: //element(*, my:type)[not @(*)my:title]; expected: (
+
+xpath //element(*, my:type)[@my:value = +'x']
+invalid: Query: //element(*, my:type)[@my:value = +'x'(*)]
+
+xpath //element(*, my:type)[@my:value = ['x']
+invalid: Query: //element(*, my:type)[@my:value = [(*)'x']; expected: @, -, +
+
+xpath //element(*, my:type)[jcr:strike(@title,'%Java%')]
+invalid: Query: //element(*, my:type)[jcr:strike(@(*)title,'%Java%')]; expected: jcr:like
| jcr:contains | jcr:score | jcr:deref
+
+xpath //element(*, my:type)[
+invalid: Query: //element(*, my:type)(*)[; expected: not, (, @, -, +
+
+xpath //element(*, my:type)[@my:value >= .]
+invalid: Query: //element(*, my:type)[@my:value >= .(*)]; expected: @, -, +



Mime
View raw message