1 package org.apache.log4j.chainsaw;
2
3 import com.thoughtworks.xstream.XStream;
4 import com.thoughtworks.xstream.io.xml.DomDriver;
5
6 import junit.framework.TestCase;
7
8 public class LogPanelPreferenceModelTest extends TestCase {
9
10 public void testLogPanelPreferenceModelSerialization() throws Exception {
11 LogPanelPreferenceModel model = new LogPanelPreferenceModel();
12
13
14 /***
15 * First modify the model from it's default state so we know we're actually storing
16 * something 'different' for deserialization tests
17 */
18
19 model.setLevelIcons(!model.isLevelIcons());
20 model.setDateFormatPattern("yyyyDDmm");
21 model.setLoggerPrecision("FATAL");
22 model.setLogTreePanelVisible(!model.isLogTreePanelVisible());
23 model.setScrollToBottom(model.isScrollToBottom());
24 model.setToolTips(!model.isToolTips());
25
26 XStream stream = new XStream(new DomDriver());
27 String xml = stream.toXML(model);
28
29
30 LogPanelPreferenceModel restored = (LogPanelPreferenceModel) stream.fromXML(xml);
31
32 assertEquals(model.isLevelIcons(), restored.isLevelIcons());
33 assertEquals(model.getDateFormatPattern(), restored.getDateFormatPattern());
34 assertEquals(model.getLoggerPrecision(), restored.getLoggerPrecision());
35 assertEquals(model.isLogTreePanelVisible(), restored.isLogTreePanelVisible());
36 assertEquals(model.isScrollToBottom(), restored.isScrollToBottom());
37 assertEquals(model.isToolTips(), restored.isToolTips());
38
39
40
41 }
42 }