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.collections;
022:
023: import java.util.*;
024:
025: import com.db4o.query.*;
026: import com.db4o.test.legacy.soda.*;
027: import com.db4o.test.legacy.soda.collections.*;
028:
029: public class STVectorEU extends Vector implements STClass {
030:
031: public static class ExtendVector extends Vector {
032: }
033:
034: public static transient SodaTest st;
035:
036: Object col;
037:
038: public STVectorEU() {
039: }
040:
041: public STVectorEU(Object[] arr) {
042: ExtendVector ev = new ExtendVector();
043: for (int i = 0; i < arr.length; i++) {
044: ev.add(arr[i]);
045: }
046: col = ev;
047: }
048:
049: public Object[] store() {
050: return new Object[] {
051:
052: new STVectorEU(),
053: new STVectorEU(new Object[0]),
054: new STVectorEU(new Object[] { new Integer(0),
055: new Integer(0) }),
056: new STVectorEU(new Object[] { new Integer(1),
057: new Integer(17),
058: new Integer(Integer.MAX_VALUE - 1) }),
059: new STVectorEU(new Object[] { new Integer(3),
060: new Integer(17), new Integer(25),
061: new Integer(Integer.MAX_VALUE - 2) }),
062: new STVectorEU(new Object[] { "foo",
063: new STElement("bar", "barbar") }),
064: new STVectorEU(new Object[] { "foo2",
065: new STElement("bar", "barbar2") }) };
066: }
067:
068: public void testDefaultContainsInteger() {
069: Query q = st.query();
070: Object[] r = store();
071: q.constrain(new STVectorEU(new Object[] { new Integer(17) }));
072: st.expect(q, new Object[] { r[3], r[4] });
073: }
074:
075: public void testDefaultContainsString() {
076: Query q = st.query();
077: Object[] r = store();
078: q.constrain(new STVectorEU(new Object[] { "foo" }));
079: st.expect(q, new Object[] { r[5] });
080: }
081:
082: public void testDefaultContainsTwo() {
083: Query q = st.query();
084: Object[] r = store();
085: q.constrain(new STVectorEU(new Object[] { new Integer(17),
086: new Integer(25) }));
087: st.expect(q, new Object[] { r[4] });
088: }
089:
090: public void testDescendOne() {
091: Query q = st.query();
092: Object[] r = store();
093: q.constrain(STVectorEU.class);
094: q.descend("col").constrain(new Integer(17));
095: st.expect(q, new Object[] { r[3], r[4] });
096: }
097:
098: public void testDescendTwo() {
099: Query q = st.query();
100: Object[] r = store();
101: q.constrain(STVectorEU.class);
102: Query qElements = q.descend("col");
103: qElements.constrain(new Integer(17));
104: qElements.constrain(new Integer(25));
105: st.expect(q, new Object[] { r[4] });
106: }
107:
108: public void testDescendSmaller() {
109: Query q = st.query();
110: Object[] r = store();
111: q.constrain(STVectorEU.class);
112: Query qElements = q.descend("col");
113: qElements.constrain(new Integer(3)).smaller();
114: st.expect(q, new Object[] { r[2], r[3] });
115: }
116:
117: public void testDefaultContainsObject() {
118: Query q = st.query();
119: Object[] r = store();
120: q.constrain(new STVectorEU(new Object[] { new STElement("bar",
121: null) }));
122: st.expect(q, new Object[] { r[5], r[6] });
123: }
124:
125: public void testDescendToObject() {
126: Query q = st.query();
127: Object[] r = store();
128: q.constrain(new STVectorEU());
129: q.descend("col").descend("foo1").constrain("bar");
130: st.expect(q, new Object[] { r[5], r[6] });
131: }
132:
133: }
|