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