01: package net.sourceforge.jaxor.example.simple.tests;
02:
03: import net.sourceforge.jaxor.example.tests.TableTestCase;
04: import net.sourceforge.jaxor.example.simple.PrimitiveMetaRow;
05: import net.sourceforge.jaxor.example.simple.PrimitiveFinder;
06: import net.sourceforge.jaxor.example.simple.PrimitiveEntity;
07: import net.sourceforge.jaxor.MetaRow;
08:
09: /**
10: * Created By: Mike
11: * Date: Jan 21, 2004
12: * Time: 11:31:48 PM
13: *
14: * Last Checkin: $Author: mrettig $
15: * Date: $Date: 2004/02/13 03:27:57 $
16: * Revision: $Revision: 1.4 $
17: */
18: public class PrimitivesTest extends TableTestCase {
19:
20: protected MetaRow getRow() {
21: return new PrimitiveMetaRow();
22: }
23:
24: public void testInsertQueryAndUpdate() {
25: PrimitiveEntity prim = createEntity();
26:
27: PrimitiveEntity primNew = PrimitiveFinder.selectByPrimaryKey(1);
28: assertFalse("shouldn't get from cache", prim == primNew);
29: assertEquals(1, prim.getId());
30: assertTrue(prim.getBooleanField());
31: assertEquals(2, prim.getByteField());
32: assertEquals(3.00, prim.getDoubleField(), 0.00);
33: assertEquals(4, prim.getFloatField(), 0.00);
34: assertEquals(5, prim.getLongField());
35: assertEquals(6, prim.getShortField());
36: }
37:
38: private PrimitiveEntity createEntity() {
39: PrimitiveEntity prim = PrimitiveFinder.newInstance(1);
40: prim.setBooleanField(true);
41: prim.setByteField((byte) 2);
42: prim.setDoubleField(3.00);
43: prim.setFloatField(4);
44: prim.setLongField(5);
45: prim.setShortField((short) 6);
46: commit();
47: return prim;
48: }
49:
50: public void testAllQueries() {
51: PrimitiveEntity prim = createEntity();
52:
53: assertEquals(prim, PrimitiveFinder.selectByBooleanField(true));
54: assertEquals(prim, PrimitiveFinder.selectByByteField((byte) 2));
55: assertEquals(prim, PrimitiveFinder.selectByDoubleField(3.00));
56: assertEquals(prim, PrimitiveFinder.selectByFloatField(4));
57: assertEquals(prim, PrimitiveFinder.selectByLongField(5));
58: assertEquals(prim, PrimitiveFinder
59: .selectByShortField((short) 6));
60: }
61: }
|