KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > db4o > test > legacy > soda > wrapper > untyped > STDateU


1 /* Copyright (C) 2004 - 2006 db4objects Inc. http://www.db4o.com
2
3 This file is part of the db4o open source object database.
4
5 db4o is free software; you can redistribute it and/or modify it under
6 the terms of version 2 of the GNU General Public License as published
7 by the Free Software Foundation and as clarified by db4objects' GPL
8 interpretation policy, available at
9 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 JavaDoc i_date;
33     
34     public STDateU(){
35     }
36     
37     private STDateU(Date a_date){
38         i_date = a_date;
39     }
40     
41     public Object JavaDoc[] store() {
42         return new Object JavaDoc[]{
43             new STDateU(null),
44             new STDateU(new Date(4000)),
45             new STDateU(new Date(5000)),
46             new STDateU(new Date(6000)),
47             new STDateU(new Date(7000)),
48         };
49     }
50     
51     public void testEquals(){
52         Query q = st.query();
53         q.constrain(store()[1]);
54         st.expectOne(q, store()[1]);
55     }
56     
57     public void testGreater(){
58         Query q = st.query();
59         q.constrain(store()[2]);
60         q.descend("i_date").constraints().greater();
61         Object JavaDoc[] r = store();
62         st.expect(q, new Object JavaDoc[] { r[3], r[4]});
63     }
64     
65     public void testSmaller(){
66         Query q = st.query();
67         q.constrain(store()[4]);
68         q.descend("i_date").constraints().smaller();
69         Object JavaDoc[] r = store();
70         st.expect(q, new Object JavaDoc[] {r[1], r[2], r[3]});
71     }
72     
73     public void testNotGreaterOrEqual(){
74         Query q = st.query();
75         q.constrain(store()[3]);
76         q.descend("i_date").constraints().not().greater().equal();
77         Object JavaDoc[] r = store();
78         st.expect(q, new Object JavaDoc[] {r[0], r[1], r[2]});
79     }
80     
81     public void testNull(){
82         Query q = st.query();
83         q.constrain(new STDateU());
84         q.descend("i_date").constrain(null);
85         st.expectOne(q, new STDateU(null));
86     }
87     
88     public void testNotNull(){
89         Query q = st.query();
90         q.constrain(new STDateU());
91         q.descend("i_date").constrain(null).not();
92         Object JavaDoc[] r = store();
93         st.expect(q, new Object JavaDoc[] {r[1], r[2], r[3], r[4]});
94     }
95 }
96
97
Popular Tags