KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > quartz > AnnualCalendarTest


1 /*
2  * Copyright 2004-2006 OpenSymphony
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy
6  * of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  * License for the specific language governing permissions and limitations
14  * under the License.
15  */

16 package org.quartz;
17
18 import java.util.Calendar JavaDoc;
19 import java.util.TimeZone JavaDoc;
20
21 import org.quartz.impl.calendar.AnnualCalendar;
22
23
24 /**
25  * Unit test for AnnualCalendar serialization backwards compatibility.
26  */

27 public class AnnualCalendarTest extends SerializationTestSupport {
28     private static final String JavaDoc[] VERSIONS = new String JavaDoc[] {"1.5.1"};
29     
30     private static final TimeZone JavaDoc EST_TIME_ZONE = TimeZone.getTimeZone("America/New_York");
31
32     /**
33      * Get the object to serialize when generating serialized file for future
34      * tests, and against which to validate deserialized object.
35      */

36     protected Object JavaDoc getTargetObject() {
37         AnnualCalendar c = new AnnualCalendar();
38         
39         c.setDescription("description");
40         
41         Calendar cal = Calendar.getInstance(EST_TIME_ZONE);
42         cal.clear();
43         cal.set(2005, Calendar.JANUARY, 20, 10, 5, 15);
44         
45         c.setDayExcluded(cal, true);
46         
47         return c;
48     }
49     
50     /**
51      * Get the Quartz versions for which we should verify
52      * serialization backwards compatibility.
53      */

54     protected String JavaDoc[] getVersions() {
55         return VERSIONS;
56     }
57     
58     /**
59      * Verify that the target object and the object we just deserialized
60      * match.
61      */

62     protected void verifyMatch(Object JavaDoc target, Object JavaDoc deserialized) {
63         AnnualCalendar targetCalendar = (AnnualCalendar)target;
64         AnnualCalendar deserializedCalendar = (AnnualCalendar)deserialized;
65         
66         assertNotNull(deserializedCalendar);
67         assertEquals(targetCalendar.getDescription(), deserializedCalendar.getDescription());
68         assertEquals(targetCalendar.getDaysExcluded(), deserializedCalendar.getDaysExcluded());
69         assertNull(deserializedCalendar.getTimeZone());
70     }
71 }
72
Popular Tags