@@ -0,0 +1,1526 @@
+package javaphone;%0A%0Aimport java.io.File;%0Aimport java.util.ArrayList;%0Aimport java.util.HashMap;%0Aimport org.junit.After;%0Aimport org.junit.AfterClass;%0Aimport org.junit.Before;%0Aimport org.junit.BeforeClass;%0Aimport org.junit.Test;%0Aimport static org.junit.Assert.*;%0A%0A/**%0A * Tests for class DataFileIO.%0A * %0A * @author iGroup%0A */%0Apublic class DataFileIOTest %7B%0A%0A    public DataFileIOTest() %7B%0A    %7D%0A%0A    /**%0A     * Test for methods write and read of class DataFileIO. A file test.xml is%0A     * created, some data is written to it. Data is then read from file and%0A     * compared to what was to be written. File is deleted.%0A     */%0A    @Test%0A    public void testWriteRead() %7B%0A        ArrayList%3CHashMap%3E fileData = new ArrayList%3C%3E();%0A        HashMap object1 = new HashMap();%0A        HashMap object2 = new HashMap();%0A%0A        object1.put(%22Price%22, 123.12);%0A        object1.put(%22ProductName%22, %22A great Java program%22);%0A%0A        object2.put(%22customerName%22, %22John Doe%22);%0A        object2.put(%22customerAge%22, 45);%0A%0A        fileData.add(object1);%0A        fileData.add(object2);%0A%0A        DataFileIO testFile = new DataFileIO(%22test.xml%22, %22objects%22, %22object%22);%0A        assert(testFile.write(fileData));%0A        %0A        assertEquals(testFile.read().get(0).get(%22Price%22), object1.get(%22Price%22).toString());%0A        assertEquals(testFile.read().get(1).get(%22customerName%22), object2.get(%22customerName%22));%0A%0A    %7D%0A%0A    @AfterClass%0A    public static void tearDownClass() %7B%0A        File file = new File(%22data/test.xml%22);%0A        assert(file.delete());%0A    %7D%0A%0A%7D%0A

Test för DataFileIO