1 package org.apache.maven.cvslib;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 import java.io.FileInputStream;
22 import java.util.Collection;
23 import java.util.Iterator;
24 import junit.framework.TestCase;
25
26 import org.apache.maven.changelog.ChangeLogEntry;
27
28
29 /**
30 * Test cases for {@link CvsChangeLogParser}
31 * @author dion
32 * @version $Id: CvsChangeLogParserTest.java 532339 2007-04-25 12:28:56Z ltheussl $
33 */
34 public class CvsChangeLogParserTest extends TestCase
35 {
36
37 /** the {@link CvsChangeLogParser} used for testing */
38 private CvsChangeLogParser instance;
39 /** file with test results to check against */
40 private String testFile;
41 /** file with test results to check against */
42 private String testFile2;
43
44 /**
45 * Create a test with the given name
46 * @param testName the name of the test
47 */
48 public CvsChangeLogParserTest(String testName)
49 {
50 super(testName);
51 }
52
53 /**
54 * Initialize per test data
55 * @throws Exception when there is an unexpected problem
56 */
57 public void setUp() throws Exception
58 {
59 String baseDir = System.getProperty("basedir");
60 assertNotNull("The system property basedir was not defined.", baseDir);
61 testFile = baseDir + "/src/test-resources/cvslib/cvslog.txt";
62 testFile2 = baseDir + "/src/test-resources/cvslib/cvslog_new.txt";
63 instance = new CvsChangeLogParser();
64 }
65
66 /**
67 * Test of parse method
68 * @throws Exception when there is an unexpected problem
69 */
70 public void testParse() throws Exception
71 {
72 parse(testFile);
73 }
74
75 /**
76 * Test of parse method
77 * @throws Exception when there is an unexpected problem
78 */
79 public void testParse2() throws Exception
80 {
81 parse(testFile2);
82 }
83
84 /**
85 * Test of parse method
86 * @throws Exception when there is an unexpected problem
87 */
88 public void parse(String file) throws Exception
89 {
90 FileInputStream fis = new FileInputStream(file);
91 Collection entries = instance.parse(fis);
92 assertEquals("Wrong number of entries returned", 3, entries.size());
93 ChangeLogEntry entry = null;
94 for (Iterator i = entries.iterator(); i.hasNext(); )
95 {
96 entry = (ChangeLogEntry) i.next();
97 assertTrue("ChangeLogEntry erroneously picked up",
98 entry.toString().indexOf("ChangeLogEntry.java") == -1);
99 }
100 }
101
102
103
104
105
106
107 }