01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: */
18: package org.apache.lenya.cms.lucene;
19:
20: import org.apache.lenya.ac.impl.AbstractAccessControlTest;
21: import org.apache.lenya.cms.publication.Document;
22: import org.apache.lenya.cms.publication.DocumentManager;
23: import org.apache.lenya.cms.publication.Publication;
24: import org.apache.lenya.cms.repository.Session;
25: import org.apache.lenya.cms.site.SiteNode;
26: import org.apache.lenya.cms.site.SiteStructure;
27:
28: public class IndexUpdaterTest extends AbstractAccessControlTest {
29:
30: public void testIndexUpdater() throws Exception {
31: Session session = login("lenya");
32:
33: Publication pub = getPublication(session, "test");
34: SiteStructure site = pub.getArea("authoring").getSite();
35:
36: SiteNode sourceNode = site.getNode("/tutorial");
37: SiteNode destNode = site.getNode("/concepts");
38:
39: Document sourceDoc = sourceNode.getLink(
40: sourceNode.getLanguages()[0]).getDocument();
41: Document destDoc = destNode.getLink(destNode.getLanguages()[0])
42: .getDocument();
43:
44: sourceDoc.getRepositoryNode().lock();
45:
46: DocumentManager docMgr = null;
47: try {
48: docMgr = (DocumentManager) getManager().lookup(
49: DocumentManager.ROLE);
50: docMgr.copy(sourceDoc, destDoc.getLocator());
51: } finally {
52: if (docMgr != null) {
53: getManager().release(docMgr);
54: }
55: }
56: checkSearchResults(pub, Publication.AUTHORING_AREA);
57:
58: }
59:
60: protected void checkSearchResults(Publication pub, String area)
61: throws Exception {
62: // String searchUri = "cocoon://modules/lucene/search.xml?queryString=tutorial";
63: // String searchUri = "cocoon://modules/lucene/search/" + pub.getId() + "/" + area + ".xml";
64: // org.w3c.dom.Document searchResult = SourceUtil.readDOM(searchUri, getManager());
65:
66: // DocumentHelper.writeDocument(searchResult, System.out);
67: }
68: }
|