01: /*
02: * UpdateCheckTest.java
03: *
04: * This file is part of SQL Workbench/J, http://www.sql-workbench.net
05: *
06: * Copyright 2002-2008, Thomas Kellerer
07: * No part of this code maybe reused without the permission of the author
08: *
09: * To contact the author please send an email to: support@sql-workbench.net
10: *
11: */
12: package workbench.util;
13:
14: import java.util.Date;
15: import junit.framework.TestCase;
16:
17: /**
18: *
19: * @author support@sql-workbench.net
20: */
21: public class UpdateCheckTest extends TestCase {
22:
23: public UpdateCheckTest(String testName) {
24: super (testName);
25: }
26:
27: @SuppressWarnings("deprecation")
28: public void testNeedCheck() {
29: try {
30: UpdateCheck check = new UpdateCheck();
31: int interval = 7;
32: Date last = new Date(2007, 3, 10);
33: Date now = new Date(2007, 3, 10);
34: boolean need = check.needCheck(interval, now, last);
35: assertFalse(need);
36:
37: now = new Date(2007, 3, 16);
38: need = check.needCheck(interval, now, last);
39: assertFalse(need);
40:
41: now = new Date(2007, 3, 17);
42: need = check.needCheck(interval, now, last);
43: assertTrue(need);
44:
45: need = check.needCheck(interval, now, null);
46: assertTrue(need);
47:
48: now = new Date(2007, 3, 10);
49: need = check.needCheck(1, now, last);
50: assertFalse(need);
51:
52: now = new Date(2007, 3, 11);
53: need = check.needCheck(1, now, last);
54: assertTrue(need);
55: } catch (Exception e) {
56: e.printStackTrace();
57: fail(e.getMessage());
58: }
59: }
60:
61: }
|