This project has retired. For details please refer to its
Attic page.
TestParserTextSearch xref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.chemistry.opencmis.server.support.query;
20
21 import org.junit.After;
22 import org.junit.Before;
23 import org.junit.Test;
24
25 public class TestParserTextSearch extends AbstractParserTest{
26
27
28
29 @Before
30 public void setUp() {
31 super.setUp(TextSearchLexer.class, TextSearchParser.class, null);
32 }
33
34 @Override
35 @After
36 public void tearDown() {
37 super.tearDown();
38 }
39
40
41
42
43
44
45 @Test
46 public void testOR1() {
47 testLexerOk("OR", "OR");
48 }
49
50
51
52
53
54
55 @Test
56 public void testTEXT_SEARCH_WORD_LIT2() {
57 testLexerOk("TEXT_SEARCH_WORD_LIT", "abc");
58 }
59
60
61
62
63
64 @Test
65 public void testTEXT_SEARCH_WORD_LIT3() {
66 testLexerFail("TEXT_SEARCH_WORD_LIT", "\"ab c\"");
67 }
68
69
70
71
72
73 @Test
74 public void testTEXT_SEARCH_WORD_LIT4() {
75 testLexerFail("TEXT_SEARCH_WORD_LIT", "\"\'abc\'\"");
76 }
77
78
79
80
81
82 @Test
83 public void testTEXT_SEARCH_WORD_LIT5() {
84 testLexerOk("TEXT_SEARCH_WORD_LIT", "\"ab\\'c\"");
85 }
86
87
88
89
90
91 @Test
92 public void testTEXT_SEARCH_WORD_LIT6() {
93 testLexerOk("TEXT_SEARCH_WORD_LIT", "\"ab\\\\c\"");
94 }
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118 @Test
119 public void testPhrase1() {
120 testParserFail("phrase", "\\'abc\\'");
121 }
122
123
124
125
126
127 @Test
128 public void testPhrase2() {
129 testParserFail("phrase", "\"abc\"");
130 }
131
132
133
134
135
136 @Test
137 public void testPhrase3() {
138 testParserOk("phrase", "'abc'");
139 }
140
141
142
143
144
145 @Test
146 public void testPhrase4() {
147 testParserOk("phrase", "'abc def'");
148 }
149
150
151
152
153
154 @Test
155 public void testPhrase5() {
156 testParserOk("phrase", "'ab\\-c'");
157 }
158
159
160
161
162
163 @Test
164 public void testPhrase6() {
165 testParserOk("phrase", "'ab\\\\c'");
166 }
167
168
169
170
171
172 @Test
173 public void testPhrase7() {
174 testParserFail("phrase", "'ab\\c'");
175 }
176
177
178
179
180
181 @Test
182 public void testPhrase8() {
183 testParserFail("phrase", "'ab\\\\\\c'");
184 }
185
186
187
188
189
190 @Test
191 public void testPhrase9() {
192 testParserOk("phrase", "'ab\\'c'");
193 }
194
195
196
197
198
199 @Test
200 public void testPhrase10() {
201 testParserOk("phrase", "'abc def'");
202 }
203
204
205
206
207
208 @Test
209 public void testPhrase11() {
210 testParserOk("phrase", "'\\'abc\\''");
211 }
212
213
214
215
216
217 @Test
218 public void testPhrase12() {
219 testParserOk("phrase", "'abc AND def'");
220 }
221
222
223
224
225
226 @Test
227 public void testPhrase13() {
228 testParserOk("phrase", "'AND'");
229 }
230
231
232
233
234
235
236
237 @Test
238 public void testWord1() {
239 testParserOk("word", "abc");
240 }
241
242
243
244
245
246 @Test
247 public void testWord2() {
248 testParserOk("word", "312#+!&abc");
249 }
250
251
252
253
254
255 @Test
256 public void testWord3() {
257 testParserOk("word", "\\'abc\\'");
258 }
259
260
261
262
263
264 @Test
265 public void testWord4() {
266 testParserFail("word", "'abc'");
267 }
268
269
270
271
272
273 @Test
274 public void testWord6() {
275 testParserOk("word", "ab\\-c");
276 }
277
278
279
280
281
282 @Test
283 public void testWord7() {
284 testParserOk("word", "ab\\\\c");
285 }
286
287
288
289
290
291 @Test
292 public void testWord8() {
293 testParserOk("word", "ab\\'c");
294 }
295
296
297
298
299
300 @Test
301 public void testWord9() {
302 testParserFail("word", "OR");
303 }
304
305
306
307
308
309 @Test
310 public void testWord10() {
311 testParserFail("word", "AND");
312 }
313
314
315
316
317
318
319
320
321 @Test
322 public void testWord11() {
323 testParserOk("term", "-abc");
324 }
325
326
327
328
329
330 @Test
331 public void testWord12() {
332 testParserOk("term", "abc");
333 }
334
335
336
337
338
339 @Test
340 public void testWord13() {
341 testParserOk("term", "'abc def'");
342 }
343
344
345
346
347
348 @Test
349 public void testWord14() {
350 testParserOk("term", "-'abc def'");
351 }
352
353
354
355
356
357
358
359 @Test
360 public void testConjunct1() {
361 testParserOk("conjunct", "abc def");
362 }
363
364
365
366
367
368 @Test
369 public void testConjunct2() {
370 testParserOk("conjunct", "abc AND def");
371 }
372
373
374
375
376
377 @Test
378 public void testConjunct3() {
379 testParserOk("conjunct", "abc AND def ghi John\\'s");
380 }
381
382
383
384
385
386
387
388 @Test
389 public void testTextSearchExpression1() {
390 testParserOk("text_search_expression", "cat mouse dog");
391 }
392
393
394
395
396
397 @Test
398 public void testTextSearchExpression2() {
399 testParserOk("text_search_expression", "cat AND mouse AND dog");
400 }
401
402
403
404
405
406 @Test
407 public void testTextSearchExpression3() {
408 testParserOk("text_search_expression", "cat OR mouse OR dog");
409 }
410
411
412
413
414
415 @Test
416 public void testTextSearchExpression4() {
417 testParserOk("text_search_expression", "cat mouse OR dog");
418 }
419
420
421
422
423
424 @Test
425 public void testTextSearchExpression5() {
426 testParserOk("text_search_expression", "cat AND mouse OR dog AND John\\'s");
427 }
428
429
430
431
432
433 @Test
434 public void testTextSearchExpression6() {
435 testParserOk("text_search_expression", "'cat AND mouse'");
436 }
437
438
439
440
441
442 @Test
443 public void testTextSearchExpression7() {
444 testParserOk("text_search_expression", "'text search expression'");
445 }
446
447
448
449
450
451 @Test
452 public void testTextSearchExpression8() {
453 testParserOk("text_search_expression", "'John\\'s presentation'");
454 }
455
456
457
458
459
460 @Test
461 public void testTextSearchExpression9() {
462 testParserFail("text_search_expression", "'John\\\\'s presentation'");
463 }
464
465
466
467
468
469 @Test
470 public void testTextSearchExpression10() {
471 testParserOk("text_search_expression", "A\\-1");
472 }
473
474
475
476
477
478 @Test
479 public void testTextSearchExpression11() {
480 testParserOk("text_search_expression", "'c:\\\\My Documents'");
481 }
482
483
484
485
486
487 @Test
488 public void testTextSearchExpression13() {
489 testParserFail("text_search_expression", "'c:\\\\\\My Documents'");
490 }
491
492
493
494
495
496 @Test
497 public void testTextSearchExpression14() {
498 testParserFail("text_search_expression", "'c:\\My Documents'");
499 }
500
501
502
503
504
505 @Test
506 public void testTextSearchExpression15() {
507 testParserFail("text_search_expression", "c:\\My Documents");
508 }
509
510 }