source: tmcsimulator-scriptbuilder/trunk/test/scriptbuilder/structures/XMLFormatIntegrationTest.java @ 56

Revision 56, 1.6 KB checked in by bmcguffin, 9 years ago (diff)

Added test files and began filling them out. Added an integration test for XML loading and saving. Added several reference files to test against.

Line 
1package scriptbuilder.structures;
2
3import java.io.File;
4import java.io.IOException;
5import junit.framework.TestCase;
6import org.apache.commons.io.FileUtils;
7
8/**
9 *
10 * @author Bryan McGuffin
11 */
12public class XMLFormatIntegrationTest extends TestCase
13{
14
15    public XMLFormatIntegrationTest(String testName)
16    {
17        super(testName);
18    }
19
20    public void testXMLFileLoadSave()
21    {
22        try
23        {
24            File inFile = new File("test/scriptbuilder/structures/test_input_file.xml");
25            assertTrue(inFile.exists());
26
27            File outFile = new File("test/scriptbuilder/structures/test_output_file.xml");
28            if (outFile.exists())
29            {
30                outFile.delete();
31            }
32            assertFalse(outFile.exists());
33
34            outFile.createNewFile();
35
36            assertTrue(outFile.exists());
37
38            SimulationScript script = new SimulationScript();
39
40            //Read in from test_input_file.xml
41            script.loadScriptFromFile(inFile);
42
43            //Save to test_output_file.xml
44            script.saveScriptToFile(outFile);
45
46            assertTrue(inFile.exists());
47            assertTrue(outFile.exists());
48
49            //Check to see if the two files are identical
50            boolean result = FileUtils.contentEquals(inFile, outFile);
51           
52            assertTrue(result);
53           
54            //If so, data model does in fact read in all data and write it back in the correct format
55
56        }
57        catch (IOException ex)
58        {
59            fail("There was an IO exception. Check file names and locations.");
60        }
61    }
62}
Note: See TracBrowser for help on using the repository browser.