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.core.engine;
18:
19: import org.compass.core.Compass;
20: import org.compass.core.config.RuntimeCompassSettings;
21: import org.compass.core.converter.DefaultConverterLookup;
22: import org.compass.core.engine.naming.StaticPropertyNamingStrategy;
23: import org.compass.core.executor.DefaultExecutorManager;
24: import org.compass.core.executor.ExecutorManager;
25: import org.compass.core.impl.DefaultCompass;
26: import org.compass.core.lucene.engine.LuceneSearchEngineFactory;
27: import org.compass.core.metadata.impl.DefaultCompassMetaData;
28:
29: /**
30: * @author kimchy
31: */
32: public abstract class AbstractSearchEngineTests extends
33: AbstractEngineTests {
34:
35: private SearchEngine searchEngine;
36:
37: private SearchEngineFactory searchEngineFactory;
38:
39: // we have it here for transactional settings
40: protected Compass compass;
41:
42: public SearchEngine getSearchEngine() {
43: return this .searchEngine;
44: }
45:
46: public SearchEngineFactory getSearchEngineFactory() {
47: return searchEngineFactory;
48: }
49:
50: protected void setUp() throws Exception {
51: super .setUp();
52: this .searchEngineFactory = createSearchEngineFactory();
53: this .compass = new DefaultCompass(getMapping(),
54: new DefaultConverterLookup(),
55: new DefaultCompassMetaData(),
56: new StaticPropertyNamingStrategy(), getSettings(),
57: (LuceneSearchEngineFactory) searchEngineFactory);
58: this .searchEngine = searchEngineFactory
59: .openSearchEngine(new RuntimeCompassSettings(compass
60: .getSettings()));
61: }
62:
63: protected void tearDown() throws Exception {
64: searchEngine.close();
65: compass.close();
66: searchEngineFactory.getIndexManager().deleteIndex();
67: super .tearDown();
68: }
69:
70: protected abstract SearchEngineFactory createSearchEngineFactory();
71:
72: protected ExecutorManager createExecutorManager() {
73: DefaultExecutorManager executorManager = new DefaultExecutorManager();
74: executorManager.configure(getSettings());
75: return executorManager;
76: }
77: }
|