01: package org.dbbrowser.ui.helper;
02:
03: import infrastructure.logging.Log;
04:
05: import java.io.IOException;
06: import java.util.ArrayList;
07: import java.util.List;
08: import org.dbbrowser.ui.KeyBinding;
09: import junit.framework.TestCase;
10:
11: public class KeyBindingsSerializerTest extends TestCase {
12: private List listOfKeyBindings = new ArrayList();
13:
14: public KeyBindingsSerializerTest(String name) {
15: super (name);
16:
17: KeyBinding keyBinding1 = new KeyBinding("Test1",
18: new Integer(10), new Integer(0), KeyBinding.HELP);
19: KeyBinding keyBinding2 = new KeyBinding("Test2",
20: new Integer(11), new Integer(1),
21: KeyBinding.FILE_CONNECT);
22: KeyBinding keyBinding3 = new KeyBinding("Test3",
23: new Integer(12), new Integer(2),
24: KeyBinding.EDIT_PREFERENCES);
25: KeyBinding keyBinding4 = new KeyBinding("Test4",
26: new Integer(13), new Integer(3),
27: KeyBinding.FILE_OPEN_SQL_SCRIPT_FILE);
28:
29: listOfKeyBindings.add(keyBinding1);
30: listOfKeyBindings.add(keyBinding2);
31: listOfKeyBindings.add(keyBinding3);
32: listOfKeyBindings.add(keyBinding4);
33: }
34:
35: public void testKeyBindingsSerializer() {
36: try {
37: Log.getInstance().debugMessage(
38: "*** Serializing key bindings *** ",
39: this .getClass().getName());
40: KeyBindingsSerializer
41: .serializeKeyBindings(listOfKeyBindings);
42: } catch (IOException exc) {
43: fail(exc.getMessage());
44: }
45: }
46:
47: public void testKeyBindingsDeSerializer() {
48: try {
49: Log.getInstance().debugMessage(
50: "*** DeSerializing key bindings *** ",
51: this .getClass().getName());
52:
53: List listOfDeserializedKeyBindings = KeyBindingsSerializer
54: .deserializeKeyBindings();
55:
56: assertEquals(
57: "KeyBindingsSerializerTest.testKeyBindingsDeSerializer failed - sizes of list is different",
58: listOfDeserializedKeyBindings.size(),
59: listOfKeyBindings.size());
60:
61: assertEquals(
62: "KeyBindingsSerializerTest.testKeyBindingsDeSerializer failed - lists are different",
63: listOfDeserializedKeyBindings, listOfKeyBindings);
64: } catch (IOException exc) {
65: fail(exc.getMessage());
66: }
67: }
68: }
|