KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > db4o > db4ounit > common > soda > arrays > typed > STArrStringTNTestCase


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.common.soda.arrays.typed;
22 import com.db4o.query.*;
23
24
25 public class STArrStringTNTestCase extends com.db4o.db4ounit.common.soda.util.SodaBaseTestCase {
26
27     public String JavaDoc[][][] strArr;
28
29     public STArrStringTNTestCase() {
30     }
31
32     public STArrStringTNTestCase(String JavaDoc[][][] arr) {
33         strArr = arr;
34     }
35
36     public Object JavaDoc[] createData() {
37         STArrStringTNTestCase[] arr = new STArrStringTNTestCase[5];
38         
39         arr[0] = new STArrStringTNTestCase();
40         
41         String JavaDoc[][][] content = new String JavaDoc[1][1][2];
42         arr[1] = new STArrStringTNTestCase(content);
43         
44         content = new String JavaDoc[1][2][3];
45         arr[2] = new STArrStringTNTestCase(content);
46         
47         content = new String JavaDoc[1][2][3];
48         content[0][0][1] = "foo";
49         content[0][1][0] = "bar";
50         content[0][1][2] = "fly";
51         arr[3] = new STArrStringTNTestCase(content);
52         
53         content = new String JavaDoc[1][2][3];
54         content[0][0][0] = "bar";
55         content[0][1][0] = "wohay";
56         content[0][1][1] = "johy";
57         arr[4] = new STArrStringTNTestCase(content);
58         
59         Object JavaDoc[] ret = new Object JavaDoc[arr.length];
60         System.arraycopy(arr, 0, ret, 0, arr.length);
61         return ret;
62     }
63
64     public void testDefaultContainsOne() {
65         Query q = newQuery();
66         
67         String JavaDoc[][][] content = new String JavaDoc[1][1][1];
68         content[0][0][0] = "bar";
69         q.constrain(new STArrStringTNTestCase(content));
70         expect(q, new int[] { 3, 4 });
71     }
72
73     public void testDefaultContainsTwo() {
74         Query q = newQuery();
75         
76         String JavaDoc[][][] content = new String JavaDoc[2][1][1];
77         content[0][0][0] = "bar";
78         content[1][0][0] = "foo";
79         q.constrain(new STArrStringTNTestCase(content));
80         expect(q, new int[] { 3 });
81     }
82
83     public void testDescendOne() {
84         Query q = newQuery();
85         
86         q.constrain(STArrStringTNTestCase.class);
87         q.descend("strArr").constrain("bar");
88         expect(q, new int[] { 3, 4 });
89     }
90
91     public void testDescendTwo() {
92         Query q = newQuery();
93         
94         q.constrain(STArrStringTNTestCase.class);
95         Query qElements = q.descend("strArr");
96         qElements.constrain("foo");
97         qElements.constrain("bar");
98         expect(q, new int[] { 3 });
99     }
100
101     public void testDescendOneNot() {
102         Query q = newQuery();
103         
104         q.constrain(STArrStringTNTestCase.class);
105         q.descend("strArr").constrain("bar").not();
106         expect(q, new int[] { 0, 1, 2 });
107     }
108
109     public void testDescendTwoNot() {
110         Query q = newQuery();
111         
112         q.constrain(STArrStringTNTestCase.class);
113         Query qElements = q.descend("strArr");
114         qElements.constrain("foo").not();
115         qElements.constrain("bar").not();
116         expect(q, new int[] { 0, 1, 2 });
117     }
118
119 }
120
Popular Tags