1 package org.apache.commons.jcs.auxiliary.disk.jdbc.mysql.util;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.text.ParseException;
23 import java.util.Date;
24
25 import junit.framework.TestCase;
26
27
28
29
30
31
32 public class ScheduleParserUtilUnitTest
33 extends TestCase
34 {
35
36
37
38
39 public void testGetDatesWithNullInput()
40 {
41 try
42 {
43 ScheduleParser.createDatesForSchedule( null );
44
45 fail( "Should have thrown an exception" );
46 }
47 catch ( ParseException e )
48 {
49
50 }
51 }
52
53
54
55
56 public void testGetDateWithNullInput()
57 {
58 try
59 {
60 ScheduleParser.getDateForSchedule( null );
61
62 fail( "Should have thrown an exception" );
63 }
64 catch ( ParseException e )
65 {
66
67 }
68 }
69
70
71
72
73
74 public void testGetsDatesSingle()
75 throws ParseException
76 {
77 String schedule = "12:34:56";
78 Date[] dates = ScheduleParser.createDatesForSchedule( schedule );
79
80 assertEquals( "Wrong number of dates returned.", 1, dates.length );
81 }
82
83
84
85
86 public void testGetsDatesMultiple()
87 throws ParseException
88 {
89 String schedule = "12:34:56,03:51:00,12:34:12";
90 Date[] dates = ScheduleParser.createDatesForSchedule( schedule );
91
92 assertEquals( "Wrong number of dates returned.", 3, dates.length );
93 }
94
95
96
97
98 public void testGetDatesMalformedNoColon()
99 {
100 try
101 {
102 String schedule = "12:34:56,03:51:00,123234";
103 ScheduleParser.createDatesForSchedule( schedule );
104
105 fail( "Should have thrown an exception for a malformed date" );
106 }
107 catch ( ParseException e )
108 {
109
110 }
111 }
112
113
114
115 public void testGetDatesMalformedNan()
116 {
117 try
118 {
119 String schedule = "12:34:56,03:51:00,aa:12:12";
120 ScheduleParser.createDatesForSchedule( schedule );
121
122 fail( "Should have thrown an exception for a malformed date" );
123 }
124 catch ( ParseException e )
125 {
126
127 }
128 }
129 }