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.test2;
22:
23: import java.util.*;
24:
25: import com.db4o.*;
26: import com.db4o.foundation.*;
27: import com.db4o.test.*;
28: import com.db4o.test.types.*;
29:
30: public abstract class RCollection implements RTestable {
31:
32: abstract public Object newInstance();
33:
34: TEntry entry() {
35: return new TEntry();
36: }
37:
38: public Object set(Object obj, int ver) {
39: TEntry[] arr = entry().test(ver);
40: Collection col = (Collection) obj;
41: col.clear();
42: for (int i = 0; i < arr.length; i++) {
43: col.add(arr[i].key);
44: }
45: return obj;
46: }
47:
48: public void compare(ObjectContainer con, Object obj, int ver) {
49: Collection col = (Collection) obj;
50: TEntry[] entries = new TEntry[col.size()];
51: Iterator it = col.iterator();
52: int i = 0;
53: while (it.hasNext()) {
54: entries[i] = new TEntry();
55: entries[i].key = it.next();
56: i++;
57: }
58: entry().compare(entries, ver, true);
59: }
60:
61: public void specific(ObjectContainer con, int step) {
62: TEntry entry = entry().firstElement();
63: Collection col = (Collection) newInstance();
64: if (step > 0) {
65: col.add(entry.key);
66: ObjectSet set = con.get(col);
67: Collection4 sizeCalc = new Collection4();
68: while (set.hasNext()) {
69: Object obj = set.next();
70: if (obj.getClass() == col.getClass()) {
71: sizeCalc.add(obj);
72: }
73: }
74: if (sizeCalc.size() != step) {
75: Regression
76: .addError("Collection member query not found");
77: }
78: }
79: entry = entry().noElement();
80: col.add(entry.key);
81: if (con.get(col).size() != 0) {
82: Regression
83: .addError("Collection member query found too many");
84: }
85: }
86:
87: public boolean jdk2() {
88: return true;
89: }
90:
91: public boolean ver3() {
92: return false;
93: }
94: }
|