Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 102 lines (69 sloc) 2.92 kb
4076d0be »
2011-07-24 Secondary indexes
1 package com.shorrockin.cascal
2
3 import org.junit.{Assert, Test}
4 import com.shorrockin.cascal.utils.Conversions._
5 import Assert._
6
739049ba »
2011-11-24 refactor embedded test poll for easier testing with various schemas
7 class TestSeconderyIndex extends EmbeddedCassandra {
4076d0be »
2011-07-24 Secondary indexes
8
9 val family = "Test" \ "StandardIndexed"
10 val key1 = family \ "key1"
11 val key2 = family \ "key2"
12
13 @Test def eqExpression = borrow { (session) =>
14
15 session.insert(key1 \ "column1" \ "b")
16 session.insert(key1 \ "column2" \ "c")
17
18 session.insert(key2 \ "column1" \ "b")
19
20 val query = family where "column1" Eq "b" startAt "a"
21
22 val rows = session.list(query)
23 assertEquals(2, rows.size)
24 }
25
26 @Test def eqExpressionForLongType = borrow { (session) =>
27
28 session.insert(key1 \ "longColumn" \ 1L)
29 session.insert(key2 \ "longColumn" \ 2L)
30
31 val query = family where "longColumn" Eq 1L startAt 0
32
33 val rows = session.list(query)
34 assertEquals(1, rows.size)
35 }
36
37 @Test def eqAndGtExpression = borrow { (session) =>
38
39 session.insert(key1 \ "column1" \ "b")
40 session.insert(key1 \ "column2" \ "c")
41
42 session.insert(key2 \ "column1" \ "b")
43 session.insert(key2 \ "column2" \ "b")
44
45 val query = family where "column1" Eq "b" and "column2" Gt "b" startAt "a"
46 val rows = session.list(query)
47 assertEquals(1, rows.size)
48 }
49
50 @Test def eqAndGteExpression = borrow { (session) =>
51
52 session.insert(key1 \ "column1" \ "b")
53 session.insert(key1 \ "column2" \ "c")
54
55 session.insert(key2 \ "column1" \ "b")
56 session.insert(key2 \ "column2" \ "b")
57
58 val query = family where "column1" Eq "b" and "column2" Gte "b" startAt "a"
59 val rows = session.list(query)
60 assertEquals(2, rows.size)
61 }
62
63 @Test def eqAndLtExpression = borrow { (session) =>
64
65 session.insert(key1 \ "column1" \ "b")
66 session.insert(key1 \ "column2" \ "a")
67
68 session.insert(key2 \ "column1" \ "b")
69 session.insert(key2 \ "column2" \ "b")
70
71 val query = family where "column1" Eq "b" and "column2" Lt "b" startAt "a"
72 val rows = session.list(query)
73 assertEquals(1, rows.size)
74 }
75
76 @Test def eqAndLteExpression = borrow { (session) =>
77
78 session.insert(key1 \ "column1" \ "b")
79 session.insert(key1 \ "column2" \ "a")
80
81 session.insert(key2 \ "column1" \ "b")
82 session.insert(key2 \ "column2" \ "b")
83
84 val query = family where "column1" Eq "b" and "column2" Lte "b" startAt "a"
85 val rows = session.list(query)
86 assertEquals(2, rows.size)
87 }
88
4e897bfc »
2011-07-29 Secondary Indexes results limit
89 @Test def limitNumberOfResult = borrow { (session) =>
90
91 session.insert(key1 \ "column1" \ "b")
92 session.insert(key1 \ "column2" \ "a")
93
94 session.insert(key2 \ "column1" \ "b")
95 session.insert(key2 \ "column2" \ "b")
96
97 val query = family where "column1" Eq "b" and "column2" Lte "b" startAt "a" limit 1
98 val rows = session.list(query)
99 assertEquals(1, rows.size)
100 }
101
4076d0be »
2011-07-24 Secondary indexes
102 }
Something went wrong with that request. Please try again.