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

Last change on this file since 1426 was 1426, checked in by pharms, 10 years ago
  • removed some TODOs
File size: 2.7 KB
Line 
1//   Copyright 2012 Georg-August-Universität Göttingen, Germany
2//
3//   Licensed under the Apache License, Version 2.0 (the "License");
4//   you may not use this file except in compliance with the License.
5//   You may obtain a copy of the License at
6//
7//       http://www.apache.org/licenses/LICENSE-2.0
8//
9//   Unless required by applicable law or agreed to in writing, software
10//   distributed under the License is distributed on an "AS IS" BASIS,
11//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12//   See the License for the specific language governing permissions and
13//   limitations under the License.
14
15package de.ugoe.cs.autoquest.plugin.jfc;
16
17import static org.junit.Assert.assertEquals;
18import static org.junit.Assert.assertNull;
19
20import java.io.BufferedReader;
21import java.io.File;
22import java.io.FileReader;
23import java.util.logging.Level;
24
25import org.junit.After;
26import org.junit.Before;
27import org.junit.Test;
28
29import de.ugoe.cs.autoquest.plugin.jfc.JFCTraceCorrector;
30import de.ugoe.cs.util.console.TextConsole;
31
32/**
33 * @author Patrick Harms
34 */
35public class JFCTraceCorrectorTest {
36
37    /** */
38    private File outputFile = new File("tmp_output.xml");
39   
40    /**
41     *
42     */
43    @Before
44    public void setUp() {
45        new TextConsole(Level.FINEST);
46    }
47
48    /**
49     *
50     */
51    @After
52    public void tearDown() {
53        if ((outputFile != null) && (outputFile.exists())) {
54            outputFile.delete();
55        }
56    }
57
58    /**
59     *
60     */
61    @Test
62    public void test() throws Exception {
63        JFCTraceCorrector corrector = new JFCTraceCorrector();
64        corrector.correctFile(getTestFile("uncorrected_trace.xml"), outputFile);
65       
66        BufferedReader reader1 = null;
67        BufferedReader reader2 = null;
68
69        try {
70            reader1 = new BufferedReader(new FileReader(getTestFile("corrected_trace.xml")));
71            reader2 = new BufferedReader(new FileReader(outputFile));
72           
73            String line;
74            do {
75                line = reader1.readLine();
76                if (line != null) {
77                    assertEquals(line, reader2.readLine());
78                }
79                else {
80                    assertNull(reader2.readLine());
81                }
82            }
83            while (line != null);
84        }
85        finally {
86            if (reader1 != null) {
87                reader1.close();
88            }
89            if (reader2 != null) {
90                reader2.close();
91            }
92        }
93    }
94
95    /**
96     *
97     */
98    private File getTestFile(String name) {
99        return new File(ClassLoader.getSystemResource(name).getFile());
100    }
101
102}
Note: See TracBrowser for help on using the repository browser.