KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > repo > search > SearcherComponentTest


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.repo.search;
18
19 import java.io.Serializable JavaDoc;
20 import java.util.HashMap JavaDoc;
21 import java.util.List JavaDoc;
22 import java.util.Map JavaDoc;
23
24 import javax.transaction.Status JavaDoc;
25 import javax.transaction.UserTransaction JavaDoc;
26
27 import junit.framework.TestCase;
28
29 import org.alfresco.model.ContentModel;
30 import org.alfresco.repo.node.BaseNodeServiceTest;
31 import org.alfresco.repo.security.authentication.AuthenticationComponent;
32 import org.alfresco.service.ServiceRegistry;
33 import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
34 import org.alfresco.service.cmr.dictionary.DictionaryService;
35 import org.alfresco.service.cmr.repository.ChildAssociationRef;
36 import org.alfresco.service.cmr.repository.NodeRef;
37 import org.alfresco.service.cmr.repository.NodeService;
38 import org.alfresco.service.cmr.repository.StoreRef;
39 import org.alfresco.service.cmr.search.QueryParameterDefinition;
40 import org.alfresco.service.namespace.DynamicNamespacePrefixResolver;
41 import org.alfresco.service.namespace.QName;
42 import org.alfresco.service.transaction.TransactionService;
43 import org.alfresco.util.ApplicationContextHelper;
44 import org.alfresco.util.ISO9075;
45 import org.springframework.context.ApplicationContext;
46
47 /**
48  * @see org.alfresco.repo.search.SearcherComponent
49  *
50  * @author Derek Hulley
51  */

