1 package org.apache.commons.jcs3.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 public class ScheduleParserUtilUnitTest
31 extends TestCase
32 {
33
34
35
36
37 public void testGetDatesWithNullInput()
38 {
39 try
40 {
41 ScheduleParser.createDatesForSchedule( null );
42
43 fail( "Should have thrown an exception" );
44 }
45 catch ( final ParseException e )
46 {
47
48 }
49 }
50
51
52
53
54 public void testGetDateWithNullInput()
55 {
56 try
57 {
58 ScheduleParser.getDateForSchedule( null );
59
60 fail( "Should have thrown an exception" );
61 }
62 catch ( final ParseException e )
63 {
64
65 }
66 }
67
68
69
70
71
72 public void testGetsDatesSingle()
73 throws ParseException
74 {
75 final String schedule = "12:34:56";
76 final Date[] dates = ScheduleParser.createDatesForSchedule( schedule );
77
78 assertEquals( "Wrong number of dates returned.", 1, dates.length );
79 }
80
81
82
83
84 public void testGetsDatesMultiple()
85 throws ParseException
86 {
87 final String schedule = "12:34:56,03:51:00,12:34:12";
88 final Date[] dates = ScheduleParser.createDatesForSchedule( schedule );
89
90 assertEquals( "Wrong number of dates returned.", 3, dates.length );
91 }
92
93
94
95
96 public void testGetDatesMalformedNoColon()
97 {
98 try
99 {
100 final String schedule = "12:34:56,03:51:00,123234";
101 ScheduleParser.createDatesForSchedule( schedule );
102
103 fail( "Should have thrown an exception for a malformed date" );
104 }
105 catch ( final ParseException e )
106 {
107
108 }
109 }
110
111
112
113 public void testGetDatesMalformedNan()
114 {
115 try
116 {
117 final String schedule = "12:34:56,03:51:00,aa:12:12";
118 ScheduleParser.createDatesForSchedule( schedule );
119
120 fail( "Should have thrown an exception for a malformed date" );
121 }
122 catch ( final ParseException e )
123 {
124
125 }
126 }
127 }