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