01: /******************************************************************************
02: * JBoss, a division of Red Hat *
03: * Copyright 2006, Red Hat Middleware, LLC, and individual *
04: * contributors as indicated by the @authors tag. See the *
05: * copyright.txt in the distribution for a full listing of *
06: * individual contributors. *
07: * *
08: * This is free software; you can redistribute it and/or modify it *
09: * under the terms of the GNU Lesser General Public License as *
10: * published by the Free Software Foundation; either version 2.1 of *
11: * the License, or (at your option) any later version. *
12: * *
13: * This software is distributed in the hope that it will be useful, *
14: * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16: * Lesser General Public License for more details. *
17: * *
18: * You should have received a copy of the GNU Lesser General Public *
19: * License along with this software; if not, write to the Free *
20: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
21: * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
22: ******************************************************************************/package org.jboss.portal.search.test;
23:
24: import junit.framework.TestCase;
25: import org.jboss.portal.search.FederatedQuery;
26: import org.jboss.portal.search.QueryConversionException;
27: import org.jboss.portal.search.QueryConverter;
28: import org.jboss.portal.search.impl.jcr.JCRQuery;
29: import org.jboss.portal.search.impl.jcr.JCRQueryConverter;
30:
31: /**
32: * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
33: * @version $Revision: 8784 $
34: */
35: public class ConverterTest extends TestCase {
36: /*
37: public void testOptionalKeyword()
38: {
39: Query query = QueryConverter.convert("test");
40: KeywordQueryTerm term = (KeywordQueryTerm)query.getOptionalTerms().get(0);
41: assertEquals("test", term.getKeyWord());
42: }
43: */
44:
45: public void testJCRConverter() {
46:
47: FederatedQuery fQuery = new FederatedQuery("bar");
48:
49: QueryConverter converter = new JCRQueryConverter();
50: try {
51: JCRQuery xpath = (JCRQuery) converter.convert(fQuery);
52: assertEquals("//*[jcr:contains(., 'bar')]", xpath
53: .toString());
54: } catch (QueryConversionException e) {
55: e.printStackTrace();
56: }
57: }
58:
59: public void testJCRConverterMultipleTerms() {
60: FederatedQuery query = new FederatedQuery("foo bar");
61:
62: QueryConverter converter = new JCRQueryConverter();
63: try {
64: JCRQuery xpath = (JCRQuery) converter.convert(query);
65: assertEquals(
66: "//*[jcr:contains(., 'foo'), jcr:contains(., 'bar')]",
67: xpath.toString());
68: } catch (QueryConversionException e) {
69: e.printStackTrace();
70: }
71: }
72: }
|