KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > db4o > test > legacy > soda > ordered > STOString


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.test.legacy.soda.ordered;
22
23 import com.db4o.query.*;
24 import com.db4o.test.legacy.soda.*;
25
26 public class STOString implements STClass {
27
28     public static transient SodaTest st;
29
30     String JavaDoc foo;
31
32     public STOString() {
33     }
34
35     public STOString(String JavaDoc str) {
36         this.foo = str;
37     }
38
39     public Object JavaDoc[] store() {
40         return new Object JavaDoc[] {
41             new STOString(null),
42             new STOString("bbb"),
43             new STOString("bbb"),
44             new STOString("dod"),
45             new STOString("aaa"),
46             new STOString("Xbb"),
47             new STOString("bbq")};
48     }
49
50     public void testAscending() {
51         Query q = st.query();
52         q.constrain(STOString.class);
53         q.descend("foo").orderAscending();
54         Object JavaDoc[] r = store();
55         st.expectOrdered(q, new Object JavaDoc[] { r[5], r[4], r[1], r[2], r[6], r[3], r[0] });
56     }
57
58     public void testDescending() {
59         Query q = st.query();
60         q.constrain(STOString.class);
61         q.descend("foo").orderDescending();
62         Object JavaDoc[] r = store();
63         st.expectOrdered(q, new Object JavaDoc[] { r[3], r[6], r[2], r[1], r[4], r[5], r[0] });
64     }
65
66     public void testAscendingLike() {
67         Query q = st.query();
68         q.constrain(STOString.class);
69         Query qStr = q.descend("foo");
70         qStr.constrain("b").like();
71         qStr.orderAscending();
72         Object JavaDoc[] r = store();
73         st.expectOrdered(q, new Object JavaDoc[] { r[5], r[1], r[2], r[6] });
74     }
75
76     public void testDescendingContains() {
77         Query q = st.query();
78         q.constrain(STOString.class);
79         Query qStr = q.descend("foo");
80         qStr.constrain("b").contains();
81         qStr.orderDescending();
82         Object JavaDoc[] r = store();
83         st.expectOrdered(q, new Object JavaDoc[] { r[6], r[2], r[1], r[5] });
84     }
85 }
86
Popular Tags