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.object;
022:
023: import com.db4o.query.*;
024: import com.db4o.test.legacy.soda.*;
025:
026: public class STArrStringON implements STClass {
027:
028: public static transient SodaTest st;
029:
030: Object strArr;
031:
032: public STArrStringON() {
033: }
034:
035: public STArrStringON(Object[][][] arr) {
036: strArr = arr;
037: }
038:
039: public Object[] store() {
040: STArrStringON[] arr = new STArrStringON[5];
041:
042: arr[0] = new STArrStringON();
043:
044: String[][][] content = new String[1][1][2];
045: arr[1] = new STArrStringON(content);
046:
047: content = new String[1][2][3];
048: arr[2] = new STArrStringON(content);
049:
050: content = new String[1][2][3];
051: content[0][0][1] = "foo";
052: content[0][1][0] = "bar";
053: content[0][1][2] = "fly";
054: arr[3] = new STArrStringON(content);
055:
056: content = new String[1][2][3];
057: content[0][0][0] = "bar";
058: content[0][1][0] = "wohay";
059: content[0][1][1] = "johy";
060: arr[4] = new STArrStringON(content);
061:
062: Object[] ret = new Object[arr.length];
063: System.arraycopy(arr, 0, ret, 0, arr.length);
064: return ret;
065: }
066:
067: public void testDefaultContainsOne() {
068: Query q = st.query();
069: Object[] r = store();
070: String[][][] content = new String[1][1][1];
071: content[0][0][0] = "bar";
072: q.constrain(new STArrStringON(content));
073: st.expect(q, new Object[] { r[3], r[4] });
074: }
075:
076: public void testDefaultContainsTwo() {
077: Query q = st.query();
078: Object[] r = store();
079: String[][][] content = new String[2][1][1];
080: content[0][0][0] = "bar";
081: content[1][0][0] = "foo";
082: q.constrain(new STArrStringON(content));
083: st.expect(q, new Object[] { r[3] });
084: }
085:
086: public void testDescendOne() {
087: Query q = st.query();
088: Object[] r = store();
089: q.constrain(STArrStringON.class);
090: q.descend("strArr").constrain("bar");
091: st.expect(q, new Object[] { r[3], r[4] });
092: }
093:
094: public void testDescendTwo() {
095: Query q = st.query();
096: Object[] r = store();
097: q.constrain(STArrStringON.class);
098: Query qElements = q.descend("strArr");
099: qElements.constrain("foo");
100: qElements.constrain("bar");
101: st.expect(q, new Object[] { r[3] });
102: }
103:
104: public void testDescendOneNot() {
105: Query q = st.query();
106: Object[] r = store();
107: q.constrain(STArrStringON.class);
108: q.descend("strArr").constrain("bar").not();
109: st.expect(q, new Object[] { r[0], r[1], r[2] });
110: }
111:
112: public void testDescendTwoNot() {
113: Query q = st.query();
114: Object[] r = store();
115: q.constrain(STArrStringON.class);
116: Query qElements = q.descend("strArr");
117: qElements.constrain("foo").not();
118: qElements.constrain("bar").not();
119: st.expect(q, new Object[] { r[0], r[1], r[2] });
120: }
121:
122: }
|