01: package org.compass.annotations.test.dynamic.jexl;
02:
03: import java.util.Calendar;
04:
05: import org.compass.annotations.test.AbstractAnnotationsTestCase;
06: import org.compass.core.CompassSession;
07: import org.compass.core.CompassTransaction;
08: import org.compass.core.Resource;
09: import org.compass.core.config.CompassConfiguration;
10:
11: /**
12: * @author kimchy
13: */
14: public class JexlDynamicTests extends AbstractAnnotationsTestCase {
15:
16: protected void addExtraConf(CompassConfiguration conf) {
17: conf.addClass(A.class);
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(1);
26: a.setValue("value");
27: a.setValue2("value2");
28: Calendar cal = Calendar.getInstance();
29: cal.set(1977, 4, 1);
30: a.setDate(cal.getTime());
31: session.save(a);
32:
33: Resource resource = session.loadResource(A.class, 1);
34: assertEquals("valuevalue2", resource.getValue("test"));
35: assertEquals("value", resource.getValue("test2"));
36: assertEquals("1977", resource.getValue("date"));
37:
38: tr.commit();
39: session.close();
40: }
41: }
|