1 package org.apache.maven.clearcaselib;
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 public class ClearcaseChangeLogParserTest extends TestCase {
31
32 /** the {@link ClearcaseChangeLogParser}used for testing */
33 private ClearcaseChangeLogParser instance;
34
35 /** file with test results to check against */
36 private String testFile;
37
38 /**
39 * Create a test with the given name
40 *
41 * @param testName
42 * the name of the test
43 */
44 public ClearcaseChangeLogParserTest(String testName) {
45 super(testName);
46 }
47
48 /**
49 * Initialize per test data
50 *
51 * @throws Exception
52 * when there is an unexpected problem
53 */
54 public void setUp() throws Exception {
55 String baseDir = System.getProperty("basedir");
56 assertNotNull("The system property basedir was not defined.", baseDir);
57 testFile = baseDir
58 + "/src/test-resources/clearcaselib/clearcaselog.txt";
59 instance = new ClearcaseChangeLogParser();
60 }
61
62 /**
63 * Test of parse method
64 *
65 * @throws Exception
66 * when there is an unexpected problem
67 */
68 public void testParse() throws Exception {
69 FileInputStream fis = new FileInputStream(testFile);
70 Collection entries = instance.parse(fis);
71 assertEquals("Wrong number of entries returned", 3, entries.size());
72 ChangeLogEntry entry = null;
73 for (Iterator i = entries.iterator(); i.hasNext();) {
74 entry = (ChangeLogEntry) i.next();
75 assertTrue("ChangeLogEntry erroneously picked up", entry.toString()
76 .indexOf("ChangeLogEntry.java") == -1);
77 }
78
79 }
80
81 public void testParseCorrectUsername() throws Exception {
82
83
84 FileInputStream fis = new FileInputStream(testFile);
85 Collection entries = instance.parse(fis);
86
87
88 Iterator i = entries.iterator();
89 ChangeLogEntry entry = (ChangeLogEntry) i.next();
90 assertEquals("exactly 8 chars expected", "88888888", entry.getAuthor());
91
92
93 entry = (ChangeLogEntry) i.next();
94 assertEquals("exactly 5 chars expected", "55555", entry.getAuthor());
95
96
97 }
98
99
100
101
102
103 }