01: /* Copyright (C) 2004 - 2007 db4objects Inc. http://www.db4o.com
02:
03: This file is part of the db4o open source object database.
04:
05: db4o is free software; you can redistribute it and/or modify it under
06: the terms of version 2 of the GNU General Public License as published
07: by the Free Software Foundation and as clarified by db4objects' GPL
08: interpretation policy, available at
09: http://www.db4o.com/about/company/legalpolicies/gplinterpretation/
10: Alternatively you can write to db4objects, Inc., 1900 S Norfolk Street,
11: Suite 350, San Mateo, CA 94403, USA.
12:
13: db4o is distributed in the hope that it will be useful, but WITHOUT ANY
14: WARRANTY; without even the implied warranty of MERCHANTABILITY or
15: FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16: for more details.
17:
18: You should have received a copy of the GNU General Public License along
19: with this program; if not, write to the Free Software Foundation, Inc.,
20: 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
21: package com.db4o.test.legacy.soda.wrapper.untyped;
22:
23: import java.util.*;
24:
25: import com.db4o.query.*;
26: import com.db4o.test.legacy.soda.*;
27:
28: public class STDateU implements STClass {
29:
30: public static transient SodaTest st;
31:
32: Object i_date;
33:
34: public STDateU() {
35: }
36:
37: private STDateU(Date a_date) {
38: i_date = a_date;
39: }
40:
41: public Object[] store() {
42: return new Object[] { new STDateU(null),
43: new STDateU(new Date(4000)),
44: new STDateU(new Date(5000)),
45: new STDateU(new Date(6000)),
46: new STDateU(new Date(7000)), };
47: }
48:
49: public void testEquals() {
50: Query q = st.query();
51: q.constrain(store()[1]);
52: st.expectOne(q, store()[1]);
53: }
54:
55: public void testGreater() {
56: Query q = st.query();
57: q.constrain(store()[2]);
58: q.descend("i_date").constraints().greater();
59: Object[] r = store();
60: st.expect(q, new Object[] { r[3], r[4] });
61: }
62:
63: public void testSmaller() {
64: Query q = st.query();
65: q.constrain(store()[4]);
66: q.descend("i_date").constraints().smaller();
67: Object[] r = store();
68: st.expect(q, new Object[] { r[1], r[2], r[3] });
69: }
70:
71: public void testNotGreaterOrEqual() {
72: Query q = st.query();
73: q.constrain(store()[3]);
74: q.descend("i_date").constraints().not().greater().equal();
75: Object[] r = store();
76: st.expect(q, new Object[] { r[0], r[1], r[2] });
77: }
78:
79: public void testNull() {
80: Query q = st.query();
81: q.constrain(new STDateU());
82: q.descend("i_date").constrain(null);
83: st.expectOne(q, new STDateU(null));
84: }
85:
86: public void testNotNull() {
87: Query q = st.query();
88: q.constrain(new STDateU());
89: q.descend("i_date").constrain(null).not();
90: Object[] r = store();
91: st.expect(q, new Object[] { r[1], r[2], r[3], r[4] });
92: }
93: }
|