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.test.singleindex;
18:
19: import org.apache.lucene.index.LuceneSubIndexInfo;
20: import org.compass.core.CompassSession;
21: import org.compass.core.CompassTransaction;
22: import org.compass.core.test.AbstractTestCase;
23:
24: public class SingleIndexTests extends AbstractTestCase {
25:
26: protected String[] getMappings() {
27: return new String[] { "singleindex/singleindex.cpm.xml" };
28: }
29:
30: public void testValidLoad() throws Exception {
31: CompassSession session = openSession();
32: CompassTransaction transaction = session.beginTransaction();
33:
34: Long id = new Long(1);
35: A a = new A();
36: a.setId(id);
37: a.setValue("value");
38: session.save(a);
39:
40: B b = new B();
41: b.setId(id);
42: b.setValue("value");
43: session.save(b);
44:
45: session.load(B.class, id);
46: session.load(A.class, id);
47:
48: transaction.commit();
49:
50: transaction = session.beginTransaction();
51: session.load(B.class, id);
52: session.load(A.class, id);
53: transaction.commit();
54:
55: LuceneSubIndexInfo indexInfo = LuceneSubIndexInfo.getIndexInfo(
56: "index", session);
57: assertNotNull(indexInfo);
58: try {
59: indexInfo = LuceneSubIndexInfo.getIndexInfo("a", session);
60: if (indexInfo != null) {
61: fail("a subindex should not exists");
62: }
63: } catch (Exception e) {
64: // all is well
65: }
66: try {
67: indexInfo = LuceneSubIndexInfo.getIndexInfo("b", session);
68: if (indexInfo != null) {
69: fail("b subindex should not exists");
70: }
71: } catch (Exception e) {
72: // all is well
73: }
74: session.close();
75: }
76: }
|