KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > repo > node > index > FtsIndexRecoveryComponentTest


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.node.index;
18
19 import junit.framework.TestCase;
20
21 import org.alfresco.repo.search.Indexer;
22 import org.alfresco.repo.transaction.TransactionUtil;
23 import org.alfresco.repo.transaction.TransactionUtil.TransactionWork;
24 import org.alfresco.service.cmr.repository.NodeService;
25 import org.alfresco.service.transaction.TransactionService;
26 import org.alfresco.util.ApplicationContextHelper;
27 import org.springframework.context.ApplicationContext;
28
29 /**
30  * Checks that the FTS index recovery component is working
31  *
32  * @author Derek Hulley
33  */

34 public class FtsIndexRecoveryComponentTest extends TestCase
35 {
36     private static ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
37     
38     private IndexRecovery indexRecoverer;
39     private NodeService nodeService;
40     private TransactionService txnService;
41     private Indexer indexer;
42     
43     public void setUp() throws Exception JavaDoc
44     {
45         indexRecoverer = (IndexRecovery) ctx.getBean("indexRecoveryComponent");
46         txnService = (TransactionService) ctx.getBean("transactionComponent");
47         nodeService = (NodeService) ctx.getBean("nodeService");
48         indexer = (Indexer) ctx.getBean("indexerComponent");
49     }
50     
51     public void testReindexing() throws Exception JavaDoc
52     {
53         // performs a reindex
54
TransactionWork<Object JavaDoc> reindexWork = new TransactionWork<Object JavaDoc>()
55         {
56             public Object JavaDoc doWork()
57             {
58                 indexRecoverer.reindex();
59                 return null;
60             }
61         };
62         
63         // reindex
64
TransactionUtil.executeInNonPropagatingUserTransaction(txnService, reindexWork);
65     }
66 }
67
Popular Tags