1   package org.apache.maven.changelog;
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 junit.framework.Test;
22  import junit.framework.TestCase;
23  import junit.framework.TestSuite;
24  import junit.textui.TestRunner;
25  
26  /**
27   * Test cases for {@link ChangeLogFile}
28   * @author dIon Gillard
29   * @version $Id: ChangeLogFileTest.java 532339 2007-04-25 12:28:56Z ltheussl $
30   */
31  public class ChangeLogFileTest extends TestCase
32  {
33  
34      /** the {@link ChangeLogFile} used for testing */
35      private ChangeLogFile instance;
36      
37      /**
38       * Create a test with the given name
39       * @param testName the name of the test
40       */
41      public ChangeLogFileTest(String testName)
42      {
43          super(testName);
44      }
45      
46      /**
47       * Run the test using the {@link TestRunner}
48       * @param args command line provided arguments
49       */
50      public static void main(String[] args)
51      {
52          TestRunner.run(suite());
53      }
54      
55      /**
56       * Create a test suite for this class
57       * @return a {@link TestSuite} for all tests in this class
58       */
59      public static Test suite()
60      {
61          return new TestSuite(ChangeLogFileTest.class);
62      }
63  
64      /**
65       * Initialize per test data
66       */
67      public void setUp()
68      {
69          instance = new ChangeLogFile("maven:dummy", "maven:rev");
70      }
71  
72      /**
73       * Test of getName method
74       */
75      public void testGetName()
76      {
77          assertEquals("Name not being retrieved correctly", "maven:dummy", 
78              instance.getName()); 
79      }
80      
81      /**
82       * Test of getRevision method
83       */
84      public void testGetRevision()
85      {
86          assertEquals("Revision not being retrieved correctly", "maven:rev", 
87              instance.getRevision()); 
88      }
89      
90      /** 
91       * Test of setName method
92       */
93      public void testSetName()
94      {
95          instance.setName("maven:dummy:name");
96          assertEquals("Name not set correctly", "maven:dummy:name", 
97              instance.getName());
98      }
99      
100     /**
101      * Test of setRevision method
102      */
103     public void testSetRevision()
104     {
105         instance.setRevision("maven:rev:test");
106         assertEquals("Revision not set correctly", "maven:rev:test", 
107             instance.getRevision());
108     }
109     
110     /** 
111      * Test of toString method
112      */
113     public void testToString()
114     {
115         String value = instance.toString();
116         assertTrue("Name not found in string", 
117             value.indexOf(instance.getName()) != -1);
118         assertTrue("Revision not found in string",
119             value.indexOf(instance.getRevision()) != -1);
120     }
121     
122     // Add test methods here, they have to start with 'test' name.
123     // for example:
124     // public void testHello() {    
125 }