1   package org.apache.maven.starteamlib;
2   
3   /* ====================================================================
4    *   Licensed to the Apache Software Foundation (ASF) under one or more
5    *   contributor license agreements.  See the NOTICE file distributed with
6    *   this work for additional information regarding copyright ownership.
7    *   The ASF licenses this file to You under the Apache License, Version 2.0
8    *   (the "License"); you may not use this file except in compliance with
9    *   the License.  You may obtain a copy of the License at
10   *
11   *       http://www.apache.org/licenses/LICENSE-2.0
12   *
13   *   Unless required by applicable law or agreed to in writing, software
14   *   distributed under the License is distributed on an "AS IS" BASIS,
15   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   *   See the License for the specific language governing permissions and
17   *   limitations under the License.
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 StarteamChangeLogParser}
31   * @author <a href="mailto:evenisse@ifrance.com">Emmanuel Venisse</a>
32   * @version $Id: StarteamChangeLogParser2Test.java 532339 2007-04-25 12:28:56Z ltheussl $
33   */
34  public class StarteamChangeLogParser2Test extends TestCase
35  {
36  
37      /** the {@link StarteamChangeLogParser} used for testing */
38      private StarteamChangeLogParser instance;
39      /** file with test results to check against */
40      private String testFile;
41  
42      /**
43       * Create a test with the given name
44       * @param testName the name of the test
45       */
46      public StarteamChangeLogParser2Test(String testName)
47      {
48          super(testName);
49      }
50  
51      /**
52       * Initialize per test data
53       * @throws Exception when there is an unexpected problem
54       */
55      public void setUp() throws Exception
56      {
57          String baseDir = System.getProperty("basedir");
58          assertNotNull("The system property basedir was not defined.", baseDir);
59          testFile = baseDir + "/src/test-resources/starteamlib/starteamlog2.txt";
60          instance = new StarteamChangeLogParser();
61      }
62  
63      /**
64       * Test of parse method
65       * @throws Exception when there is an unexpected problem
66       */
67      public void testParse() throws Exception
68      {
69          FileInputStream fis = new FileInputStream(testFile);
70          instance.setDateFormatInFile("yy-MM-dd HH:mm");
71          Collection entries = instance.parse(fis);
72          assertEquals("Wrong number of entries returned", 3, entries.size());
73          ChangeLogEntry entry = null;
74          for (Iterator i = entries.iterator(); i.hasNext(); )
75          {
76              entry = (ChangeLogEntry) i.next();
77              assertTrue("ChangeLogEntry erroneously picked up",
78                  entry.toString().indexOf("ChangeLogEntry.java") == -1);
79          }
80  
81      }
82  
83  }