KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > java2html > properties > test > ConversionOptionsPropertiesPersistenceTest


1 package de.java2html.properties.test;
2
3 import de.java2html.javasource.JavaSourceType;
4 import de.java2html.options.HorizontalAlignment;
5 import de.java2html.options.JavaSourceConversionOptions;
6 import de.java2html.options.JavaSourceStyleEntry;
7 import de.java2html.options.JavaSourceStyleTable;
8 import de.java2html.properties.ConversionOptionsPropertiesReader;
9 import de.java2html.properties.ConversionOptionsPropertiesWriter;
10 import de.java2html.properties.IllegalPropertyValueException;
11 import de.java2html.util.RGB;
12 import junit.framework.TestCase;
13
14 /**
15  * @author Markus
16  */

17 public class ConversionOptionsPropertiesPersistenceTest extends TestCase {
18   private JavaSourceConversionOptions options;
19   
20   protected void setUp() throws Exception JavaDoc {
21     options = JavaSourceConversionOptions.getDefault();
22   }
23   
24   public void testPersistDefaultOptions() throws IllegalPropertyValueException {
25     assertEquals(options, writeAndRead(options));
26   }
27   
28   public void testPersistDefaultStyleTableName() throws IllegalPropertyValueException {
29     JavaSourceStyleTable styleTable = JavaSourceStyleTable.getDefaultKawaStyleTable();
30     options.setStyleTable(styleTable);
31     assertEquals(styleTable.getName(), writeAndRead(options).getStyleTable().getName());
32   }
33
34   public void testPersistTabSize() throws IllegalPropertyValueException {
35     options.setTabSize(11);
36     assertEquals(11, writeAndRead(options).getTabSize());
37   }
38
39   public void testPersistShowLineNumbers() throws IllegalPropertyValueException {
40     options.setShowLineNumbers(!options.isShowLineNumbers());
41     assertEquals(options.isShowLineNumbers(), writeAndRead(options).isShowLineNumbers());
42   }
43   
44   public void testPersistShowJava2HtmlLink() throws IllegalPropertyValueException {
45     options.setShowJava2HtmlLink(!options.isShowJava2HtmlLink());
46     assertEquals(options.isShowJava2HtmlLink(), writeAndRead(options).isShowJava2HtmlLink());
47   }
48   
49   public void testPersistShowFileName() throws IllegalPropertyValueException {
50     options.setShowFileName(!options.isShowFileName());
51     assertEquals(options.isShowFileName(), writeAndRead(options).isShowFileName());
52   }
53   
54   public void testPersistShowTableBorder() throws IllegalPropertyValueException {
55     options.setShowTableBorder(!options.isShowTableBorder());
56     assertEquals(options.isShowTableBorder(), writeAndRead(options).isShowTableBorder());
57   }
58   
59   public void testPersistHorizontalAlignment() throws IllegalPropertyValueException {
60     options.setHorizontalAlignment(HorizontalAlignment.RIGHT);
61     assertEquals(options.getHorizontalAlignment(), writeAndRead(options).getHorizontalAlignment());
62   }
63   
64   public void testPersistStyleEntry1() throws IllegalPropertyValueException {
65     JavaSourceStyleEntry entry = new JavaSourceStyleEntry(RGB.MAGENTA, true, false);
66     options.getStyleTable().put(JavaSourceType.COMMENT_LINE, entry);
67     assertEquals(entry, writeAndRead(options).getStyleTable().get(JavaSourceType.COMMENT_LINE));
68   }
69
70   public void testPersistStyleEntry2() throws IllegalPropertyValueException {
71     JavaSourceStyleEntry entry = new JavaSourceStyleEntry(RGB.GREEN, false, true);
72     options.getStyleTable().put(JavaSourceType.COMMENT_LINE, entry);
73     assertEquals(entry, writeAndRead(options).getStyleTable().get(JavaSourceType.COMMENT_LINE));
74   }
75   
76   private JavaSourceConversionOptions writeAndRead(JavaSourceConversionOptions options) throws IllegalPropertyValueException {
77     return new ConversionOptionsPropertiesReader().read(new ConversionOptionsPropertiesWriter().write(options));
78   }
79 }
Popular Tags