01: package org.compass.core.test.localcache;
02:
03: import org.compass.core.CompassHits;
04: import org.compass.core.CompassSession;
05: import org.compass.core.CompassTransaction;
06: import org.compass.core.config.CompassSettings;
07: import org.compass.core.lucene.LuceneEnvironment;
08: import org.compass.core.test.AbstractTestCase;
09:
10: /**
11: * @author kimchy
12: */
13: public class LocalCacheSimpleTests extends AbstractTestCase {
14:
15: protected String[] getMappings() {
16: return new String[] { "localcache/A.cpm.xml" };
17: }
18:
19: protected void addSettings(CompassSettings settings) {
20: settings
21: .setGroupSettings(
22: LuceneEnvironment.LocalCache.PREFIX,
23: "a",
24: new String[] { LuceneEnvironment.LocalCache.CONNECTION },
25: new String[] { "ram://" });
26: }
27:
28: public void testSimpleLocalCache() {
29: CompassSession session = openSession();
30: CompassTransaction tr = session.beginTransaction();
31:
32: A a = new A();
33: a.id = new Long(1);
34: a.value = "test";
35: session.save(a);
36:
37: tr.commit();
38: session.close();
39:
40: session = openSession();
41: tr = session.beginTransaction();
42:
43: CompassHits hits = session.queryBuilder().matchAll().hits();
44: assertEquals(1, hits.length());
45:
46: tr.commit();
47: session.close();
48: }
49: }
|