1 /************************************************************************* |
|
2 /* DateTest.java - Test java.sql.Date |
|
3 /* |
|
4 /* Copyright (c) 2003 Dalibor Topic (robilad@yahoo.de) |
|
5 /* |
|
6 /* This program is free software; you can redistribute it and/or modify |
|
7 /* it under the terms of the GNU General Public License as published |
|
8 /* by the Free Software Foundation, either version 2 of the License, or |
|
9 /* (at your option) any later version. |
|
10 /* |
|
11 /* This program is distributed in the hope that it will be useful, but |
|
12 /* WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 /* GNU General Public License for more details. |
|
15 /* |
|
16 /* You should have received a copy of the GNU General Public License |
|
17 /* along with this program; if not, write to the Free Software Foundation |
|
18 /* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA |
|
19 /*************************************************************************/ |
|
20 |
|
21 // Tags: JDK1.2 |
|
22 |
|
23 package gnu.testlet.java.sql.Date; |
|
24 |
|
25 import gnu.testlet.Testlet; |
|
26 import gnu.testlet.TestHarness; |
|
27 |
|
28 import java.sql.*; |
|
29 |
|
30 public class DateTest implements Testlet |
|
31 { |
|
32 |
|
33 public void |
|
34 test(TestHarness harness) |
|
35 { |
|
36 Date d = new Date(0); |
|
37 |
|
38 try { |
|
39 d.getHours(); |
|
40 harness.check(false, "getHours"); |
|
41 } |
|
42 catch (IllegalArgumentException e) { |
|
43 harness.check(true, "getHours"); |
|
44 } |
|
45 |
|
46 try { |
|
47 d.getMinutes(); |
|
48 harness.check(false, "getMinutes"); |
|
49 } |
|
50 catch (IllegalArgumentException e) { |
|
51 harness.check(true, "getMinutes"); |
|
52 } |
|
53 |
|
54 try { |
|
55 d.getSeconds(); |
|
56 harness.check(false, "getSeconds"); |
|
57 } |
|
58 catch (IllegalArgumentException e) { |
|
59 harness.check(true, "getSeconds"); |
|
60 } |
|
61 |
|
62 try { |
|
63 d.setHours(0); |
|
64 harness.check(false, "setHours"); |
|
65 } |
|
66 catch (IllegalArgumentException e) { |
|
67 harness.check(true, "setHours"); |
|
68 } |
|
69 |
|
70 try { |
|
71 d.setMinutes(0); |
|
72 harness.check(false, "setMinutes"); |
|
73 } |
|
74 catch (IllegalArgumentException e) { |
|
75 harness.check(true, "setMinutes"); |
|
76 } |
|
77 |
|
78 try { |
|
79 d.setSeconds(0); |
|
80 harness.check(false, "setSeconds"); |
|
81 } |
|
82 catch (IllegalArgumentException e) { |
|
83 harness.check(true, "setSeconds"); |
|
84 } |
|
85 |
|
86 try { |
|
87 Date.valueOf("NoSuchDate"); |
|
88 harness.check(false, "valueOf"); |
|
89 } |
|
90 catch (IllegalArgumentException e) { |
|
91 harness.check(true, "valueOf"); |
|
92 } |
|
93 } |
|
94 } |
|
95 |
|