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.jre11.soda.classes.simple;
022:
023: import java.util.*;
024:
025: import com.db4o.query.*;
026:
027: public class STDateTestCase extends
028: com.db4o.db4ounit.common.soda.util.SodaBaseTestCase {
029:
030: public Date i_date;
031:
032: public STDateTestCase() {
033: }
034:
035: private STDateTestCase(Date a_date) {
036: i_date = a_date;
037: }
038:
039: public Object[] createData() {
040: return new Object[] { new STDateTestCase(null),
041: new STDateTestCase(new Date(4000)),
042: new STDateTestCase(new Date(5000)),
043: new STDateTestCase(new Date(6000)),
044: new STDateTestCase(new Date(7000)), };
045: }
046:
047: public void testEquals() {
048: Query q = newQuery();
049: q.constrain(_array[1]);
050: com.db4o.db4ounit.common.soda.util.SodaTestUtil.expectOne(q,
051: _array[1]);
052: }
053:
054: public void testGreater() {
055: Query q = newQuery();
056: q.constrain(_array[2]);
057: q.descend("i_date").constraints().greater();
058:
059: expect(q, new int[] { 3, 4 });
060: }
061:
062: public void testSmaller() {
063: Query q = newQuery();
064: q.constrain(_array[4]);
065: q.descend("i_date").constraints().smaller();
066:
067: expect(q, new int[] { 1, 2, 3 });
068: }
069:
070: public void testGreaterOrEqual() {
071: Query q = newQuery();
072: q.constrain(_array[2]);
073: q.descend("i_date").constraints().greater().equal();
074:
075: expect(q, new int[] { 2, 3, 4 });
076:
077: }
078:
079: public void testNotGreaterOrEqual() {
080: Query q = newQuery();
081: q.constrain(_array[3]);
082: q.descend("i_date").constraints().not().greater().equal();
083:
084: expect(q, new int[] { 0, 1, 2 });
085: }
086:
087: public void testNull() {
088: Query q = newQuery();
089: q.constrain(new STDateTestCase());
090: q.descend("i_date").constrain(null);
091: com.db4o.db4ounit.common.soda.util.SodaTestUtil.expectOne(q,
092: new STDateTestCase(null));
093: }
094:
095: public void testNotNull() {
096: Query q = newQuery();
097: q.constrain(new STDateTestCase());
098: q.descend("i_date").constrain(null).not();
099:
100: expect(q, new int[] { 1, 2, 3, 4 });
101: }
102: }
|