source: trunk/quest-plugin-jfc-test/src/test/java/de/ugoe/cs/quest/plugin/jfc/JFCTraceCorrectorTest.java @ 829

Last change on this file since 829 was 829, checked in by pharms, 12 years ago
  • improved correction of sources by also considering other correct sources with the same value of the toString parameter
File size: 2.2 KB
Line 
1package de.ugoe.cs.quest.plugin.jfc;
2
3import static org.junit.Assert.assertEquals;
4import static org.junit.Assert.assertNull;
5
6import java.io.BufferedReader;
7import java.io.File;
8import java.io.FileReader;
9import java.util.logging.Level;
10
11import org.junit.After;
12import org.junit.Before;
13import org.junit.Test;
14
15import de.ugoe.cs.util.console.TextConsole;
16
17/**
18 * TODO comment
19 *
20 * @version $Revision: $ $Date: $
21 * @author 2011, last modified by $Author: $
22 */
23public class JFCTraceCorrectorTest {
24
25    /** */
26    private File outputFile = new File("tmp_output.xml");
27   
28    /**
29     *
30     */
31    @Before
32    public void setUp() {
33        new TextConsole(Level.FINEST);
34    }
35
36    /**
37     *
38     */
39    @After
40    public void tearDown() {
41        if ((outputFile != null) && (outputFile.exists())) {
42            outputFile.delete();
43        }
44    }
45
46    /**
47     *
48     */
49    @Test
50    public void test() throws Exception {
51        JFCTraceCorrector corrector = new JFCTraceCorrector();
52        corrector.correctFile(getTestFile("uncorrected_trace.xml"), outputFile);
53       
54        BufferedReader reader1 = null;
55        BufferedReader reader2 = null;
56
57        try {
58            reader1 = new BufferedReader(new FileReader(getTestFile("corrected_trace.xml")));
59            reader2 = new BufferedReader(new FileReader(outputFile));
60           
61            String line;
62            do {
63                line = reader1.readLine();
64                if (line != null) {
65                    assertEquals(line, reader2.readLine());
66                }
67                else {
68                    assertNull(reader2.readLine());
69                }
70            }
71            while (line != null);
72        }
73        finally {
74            if (reader1 != null) {
75                reader1.close();
76            }
77            if (reader2 != null) {
78                reader2.close();
79            }
80        }
81    }
82
83    /**
84     * <p>
85     * TODO: comment
86     * </p>
87     *
88     * @param string
89     * @return
90     */
91    private File getTestFile(String name) {
92        return new File(ClassLoader.getSystemResource(name).getFile());
93    }
94
95}
Note: See TracBrowser for help on using the repository browser.