1 37 package net.sourceforge.cruisecontrol.config; 38 39 import junit.framework.TestCase; 40 import net.sourceforge.cruisecontrol.ConfigManager; 41 42 import java.io.BufferedWriter ; 43 import java.io.File ; 44 import java.io.FileWriter ; 45 import java.io.IOException ; 46 47 public class XMLConfigManagerTest extends TestCase { 48 private File configurationFile; 49 50 protected void setUp() throws Exception { 51 super.setUp(); 52 53 configurationFile = File.createTempFile("config", "xml"); 54 configurationFile.deleteOnExit(); 55 writeConfigurationFile( 56 "<cruisecontrol><project name=\"DOESNTMATTER\"><schedule>" 57 + "<ant/></schedule></project></cruisecontrol>\n"); 58 } 59 60 public void testShouldStoreUpdatedMD5HashWhenItChanges() throws Exception { 61 ConfigManager configManager = new XMLConfigManager(configurationFile); 62 63 assertFalse(configManager.reloadIfNecessary()); 64 65 writeConfigurationFile( 66 "<cruisecontrol><project name=\"DOESNTMATTER\"><schedule interval=\"30\">" 67 + "<ant/></schedule></project></cruisecontrol>"); 68 assertTrue(configManager.reloadIfNecessary()); 69 70 assertFalse(configManager.reloadIfNecessary()); 71 } 72 73 private void writeConfigurationFile(String contents) throws IOException { 74 StringBuffer configuration = new StringBuffer (); 75 configuration.append(contents); 76 BufferedWriter writer = new BufferedWriter (new FileWriter (configurationFile)); 77 writer.write(configuration.toString()); 78 writer.close(); 79 } 80 } 81 | Popular Tags |