01: /*
02: * Copyright 2004-2006 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.compass.gps.device.hibernate.simple;
18:
19: import java.io.IOException;
20:
21: import org.compass.core.CompassHits;
22: import org.compass.core.CompassSession;
23: import org.compass.core.CompassTransaction;
24: import org.compass.core.config.CompassConfiguration;
25: import org.compass.core.lucene.LuceneEnvironment;
26:
27: /**
28: * A test to verify that spell check works with Gps (Hibernate chosen here)
29: *
30: * @author kimchy
31: */
32: public class SpellCheckSimpleHibernateGpsDeviceTests extends
33: ScrollableSimpleHibernateGpsDeviceTests {
34:
35: protected void setUpCoreCompass(CompassConfiguration conf) {
36: super .setUpCoreCompass(conf);
37: conf.setSetting(LuceneEnvironment.SpellCheck.ENABLE, "true");
38: }
39:
40: protected void setUpCompass() throws IOException {
41: super .setUpCompass();
42: }
43:
44: protected void doTearDown() throws Exception {
45: super .doTearDown();
46: compass.getSpellCheckManager().deleteIndex();
47: }
48:
49: public void testSimpleSpellCheck() {
50: compassGps.index();
51:
52: CompassSession sess = compass.openSession();
53: CompassTransaction tr = sess.beginTransaction();
54:
55: CompassHits hits = sess.queryBuilder().queryString("valu")
56: .toQuery().hits();
57: assertEquals(0, hits.length());
58: assertNotNull(hits.getQuery());
59: assertFalse(hits.getQuery().isSuggested());
60: assertNotNull(hits.getSuggestedQuery());
61: assertTrue(hits.getSuggestedQuery().isSuggested());
62: assertEquals("value", hits.getSuggestedQuery().toString());
63:
64: tr.commit();
65: sess.close();
66: }
67: }
|