01: package net.sourceforge.jaxor.util.tests;
02:
03: import junit.framework.TestCase;
04: import net.sourceforge.jaxor.util.JaxorDate;
05: import net.sourceforge.jaxor.util.JaxorTimestamp;
06:
07: import java.sql.Date;
08: import java.sql.Timestamp;
09:
10: /**
11: * Created By: Mike
12: * Date: Feb 9, 2004
13: * Time: 12:13:07 AM
14: *
15: * Last Checkin: $Author: mrettig $
16: * Date: $Date: 2004/02/10 02:50:39 $
17: * Revision: $Revision: 1.3 $
18: */
19: public class JaxorDateTest extends TestCase {
20:
21: public void testCallingUpdate() {
22: MockFieldAdapter mock = new MockFieldAdapter();
23: mock.setValue(new Date(System.currentTimeMillis()));
24: //field will unwrap the jaxordate and create a new object, so we must retrieve it.
25: JaxorDate d = (JaxorDate) mock.getValue();
26: d.setDate(1);
27: d.setMonth(4);
28: d.setTime(6);
29: d.setYear(7);
30: assertEquals(5, mock.changeCount);
31:
32: mock.setValue(null);//should register change
33: d.setTime(7);//should not register change
34:
35: assertEquals(6, mock.changeCount);
36: }
37:
38: public void testCallingUpdateOnTimestamp() {
39: MockFieldAdapter mock = new MockFieldAdapter();
40: mock.setValue(new Timestamp(System.currentTimeMillis()));
41: JaxorTimestamp d = (JaxorTimestamp) mock.getValue();
42: d.setDate(1);
43: d.setHours(2);
44: d.setMinutes(3);
45: d.setMonth(4);
46: d.setNanos(5);
47: d.setSeconds(6);
48: d.setTime(7);
49: d.setYear(8);
50: assertEquals(9, mock.changeCount);
51:
52: mock.setValue(null);//should register change
53: d.setTime(7);//should not register change
54:
55: assertEquals(10, mock.changeCount);
56: }
57:
58: }
|