package scriptbuilder.structures; import java.io.File; import java.io.IOException; import junit.framework.TestCase; import org.apache.commons.io.FileUtils; /** * * @author Bryan McGuffin */ public class XMLFormatIntegrationTest extends TestCase { public XMLFormatIntegrationTest(String testName) { super(testName); } public void testXMLFileLoadSave() { try { File inFile = new File("test/scriptbuilder/structures/test_input_file.xml"); assertTrue(inFile.exists()); File outFile = new File("test/scriptbuilder/structures/test_output_file.xml"); if (outFile.exists()) { outFile.delete(); } assertFalse(outFile.exists()); outFile.createNewFile(); assertTrue(outFile.exists()); SimulationScript script = new SimulationScript(); //Read in from test_input_file.xml script.loadScriptFromFile(inFile); //Save to test_output_file.xml script.saveScriptToFile(outFile); assertTrue(inFile.exists()); assertTrue(outFile.exists()); //Check to see if the two files are identical boolean result = FileUtils.contentEquals(inFile, outFile); assertTrue(result); //If so, data model does in fact read in all data and write it back in the correct format } catch (IOException ex) { fail("There was an IO exception. Check file names and locations."); } } }