📄 configmanagertest.java
字号:
package org.roller.business;import junit.framework.Test;import junit.framework.TestSuite; import org.roller.RollerException;import org.roller.RollerPermissionsException;import org.roller.model.ConfigManager;import org.roller.pojos.RollerConfigData;import org.roller.pojos.UserData;import org.roller.pojos.WebsiteData;import org.roller.util.OldRollerConfig;import org.roller.RollerTestBase; ////////////////////////////////////////////////////////////////////////////////** * Test Roller Config Management. */public class ConfigManagerTest extends RollerTestBase{ String basedir = System.getProperty("basedir"); String path = "web/WEB-INF/roller-config.xml"; ConfigManager configMgr = null; OldRollerConfig originalConfig; //------------------------------------------------------------------------ public ConfigManagerTest() { super(); } //------------------------------------------------------------------------ public ConfigManagerTest(String name) { super(name); } //------------------------------------------------------------------------ public static Test suite() { return new TestSuite(ConfigManagerTest.class); } //------------------------------------------------------------------------ public static void main(String args[]) { junit.textui.TestRunner.run(ConfigManagerTest.class); } /** * @see junit.framework.TestCase#setUp() */ public void setUp() throws Exception { super.setUp(); configMgr = getRoller().getConfigManager(); } public void tearDown() throws Exception { super.tearDown(); } /* this is no longer a file, so this test is obsolete public void testRollerConfigFile() { path = new java.io.File(basedir,path).getAbsolutePath(); RollerConfigFile bean = RollerConfigFile.readConfig( path ); assertNotNull("RollerConfigFile should not be null", bean); assertEquals("# editor pages = 0", 0, bean.getEditorPages().size()); } */ public void testReadFromFile() throws RollerException {/* This hoses my config every time. TODO:Fix // first delete any existing - hold value in originalConfig deleteConfig(); // create new RollerConfig from file at path path = new java.io.File(basedir,path).getAbsolutePath(); getRoller().begin(UserData.SYSTEM_USER); RollerConfig config = configMgr.readFromFile(path); configMgr.storeRollerConfig(config); assertNotNull("Got RollerConfig back", config); getRoller().commit(); // now fetch it back out getRoller().begin(UserData.SYSTEM_USER); RollerConfig config2 = configMgr.getRollerConfig(); assertEquals("Same RollerConfig", config, config2); getRoller().commit(); // delete our new config if (originalConfig != null) { RollerConfig oldConfig = originalConfig; deleteConfig(); getRoller().begin(UserData.SYSTEM_USER); configMgr.storeRollerConfig(oldConfig); getRoller().commit(); }*/ }/* private RollerConfig createNewConfig() { RollerConfig config = new RollerConfig(); config.setAbsoluteURL ( "http://www.rollerweblogger.org/" ); config.setRssUseCache ( Boolean.TRUE ); config.setRssCacheTime ( new Integer(4000) ); config.setNewUserAllowed ( Boolean.TRUE ); config.setAdminUsers ( "dave,lance,matt" ); config.setUserThemes ( "/themes" ); config.setEditorPages ( "editor.jsp" ); config.setEnableAggregator ( Boolean.FALSE ); config.setUploadEnabled ( Boolean.TRUE ); config.setUploadMaxDirMB ( new BigDecimal("5.0") ); config.setUploadMaxFileMB ( new BigDecimal("0.5") ); config.setUploadAllow ( "gif,jpg" ); config.setUploadForbid ( "" ); config.setUploadDir ( null ); config.setUploadPath ( "/resources" ); config.setMemDebug ( Boolean.FALSE ); config.setAutoformatComments ( Boolean.FALSE ); config.setEscapeCommentHtml ( Boolean.FALSE ); config.setEmailComments ( Boolean.FALSE ); config.setEnableLinkback ( Boolean.FALSE ); config.setSiteName ( "RollerConfig Test" ); config.setSiteDescription ( "JUnit Test of RollerConfig Manager" ); config.setEmailAddress ( "lance@brainopolis.com" ); config.setIndexDir ( "/var/lucene-index" ); return config; } private void deleteConfig() throws RollerException { getRoller().begin(UserData.SYSTEM_USER); originalConfig = configMgr.getRollerConfig(); if (originalConfig != null) { ((ConfigManagerImpl)configMgr).removeRollerConfig(originalConfig.getId()); } getRoller().commit(); }*/}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -