001: package de.java2html.properties.test;
002:
003: import de.java2html.javasource.JavaSourceType;
004: import de.java2html.options.HorizontalAlignment;
005: import de.java2html.options.JavaSourceConversionOptions;
006: import de.java2html.options.JavaSourceStyleEntry;
007: import de.java2html.options.JavaSourceStyleTable;
008: import de.java2html.properties.ConversionOptionsPropertiesReader;
009: import de.java2html.properties.ConversionOptionsPropertiesWriter;
010: import de.java2html.properties.IllegalPropertyValueException;
011: import de.java2html.util.RGB;
012: import junit.framework.TestCase;
013:
014: /**
015: * @author Markus
016: */
017: public class ConversionOptionsPropertiesPersistenceTest extends
018: TestCase {
019: private JavaSourceConversionOptions options;
020:
021: protected void setUp() throws Exception {
022: options = JavaSourceConversionOptions.getDefault();
023: }
024:
025: public void testPersistDefaultOptions()
026: throws IllegalPropertyValueException {
027: assertEquals(options, writeAndRead(options));
028: }
029:
030: public void testPersistDefaultStyleTableName()
031: throws IllegalPropertyValueException {
032: JavaSourceStyleTable styleTable = JavaSourceStyleTable
033: .getDefaultKawaStyleTable();
034: options.setStyleTable(styleTable);
035: assertEquals(styleTable.getName(), writeAndRead(options)
036: .getStyleTable().getName());
037: }
038:
039: public void testPersistTabSize()
040: throws IllegalPropertyValueException {
041: options.setTabSize(11);
042: assertEquals(11, writeAndRead(options).getTabSize());
043: }
044:
045: public void testPersistShowLineNumbers()
046: throws IllegalPropertyValueException {
047: options.setShowLineNumbers(!options.isShowLineNumbers());
048: assertEquals(options.isShowLineNumbers(), writeAndRead(options)
049: .isShowLineNumbers());
050: }
051:
052: public void testPersistShowJava2HtmlLink()
053: throws IllegalPropertyValueException {
054: options.setShowJava2HtmlLink(!options.isShowJava2HtmlLink());
055: assertEquals(options.isShowJava2HtmlLink(), writeAndRead(
056: options).isShowJava2HtmlLink());
057: }
058:
059: public void testPersistShowFileName()
060: throws IllegalPropertyValueException {
061: options.setShowFileName(!options.isShowFileName());
062: assertEquals(options.isShowFileName(), writeAndRead(options)
063: .isShowFileName());
064: }
065:
066: public void testPersistShowTableBorder()
067: throws IllegalPropertyValueException {
068: options.setShowTableBorder(!options.isShowTableBorder());
069: assertEquals(options.isShowTableBorder(), writeAndRead(options)
070: .isShowTableBorder());
071: }
072:
073: public void testPersistHorizontalAlignment()
074: throws IllegalPropertyValueException {
075: options.setHorizontalAlignment(HorizontalAlignment.RIGHT);
076: assertEquals(options.getHorizontalAlignment(), writeAndRead(
077: options).getHorizontalAlignment());
078: }
079:
080: public void testPersistStyleEntry1()
081: throws IllegalPropertyValueException {
082: JavaSourceStyleEntry entry = new JavaSourceStyleEntry(
083: RGB.MAGENTA, true, false);
084: options.getStyleTable().put(JavaSourceType.COMMENT_LINE, entry);
085: assertEquals(entry, writeAndRead(options).getStyleTable().get(
086: JavaSourceType.COMMENT_LINE));
087: }
088:
089: public void testPersistStyleEntry2()
090: throws IllegalPropertyValueException {
091: JavaSourceStyleEntry entry = new JavaSourceStyleEntry(
092: RGB.GREEN, false, true);
093: options.getStyleTable().put(JavaSourceType.COMMENT_LINE, entry);
094: assertEquals(entry, writeAndRead(options).getStyleTable().get(
095: JavaSourceType.COMMENT_LINE));
096: }
097:
098: private JavaSourceConversionOptions writeAndRead(
099: JavaSourceConversionOptions options)
100: throws IllegalPropertyValueException {
101: return new ConversionOptionsPropertiesReader()
102: .read(new ConversionOptionsPropertiesWriter()
103: .write(options));
104: }
105: }
|