52 public class SearcherComponentTest extends TestCase
53 {
54     private static ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
55     
56     private static String JavaDoc COMPLEX_LOCAL_NAME = " `¬¦!\"£$%^&*()-_=+\t\n\\\u0000[]{};'#:@~,./<>?\\|\u0123\u4567\u8900\uabcd\uefff_xT65A_";
57     
58     private ServiceRegistry serviceRegistry;
59     private TransactionService transactionService;
60     private DictionaryService dictionaryService;
61     private SearcherComponent searcher;
62     private NodeService nodeService;
63     private AuthenticationComponent authenticationComponent;
64     
65     private NodeRef rootNodeRef;
66     private UserTransaction JavaDoc txn;
67     
68     public void setUp() throws Exception JavaDoc
69     {
70         serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
71         transactionService = serviceRegistry.getTransactionService();
72         dictionaryService = BaseNodeServiceTest.loadModel(ctx);
73         nodeService = serviceRegistry.getNodeService();
74         
75         this.authenticationComponent = (AuthenticationComponent)ctx.getBean("authenticationComponent");
76         this.authenticationComponent.setSystemUserAsCurrentUser();
77         
78         // get the indexer and searcher factory
79
IndexerAndSearcher indexerAndSearcher = (IndexerAndSearcher) ctx.getBean("indexerAndSearcherFactory");
80         searcher = new SearcherComponent();
81         searcher.setIndexerAndSearcherFactory(indexerAndSearcher);
82         // create a test workspace
83
StoreRef storeRef = nodeService.createStore(
84                 StoreRef.PROTOCOL_WORKSPACE,
85                 getName() + "_" + System.currentTimeMillis());
86         rootNodeRef = nodeService.getRootNode(storeRef);
87         // begin a transaction
88
txn = transactionService.getUserTransaction();
89         txn.begin();
90     }
91     
92     public void tearDown() throws Exception JavaDoc
93     {
94         if (txn.getStatus() == Status.STATUS_ACTIVE)
95         {
96             txn.rollback();
97         }
98         authenticationComponent.clearCurrentSecurityContext();
99         super.tearDown();
100     }
101
102     public void testNodeXPath() throws Exception JavaDoc
103     {
104         
105         Map JavaDoc<QName, ChildAssociationRef> assocRefs = BaseNodeServiceTest.buildNodeGraph(nodeService, rootNodeRef);
106         
107         Map JavaDoc<QName, Serializable JavaDoc> properties = new HashMap JavaDoc<QName, Serializable JavaDoc>();
108         properties.put(QName.createQName(BaseNodeServiceTest.NAMESPACE, COMPLEX_LOCAL_NAME), "monkey");
109         QName qnamerequiringescaping = QName.createQName(BaseNodeServiceTest.NAMESPACE, COMPLEX_LOCAL_NAME);
110         nodeService.createNode(rootNodeRef, BaseNodeServiceTest.ASSOC_TYPE_QNAME_TEST_CHILDREN, qnamerequiringescaping, ContentModel.TYPE_CONTAINER);
111         QName qname = QName.createQName(BaseNodeServiceTest.NAMESPACE, "n2_p_n4");
112         
113         
114         NodeServiceXPath xpath;
115         String JavaDoc xpathStr;
116         QueryParameterDefImpl paramDef;
117         List JavaDoc list;
118         
119         DynamicNamespacePrefixResolver namespacePrefixResolver = new DynamicNamespacePrefixResolver(null);
120         namespacePrefixResolver.registerNamespace(BaseNodeServiceTest.TEST_PREFIX, BaseNodeServiceTest.NAMESPACE);
121         // create the document navigator
122
DocumentNavigator documentNavigator = new DocumentNavigator(
123                 dictionaryService,
124                 nodeService,
125                 searcher,
126                 namespacePrefixResolver,
127                 false, false);
128         
129         xpath = new NodeServiceXPath("//.[@test:animal='monkey']", documentNavigator, null);
130         xpath.addNamespace(BaseNodeServiceTest.TEST_PREFIX, BaseNodeServiceTest.NAMESPACE);
131         list = xpath.selectNodes(new ChildAssociationRef(null, null, null, rootNodeRef));
132         assertEquals(1, list.size());
133       
134         xpath = new NodeServiceXPath("*", documentNavigator, null);
135         list = xpath.selectNodes(new ChildAssociationRef(null, null, null, rootNodeRef));
136         assertEquals(3, list.size());
137         
138         xpath = new NodeServiceXPath("*/*", documentNavigator, null);
139         list = xpath.selectNodes(new ChildAssociationRef(null, null, null, rootNodeRef));
140         assertEquals(4, list.size());
141         
142         xpath = new NodeServiceXPath("*/*/*", documentNavigator, null);
143         list = xpath.selectNodes(new ChildAssociationRef(null, null, null, rootNodeRef));
144         assertEquals(3, list.size());
145         
146         xpath = new NodeServiceXPath("*/*/*/*", documentNavigator, null);
147         list = xpath.selectNodes(new ChildAssociationRef(null, null, null, rootNodeRef));
148         assertEquals(2, list.size());
149         
150         xpath = new NodeServiceXPath("*/*/*/*/..", documentNavigator, null);
151         list = xpath.selectNodes(new ChildAssociationRef(null, null, null, rootNodeRef));
152         assertEquals(2, list.size());
153         
154         xpath = new NodeServiceXPath("*//.", documentNavigator, null);
155         list = xpath.selectNodes(new ChildAssociationRef(null, null, null, rootNodeRef));
156         assertEquals(12, list.size());
157         
158         xpathStr = "test:root_p_n1";
159         xpath = new NodeServiceXPath(xpathStr, documentNavigator, null);
160         xpath.addNamespace(BaseNodeServiceTest.TEST_PREFIX, BaseNodeServiceTest.NAMESPACE);
161         list = xpath.selectNodes(new ChildAssociationRef(null, null, null, rootNodeRef));
162         assertEquals(1, list.size());
163         
164         xpathStr = "*//.[@test:animal]";
165         xpath = new NodeServiceXPath(xpathStr, documentNavigator, null);
166         xpath.addNamespace(BaseNodeServiceTest.TEST_PREFIX, BaseNodeServiceTest.NAMESPACE);
167         list = xpath.selectNodes(new ChildAssociationRef(null, null, null, rootNodeRef));
168         assertEquals(1, list.size());
169         
170         xpathStr = "*//.[@test:animal='monkey']";
171         xpath = new NodeServiceXPath(xpathStr, documentNavigator, null);
172         xpath.addNamespace(BaseNodeServiceTest.TEST_PREFIX, BaseNodeServiceTest.NAMESPACE);
173         list = xpath.selectNodes(new ChildAssociationRef(null, null, null, rootNodeRef));
174         assertEquals(1, list.size());
175         
176         xpathStr = "//.[@test:animal='monkey']";
177         xpath = new NodeServiceXPath(xpathStr, documentNavigator, null);
178         xpath.addNamespace(BaseNodeServiceTest.TEST_PREFIX, BaseNodeServiceTest.NAMESPACE);
179         list = xpath.selectNodes(new ChildAssociationRef(null, null, null, rootNodeRef));
180         assertEquals(1, list.size());
181         
182         paramDef = new QueryParameterDefImpl(
183                 QName.createQName("test:test", namespacePrefixResolver),
184                 dictionaryService.getDataType(DataTypeDefinition.TEXT),
185                 true,
186                 "monkey");
187         xpathStr = "//.[@test:animal=$test:test]";
188         xpath = new NodeServiceXPath(xpathStr, documentNavigator, new QueryParameterDefinition[]{paramDef});
189         xpath.addNamespace(BaseNodeServiceTest.TEST_PREFIX, BaseNodeServiceTest.NAMESPACE);
190         list = xpath.selectNodes(new ChildAssociationRef(null, null, null, rootNodeRef));
191         assertEquals(1, list.size());
192         
193         xpath = new NodeServiceXPath(".", documentNavigator, null);
194         list = xpath.selectNodes(assocRefs.get(qname));
195         assertEquals(1, list.size());
196         
197         xpath = new NodeServiceXPath("/test:"+ISO9075.encode(COMPLEX_LOCAL_NAME), documentNavigator, null);
198         list = xpath.selectNodes(new ChildAssociationRef(null, null, null, rootNodeRef));
199         assertEquals(1, list.size());
200         
201         xpath = new NodeServiceXPath("//test:"+ISO9075.encode(COMPLEX_LOCAL_NAME), documentNavigator, null);
202         list = xpath.selectNodes(new ChildAssociationRef(null, null, null, rootNodeRef));
203         assertEquals(1, list.size());
204         
205         xpath = new NodeServiceXPath("..", documentNavigator, null);
206         list = xpath.selectNodes(assocRefs.get(qname));
207         assertEquals(1, list.size());
208         
209         // follow all parent links now
210
documentNavigator.setFollowAllParentLinks(true);
211         
212         xpath = new NodeServiceXPath("..", documentNavigator, null);
213         list = xpath.selectNodes(assocRefs.get(qname));
214         assertEquals(2, list.size());
215         
216         xpathStr = "//@test:animal";
217         xpath = new NodeServiceXPath(xpathStr, documentNavigator, null);
218         xpath.addNamespace(BaseNodeServiceTest.TEST_PREFIX, BaseNodeServiceTest.NAMESPACE);
219         list = xpath.selectNodes(assocRefs.get(qname));
220         assertEquals(1, list.size());
221         assertTrue(list.get(0) instanceof DocumentNavigator.Property);
222         
223         xpathStr = "//@test:reference";
224         xpath = new NodeServiceXPath(xpathStr, documentNavigator, null);
225         xpath.addNamespace(BaseNodeServiceTest.TEST_PREFIX, BaseNodeServiceTest.NAMESPACE);
226         list = xpath.selectNodes(assocRefs.get(qname));
227         assertEquals(1, list.size());
228         
229         // stop following parent links
230
documentNavigator.setFollowAllParentLinks(false);
231         
232         xpathStr = "deref(/test:root_p_n1/test:n1_p_n3/@test:reference, '*')";
233         xpath = new NodeServiceXPath(xpathStr, documentNavigator, null);
234         xpath.addNamespace(BaseNodeServiceTest.TEST_PREFIX, BaseNodeServiceTest.NAMESPACE);
235         list = xpath.selectNodes(assocRefs.get(qname));
236         assertEquals(1, list.size());
237         
238         xpathStr = "deref(/test:root_p_n1/test:n1_p_n3/@test:reference, 'test:root_p_n1')";
239         xpath = new NodeServiceXPath(xpathStr, documentNavigator, null);
240         xpath.addNamespace(BaseNodeServiceTest.TEST_PREFIX, BaseNodeServiceTest.NAMESPACE);
241         list = xpath.selectNodes(assocRefs.get(qname));
242         assertEquals(0, list.size());
243         
244         xpathStr = "deref(/test:root_p_n1/test:n1_p_n3/@test:reference, 'test:root_p_n2')";
245         xpath = new NodeServiceXPath(xpathStr, documentNavigator, null);
246         xpath.addNamespace(BaseNodeServiceTest.TEST_PREFIX, BaseNodeServiceTest.NAMESPACE);
247         list = xpath.selectNodes(assocRefs.get(qname));
248         assertEquals(1, list.size());
249         
250         
251         // test 'subtypeOf' function
252
paramDef = new QueryParameterDefImpl(
253                 QName.createQName("test:type", namespacePrefixResolver),
254                 dictionaryService.getDataType(DataTypeDefinition.QNAME),
255                 true,
256                 BaseNodeServiceTest.TYPE_QNAME_TEST_CONTENT.toPrefixString(namespacePrefixResolver));
257         xpathStr = "//.[subtypeOf($test:type)]";
258         xpath = new NodeServiceXPath(xpathStr, documentNavigator, new QueryParameterDefinition[]{paramDef});
259         xpath.addNamespace(BaseNodeServiceTest.TEST_PREFIX, BaseNodeServiceTest.NAMESPACE);
260         list = xpath.selectNodes(assocRefs.get(qname));
261         assertEquals(2, list.size()); // 2 distinct paths to node n8, which is of type content
262

263         xpath = new NodeServiceXPath("/", documentNavigator, null);
264         xpath.addNamespace(BaseNodeServiceTest.TEST_PREFIX, BaseNodeServiceTest.NAMESPACE);
265         list = xpath.selectNodes(assocRefs.get(qname));
266         assertEquals(1, list.size());
267     }
268     
269     
270     public void testSelectAPI() throws Exception JavaDoc
271     {
272         Map JavaDoc<QName, ChildAssociationRef> assocRefs = BaseNodeServiceTest.buildNodeGraph(nodeService, rootNodeRef);
273         NodeRef n6Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "n3_p_n6")).getChildRef();
274         
275         DynamicNamespacePrefixResolver namespacePrefixResolver = new DynamicNamespacePrefixResolver(null);
276         namespacePrefixResolver.registerNamespace(BaseNodeServiceTest.TEST_PREFIX, BaseNodeServiceTest.NAMESPACE);
277         
278         List JavaDoc<NodeRef> answer = searcher.selectNodes(rootNodeRef, "/test:root_p_n1/test:n1_p_n3/*", null, namespacePrefixResolver, false);
279         assertEquals(1, answer.size());
280         assertTrue(answer.contains(n6Ref));
281         
282         //List<ChildAssocRef>
283
answer = searcher.selectNodes(rootNodeRef, "*", null, namespacePrefixResolver, false);
284         assertEquals(2, answer.size());
285         
286         List JavaDoc<Serializable JavaDoc> attributes = searcher.selectProperties(rootNodeRef, "//@test:animal", null, namespacePrefixResolver, false);
287         assertEquals(1, attributes.size());
288     }
289     
290     /**
291      * Tests the <b>like</b> and <b>contains</b> functions (FTS functions) within a currently executing
292      * transaction
293      */

