01: /* Copyright (C) 2004 - 2007 db4objects Inc. http://www.db4o.com
02:
03: This file is part of the db4o open source object database.
04:
05: db4o is free software; you can redistribute it and/or modify it under
06: the terms of version 2 of the GNU General Public License as published
07: by the Free Software Foundation and as clarified by db4objects' GPL
08: interpretation policy, available at
09: 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.arrays.object;
22:
23: import com.db4o.query.*;
24: import com.db4o.test.legacy.soda.*;
25:
26: public class STArrIntegerO implements STClass {
27:
28: public static transient SodaTest st;
29:
30: Object intArr;
31:
32: public STArrIntegerO() {
33: }
34:
35: public STArrIntegerO(Object[] arr) {
36: intArr = arr;
37: }
38:
39: public Object[] store() {
40: return new Object[] {
41: new STArrIntegerO(),
42: new STArrIntegerO(new Object[0]),
43: new STArrIntegerO(new Object[] { new Integer(0),
44: new Integer(0) }),
45: new STArrIntegerO(new Object[] { new Integer(1),
46: new Integer(17),
47: new Integer(Integer.MAX_VALUE - 1) }),
48: new STArrIntegerO(new Object[] { new Integer(3),
49: new Integer(17), new Integer(25),
50: new Integer(Integer.MAX_VALUE - 2) }) };
51: }
52:
53: public void testDefaultContainsOne() {
54: Query q = st.query();
55: Object[] r = store();
56: q
57: .constrain(new STArrIntegerO(
58: new Object[] { new Integer(17) }));
59: st.expect(q, new Object[] { r[3], r[4] });
60: }
61:
62: public void testDefaultContainsTwo() {
63: Query q = st.query();
64: Object[] r = store();
65: q.constrain(new STArrIntegerO(new Object[] { new Integer(17),
66: new Integer(25) }));
67: st.expect(q, new Object[] { r[4] });
68: }
69:
70: public void testDescendOne() {
71: Query q = st.query();
72: Object[] r = store();
73: q.constrain(STArrIntegerO.class);
74: q.descend("intArr").constrain(new Integer(17));
75: st.expect(q, new Object[] { r[3], r[4] });
76: }
77:
78: public void testDescendTwo() {
79: Query q = st.query();
80: Object[] r = store();
81: q.constrain(STArrIntegerO.class);
82: Query qElements = q.descend("intArr");
83: qElements.constrain(new Integer(17));
84: qElements.constrain(new Integer(25));
85: st.expect(q, new Object[] { r[4] });
86: }
87:
88: public void testDescendSmaller() {
89: Query q = st.query();
90: Object[] r = store();
91: q.constrain(STArrIntegerO.class);
92: Query qElements = q.descend("intArr");
93: qElements.constrain(new Integer(3)).smaller();
94: st.expect(q, new Object[] { r[2], r[3] });
95: }
96:
97: }
|