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;
22:
23: import com.db4o.*;
24:
25: public class SortResult {
26: private final static int[] ORIG = { 2, 4, 1, 3 };
27:
28: public int id;
29:
30: public SortResult() {
31: this (0);
32: }
33:
34: public SortResult(int id) {
35: this .id = id;
36: }
37:
38: public int id() {
39: return id;
40: }
41:
42: public String toString() {
43: return "<" + id + ">";
44: }
45:
46: public void configure() {
47: Db4o.configure().optimizeNativeQueries(false);
48: }
49:
50: public void store() {
51: for (int idx = 0; idx < ORIG.length; idx++) {
52: SortResult sortResult = new SortResult(ORIG[idx]);
53: Test.store(sortResult);
54: //System.err.println(sortResult+"/"+Test.objectContainer().ext().getID(sortResult));
55: }
56: }
57:
58: public void test() {
59: ObjectSet result = Test.objectContainer().get(SortResult.class);
60: // FIXME: Why 0 results?
61: // ObjectSet result=Test.objectContainer().query(
62: // new Predicate() {
63: // public boolean match(SortResult candidate) {
64: // return true;
65: // }
66: // });
67:
68: /*
69: result.ext().sort(new QueryComparator() {
70: public int compare(Object first, Object second) {
71: return ((SortResult)first).id()-((SortResult)second).id();
72: }
73: });
74: Test.ensure(ORIG.length==result.size());
75: for(int i=1;i<=ORIG.length;i++) {
76: Test.ensure(((SortResult)result.next()).id()==i);
77: }
78: */
79: }
80: }
|