KickJava   Java API By Example, From Geeks To Geeks.

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


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
24 import com.db4o.query.*;
25 import com.db4o.test.legacy.soda.*;
26
27 public class STBooleanWU implements STClass1{
28     
29     final static String JavaDoc DESCENDANT = "i_boolean";
30
31     public static transient SodaTest st;
32     
33     public Object JavaDoc i_boolean;
34     
35     public STBooleanWU(){
36     }
37     
38     private STBooleanWU(boolean a_boolean){
39         i_boolean = new Boolean JavaDoc(a_boolean);
40     }
41     
42     public Object JavaDoc[] store() {
43         return new Object JavaDoc[]{
44             new STBooleanWU(false),
45             new STBooleanWU(true),
46             new STBooleanWU(false),
47             new STBooleanWU(false),
48             new STBooleanWU()
49         };
50     }
51     
52     public void testEqualsTrue(){
53         Query q = st.query();
54         q.constrain(new STBooleanWU(true));
55         Object JavaDoc[] r = store();
56         st.expectOne(q, new STBooleanWU(true));
57     }
58     
59     public void testEqualsFalse(){
60         Query q = st.query();
61         q.constrain(new STBooleanWU(false));
62         q.descend(DESCENDANT).constrain(new Boolean JavaDoc(false));
63         Object JavaDoc[] r = store();
64         st.expect(q, new Object JavaDoc[] {r[0], r[2], r[3]});
65     }
66     
67     public void testNull(){
68         Query q = st.query();
69         q.constrain(new STBooleanWU());
70         q.descend(DESCENDANT).constrain(null);
71         Object JavaDoc[] r = store();
72         st.expectOne(q, new STBooleanWU());
73     }
74     
75     public void testNullOrTrue(){
76         Query q = st.query();
77         q.constrain(new STBooleanWU());
78         Query qd = q.descend(DESCENDANT);
79         qd.constrain(null).or(qd.constrain(new Boolean JavaDoc(true)));
80         Object JavaDoc[] r = store();
81         st.expect(q, new Object JavaDoc[] {r[1], r[4]});
82     }
83     
84     public void testNotNullAndFalse(){
85         Query q = st.query();
86         q.constrain(new STBooleanWU());
87         Query qd = q.descend(DESCENDANT);
88         qd.constrain(null).not().and(qd.constrain(new Boolean JavaDoc(false)));
89         Object JavaDoc[] r = store();
90         st.expect(q, new Object JavaDoc[] {r[0], r[2], r[3]});
91     }
92     
93 }
94
95
Popular Tags