KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > roller > business > ConfigManagerTest


1 package org.roller.business;
2
3 import junit.framework.Test;
4 import junit.framework.TestSuite;
5
6 import org.roller.RollerException;
7 import org.roller.RollerPermissionsException;
8 import org.roller.model.ConfigManager;
9 import org.roller.pojos.RollerConfigData;
10 import org.roller.pojos.UserData;
11 import org.roller.pojos.WebsiteData;
12 import org.roller.util.OldRollerConfig;
13 import org.roller.RollerTestBase;
14  
15 ///////////////////////////////////////////////////////////////////////////////
16
/**
17  * Test Roller Config Management.
18  */

19 public class ConfigManagerTest extends RollerTestBase
20 {
21     String JavaDoc basedir = System.getProperty("basedir");
22     String JavaDoc path = "web/WEB-INF/roller-config.xml";
23     ConfigManager configMgr = null;
24     OldRollerConfig originalConfig;
25
26     //------------------------------------------------------------------------
27
public ConfigManagerTest()
28     {
29         super();
30     }
31
32     //------------------------------------------------------------------------
33
public ConfigManagerTest(String JavaDoc name)
34     {
35         super(name);
36     }
37
38     //------------------------------------------------------------------------
39
public static Test suite()
40     {
41         return new TestSuite(ConfigManagerTest.class);
42     }
43
44     //------------------------------------------------------------------------
45
public static void main(String JavaDoc args[])
46     {
47         junit.textui.TestRunner.run(ConfigManagerTest.class);
48     }
49
50     /**
51      * @see junit.framework.TestCase#setUp()
52      */

53     public void setUp() throws Exception JavaDoc
54     {
55         super.setUp();
56
57         configMgr = getRoller().getConfigManager();
58     }
59
60     public void tearDown() throws Exception JavaDoc
61     {
62         super.tearDown();
63     }
64
65     /* this is no longer a file, so this test is obsolete
66     public void testRollerConfigFile()
67     {
68         path = new java.io.File(basedir,path).getAbsolutePath();
69         RollerConfigFile bean = RollerConfigFile.readConfig( path );
70         assertNotNull("RollerConfigFile should not be null", bean);
71         assertEquals("# editor pages = 0", 0, bean.getEditorPages().size());
72     }
73     */

74
75     public void testReadFromFile() throws RollerException
76     {
77 /* This hoses my config every time. TODO:Fix
78         // first delete any existing - hold value in originalConfig
79         deleteConfig();
80
81         // create new RollerConfig from file at path
82         path = new java.io.File(basedir,path).getAbsolutePath();
83         getRoller().begin(UserData.SYSTEM_USER);
84         RollerConfig config = configMgr.readFromFile(path);
85         configMgr.storeRollerConfig(config);
86         assertNotNull("Got RollerConfig back", config);
87         getRoller().commit();
88
89         // now fetch it back out
90         getRoller().begin(UserData.SYSTEM_USER);
91         RollerConfig config2 = configMgr.getRollerConfig();
92         assertEquals("Same RollerConfig", config, config2);
93         getRoller().commit();
94
95         // delete our new config
96         if (originalConfig != null)
97         {
98             RollerConfig oldConfig = originalConfig;
99             deleteConfig();
100             getRoller().begin(UserData.SYSTEM_USER);
101             configMgr.storeRollerConfig(oldConfig);
102             getRoller().commit();
103         }
104 */

105     }
106
107 /*
108     private RollerConfig createNewConfig()
109     {
110         RollerConfig config = new RollerConfig();
111         config.setAbsoluteURL ( "http://www.rollerweblogger.org/" );
112         config.setRssUseCache ( Boolean.TRUE );
113         config.setRssCacheTime ( new Integer(4000) );
114         config.setNewUserAllowed ( Boolean.TRUE );
115         config.setAdminUsers ( "dave,lance,matt" );
116         config.setUserThemes ( "/themes" );
117         config.setEditorPages ( "editor.jsp" );
118         config.setEnableAggregator ( Boolean.FALSE );
119         config.setUploadEnabled ( Boolean.TRUE );
120         config.setUploadMaxDirMB ( new BigDecimal("5.0") );
121         config.setUploadMaxFileMB ( new BigDecimal("0.5") );
122         config.setUploadAllow ( "gif,jpg" );
123         config.setUploadForbid ( "" );
124         config.setUploadDir ( null );
125         config.setUploadPath ( "/resources" );
126         config.setMemDebug ( Boolean.FALSE );
127         config.setAutoformatComments ( Boolean.FALSE );
128         config.setEscapeCommentHtml ( Boolean.FALSE );
129         config.setEmailComments ( Boolean.FALSE );
130         config.setEnableLinkback ( Boolean.FALSE );
131         config.setSiteName ( "RollerConfig Test" );
132         config.setSiteDescription ( "JUnit Test of RollerConfig Manager" );
133         config.setEmailAddress ( "lance@brainopolis.com" );
134         config.setIndexDir ( "/var/lucene-index" );
135         return config;
136     }
137
138     private void deleteConfig() throws RollerException
139     {
140         getRoller().begin(UserData.SYSTEM_USER);
141         originalConfig = configMgr.getRollerConfig();
142         if (originalConfig != null)
143         {
144             ((ConfigManagerImpl)configMgr).removeRollerConfig(originalConfig.getId());
145         }
146         getRoller().commit();
147     }
148 */

149
150 }
Popular Tags