1 18 23 24 package org.apache.roller.business; 25 26 import java.util.Map ; 27 import junit.framework.Test; 28 import junit.framework.TestCase; 29 import junit.framework.TestSuite; 30 import org.apache.commons.logging.Log; 31 import org.apache.commons.logging.LogFactory; 32 import org.apache.roller.TestUtils; 33 import org.apache.roller.model.PropertiesManager; 34 import org.apache.roller.model.RollerFactory; 35 import org.apache.roller.pojos.RollerPropertyData; 36 37 43 public class PropertiesTest extends TestCase { 44 45 public static Log log = LogFactory.getLog(PropertiesTest.class); 46 47 48 public PropertiesTest(String name) { 49 super(name); 50 } 51 52 53 public static Test suite() { 54 return new TestSuite(PropertiesTest.class); 55 } 56 57 58 public void setUp() throws Exception { 59 60 } 61 62 public void tearDown() throws Exception { 63 64 } 65 66 67 public void testProperiesCRUD() throws Exception { 68 69 PropertiesManager mgr = RollerFactory.getRoller().getPropertiesManager(); 71 TestUtils.endSession(true); 72 73 RollerPropertyData prop = null; 74 75 prop = mgr.getProperty("site.name"); 77 assertNotNull(prop); 78 79 prop.setValue("testtest"); 81 mgr.saveProperty(prop); 82 TestUtils.endSession(true); 83 84 prop = null; 86 prop = mgr.getProperty("site.name"); 87 assertNotNull(prop); 88 assertEquals("testtest", prop.getValue()); 89 90 Map props = mgr.getProperties(); 92 assertNotNull(props); 93 assertTrue(props.containsKey("site.name")); 94 95 prop = (RollerPropertyData) props.get("site.name"); 97 prop.setValue("foofoo"); 98 prop = (RollerPropertyData) props.get("site.description"); 99 prop.setValue("blahblah"); 100 mgr.saveProperties(props); 101 TestUtils.endSession(true); 102 103 props = mgr.getProperties(); 105 assertNotNull(props); 106 assertEquals("foofoo", ((RollerPropertyData)props.get("site.name")).getValue()); 107 assertEquals("blahblah", ((RollerPropertyData)props.get("site.description")).getValue()); 108 } 109 110 } 111 | Popular Tags |