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.ext.*;
24:
25: public class StoredFieldValue {
26:
27: public String foo;
28: public int bar;
29: public Atom[] atoms;
30:
31: public void storeOne() {
32: foo = "foo";
33: bar = 10;
34: atoms = new Atom[2];
35: atoms[0] = new Atom("one");
36: atoms[1] = new Atom("two");
37: }
38:
39: public void testOne() {
40: ExtObjectContainer oc = Test.objectContainer();
41: StoredClass sc = oc.storedClass(this );
42: StoredField[] sf = sc.getStoredFields();
43: boolean[] cases = new boolean[3];
44: for (int i = 0; i < sf.length; i++) {
45: StoredField f = sf[i];
46: if (f.getName().equals("foo")) {
47: Test.ensure(f.get(this ).equals("foo"));
48: Test.ensure(f.getStoredType().getName().equals(
49: String.class.getName()));
50: cases[0] = true;
51: }
52: if (f.getName().equals("bar")) {
53: Test.ensure(f.get(this ).equals(new Integer(10)));
54: Test.ensure(f.getStoredType().getName().equals(
55: int.class.getName()));
56: cases[1] = true;
57: }
58: if (f.getName().equals("atoms")) {
59: Test.ensure(f.getStoredType().getName().equals(
60: Atom.class.getName()));
61: Test.ensure(f.isArray());
62: Atom[] at = (Atom[]) f.get(this );
63: Test.ensure(at[0].name.equals("one"));
64: Test.ensure(at[1].name.equals("two"));
65: cases[2] = true;
66: }
67: }
68: for (int i = 0; i < cases.length; i++) {
69: Test.ensure(cases[i]);
70: }
71: }
72: }
|