KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > db4o > test > legacy > soda > classes > simple > STDate


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.classes.simple;
22
23 import java.util.*;
24
25 import com.db4o.query.*;
26 import com.db4o.test.legacy.soda.*;
27
28 public class STDate implements STClass1{
29     
30     public static transient SodaTest st;
31     
32     public Date i_date;
33     
34     public STDate(){
35     }
36     
37     private STDate(Date a_date){
38         i_date = a_date;
39     }
40     
41     public Object JavaDoc[] store() {
42         return new Object JavaDoc[]{
43             new STDate(null),
44             new STDate(new Date(4000)),
45             new STDate(new Date(5000)),
46             new STDate(new Date(6000)),
47             new STDate(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 testGreaterOrEqual(){
74         Query q = st.query();
75         q.constrain(store()[2]);
76         q.descend("i_date").constraints().greater().equal();
77         Object JavaDoc[] r = store();
78         st.expect(q, new Object JavaDoc[] {r[2], r[3], r[4]});
79         
80     }
81     
82     public void testNotGreaterOrEqual(){
83         Query q = st.query();
84         q.constrain(store()[3]);
85         q.descend("i_date").constraints().not().greater().equal();
86         Object JavaDoc[] r = store();
87         st.expect(q, new Object JavaDoc[] {r[0], r[1], r[2]});
88     }
89     
90     public void testNull(){
91         Query q = st.query();
92         q.constrain(new STDate());
93         q.descend("i_date").constrain(null);
94         st.expectOne(q, new STDate(null));
95     }
96     
97     public void testNotNull(){
98         Query q = st.query();
99         q.constrain(new STDate());
100         q.descend("i_date").constrain(null).not();
101         Object JavaDoc[] r = store();
102         st.expect(q, new Object JavaDoc[] {r[1], r[2], r[3], r[4]});
103     }
104 }
105
106
Popular Tags