01: /*******************************************************************************
02: * Portions created by Sebastian Thomschke are copyright (c) 2005-2007 Sebastian
03: * Thomschke.
04: *
05: * All Rights Reserved. This program and the accompanying materials
06: * are made available under the terms of the Eclipse Public License v1.0
07: * which accompanies this distribution, and is available at
08: * http://www.eclipse.org/legal/epl-v10.html
09: *
10: * Contributors:
11: * Sebastian Thomschke - initial implementation.
12: *******************************************************************************/package net.sf.oval.test.constraints;
13:
14: import java.text.DateFormat;
15: import java.util.Calendar;
16:
17: import net.sf.oval.constraint.FutureCheck;
18:
19: /**
20: * @author Sebastian Thomschke
21: */
22: public class FutureTest extends AbstractContraintsTest {
23: public void testFuture() {
24: final FutureCheck check = new FutureCheck();
25: super .testCheck(check);
26: assertTrue(check.isSatisfied(null, null, null, null));
27:
28: Calendar cal = Calendar.getInstance();
29: cal.roll(Calendar.YEAR, 1);
30: assertTrue(check.isSatisfied(null, cal, null, null));
31: assertTrue(check.isSatisfied(null, cal.getTime(), null, null));
32: assertTrue(check.isSatisfied(null, DateFormat
33: .getDateTimeInstance().format(cal.getTime()), null,
34: null));
35:
36: cal.roll(Calendar.YEAR, -2);
37: assertFalse(check.isSatisfied(null, cal, null, null));
38: assertFalse(check.isSatisfied(null, cal.getTime(), null, null));
39: assertFalse(check.isSatisfied(null, DateFormat
40: .getDateTimeInstance().format(cal.getTime()), null,
41: null));
42:
43: assertFalse(check.isSatisfied(null, "bla", null, null));
44: }
45: }
|