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