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