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.db4ounit.jre11.types.arrays;
22:
23: import db4ounit.*;
24: import db4ounit.extensions.AbstractDb4oTestCase;
25:
26: public class PrimitiveWrapperArrayTestCase extends AbstractDb4oTestCase {
27:
28: public static void main(String[] args) {
29: new PrimitiveWrapperArrayTestCase().runSolo();
30: }
31:
32: protected void store() throws Exception {
33: store(BooleanContainer.testInstance());
34: store(IntegerContainer.testInstance());
35: }
36:
37: public void testBooleanArray() {
38: assertArrayContainer(BooleanContainer.testInstance());
39: }
40:
41: public void _testIntegerArray() {
42: assertArrayContainer(IntegerContainer.testInstance());
43: }
44:
45: private void assertArrayContainer(final ArrayContainer expected) {
46: ArrayContainer item = (ArrayContainer) retrieveOnlyInstance(expected
47: .getClass());
48: ArrayAssert.areEqual(expected.getArray(), item.getArray());
49: }
50:
51: public static interface ArrayContainer {
52:
53: public Object[] getArray();
54: }
55:
56: public static class IntegerContainer implements ArrayContainer {
57: public Integer[] _array;
58:
59: public IntegerContainer() {
60: }
61:
62: public IntegerContainer(Integer[] array) {
63: _array = array;
64: }
65:
66: public Object[] getArray() {
67: return _array;
68: }
69:
70: public static IntegerContainer testInstance() {
71: return new IntegerContainer(new Integer[] {
72: new Integer(42), new Integer(0), null,
73: new Integer(1), new Integer(-42) });
74: }
75: }
76:
77: public static class BooleanContainer implements ArrayContainer {
78:
79: public Boolean[] _array;
80:
81: public BooleanContainer() {
82: }
83:
84: public BooleanContainer(Boolean[] array) {
85: _array = array;
86: }
87:
88: public Object[] getArray() {
89: return _array;
90: }
91:
92: public static BooleanContainer testInstance() {
93: return new BooleanContainer(new Boolean[] {
94: new Boolean(true), new Boolean(false), null });
95: }
96: }
97:
98: }
|