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.eg;
18:
19: import javax.naming.Context;
20: import javax.naming.InitialContext;
21:
22: import junit.framework.TestCase;
23: import org.compass.core.Compass;
24: import org.compass.core.config.CompassConfiguration;
25: import org.compass.gps.impl.DualCompassGps;
26: import org.objectweb.jotm.Jotm;
27:
28: public abstract class AbstractHibernateGpsDeviceTests extends TestCase {
29:
30: private Jotm jotm;
31:
32: protected Compass mirrorCompass;
33:
34: protected Compass indexCompass;
35:
36: protected DualCompassGps compassGps;
37:
38: protected void setUp() throws Exception {
39: super .setUp();
40:
41: System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
42: "com.sun.jndi.rmi.registry.RegistryContextFactory");
43: System
44: .setProperty(Context.PROVIDER_URL,
45: "rmi://localhost:1099");
46:
47: try {
48: java.rmi.registry.LocateRegistry.createRegistry(1099);
49: } catch (Exception e) {
50:
51: }
52:
53: jotm = new Jotm(true, true);
54: Context ctx = new InitialContext();
55: ctx.rebind("java:comp/UserTransaction", jotm
56: .getUserTransaction());
57:
58: CompassConfiguration cpConf = new CompassConfiguration()
59: .configure("/org/compass/gps/device/hibernate/eg/compass-mirror.cfg.xml");
60: mirrorCompass = cpConf.buildCompass();
61: mirrorCompass.getSearchEngineIndexManager().deleteIndex();
62: mirrorCompass.getSearchEngineIndexManager().verifyIndex();
63:
64: CompassConfiguration cpBatchConf = new CompassConfiguration()
65: .configure("/org/compass/gps/device/hibernate/eg/compass-index.cfg.xml");
66: indexCompass = cpBatchConf.buildCompass();
67: indexCompass.getSearchEngineIndexManager().deleteIndex();
68: indexCompass.getSearchEngineIndexManager().verifyIndex();
69:
70: compassGps = new DualCompassGps(indexCompass, mirrorCompass);
71: }
72:
73: protected void tearDown() throws Exception {
74: jotm.stop();
75: mirrorCompass.close();
76: indexCompass.close();
77: super.tearDown();
78: }
79:
80: }
|