001: /* Copyright (C) 2004 - 2007 db4objects Inc. http://www.db4o.com
002:
003: This file is part of the db4o open source object database.
004:
005: db4o is free software; you can redistribute it and/or modify it under
006: the terms of version 2 of the GNU General Public License as published
007: by the Free Software Foundation and as clarified by db4objects' GPL
008: interpretation policy, available at
009: http://www.db4o.com/about/company/legalpolicies/gplinterpretation/
010: Alternatively you can write to db4objects, Inc., 1900 S Norfolk Street,
011: Suite 350, San Mateo, CA 94403, USA.
012:
013: db4o is distributed in the hope that it will be useful, but WITHOUT ANY
014: WARRANTY; without even the implied warranty of MERCHANTABILITY or
015: FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
016: for more details.
017:
018: You should have received a copy of the GNU General Public License along
019: with this program; if not, write to the Free Software Foundation, Inc.,
020: 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
021: package com.db4o.test;
022:
023: import java.util.*;
024:
025: import com.db4o.*;
026: import com.db4o.query.*;
027:
028: /**
029: *
030: */
031: public class NullWrapperQueries {
032:
033: public Boolean m1;
034: // Byte m2; Byte will not work, since we always use 0 for null.
035: public Boolean m2;
036: public Character m3;
037: public Date m4;
038: public Double m5;
039: public Float m6;
040: public Integer m7;
041: public Long m8;
042: public Short m9;
043: public String m10;
044:
045: public void configure() {
046: for (int i = 1; i < 11; i++) {
047: String desc = "m" + i;
048: Db4o.configure().objectClass(this ).objectField(desc)
049: .indexed(true);
050: }
051: }
052:
053: public void store() {
054: Test.deleteAllInstances(this );
055: NullWrapperQueries nwq = new NullWrapperQueries();
056: nwq.fill1();
057: Test.store(nwq);
058: nwq = new NullWrapperQueries();
059: nwq.fill0();
060: Test.store(nwq);
061: nwq = new NullWrapperQueries();
062: nwq.fill0();
063: Test.store(nwq);
064: nwq = new NullWrapperQueries();
065: nwq.fill1();
066: Test.store(nwq);
067: nwq = new NullWrapperQueries();
068: Test.store(nwq);
069: nwq = new NullWrapperQueries();
070: Test.store(nwq);
071: }
072:
073: public void test() {
074: for (int i = 1; i < 11; i++) {
075: Query q = Test.query();
076: q.constrain(NullWrapperQueries.class);
077: String desc = "m" + i;
078: q.descend(desc).constrain(null);
079: Test.ensureEquals(2, q.execute().size());
080: }
081: }
082:
083: private void fill0() {
084: m1 = new Boolean(false);
085: // m2 = new Byte((byte)0);
086: m2 = new Boolean(false);
087:
088: m3 = new Character((char) 0);
089: m4 = new Date(0);
090: m5 = new Double(0);
091: m6 = new Float(0);
092: m7 = new Integer(0);
093: m8 = new Long(0);
094: m9 = new Short((short) 0);
095: m10 = "";
096: }
097:
098: private void fill1() {
099: m1 = new Boolean(true);
100: // m2 = new Byte((byte)1);
101: m2 = new Boolean(true);
102: m3 = new Character((char) 1);
103: m4 = new Date(1);
104: m5 = new Double(1);
105: m6 = new Float(1);
106: m7 = new Integer(1);
107: m8 = new Long(1);
108: m9 = new Short((short) 1);
109: m10 = "1";
110: }
111:
112: }
|