KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > db4o > db4ounit > jre12 > soda > experiments > STIdentityEvaluationTestCase


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.jre12.soda.experiments;
22 import com.db4o.*;
23 import com.db4o.query.*;
24
25
26
27 public class STIdentityEvaluationTestCase extends com.db4o.db4ounit.common.soda.util.SodaBaseTestCase{
28     
29     public Object JavaDoc[] createData() {
30         
31         Helper helperA = new Helper("aaa");
32         
33         return new Object JavaDoc[] {
34             new STIdentityEvaluationTestCase(null),
35             new STIdentityEvaluationTestCase(helperA),
36             new STIdentityEvaluationTestCase(helperA),
37             new STIdentityEvaluationTestCase(helperA),
38             new STIdentityEvaluationTestCase(new HelperDerivate("bbb")),
39             new STIdentityEvaluationTestCase(new Helper("dod"))
40             };
41     }
42     
43     public Helper helper;
44     
45     public STIdentityEvaluationTestCase(){
46     }
47     
48     public STIdentityEvaluationTestCase(Helper h){
49         this.helper = h;
50     }
51     
52     public void test(){
53         Query q = newQuery();
54         
55         q.constrain(new Helper("aaa"));
56         ObjectSet os = q.execute();
57         Helper helperA = (Helper)os.next();
58         q = newQuery();
59         q.constrain(STIdentityEvaluationTestCase.class);
60         q.descend("helper").constrain(helperA).identity();
61         q.constrain(new Evaluation() {
62             public void evaluate(Candidate candidate) {
63                 candidate.include(true);
64             }
65         });
66         expect(q, new int[] {1, 2, 3});
67     }
68     
69     public void testMemberClassConstraint(){
70         Query q = newQuery();
71         
72         q.constrain(STIdentityEvaluationTestCase.class);
73         q.descend("helper").constrain(HelperDerivate.class);
74         expect(q, new int[] {4});
75     }
76     
77     public static class Helper{
78         
79         public String JavaDoc hString;
80         
81         public Helper(){
82         }
83         
84         public Helper(String JavaDoc str){
85             hString = str;
86         }
87     }
88     
89     public static class HelperDerivate extends Helper{
90         public HelperDerivate(){
91         }
92         
93         public HelperDerivate(String JavaDoc str){
94             super(str);
95         }
96         
97     }
98     
99 }
100
Popular Tags