KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > db4o > db4ounit > common > soda > classes > typedhierarchy > STSDFT1TestCase


1 /* Copyright (C) 2004 - 2006 db4objects Inc. http://www.db4o.com
2
3 This file is part of the db4o open source object database.
4
5 db4o is free software; you can redistribute it and/or modify it under
6 the terms of version 2 of the GNU General Public License as published
7 by the Free Software Foundation and as clarified by db4objects' GPL
8 interpretation policy, available at
9 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 import com.db4o.query.*;
23
24
25 /** SDFT: Same descendant field typed*/
26 public class STSDFT1TestCase extends com.db4o.db4ounit.common.soda.util.SodaBaseTestCase{
27     
28     public STSDFT1TestCase(){
29     }
30     
31     public Object JavaDoc[] createData() {
32         return new Object JavaDoc[]{
33             new STSDFT1TestCase(),
34             new STSDFT2(),
35             new STSDFT2("str1"),
36             new STSDFT2("str2"),
37             new STSDFT3(),
38             new STSDFT3("str1"),
39             new STSDFT3("str3")
40         };
41     }
42     
43     public void testStrNull(){
44         Query q = newQuery();
45         q.constrain(new STSDFT1TestCase());
46         q.descend("foo").constrain(null);
47         
48         expect(q, new int[] {0, 1, 4});
49     }
50     
51     public void testStrVal(){
52         Query q = newQuery();
53         q.constrain(STSDFT1TestCase.class);
54         q.descend("foo").constrain("str1");
55         
56         expect(q, new int[] {2, 5});
57     }
58     
59     public void testOrValue(){
60         Query q = newQuery();
61         q.constrain(STSDFT1TestCase.class);
62         Query foo = q.descend("foo");
63         foo.constrain("str1").or(foo.constrain("str2"));
64         
65         expect(q, new int[] {2, 3, 5});
66     }
67     
68     public void testOrNull(){
69         Query q = newQuery();
70         q.constrain(STSDFT1TestCase.class);
71         Query foo = q.descend("foo");
72         foo.constrain("str1").or(foo.constrain(null));
73         
74         expect(q, new int[] {0, 1, 2, 4, 5});
75     }
76     
77     public void testTripleOrNull(){
78         Query q = newQuery();
79         q.constrain(STSDFT1TestCase.class);
80         Query foo = q.descend("foo");
81         foo.constrain("str1").or(foo.constrain(null)).or(foo.constrain("str2"));
82         
83         expect(q, new int[] {0, 1, 2,3, 4, 5});
84     }
85
86 // work in progress
87

88 // public void testOverConstrainedByClass(){
89
// Query q = SodaTenewQuery();
90
// q.constrain(STSDFT1TestCase.class).or(q.constrain(STSDFT2.class));
91
// Query foo = q.descend("foo");
92
// foo.constrain("str1").or(foo.constrain(null)).or(foo.constrain("str2"));
93
//
94
// SodaTeexpect(q, new int[] {0, 1, 2,3, 4, 5});
95
// }
96

97 }
98
99
Popular Tags