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.property.exclude;
18:
19: import org.compass.core.CompassHits;
20: import org.compass.core.CompassSession;
21: import org.compass.core.CompassTransaction;
22: import org.compass.core.test.AbstractTestCase;
23:
24: /**
25: * @author kimchy
26: */
27: public class ExcludeTests extends AbstractTestCase {
28:
29: protected String[] getMappings() {
30: return new String[] { "property/exclude/mapping.cpm.xml" };
31: }
32:
33: public void testExcludeNoPropertyMapping() {
34: CompassSession session = openSession();
35: CompassTransaction tr = session.beginTransaction();
36:
37: A a = new A("1", "value1", "value2");
38: session.save("a1", a);
39:
40: a = (A) session.load("a1", "1");
41: assertEquals("1", a.id);
42: // value 1 is null since we have no property mapping for it
43: assertNull(a.value1);
44: assertEquals("value2", a.value2);
45:
46: // since value 1 has no property mapping, it should not be
47: // found in all
48: CompassHits hits = session.find("value1");
49: assertEquals(0, hits.length());
50:
51: hits = session.find("value2");
52: assertEquals(1, hits.length());
53:
54: tr.commit();
55: session.close();
56: }
57:
58: public void testExcludePropertyMappingNoMetaData() {
59: CompassSession session = openSession();
60: CompassTransaction tr = session.beginTransaction();
61:
62: A a = new A("1", "value1", "value2");
63: session.save("a2", a);
64:
65: a = (A) session.load("a2", "1");
66: assertEquals("1", a.id);
67: assertEquals("value1", a.value1);
68: assertEquals("value2", a.value2);
69:
70: // since value 1 has no property mapping, it should not be
71: // found in all
72: CompassHits hits = session.find("value1");
73: assertEquals(0, hits.length());
74:
75: hits = session.find("value2");
76: assertEquals(1, hits.length());
77:
78: tr.commit();
79: session.close();
80: }
81: }
|