01: /*
02: * Copyright (C) 2005 Joe Walnes.
03: * Copyright (C) 2006, 2007 XStream Committers.
04: * All rights reserved.
05: *
06: * The software in this package is published under the terms of the BSD
07: * style license a copy of which has been included with this distribution in
08: * the LICENSE.txt file.
09: *
10: * Created on 30. April 2005 by Joe Walnes
11: */
12: package com.thoughtworks.acceptance;
13:
14: import javax.swing.DefaultListModel;
15: import javax.swing.JList;
16: import javax.swing.JTable;
17: import javax.swing.LookAndFeel;
18: import javax.swing.plaf.metal.MetalLookAndFeel;
19:
20: public class SwingTest extends AbstractAcceptanceTest {
21:
22: // JTable is one of the nastiest components to serialize. If this works, we're in good shape :)
23:
24: public void testJTable() {
25: // Note: JTable does not have a sensible .equals() method, so we compare the XML instead.
26: JTable original = new JTable();
27: String originalXml = xstream.toXML(original);
28:
29: JTable deserialized = (JTable) xstream.fromXML(originalXml);
30: String deserializedXml = xstream.toXML(deserialized);
31:
32: assertEquals(originalXml, deserializedXml);
33: }
34:
35: public void testDefaultListModel() {
36: final DefaultListModel original = new DefaultListModel();
37: final JList list = new JList();
38: list.setModel(original);
39:
40: String originalXml = xstream.toXML(original);
41:
42: DefaultListModel deserialized = (DefaultListModel) xstream
43: .fromXML(originalXml);
44: String deserializedXml = xstream.toXML(deserialized);
45:
46: assertEquals(originalXml, deserializedXml);
47:
48: list.setModel(deserialized);
49: }
50:
51: public void testMetalLookAndFeel() {
52: LookAndFeel plaf = new MetalLookAndFeel();
53: String originalXml = xstream.toXML(plaf);
54: assertBothWays(plaf, originalXml);
55: }
56: }
|