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.db4ounit.common.concurrency;
022:
023: import java.util.*;
024:
025: import com.db4o.config.*;
026: import com.db4o.ext.*;
027: import com.db4o.query.*;
028:
029: import db4ounit.*;
030: import db4ounit.extensions.*;
031:
032: public class NullWrapperQueriesTestCase extends
033: Db4oClientServerTestCase {
034:
035: public static void main(String[] args) {
036: new NullWrapperQueriesTestCase().runConcurrency();
037: }
038:
039: public Boolean m1;
040:
041: public Boolean m2;
042:
043: public Character m3;
044:
045: public Date m4;
046:
047: public Double m5;
048:
049: public Float m6;
050:
051: public Integer m7;
052:
053: public Long m8;
054:
055: public Short m9;
056:
057: public String m10;
058:
059: protected void configure(Configuration config) {
060: for (int i = 1; i < 11; i++) {
061: String desc = "m" + i;
062: config.objectClass(this ).objectField(desc).indexed(true);
063: }
064: }
065:
066: protected void store() {
067: NullWrapperQueriesTestCase nwq = new NullWrapperQueriesTestCase();
068: nwq.fill1();
069: store(nwq);
070: nwq = new NullWrapperQueriesTestCase();
071: nwq.fill0();
072: store(nwq);
073: nwq = new NullWrapperQueriesTestCase();
074: nwq.fill0();
075: store(nwq);
076: nwq = new NullWrapperQueriesTestCase();
077: nwq.fill1();
078: store(nwq);
079: nwq = new NullWrapperQueriesTestCase();
080: store(nwq);
081: nwq = new NullWrapperQueriesTestCase();
082: store(nwq);
083: }
084:
085: public void conc(ExtObjectContainer oc) {
086: for (int i = 1; i < 11; i++) {
087: Query q = oc.query();
088: q.constrain(NullWrapperQueriesTestCase.class);
089: String desc = "m" + i;
090: q.descend(desc).constrain(null);
091: Assert.areEqual(2, q.execute().size());
092: }
093: }
094:
095: private void fill0() {
096: m1 = new Boolean(false);
097: m2 = new Boolean(false);
098: m3 = new Character((char) 0);
099: m4 = new Date(0);
100: m5 = new Double(0);
101: m6 = new Float(0);
102: m7 = new Integer(0);
103: m8 = new Long(0);
104: m9 = new Short((short) 0);
105: m10 = "";
106: }
107:
108: private void fill1() {
109: m1 = new Boolean(true);
110: m2 = new Boolean(true);
111: m3 = new Character((char) 1);
112: m4 = new Date(1);
113: m5 = new Double(1);
114: m6 = new Float(1);
115: m7 = new Integer(1);
116: m8 = new Long(1);
117: m9 = new Short((short) 1);
118: m10 = "1";
119: }
120:
121: }
|