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.db4ounit.common.soda.classes.typedhierarchy;
022:
023: import com.db4o.query.*;
024:
025: /** ETH: Extends Typed Hierarchy */
026: public class STETH1TestCase extends
027: com.db4o.db4ounit.common.soda.util.SodaBaseTestCase {
028:
029: public String foo1;
030:
031: public STETH1TestCase() {
032: }
033:
034: public STETH1TestCase(String str) {
035: foo1 = str;
036: }
037:
038: public Object[] createData() {
039: return new Object[] { new STETH1TestCase(),
040: new STETH1TestCase("str1"), new STETH2(),
041: new STETH2("str1", "str2"), new STETH3(),
042: new STETH3("str1a", "str2", "str3"),
043: new STETH3("str1a", "str2a", null), new STETH4(),
044: new STETH4("str1a", "str2", "str4"),
045: new STETH4("str1b", "str2a", "str4") };
046: }
047:
048: public void testStrNull() {
049: Query q = newQuery();
050: q.constrain(new STETH1TestCase());
051: q.descend("foo1").constrain(null);
052:
053: expect(q, new int[] { 0, 2, 4, 7 });
054: }
055:
056: public void testTwoNull() {
057: Query q = newQuery();
058: q.constrain(new STETH1TestCase());
059: q.descend("foo1").constrain(null);
060: q.descend("foo3").constrain(null);
061:
062: expect(q, new int[] { 0, 2, 4, 7 });
063: }
064:
065: public void testClass() {
066: Query q = newQuery();
067: q.constrain(STETH2.class);
068:
069: expect(q, new int[] { 2, 3, 4, 5, 6, 7, 8, 9 });
070: }
071:
072: public void testOrClass() {
073: Query q = newQuery();
074: q.constrain(STETH3.class).or(q.constrain(STETH4.class));
075:
076: expect(q, new int[] { 4, 5, 6, 7, 8, 9 });
077: }
078:
079: public void testAndClass() {
080: Query q = newQuery();
081: q.constrain(STETH1TestCase.class);
082: q.constrain(STETH4.class);
083:
084: expect(q, new int[] { 7, 8, 9 });
085: }
086:
087: public void testParalellDescendantPaths() {
088: Query q = newQuery();
089: q.constrain(STETH3.class).or(q.constrain(STETH4.class));
090: q.descend("foo3").constrain("str3").or(
091: q.descend("foo4").constrain("str4"));
092:
093: expect(q, new int[] { 5, 8, 9 });
094: }
095:
096: public void testOrObjects() {
097: Query q = newQuery();
098:
099: q.constrain(_array[3]).or(q.constrain(_array[5]));
100: expect(q, new int[] { 3, 5 });
101: }
102:
103: }
|