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