01: package org.compass.core.test.dynamic.el;
02:
03: import java.util.Calendar;
04:
05: import org.compass.core.CompassHits;
06: import org.compass.core.CompassSession;
07: import org.compass.core.CompassTransaction;
08: import org.compass.core.Resource;
09: import org.compass.core.test.AbstractTestCase;
10:
11: /**
12: * @author kimchy
13: */
14: public class JakartaElDynamicTests extends AbstractTestCase {
15:
16: protected String[] getMappings() {
17: return new String[] { "dynamic/el/A.cpm.xml" };
18: }
19:
20: public void testSimpleExpression() throws Exception {
21: CompassSession session = openSession();
22: CompassTransaction tr = session.beginTransaction();
23:
24: A a = new A();
25: a.setId(new Long(1));
26: a.setValue("value");
27: a.setValue2("value2");
28: session.save("a1", a);
29:
30: Resource resource = session.loadResource("a1", new Long(1));
31: assertEquals("valuevalue2", resource.getValue("test"));
32:
33: CompassHits hits = session.find("valuevalue2");
34: assertEquals(1, hits.length());
35:
36: tr.commit();
37: session.close();
38: }
39:
40: public void testExpressionWithFormat() throws Exception {
41: CompassSession session = openSession();
42: CompassTransaction tr = session.beginTransaction();
43:
44: A a = new A();
45: a.setId(new Long(1));
46: Calendar cal = Calendar.getInstance();
47: cal.set(1977, 4, 1);
48: a.setDate(cal.getTime());
49: session.save("a2", a);
50:
51: Resource resource = session.loadResource("a2", new Long(1));
52: assertEquals("1977", resource.getValue("test"));
53:
54: tr.commit();
55: session.close();
56: }
57: }
|