KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > db4o > db4ounit > jre11 > soda > wrapper > typed > STByteWTTestCase


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.db4ounit.jre11.soda.wrapper.typed;
22 import java.io.*;
23
24 import com.db4o.*;
25 import com.db4o.query.*;
26
27
28 public class STByteWTTestCase extends com.db4o.db4ounit.common.soda.util.SodaBaseTestCase implements Serializable{
29     
30     final static String JavaDoc DESCENDANT = "i_byte";
31     
32     public Byte JavaDoc i_byte;
33     
34     
35     public STByteWTTestCase(){
36     }
37     
38     private STByteWTTestCase(byte a_byte){
39         i_byte = new Byte JavaDoc(a_byte);
40     }
41     
42     public Object JavaDoc[] createData() {
43         return new Object JavaDoc[]{
44             new STByteWTTestCase((byte)0),
45             new STByteWTTestCase((byte)1),
46             new STByteWTTestCase((byte)99),
47             new STByteWTTestCase((byte)113),
48         };
49     }
50     
51     public void testEquals(){
52         Query q = newQuery();
53         q.constrain(new STByteWTTestCase((byte)0));
54         com.db4o.db4ounit.common.soda.util.SodaTestUtil.expectOne(q, _array[0]);
55     }
56     
57     public void testNotEquals(){
58         Query q = newQuery();
59         
60         q.constrain(_array[0]);
61         q.descend(DESCENDANT).constraints().not();
62         expect(q, new int[] {1, 2, 3});
63     }
64     
65     public void testGreater(){
66         Query q = newQuery();
67         q.constrain(new STByteWTTestCase((byte)9));
68         q.descend(DESCENDANT).constraints().greater();
69         
70         expect(q, new int[] {2, 3});
71     }
72     
73     public void testSmaller(){
74         Query q = newQuery();
75         q.constrain(new STByteWTTestCase((byte)1));
76         q.descend(DESCENDANT).constraints().smaller();
77         com.db4o.db4ounit.common.soda.util.SodaTestUtil.expectOne(q, _array[0]);
78     }
79     
80     public void testContains(){
81         Query q = newQuery();
82         q.constrain(new STByteWTTestCase((byte)9));
83         q.descend(DESCENDANT).constraints().contains();
84         
85         expect(q, new int[] {2});
86     }
87     
88     public void testNotContains(){
89         Query q = newQuery();
90         q.constrain(new STByteWTTestCase((byte)0));
91         q.descend(DESCENDANT).constraints().contains().not();
92         
93         expect(q, new int[] {1, 2, 3});
94     }
95     
96     public void testLike(){
97         Query q = newQuery();
98         q.constrain(new STByteWTTestCase((byte)11));
99         q.descend(DESCENDANT).constraints().like();
100         com.db4o.db4ounit.common.soda.util.SodaTestUtil.expectOne(q, new STByteWTTestCase((byte)113));
101         q = newQuery();
102         q.constrain(new STByteWTTestCase((byte)10));
103         q.descend(DESCENDANT).constraints().like();
104         expect(q, new int[] {});
105     }
106     
107     public void testNotLike(){
108         Query q = newQuery();
109         q.constrain(new STByteWTTestCase((byte)1));
110         q.descend(DESCENDANT).constraints().like().not();
111         
112         expect(q, new int[] {0, 2});
113     }
114     
115     public void testIdentity(){
116         Query q = newQuery();
117         q.constrain(new STByteWTTestCase((byte)1));
118         ObjectSet set = q.execute();
119         STByteWTTestCase identityConstraint = (STByteWTTestCase)set.next();
120         identityConstraint.i_byte = new Byte JavaDoc((byte)102);
121         q = newQuery();
122         q.constrain(identityConstraint).identity();
123         identityConstraint.i_byte = new Byte JavaDoc((byte)1);
124         com.db4o.db4ounit.common.soda.util.SodaTestUtil.expectOne(q,_array[1]);
125     }
126     
127     public void testNotIdentity(){
128         Query q = newQuery();
129         q.constrain(new STByteWTTestCase((byte)1));
130         ObjectSet set = q.execute();
131         STByteWTTestCase identityConstraint = (STByteWTTestCase)set.next();
132         identityConstraint.i_byte = new Byte JavaDoc((byte)102);
133         q = newQuery();
134         q.constrain(identityConstraint).identity().not();
135         identityConstraint.i_byte = new Byte JavaDoc((byte)1);
136         
137         expect(q, new int[] {0, 2, 3});
138     }
139     
140     public void testConstraints(){
141         Query q = newQuery();
142         q.constrain(new STByteWTTestCase((byte)1));
143         q.constrain(new STByteWTTestCase((byte)0));
144         Constraints cs = q.constraints();
145         Constraint[] csa = cs.toArray();
146         if(csa.length != 2){
147             db4ounit.Assert.fail("Constraints not returned");
148         }
149     }
150     
151     public void testNull(){
152         
153     }
154     
155     public void testEvaluation(){
156         Query q = newQuery();
157         q.constrain(new STByteWTTestCase());
158         q.constrain(new Evaluation() {
159             public void evaluate(Candidate candidate) {
160                 STByteWTTestCase sts = (STByteWTTestCase)candidate.getObject();
161                 candidate.include((sts.i_byte.byteValue() + 2) > 100);
162             }
163         });
164         
165         expect(q, new int[] {2, 3});
166     }
167     
168 }
169
170
Popular Tags