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.db4ounit.common.soda.classes.typedhierarchy;
22:
23: import com.db4o.query.*;
24:
25: /** SDFT: Same descendant field typed*/
26: public class STSDFT1TestCase extends
27: com.db4o.db4ounit.common.soda.util.SodaBaseTestCase {
28:
29: public STSDFT1TestCase() {
30: }
31:
32: public Object[] createData() {
33: return new Object[] { new STSDFT1TestCase(), new STSDFT2(),
34: new STSDFT2("str1"), new STSDFT2("str2"),
35: new STSDFT3(), new STSDFT3("str1"), new STSDFT3("str3") };
36: }
37:
38: public void testStrNull() {
39: Query q = newQuery();
40: q.constrain(new STSDFT1TestCase());
41: q.descend("foo").constrain(null);
42:
43: expect(q, new int[] { 0, 1, 4 });
44: }
45:
46: public void testStrVal() {
47: Query q = newQuery();
48: q.constrain(STSDFT1TestCase.class);
49: q.descend("foo").constrain("str1");
50:
51: expect(q, new int[] { 2, 5 });
52: }
53:
54: public void testOrValue() {
55: Query q = newQuery();
56: q.constrain(STSDFT1TestCase.class);
57: Query foo = q.descend("foo");
58: foo.constrain("str1").or(foo.constrain("str2"));
59:
60: expect(q, new int[] { 2, 3, 5 });
61: }
62:
63: public void testOrNull() {
64: Query q = newQuery();
65: q.constrain(STSDFT1TestCase.class);
66: Query foo = q.descend("foo");
67: foo.constrain("str1").or(foo.constrain(null));
68:
69: expect(q, new int[] { 0, 1, 2, 4, 5 });
70: }
71:
72: public void testTripleOrNull() {
73: Query q = newQuery();
74: q.constrain(STSDFT1TestCase.class);
75: Query foo = q.descend("foo");
76: foo.constrain("str1").or(foo.constrain(null)).or(
77: foo.constrain("str2"));
78:
79: expect(q, new int[] { 0, 1, 2, 3, 4, 5 });
80: }
81:
82: // work in progress
83:
84: // public void testOverConstrainedByClass(){
85: // Query q = SodaTenewQuery();
86: // q.constrain(STSDFT1TestCase.class).or(q.constrain(STSDFT2.class));
87: // Query foo = q.descend("foo");
88: // foo.constrain("str1").or(foo.constrain(null)).or(foo.constrain("str2"));
89: //
90: // SodaTeexpect(q, new int[] {0, 1, 2,3, 4, 5});
91: // }
92:
93: }
|