001: /* Copyright (C) 2004 - 2007 db4objects Inc. http://www.db4o.com
002:
003: This file is part of the db4o open source object database.
004:
005: db4o is free software; you can redistribute it and/or modify it under
006: the terms of version 2 of the GNU General Public License as published
007: by the Free Software Foundation and as clarified by db4objects' GPL
008: interpretation policy, available at
009: http://www.db4o.com/about/company/legalpolicies/gplinterpretation/
010: Alternatively you can write to db4objects, Inc., 1900 S Norfolk Street,
011: Suite 350, San Mateo, CA 94403, USA.
012:
013: db4o is distributed in the hope that it will be useful, but WITHOUT ANY
014: WARRANTY; without even the implied warranty of MERCHANTABILITY or
015: FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
016: for more details.
017:
018: You should have received a copy of the GNU General Public License along
019: with this program; if not, write to the Free Software Foundation, Inc.,
020: 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
021: package com.db4o.test.legacy.soda.arrays.untyped;
022:
023: import com.db4o.query.*;
024: import com.db4o.test.legacy.soda.*;
025:
026: public class STArrMixedN implements STClass {
027:
028: public static transient SodaTest st;
029:
030: Object[][][] arr;
031:
032: public STArrMixedN() {
033: }
034:
035: public STArrMixedN(Object[][][] arr) {
036: this .arr = arr;
037: }
038:
039: public Object[] store() {
040: STArrMixedN[] arrMixed = new STArrMixedN[5];
041:
042: arrMixed[0] = new STArrMixedN();
043:
044: Object[][][] content = new Object[1][1][2];
045: arrMixed[1] = new STArrMixedN(content);
046:
047: content = new Object[2][2][3];
048: arrMixed[2] = new STArrMixedN(content);
049:
050: content = new Object[2][2][3];
051: content[0][0][1] = "foo";
052: content[0][1][0] = "bar";
053: content[0][1][2] = "fly";
054: content[1][0][0] = new Boolean(false);
055: arrMixed[3] = new STArrMixedN(content);
056:
057: content = new Object[2][2][3];
058: content[0][0][0] = "bar";
059: content[0][1][0] = "wohay";
060: content[0][1][1] = "johy";
061: content[1][0][0] = new Integer(12);
062: arrMixed[4] = new STArrMixedN(content);
063:
064: Object[] ret = new Object[arrMixed.length];
065: System.arraycopy(arrMixed, 0, ret, 0, arrMixed.length);
066: return ret;
067: }
068:
069: public void testDefaultContainsString() {
070: Query q = st.query();
071: Object[] r = store();
072: Object[][][] content = new Object[1][1][1];
073: content[0][0][0] = "bar";
074: q.constrain(new STArrMixedN(content));
075: st.expect(q, new Object[] { r[3], r[4] });
076: }
077:
078: public void testDefaultContainsInteger() {
079: Query q = st.query();
080: Object[] r = store();
081: Object[][][] content = new Object[1][1][1];
082: content[0][0][0] = new Integer(12);
083: q.constrain(new STArrMixedN(content));
084: st.expect(q, new Object[] { r[4] });
085: }
086:
087: public void testDefaultContainsBoolean() {
088: Query q = st.query();
089: Object[] r = store();
090: Object[][][] content = new Object[1][1][1];
091: content[0][0][0] = new Boolean(false);
092: q.constrain(new STArrMixedN(content));
093: st.expect(q, new Object[] { r[3] });
094: }
095:
096: public void testDefaultContainsTwo() {
097: Query q = st.query();
098: Object[] r = store();
099: Object[][][] content = new Object[2][1][1];
100: content[0][0][0] = "bar";
101: content[1][0][0] = new Integer(12);
102: q.constrain(new STArrMixedN(content));
103: st.expect(q, new Object[] { r[4] });
104: }
105:
106: public void testDescendOne() {
107: Query q = st.query();
108: Object[] r = store();
109: q.constrain(STArrMixedN.class);
110: q.descend("arr").constrain("bar");
111: st.expect(q, new Object[] { r[3], r[4] });
112: }
113:
114: public void testDescendTwo() {
115: Query q = st.query();
116: Object[] r = store();
117: q.constrain(STArrMixedN.class);
118: Query qElements = q.descend("arr");
119: qElements.constrain("foo");
120: qElements.constrain("bar");
121: st.expect(q, new Object[] { r[3] });
122: }
123:
124: public void testDescendOneNot() {
125: Query q = st.query();
126: Object[] r = store();
127: q.constrain(STArrMixedN.class);
128: q.descend("arr").constrain("bar").not();
129: st.expect(q, new Object[] { r[0], r[1], r[2] });
130: }
131:
132: public void testDescendTwoNot() {
133: Query q = st.query();
134: Object[] r = store();
135: q.constrain(STArrMixedN.class);
136: Query qElements = q.descend("arr");
137: qElements.constrain("foo").not();
138: qElements.constrain("bar").not();
139: st.expect(q, new Object[] { r[0], r[1], r[2] });
140: }
141:
142: }
|