Needs the license.
-jon
on 4/14/02 9:17 AM, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> dion 02/04/14 09:17:28
>
> Added: src/test/org/apache/maven/cvslib ChangeLogEntryTest.java
> Log:
> Initial tests for cvslib code: ChangeLogEntry only at this point
>
> Revision Changes Path
> 1.1
> jakarta-turbine-maven/src/test/org/apache/maven/cvslib/ChangeLogEntryTest.java
>
> Index: ChangeLogEntryTest.java
> ===================================================================
> /*
> * ChangeLogEntryTest.java
> * JUnit based test
> *
> * Created on 14 April 2002, 18:47
> */
>
> package org.apache.maven.cvslib;
>
> import java.text.ParseException;
> import java.text.SimpleDateFormat;
> import java.util.Calendar;
> import java.util.Date;
> import java.util.Enumeration;
> import java.util.Vector;
> import junit.framework.Test;
> import junit.framework.TestCase;
> import junit.framework.TestSuite;
> import junit.textui.TestRunner;
>
> /**
> * Tests for the {@link ChangeLogEntry} class
> *
> * @author dion
> * @version $Id: ChangeLogEntryTest.java,v 1.1 2002/04/14 16:17:28 dion Exp $
> */
> public class ChangeLogEntryTest extends TestCase {
>
> /** the {@link ChangeLogEntry} used for testing */
> private ChangeLogEntry instance;
>
> /**
> * Create a test with the given name
> * @param testName the name of the test
> */
> public ChangeLogEntryTest(String testName) {
> super(testName);
> }
>
> /**
> * Run the test using the {@link TestRunner}
> * @param args command line provided arguments
> */
> public static void main(String[] args) {
> TestRunner.run(suite());
> }
>
> /**
> * Create a test suite for this class
> * @return a {@link TestSuite} for all tests in this class
> */
> public static Test suite() {
> return new TestSuite(ChangeLogEntryTest.class);
> }
>
> /**
> * Initialize per test data
> */
> public void setUp() throws Exception
> {
> instance = new ChangeLogEntry();
> instance.setAuthor("dion");
> instance.setComment("comment");
> instance.setDate("2002/04/01");
> }
>
> /**
> * Test of addFile methods: using ChangeLogFile
> */
> public void testAddFileWithFile() {
> ChangeLogFile file = new ChangeLogFile("maven:dummy");
> instance.addFile(file);
> assertTrue("File name not found in list",
> instance.toString().indexOf("maven:dummy") != -1 );
> }
>
> /**
> * Test of addFile methods: using file & revision
> */
> public void testAddFileWithFileAndRevision() {
> instance.addFile("maven:dummy", "x.y");
> assertTrue("File name not found in list",
> instance.toString().indexOf("maven:dummy") != -1);
> assertTrue("Revision not found in list",
> instance.toString().indexOf("x.y") != -1);
> }
>
> /**
> * Test of addFile method file, revision and previous revision
> */
> public void testAddFileWithFileRevisionAndPrevious() {
> instance.addFile("maven:dummy", "x.y", "a.b");
> assertTrue("File name not found in list",
> instance.toString().indexOf("maven:dummy") != -1);
> assertTrue("Revision not found in list",
> instance.toString().indexOf("x.y") != -1);
> assertTrue("Previous revision not found in list",
> instance.toString().indexOf("a.b") != -1);
> }
>
> /**
> * Test of toString method
> */
> public void testToString() {
> //dion, Mon Apr 01 00:00:00 EST 2002, [], comment
> String value = instance.toString();
> assertTrue("author not found in string", value.indexOf("dion") != -1);
> assertTrue("comment not found in string",
> value.indexOf("comment") != -1);
> assertTrue("date not found in string",
> value.indexOf("Mon Apr 01") != -1);
> assertTrue("empty file list not found in string",
> value.indexOf("[]") != -1);
> }
>
> /**
> * Test of toXML method
> */
> public void testToXML() {
> String value = instance.toXML();
> String trimmedValue = value.trim();
> assertTrue("XML doesn't start with changelog-entry",
> trimmedValue.startsWith("<changelog-entry>"));
> assertTrue("XML doesn't contain date",
> value.indexOf("<date>2002-04-01</date>") != -1);
> assertTrue("XML doesn't contain author CDATA",
> value.indexOf("<author><![CDATA[dion]]></author>") != -1);
> assertTrue("XML doesn't contain comment CDATA",
> value.indexOf("<msg><![CDATA[comment]]></msg>") != -1);
> }
>
> /**
> * Test of getAuthor method
> */
> public void testGetAuthor() {
> assertEquals("Author value not retrieved correctly", "dion",
> instance.getAuthor());
> }
>
> /**
> * Test of setAuthor method
> */
> public void testSetAuthor() {
> instance.setAuthor("maven:dion");
> assertEquals("Author not set correctly", "maven:dion",
> instance.getAuthor());
> }
>
> /**
> * Test of getComment method
> */
> public void testGetComment() {
> assertEquals("Comment value not retrieved correctly", "comment",
> instance.getComment());
> }
>
> /**
> * Test of setComment method
> */
> public void testSetComment() {
> instance.setComment("maven:comment");
> assertEquals("Comment not set correctly", "maven:comment",
> instance.getComment());
> }
>
> /**
> * Test of getDate method
> */
> public void testGetDate() {
> Calendar cal = Calendar.getInstance();
> cal.set(2002, 3, 1, 0, 0, 0);
> cal.set(Calendar.MILLISECOND, 0);
> System.err.println(instance.getDate().getTime() + ", " +
> cal.getTimeInMillis());
> assertEquals("Date value not retrieved correctly", 0,
> instance.getDate().compareTo(cal.getTime()));
> }
>
> /**
> * Test of setDate method with Date object
> */
> public void testSetDate() {
> Calendar cal = Calendar.getInstance();
> Date date = cal.getTime();
> instance.setDate(date);
> assertEquals("Date value not set correctly", date,
> instance.getDate());
> }
>
> /**
> * Test of setDate method with String
> */
> public void testSetDateFromString() {
> instance.setDate("2002/03/04");
> Calendar cal = Calendar.getInstance();
> cal.set(2002, 2, 4, 0, 0, 0);
> cal.set(Calendar.MILLISECOND, 0);
> assertEquals("Date value not set correctly from a string",
> cal.getTime(), instance.getDate());
> }
>
>
> /**
> * Test of getDateFormatted method
> */
> public void testGetDateFormatted() {
> assertEquals("Date not formatted correctly", "2002-04-01",
> instance.getDateFormatted());
> }
>
> // Add test methods here, they have to start with 'test' name.
> // for example:
> // public void testHello() {}
>
>
> }
>
>
>