KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > quartz > JobDataMapTest


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
19 /**
20  * Unit test for JobDataMap serialization backwards compatibility.
21  */

22 public class JobDataMapTest extends SerializationTestSupport {
23     private static final String JavaDoc[] VERSIONS = new String JavaDoc[] {"1.4.5", "1.5.1"};
24     
25     /**
26      * Get the object to serialize when generating serialized file for future
27      * tests, and against which to validate deserialized object.
28      */

29     protected Object JavaDoc getTargetObject() {
30         JobDataMap m = new JobDataMap();
31         m.put("key", new Integer JavaDoc(5));
32         return m;
33     }
34     
35     /**
36      * Get the Quartz versions for which we should verify
37      * serialization backwards compatibility.
38      */

39     protected String JavaDoc[] getVersions() {
40         return VERSIONS;
41     }
42     
43     /**
44      * Verify that the target object and the object we just deserialized
45      * match.
46      */

47     protected void verifyMatch(Object JavaDoc target, Object JavaDoc deserialized) {
48         JobDataMap targetMap = (JobDataMap)target;
49         JobDataMap deserializedMap = (JobDataMap)deserialized;
50         
51         assertNotNull(deserializedMap);
52         assertEquals(targetMap.getWrappedMap(), deserializedMap.getWrappedMap());
53         assertEquals(targetMap.getAllowsTransientData(), deserializedMap.getAllowsTransientData());
54         assertEquals(targetMap.isDirty(), deserializedMap.isDirty());
55     }
56 }
57
Popular Tags