294     public void testLikeAndContains() throws Exception JavaDoc
295     {
296         Map JavaDoc<QName, ChildAssociationRef> assocRefs = BaseNodeServiceTest.buildNodeGraph(nodeService, rootNodeRef);
297         
298         
299         Map JavaDoc<QName, Serializable JavaDoc> properties = new HashMap JavaDoc<QName, Serializable JavaDoc>();
300         properties.put(QName.createQName(BaseNodeServiceTest.NAMESPACE, COMPLEX_LOCAL_NAME), "monkey");
301         QName qnamerequiringescaping = QName.createQName(BaseNodeServiceTest.NAMESPACE, COMPLEX_LOCAL_NAME);
302         nodeService.createNode(rootNodeRef, BaseNodeServiceTest.ASSOC_TYPE_QNAME_TEST_CHILDREN, qnamerequiringescaping, ContentModel.TYPE_CONTAINER, properties);
303         
304         // commit the node graph
305
txn.commit();
306         
307         txn = transactionService.getUserTransaction();
308         txn.begin();
309         
310         DynamicNamespacePrefixResolver namespacePrefixResolver = new DynamicNamespacePrefixResolver(null);
311         namespacePrefixResolver.registerNamespace(BaseNodeServiceTest.TEST_PREFIX, BaseNodeServiceTest.NAMESPACE);
312         
313         List JavaDoc<NodeRef> answer = searcher.selectNodes(
314                 rootNodeRef,
315                 "//*[like(@test:animal, 'm__k%', false)]",
316                 null,
317                 namespacePrefixResolver, false);
318         assertEquals(1, answer.size());
319         
320         answer = searcher.selectNodes(
321                 rootNodeRef,
322                 "//*[like(@test:"+ISO9075.encode(COMPLEX_LOCAL_NAME)+", 'm__k%', false)]",
323                 null,
324                 namespacePrefixResolver, false);
325 // assertEquals(1, answer.size());
326

327         answer = searcher.selectNodes(
328                 rootNodeRef,
329                 "//*[like(@test:animal, 'M__K%', false)]",
330                 null,
331                 namespacePrefixResolver, false);
332         assertEquals(1, answer.size());
333         
334         answer = searcher.selectNodes(
335                 rootNodeRef,
336                 "//*[like(@test:"+ISO9075.encode(COMPLEX_LOCAL_NAME)+", 'M__K%', false)]",
337                 null,
338                 namespacePrefixResolver, false);
339 // assertEquals(1, answer.size());
340

341         answer = searcher.selectNodes(
342                 rootNodeRef,
343                 "//*[like(@test:UPPERANIMAL, 'm__k%', false)]",
344                 null,
345                 namespacePrefixResolver, false);
346         assertEquals(1, answer.size());
347         
348         answer = searcher.selectNodes(
349                 rootNodeRef,
350                 "//*[like(@test:UPPERANIMAL, 'M__K%', false)]",
351                 null,
352                 namespacePrefixResolver, false);
353         assertEquals(1, answer.size());
354         
355         answer = searcher.selectNodes(
356                 rootNodeRef,
357                 "//*[like(@test:UPPERANIMAL, 'M__K%', true)]",
358                 null,
359                 namespacePrefixResolver, false);
360         assertEquals(1, answer.size());
361         
362         answer = searcher.selectNodes(rootNodeRef, "//*[contains('monkey')]", null, namespacePrefixResolver, false);
363         assertEquals(2, answer.size());
364         
365         answer = searcher.selectNodes(rootNodeRef, "//*[contains('MONKEY')]", null, namespacePrefixResolver, false);
366         assertEquals(2, answer.size());
367         
368         answer = searcher.selectNodes(rootNodeRef, "//*[contains(lower-case('MONKEY'))]", null, namespacePrefixResolver, false);
369         assertEquals(2, answer.size());
370
371         // select the monkey node in the second level
372
QueryParameterDefinition[] paramDefs = new QueryParameterDefinition[2];
373         paramDefs[0] = new QueryParameterDefImpl(
374                 QName.createQName("test:animal", namespacePrefixResolver),
375                 dictionaryService.getDataType(DataTypeDefinition.TEXT),
376                 true,
377                 "monkey%");
378         paramDefs[1] = new QueryParameterDefImpl(
379                 QName.createQName("test:type", namespacePrefixResolver),
380                 dictionaryService.getDataType(DataTypeDefinition.TEXT),
381                 true,
382                 BaseNodeServiceTest.TYPE_QNAME_TEST_CONTENT.toString());
383         answer = searcher.selectNodes(
384                 rootNodeRef,
385                 "./*/*[like(@test:animal, $test:animal, false) or subtypeOf($test:type)]",
386                 paramDefs,
387                 namespacePrefixResolver,
388                 false);
389         assertEquals(1, answer.size());
390         
391         // select the monkey node again, but use the first level as the starting poing
392
NodeRef n1Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "root_p_n1")).getChildRef();
393         NodeRef n3Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "n1_p_n3")).getChildRef();
394         // first time go too deep
395
answer = searcher.selectNodes(
396                 n1Ref,
397                 "./*/*[like(@test:animal, $test:animal, false) or subtypeOf($test:type)]",
398                 paramDefs,
399                 namespacePrefixResolver,
400                 false);
401         assertEquals(0, answer.size());
402         // second time get it right
403
answer = searcher.selectNodes(
404                 n1Ref,
405                 "./*[like(@test:animal, $test:animal, false) or subtypeOf($test:type)]",
406                 paramDefs,
407                 namespacePrefixResolver,
408                 false);
409         assertEquals(1, answer.size());
410         assertFalse("Incorrect result: search root node pulled back", answer.contains(n1Ref));
411         assertTrue("Incorrect result: incorrect node retrieved", answer.contains(n3Ref));
412     }
413     
414     public void testJCRRoot() throws Exception JavaDoc
415     {
416         
417         BaseNodeServiceTest.buildNodeGraph(nodeService, rootNodeRef);
418         // commit the node graph
419
txn.commit();
420         
421         txn = transactionService.getUserTransaction();
422         txn.begin();
423         
424         NodeServiceXPath xpath;
425         List JavaDoc list;
426         
427         DynamicNamespacePrefixResolver namespacePrefixResolver = new DynamicNamespacePrefixResolver(null);
428         namespacePrefixResolver.registerNamespace("jcr", "http://www.jcp.org/jcr/1.0");
429         // create the document navigator
430
DocumentNavigator documentNavigator = new DocumentNavigator(
431                 dictionaryService,
432                 nodeService,
433                 searcher,
434                 namespacePrefixResolver,
435                 false, true);
436         
437         xpath = new NodeServiceXPath("/jcr:root", documentNavigator, null);
438         list = xpath.selectNodes(new ChildAssociationRef(null, null, null, rootNodeRef));
439         assertEquals(1, list.size());
440         
441         xpath = new NodeServiceXPath("/jcr:root/*", documentNavigator, null);
442         list = xpath.selectNodes(new ChildAssociationRef(null, null, null, rootNodeRef));
443         assertEquals(2, list.size());
444         
445         xpath = new NodeServiceXPath("/*/*", documentNavigator, null);
446         list = xpath.selectNodes(new ChildAssociationRef(null, null, null, rootNodeRef));
447         assertEquals(2, list.size());
448     }
449     
450     public void testBooleanFunctions() throws Exception JavaDoc
451     {
452         BaseNodeServiceTest.buildNodeGraph(nodeService, rootNodeRef);
453         // commit the node graph
454
txn.commit();
455         
456         txn = transactionService.getUserTransaction();
457         txn.begin();
458         
459         NodeServiceXPath xpath;
460         List JavaDoc list;
461         
462         DynamicNamespacePrefixResolver namespacePrefixResolver = new DynamicNamespacePrefixResolver(null);
463         namespacePrefixResolver.registerNamespace("jcr", "http://www.jcp.org/jcr/1.0");
464         // create the document navigator
465
DocumentNavigator documentNavigator = new DocumentNavigator(
466                 dictionaryService,
467                 nodeService,
468                 searcher,
469                 namespacePrefixResolver,
470                 false, true);
471         
472         xpath = new NodeServiceXPath("/jcr:root[true()]", documentNavigator, null);
473         list = xpath.selectNodes(new ChildAssociationRef(null, null, null, rootNodeRef));
474         assertEquals(1, list.size());
475         
476         xpath = new NodeServiceXPath("/jcr:root[false()]", documentNavigator, null);
477         list = xpath.selectNodes(new ChildAssociationRef(null, null, null, rootNodeRef));
478         assertEquals(0, list.size());
479         
480         xpath = new NodeServiceXPath("/jcr:root[not(true())]", documentNavigator, null);
481         list = xpath.selectNodes(new ChildAssociationRef(null, null, null, rootNodeRef));
482         assertEquals(0, list.size());
483         
484         xpath = new NodeServiceXPath("/jcr:root[not(false())]", documentNavigator, null);
485         list = xpath.selectNodes(new ChildAssociationRef(null, null, null, rootNodeRef));
486         assertEquals(1, list.size());
487     }
488     
489     public void testMutiValueProperties() throws Exception JavaDoc
490     {
491         BaseNodeServiceTest.buildNodeGraph(nodeService, rootNodeRef);
492         // commit the node graph
493
txn.commit();
494         
495         txn = transactionService.getUserTransaction();
496         txn.begin();
497         
498         NodeServiceXPath xpath;
499         List JavaDoc list;
500         
501         DynamicNamespacePrefixResolver namespacePrefixResolver = new DynamicNamespacePrefixResolver(null);
502         namespacePrefixResolver.registerNamespace("jcr", "http://www.jcp.org/jcr/1.0");
503         namespacePrefixResolver.registerNamespace(BaseNodeServiceTest.TEST_PREFIX, BaseNodeServiceTest.NAMESPACE);
504         // create the document navigator
505
DocumentNavigator documentNavigator = new DocumentNavigator(
506                 dictionaryService,
507                 nodeService,
508                 searcher,
509                 namespacePrefixResolver,
510                 false, true);
511         
512         xpath = new NodeServiceXPath("/jcr:root//*[@test:mvp = 'first']", documentNavigator, null);
513         list = xpath.selectNodes(new ChildAssociationRef(null, null, null, rootNodeRef));
514         assertEquals(1, list.size());
515         
516         xpath = new NodeServiceXPath("/jcr:root//*[@test:mvp = 'second']", documentNavigator, null);
517         list = xpath.selectNodes(new ChildAssociationRef(null, null, null, rootNodeRef));
518         assertEquals(1, list.size());
519         
520         xpath = new NodeServiceXPath("/jcr:root//*[@test:mvp = 'third']", documentNavigator, null);
521         list = xpath.selectNodes(new ChildAssociationRef(null, null, null, rootNodeRef));
522         assertEquals(1, list.size());
523         
524         xpath = new NodeServiceXPath("/jcr:root//*[@test:mvp != 'third']", documentNavigator, null);
525         list = xpath.selectNodes(new ChildAssociationRef(null, null, null, rootNodeRef));
526         assertEquals(1, list.size());
527         
528         xpath = new NodeServiceXPath("/jcr:root//*[@test:mvp < 'e']", documentNavigator, null);
529         list = xpath.selectNodes(new ChildAssociationRef(null, null, null, rootNodeRef));
530         assertEquals(0, list.size());
531         
532         xpath = new NodeServiceXPath("/jcr:root//*[@test:mvp > 'e']", documentNavigator, null);
533         list = xpath.selectNodes(new ChildAssociationRef(null, null, null, rootNodeRef));
534         assertEquals(0, list.size());
535         
536         xpath = new NodeServiceXPath("/jcr:root//*[@test:mvp < 'first']", documentNavigator, null);
537         list = xpath.selectNodes(new ChildAssociationRef(null, null, null, rootNodeRef));
538         assertEquals(0, list.size());
539         
540         xpath = new NodeServiceXPath("/jcr:root//*[@test:mvp <= 'first']", documentNavigator, null);
541         list = xpath.selectNodes(new ChildAssociationRef(null, null, null, rootNodeRef));
542         assertEquals(0, list.size());
543         
544         xpath = new NodeServiceXPath("/jcr:root//*[@test:mvp > 'third']", documentNavigator, null);
545         list = xpath.selectNodes(new ChildAssociationRef(null, null, null, rootNodeRef));
546         assertEquals(0, list.size());
547         
548         xpath = new NodeServiceXPath("/jcr:root//*[@test:mvp >= 'third']", documentNavigator, null);
549         list = xpath.selectNodes(new ChildAssociationRef(null, null, null, rootNodeRef));
550         assertEquals(0, list.size());
551         
552         xpath = new NodeServiceXPath("/jcr:root//*[@test:mvi < 1]", documentNavigator, null);
553         list = xpath.selectNodes(new ChildAssociationRef(null, null, null, rootNodeRef));
554         assertEquals(0, list.size());
555         
556         xpath = new NodeServiceXPath("/jcr:root//*[@test:mvi <= 1]", documentNavigator, null);
557         list = xpath.selectNodes(new ChildAssociationRef(null, null, null, rootNodeRef));
558         assertEquals(1, list.size());
559         
560         xpath = new NodeServiceXPath("/jcr:root//*[@test:mvi > 3]", documentNavigator, null);
561         list = xpath.selectNodes(new ChildAssociationRef(null, null, null, rootNodeRef));
562         assertEquals(0, list.size());
563         
564         xpath = new NodeServiceXPath("/jcr:root//*[@test:mvi >= 3]", documentNavigator, null);
565         list = xpath.selectNodes(new ChildAssociationRef(null, null, null, rootNodeRef));
566         assertEquals(1, list.size());
567     }
568     
569     public void testElementNodeTest() throws Exception JavaDoc
570     {
571         BaseNodeServiceTest.buildNodeGraph(nodeService, rootNodeRef);
572         // commit the node graph
573
txn.commit();
574         
575         txn = transactionService.getUserTransaction();
576         txn.begin();
577         
578         NodeServiceXPath xpath;
579         List JavaDoc list;
580         
581         DynamicNamespacePrefixResolver namespacePrefixResolver = new DynamicNamespacePrefixResolver(null);
582         namespacePrefixResolver.registerNamespace("jcr", "http://www.jcp.org/jcr/1.0");
583         namespacePrefixResolver.registerNamespace(BaseNodeServiceTest.TEST_PREFIX, BaseNodeServiceTest.NAMESPACE);
584         // create the document navigator
585
DocumentNavigator documentNavigator = new DocumentNavigator(
586                 dictionaryService,
587                 nodeService,
588                 searcher,
589                 namespacePrefixResolver,
590                 false, true);
591         
592         xpath = new NodeServiceXPath("//element(*, *)".replaceAll("element\\(\\s*(\\*|\\$?\\w*:\\w*)\\s*,\\s*(\\*|\\$?\\w*:\\w*)\\s*\\)", "$1[subtypeOf(\"$2\")]"), documentNavigator, null);
593         list = xpath.selectNodes(new ChildAssociationRef(null, null, null, rootNodeRef));
594         assertEquals(12, list.size());
595         
596         xpath = new NodeServiceXPath("//element(jcr:root, *)".replaceAll("element\\(\\s*(\\*|\\$?\\w*:\\w*)\\s*,\\s*(\\*|\\$?\\w*:\\w*)\\s*\\)", "$1[subtypeOf(\"$2\")]"), documentNavigator, null);
597         list = xpath.selectNodes(new ChildAssociationRef(null, null, null, rootNodeRef));
598         assertEquals(1, list.size());
599         
600         QueryParameterDefImpl paramDef;
601         
602         paramDef = new QueryParameterDefImpl(
603                 QName.createQName("test:type", namespacePrefixResolver),
604                 dictionaryService.getDataType(DataTypeDefinition.QNAME),
605                 true,
606                 BaseNodeServiceTest.TYPE_QNAME_TEST_CONTENT.toPrefixString(namespacePrefixResolver));
607         xpath = new NodeServiceXPath("//element(*, test:content)".replaceAll("element\\(\\s*(\\*|\\$?\\w*:\\w*)\\s*,\\s*(\\*|\\$?\\w*:\\w*)\\s*\\)", "$1[subtypeOf(\"$2\")]"), documentNavigator, new QueryParameterDefinition[]{paramDef});
608         list = xpath.selectNodes(new ChildAssociationRef(null, null, null, rootNodeRef));
609         assertEquals(2, list.size());
610         
611         paramDef = new QueryParameterDefImpl(
612                 QName.createQName("test:type", namespacePrefixResolver),
613                 dictionaryService.getDataType(DataTypeDefinition.QNAME),
614                 true,
615                 BaseNodeServiceTest.TYPE_QNAME_TEST_CONTENT.toPrefixString(namespacePrefixResolver));
616         xpath = new NodeServiceXPath("//element(test:n6_p_n8, test:content)".replaceAll("element\\(\\s*(\\*|\\$?\\w*:\\w*)\\s*,\\s*(\\*|\\$?\\w*:\\w*)\\s*\\)", "$1[subtypeOf(\"$2\")]"), documentNavigator, new QueryParameterDefinition[]{paramDef});
617         list = xpath.selectNodes(new ChildAssociationRef(null, null, null, rootNodeRef));
618         assertEquals(1, list.size());
619         
620     }
621     
622     public void testJCRLike() throws Exception JavaDoc
623     {
624         BaseNodeServiceTest.buildNodeGraph(nodeService, rootNodeRef);
625         // commit the node graph
626
txn.commit();
627         
628         txn = transactionService.getUserTransaction();
629         txn.begin();
630         
631         DynamicNamespacePrefixResolver namespacePrefixResolver = new DynamicNamespacePrefixResolver(null);
632         namespacePrefixResolver.registerNamespace("jcr", "http://www.jcp.org/jcr/1.0");
633         namespacePrefixResolver.registerNamespace(BaseNodeServiceTest.TEST_PREFIX, BaseNodeServiceTest.NAMESPACE);
634         // create the document navigator
635
// DocumentNavigator documentNavigator = new DocumentNavigator(
636
// dictionaryService,
637
// nodeService,
638
// searcher,
639
// namespacePrefixResolver,
640
// false, true);
641

642         
643         List JavaDoc<NodeRef> answer = searcher.selectNodes(
644                 rootNodeRef,
645                 "//*[jcr:like(@test:animal, 'm__k%')]",
646                 null,
647                 namespacePrefixResolver, false);
648         assertEquals(1, answer.size());
649     }
650     
651     public void testJCRScore() throws Exception JavaDoc
652     {
653         BaseNodeServiceTest.buildNodeGraph(nodeService, rootNodeRef);
654         // commit the node graph
655
txn.commit();
656         
657         txn = transactionService.getUserTransaction();
658         txn.begin();
659         
660         DynamicNamespacePrefixResolver namespacePrefixResolver = new DynamicNamespacePrefixResolver(null);
661         namespacePrefixResolver.registerNamespace("jcr", "http://www.jcp.org/jcr/1.0");
662         namespacePrefixResolver.registerNamespace(BaseNodeServiceTest.TEST_PREFIX, BaseNodeServiceTest.NAMESPACE);
663         // create the document navigator
664
// DocumentNavigator documentNavigator = new DocumentNavigator(
665
// dictionaryService,
666
// nodeService,
667
// searcher,
668
// namespacePrefixResolver,
669
// false, true);
670

671         List JavaDoc<NodeRef> answer;
672         
673         answer = searcher.selectNodes(
674                 rootNodeRef,
675                 "//.",
676                 null,
677                 namespacePrefixResolver, false);
678         assertEquals(9, answer.size());
679         
680         answer = searcher.selectNodes(
681                 rootNodeRef,
682                 "//.[jcr:score() = 1.0]",
683                 null,
684                 namespacePrefixResolver, false);
685         assertEquals(9, answer.size());
686     }
687     
688     public void testJCRContains() throws Exception JavaDoc
689     {
690         BaseNodeServiceTest.buildNodeGraph(nodeService, rootNodeRef);
691         // commit the node graph
692
txn.commit();
693         
694         txn = transactionService.getUserTransaction();
695         txn.begin();
696         
697         
698         DynamicNamespacePrefixResolver namespacePrefixResolver = new DynamicNamespacePrefixResolver(null);
699         namespacePrefixResolver.registerNamespace("jcr", "http://www.jcp.org/jcr/1.0");
700         namespacePrefixResolver.registerNamespace(BaseNodeServiceTest.TEST_PREFIX, BaseNodeServiceTest.NAMESPACE);
701         // create the document navigator
702
// DocumentNavigator documentNavigator = new DocumentNavigator(
703
// dictionaryService,
704
// nodeService,
705
// searcher,
706
// namespacePrefixResolver,
707
// false, true);
708

709         List JavaDoc<NodeRef> answer;
710         
711         
712         answer = searcher.selectNodes(
713                 rootNodeRef,
714                 "//*[jcr:contains(@test:text1, 'bun')]",
715                 null,
716                 namespacePrefixResolver, false);
717         assertEquals(1, answer.size());
718         
719         answer = searcher.selectNodes(
720                 rootNodeRef,
721                 "//*[jcr:contains(@test:text1, 'cake')]",
722                 null,
723                 namespacePrefixResolver, false);
724         assertEquals(0, answer.size());
725        
726         answer = searcher.selectNodes(
727                 rootNodeRef,
728                 "//*[jcr:contains(@test:text1, 'biscuit')]",
729                 null,
730                 namespacePrefixResolver, false);
731         assertEquals(0, answer.size());
732         
733         answer = searcher.selectNodes(
734                 rootNodeRef,
735                 "//*[jcr:contains(@test:text1, 'bun cake')]",
736                 null,
737                 namespacePrefixResolver, false);
738         assertEquals(0, answer.size());
739         
740         answer = searcher.selectNodes(
741                 rootNodeRef,
742                 "//*[jcr:contains(@test:text1, 'cake biscuit')]",
743                 null,
744                 namespacePrefixResolver, false);
745         assertEquals(0, answer.size());
746         
747         answer = searcher.selectNodes(
748                 rootNodeRef,
749                 "//*[jcr:contains(@test:text1, 'bun biscuit')]",
750                 null,
751                 namespacePrefixResolver, false);
752         assertEquals(0, answer.size());
753         
754         answer = searcher.selectNodes(
755                 rootNodeRef,
756                 "//*[jcr:contains(@test:text1, 'bun cake biscuit')]",
757                 null,
758                 namespacePrefixResolver, false);
759         assertEquals(0, answer.size());
760         
761         
762         
763         
764         
765         answer = searcher.selectNodes(
766                 rootNodeRef,
767                 "//*[jcr:contains(@test:text2, 'bun')]",
768                 null,
769                 namespacePrefixResolver, false);
770         assertEquals(0, answer.size());
771         
772         answer = searcher.selectNodes(
773                 rootNodeRef,
774                 "//*[jcr:contains(@test:text2, 'cake')]",
775                 null,
776                 namespacePrefixResolver, false);
777         assertEquals(1, answer.size());
778        
779         answer = searcher.selectNodes(
780                 rootNodeRef,
781                 "//*[jcr:contains(@test:text2, 'biscuit')]",
782                 null,
783                 namespacePrefixResolver, false);
784         assertEquals(0, answer.size());
785         
786         answer = searcher.selectNodes(
787                 rootNodeRef,
788                 "//*[jcr:contains(@test:text2, 'bun cake')]",
789                 null,
790                 namespacePrefixResolver, false);
791         assertEquals(0, answer.size());
792         
793         answer = searcher.selectNodes(
794                 rootNodeRef,
795                 "//*[jcr:contains(@test:text2, 'cake biscuit')]",
796                 null,
797                 namespacePrefixResolver, false);
798         assertEquals(0, answer.size());
799         
800         answer = searcher.selectNodes(
801                 rootNodeRef,
802                 "//*[jcr:contains(@test:text2, 'bun biscuit')]",
803                 null,
804                 namespacePrefixResolver, false);
805         assertEquals(0, answer.size());
806         
807         answer = searcher.selectNodes(
808                 rootNodeRef,
809                 "//*[jcr:contains(@test:text2, 'bun cake biscuit')]",
810                 null,
811                 namespacePrefixResolver, false);
812         assertEquals(0, answer.size());
813         
814         
815         
816         
817         
818         
819         
820         
821         
822         answer = searcher.selectNodes(
823                 rootNodeRef,
824                 "//*[jcr:contains(@test:text3, 'bun')]",
825                 null,
826                 namespacePrefixResolver, false);
827         assertEquals(0, answer.size());
828         
829         answer = searcher.selectNodes(
830                 rootNodeRef,
831                 "//*[jcr:contains(@test:text3, 'cake')]",
832                 null,
833                 namespacePrefixResolver, false);
834         assertEquals(0, answer.size());
835        
836         answer = searcher.selectNodes(
837                 rootNodeRef,
838                 "//*[jcr:contains(@test:text3, 'biscuit')]",
839                 null,
840                 namespacePrefixResolver, false);
841         assertEquals(1, answer.size());
842         
843         answer = searcher.selectNodes(
844                 rootNodeRef,
845                 "//*[jcr:contains(@test:text3, 'bun cake')]",
846                 null,
847                 namespacePrefixResolver, false);
848         assertEquals(0, answer.size());
849         
850         answer = searcher.selectNodes(
851                 rootNodeRef,
852                 "//*[jcr:contains(@test:text3, 'cake biscuit')]",
853                 null,
854                 namespacePrefixResolver, false);
855         assertEquals(0, answer.size());
856         
857         answer = searcher.selectNodes(
858                 rootNodeRef,
859                 "//*[jcr:contains(@test:text2, 'bun biscuit')]",
860                 null,
861                 namespacePrefixResolver, false);
862         assertEquals(0, answer.size());
863         
864         answer = searcher.selectNodes(
865                 rootNodeRef,
866                 "//*[jcr:contains(@test:text2, 'bun cake biscuit')]",
867                 null,
868                 namespacePrefixResolver, false);
869         assertEquals(0, answer.size());
870         
871         
872         
873         
874         
875         answer = searcher.selectNodes(
876                 rootNodeRef,
877                 "//*[jcr:contains(@test:text12, 'bun')]",
878                 null,
879                 namespacePrefixResolver, false);
880         assertEquals(1, answer.size());
881         
882         answer = searcher.selectNodes(
883                 rootNodeRef,
884                 "//*[jcr:contains(@test:text12, 'cake')]",
885                 null,
886                 namespacePrefixResolver, false);
887         assertEquals(1, answer.size());
888        
889         answer = searcher.selectNodes(
890                 rootNodeRef,
891                 "//*[jcr:contains(@test:text12, 'biscuit')]",
892                 null,
893                 namespacePrefixResolver, false);
894         assertEquals(0, answer.size());
895         
896         answer = searcher.selectNodes(
897                 rootNodeRef,
898                 "//*[jcr:contains(@test:text12, 'bun cake')]",
899                 null,
900                 namespacePrefixResolver, false);
901         assertEquals(1, answer.size());
902         
903         answer = searcher.selectNodes(
904                 rootNodeRef,
905                 "//*[jcr:contains(@test:text12, 'cake biscuit')]",
906                 null,
907                 namespacePrefixResolver, false);
908         assertEquals(0, answer.size());
909         
910         answer = searcher.selectNodes(
911                 rootNodeRef,
912                 "//*[jcr:contains(@test:text12, 'bun biscuit')]",
913                 null,
914                 namespacePrefixResolver, false);
915         assertEquals(0, answer.size());
916         
917         answer = searcher.selectNodes(
918                 rootNodeRef,
919                 "//*[jcr:contains(@test:text12, 'bun cake biscuit')]",
920                 null,
921                 namespacePrefixResolver, false);
922         assertEquals(0, answer.size());
923         
924         
925         
926         
927         
928         answer = searcher.selectNodes(
929                 rootNodeRef,
930                 "//*[jcr:contains(@test:text13, 'bun')]",
931                 null,
932                 namespacePrefixResolver, false);
933         assertEquals(1, answer.size());
934         
935         answer = searcher.selectNodes(
936                 rootNodeRef,
937                 "//*[jcr:contains(@test:text13, 'cake')]",
938                 null,
939                 namespacePrefixResolver, false);
940         assertEquals(0, answer.size());
941        
942         answer = searcher.selectNodes(
943                 rootNodeRef,
944                 "//*[jcr:contains(@test:text13, 'biscuit')]",
945                 null,
946                 namespacePrefixResolver, false);
947         assertEquals(1, answer.size());
948         
949         answer = searcher.selectNodes(
950                 rootNodeRef,
951                 "//*[jcr:contains(@test:text13, 'bun cake')]",
952                 null,
953                 namespacePrefixResolver, false);
954         assertEquals(0, answer.size());
955         
956         answer = searcher.selectNodes(
957                 rootNodeRef,
958                 "//*[jcr:contains(@test:text13, 'cake biscuit')]",
959                 null,
960                 namespacePrefixResolver, false);
961         assertEquals(0, answer.size());
962         
963         answer = searcher.selectNodes(
964                 rootNodeRef,
965                 "//*[jcr:contains(@test:text13, 'bun biscuit')]",
966                 null,
967                 namespacePrefixResolver, false);
968         assertEquals(1, answer.size());
969         
970         answer = searcher.selectNodes(
971                 rootNodeRef,
972                 "//*[jcr:contains(@test:text13, 'bun cake biscuit')]",
973                 null,
974                 namespacePrefixResolver, false);
975         assertEquals(0, answer.size());
976         
977         
978         
979         
980         answer = searcher.selectNodes(
981                 rootNodeRef,
982                 "//*[jcr:contains(@test:text23, 'bun')]",
983                 null,
984                 namespacePrefixResolver, false);
985         assertEquals(0, answer.size());
986         
987         answer = searcher.selectNodes(
988                 rootNodeRef,
989                 "//*[jcr:contains(@test:text23, 'cake')]",
990                 null,
991                 namespacePrefixResolver, false);
992         assertEquals(1, answer.size());
993        
994         answer = searcher.selectNodes(
995                 rootNodeRef,
996                 "//*[jcr:contains(@test:text23, 'biscuit')]",
997                 null,
998                 namespacePrefixResolver, false);
999         assertEquals(1, answer.size());
1000        
1001        answer = searcher.selectNodes(
1002                rootNodeRef,
1003                "//*[jcr:contains(@test:text23, 'bun cake')]",
1004                null,
1005                namespacePrefixResolver, false);
1006        assertEquals(0, answer.size());
1007        
1008        answer = searcher.selectNodes(
1009                rootNodeRef,
1010                "//*[jcr:contains(@test:text23, 'cake biscuit')]",
1011                null,
1012                namespacePrefixResolver, false);
1013        assertEquals(1, answer.size());
1014        
1015        answer = searcher.selectNodes(
1016                rootNodeRef,
1017                "//*[jcr:contains(@test:text23, 'bun biscuit')]",
1018                null,
1019                namespacePrefixResolver, false);
1020        assertEquals(0, answer.size());
1021        
1022        answer = searcher.selectNodes(
1023                rootNodeRef,
1024                "//*[jcr:contains(@test:text23, 'bun cake biscuit')]",
1025                null,
1026                namespacePrefixResolver, false);
1027        assertEquals(0, answer.size());
1028        
1029        
1030        
1031        
1032        
1033        
1034        
1035        
1036        answer = searcher.selectNodes(
1037                rootNodeRef,
1038                "//*[jcr:contains(@test:text123, 'bun')]",
1039                null,
1040                namespacePrefixResolver, false);
1041        assertEquals(1, answer.size());
1042        
1043        answer = searcher.selectNodes(
1044                rootNodeRef,
1045                "//*[jcr:contains(@test:text123, 'cake')]",
1046                null,
1047                namespacePrefixResolver, false);
1048        assertEquals(1, answer.size());
1049       
1050        answer = searcher.selectNodes(
1051                rootNodeRef,
1052                "//*[jcr:contains(@test:text123, 'biscuit')]",
1053                null,
1054                namespacePrefixResolver, false);
1055        assertEquals(1, answer.size());
1056        
1057        answer = searcher.selectNodes(
1058                rootNodeRef,
1059                "//*[jcr:contains(@test:text123, 'bun cake')]",
1060                null,
1061                namespacePrefixResolver, false);
1062        assertEquals(1, answer.size());
1063        
1064        answer = searcher.selectNodes(
1065                rootNodeRef,
1066                "//*[jcr:contains(@test:text123, 'cake biscuit')]",
1067                null,
1068                namespacePrefixResolver, false);
1069        assertEquals(1, answer.size());
1070        
1071        answer = searcher.selectNodes(
1072                rootNodeRef,
1073                "//*[jcr:contains(@test:text123, 'bun biscuit')]",
1074                null,
1075                namespacePrefixResolver, false);
1076        assertEquals(1, answer.size());
1077        
1078        answer = searcher.selectNodes(
1079                rootNodeRef,
1080                "//*[jcr:contains(@test:text123, 'bun cake biscuit')]",
1081                null,
1082                namespacePrefixResolver, false);
1083        assertEquals(1, answer.size());
1084        
1085        
1086        
1087        answer = searcher.selectNodes(
1088                rootNodeRef,
1089                "//*[jcr:contains(., 'bun')]",
1090                null,
1091                namespacePrefixResolver, false);
1092        assertEquals(1, answer.size());
1093        
1094        answer = searcher.selectNodes(
1095                rootNodeRef,
1096                "//*[jcr:contains(., 'cake')]",
1097                null,
1098                namespacePrefixResolver, false);
1099        assertEquals(1, answer.size());
1100       
1101        answer = searcher.selectNodes(
1102                rootNodeRef,
1103                "//*[jcr:contains(., 'biscuit')]",
1104                null,
1105                namespacePrefixResolver, false);
1106        assertEquals(1, answer.size());
1107        
1108        answer = searcher.selectNodes(
1109                rootNodeRef,
1110                "//*[jcr:contains(., 'bun cake')]",
1111                null,
1112                namespacePrefixResolver, false);
1113        assertEquals(1, answer.size());
1114        
1115        answer = searcher.selectNodes(
1116                rootNodeRef,
1117                "//*[jcr:contains(., 'cake biscuit')]",
1118                null,
1119                namespacePrefixResolver, false);
1120        assertEquals(1, answer.size());
1121        
1122        answer = searcher.selectNodes(
1123                rootNodeRef,
1124                "//*[jcr:contains(., 'bun biscuit')]",
1125                null,
1126                namespacePrefixResolver, false);
1127        assertEquals(1, answer.size());
1128        
1129        answer = searcher.selectNodes(
1130                rootNodeRef,
1131                "//*[jcr:contains(., 'bun cake biscuit')]",
1132                null,
1133                namespacePrefixResolver, false);
1134        assertEquals(1, answer.size());
1135        
1136    }
1137}
1138
Popular Tags