KickJava   Java API By Example, From Geeks To Geeks.

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


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 junit.framework.TestCase;
20
21 import org.alfresco.service.cmr.dictionary.DictionaryService;
22 import org.alfresco.service.namespace.NamespaceService;
23 import org.alfresco.service.namespace.QName;
24 import org.alfresco.util.ApplicationContextHelper;
25 import org.springframework.context.ApplicationContext;
26
27 public class QueryRegisterComponentTest extends TestCase
28 {
29     static ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
30
31     private DictionaryService dictionaryService;
32     private NamespaceService namespaceService;
33
34     public QueryRegisterComponentTest()
35     {
36         super();
37     }
38     
39     public QueryRegisterComponentTest(String JavaDoc arg0)
40     {
41         super(arg0);
42     }
43     
44     public void setUp()
45     {
46       
47         dictionaryService = (DictionaryService) ctx.getBean("dictionaryService");
48         namespaceService = (NamespaceService) ctx.getBean("namespaceService");
49        
50     }
51
52     public void testLoad()
53     {
54         QueryRegisterComponentImpl qr = new QueryRegisterComponentImpl();
55         qr.setNamespaceService(namespaceService);
56         qr.setDictionaryService(dictionaryService);
57         qr.loadQueryCollection("testQueryRegister.xml");
58         
59         assertNotNull(qr.getQueryDefinition(QName.createQName("alf", "query1", namespaceService)));
60         assertEquals("lucene", qr.getQueryDefinition(QName.createQName("alf", "query1", namespaceService)).getLanguage());
61         assertEquals("http://www.trees.tulip/barking/woof", qr.getQueryDefinition(QName.createQName("alf", "query1", namespaceService)).getNamespacePrefixResolver().getNamespaceURI("tulip"));
62         assertEquals("+QNAME:$alf:query-parameter-name", qr.getQueryDefinition(QName.createQName("alf", "query1", namespaceService)).getQuery());
63         assertEquals(2, qr.getQueryDefinition(QName.createQName("alf", "query1", namespaceService)).getQueryParameterDefs().size());
64     }
65
66 }
67
Popular Tags