maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From epunza...@apache.org
Subject svn commit: r392172 - in /maven/sandbox/plugins/maven-changelog-plugin/src: main/java/org/apache/maven/changelog/ test/ test/java/ test/java/org/ test/java/org/apache/ test/java/org/apache/maven/ test/java/org/apache/maven/changelog/
Date Fri, 07 Apr 2006 03:25:10 GMT
Author: epunzalan
Date: Thu Apr  6 20:25:09 2006
New Revision: 392172

URL: http://svn.apache.org/viewcvs?rev=392172&view=rev
Log:
PR: MCHANGELOG-34

Added unit tests and fixed a bug found during the tests.

Added:
    maven/sandbox/plugins/maven-changelog-plugin/src/test/
    maven/sandbox/plugins/maven-changelog-plugin/src/test/java/
    maven/sandbox/plugins/maven-changelog-plugin/src/test/java/org/
    maven/sandbox/plugins/maven-changelog-plugin/src/test/java/org/apache/
    maven/sandbox/plugins/maven-changelog-plugin/src/test/java/org/apache/maven/
    maven/sandbox/plugins/maven-changelog-plugin/src/test/java/org/apache/maven/changelog/
    maven/sandbox/plugins/maven-changelog-plugin/src/test/java/org/apache/maven/changelog/FileActivityComparatorTest.java
Modified:
    maven/sandbox/plugins/maven-changelog-plugin/src/main/java/org/apache/maven/changelog/FileActivityComparator.java

Modified: maven/sandbox/plugins/maven-changelog-plugin/src/main/java/org/apache/maven/changelog/FileActivityComparator.java
URL: http://svn.apache.org/viewcvs/maven/sandbox/plugins/maven-changelog-plugin/src/main/java/org/apache/maven/changelog/FileActivityComparator.java?rev=392172&r1=392171&r2=392172&view=diff
==============================================================================
--- maven/sandbox/plugins/maven-changelog-plugin/src/main/java/org/apache/maven/changelog/FileActivityComparator.java
(original)
+++ maven/sandbox/plugins/maven-changelog-plugin/src/main/java/org/apache/maven/changelog/FileActivityComparator.java
Thu Apr  6 20:25:09 2006
@@ -20,7 +20,6 @@
 
 import java.util.Comparator;
 import java.util.Iterator;
-import java.util.LinkedList;
 import java.util.List;
 
 
@@ -38,9 +37,9 @@
     {
         int returnValue;
 
-        LinkedList list1 = (LinkedList) o1;
+        List list1 = (List) o1;
 
-        LinkedList list2 = (LinkedList) o2;
+        List list2 = (List) o2;
 
         returnValue = sortByCommits( list1, list2 );
 
@@ -117,7 +116,7 @@
             {
                 latest = file.getRevision();
             }
-            else if ( latest.compareTo( file.getRevision() ) > 0 )
+            else if ( latest.compareTo( file.getRevision() ) < 0 )
             {
                 latest = file.getRevision();
             }

Added: maven/sandbox/plugins/maven-changelog-plugin/src/test/java/org/apache/maven/changelog/FileActivityComparatorTest.java
URL: http://svn.apache.org/viewcvs/maven/sandbox/plugins/maven-changelog-plugin/src/test/java/org/apache/maven/changelog/FileActivityComparatorTest.java?rev=392172&view=auto
==============================================================================
--- maven/sandbox/plugins/maven-changelog-plugin/src/test/java/org/apache/maven/changelog/FileActivityComparatorTest.java
(added)
+++ maven/sandbox/plugins/maven-changelog-plugin/src/test/java/org/apache/maven/changelog/FileActivityComparatorTest.java
Thu Apr  6 20:25:09 2006
@@ -0,0 +1,103 @@
+package org.apache.maven.changelog;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import junit.framework.TestCase;
+import org.apache.maven.scm.ChangeFile;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Edwin Punzalan
+ */
+public class FileActivityComparatorTest
+    extends TestCase
+{
+    private FileActivityComparator comparator;
+
+    protected void setUp()
+        throws Exception
+    {
+        comparator = new FileActivityComparator();
+    }
+
+    public void testCompareByNumberOfCommits()
+    {
+        List list1 = new ArrayList();
+        list1.add( new ChangeFile( "anything" ) );
+
+        List list2 = new ArrayList();
+
+        assertTrue( "Test compare by commits, less than", comparator.compare( list1, list2
) < 0 );
+
+        list1 = new ArrayList();
+        list1.add( new ChangeFile( "anything" ) );
+
+        list2 = new ArrayList();
+        list2.add( new ChangeFile( "one thing" ) );
+        list2.add( new ChangeFile( "something") );
+
+        assertTrue( "Test compare by commits, greater than", comparator.compare( list1, list2
) > 0 );
+    }
+
+    public void testCompareByRevision()
+    {
+        List list1 = new ArrayList();
+        list1.add( new ChangeFile( "changefile-1", "123" ) );
+        list1.add( new ChangeFile( "changefile-1", "234" ) );
+
+        List list2 = new ArrayList();
+        list2.add( new ChangeFile( "changefile-2", "246" ) );
+        list2.add( new ChangeFile( "changefile-2", "468" ) );
+
+        assertTrue( "Test compare by revision, less than", comparator.compare( list1, list2
) < 0 );
+
+        list1 = new ArrayList();
+        list1.add( new ChangeFile( "changefile-1", "246" ) );
+        list1.add( new ChangeFile( "changefile-1", "468" ) );
+
+        list2 = new ArrayList();
+        list2.add( new ChangeFile( "changefile-2", "123" ) );
+        list2.add( new ChangeFile( "changefile-2", "234" ) );
+
+        assertTrue( "Test compare by revision, greater than", comparator.compare( list1,
list2 ) > 0 );
+    }
+
+    public void testCompareByName()
+    {
+        List list1 = new ArrayList();
+        list1.add( new ChangeFile( "changefile-1", "123" ) );
+        list1.add( new ChangeFile( "changefile-1", "468" ) );
+
+        List list2 = new ArrayList();
+        list2.add( new ChangeFile( "changefile-2", "246" ) );
+        list2.add( new ChangeFile( "changefile-2", "468" ) );
+
+        assertTrue( "Test compare by name, less than", comparator.compare( list1, list2 )
< 0 );
+
+        list1 = new ArrayList();
+        list1.add( new ChangeFile( "changefile-1", "246" ) );
+        list1.add( new ChangeFile( "changefile-1", "468" ) );
+
+        list2 = new ArrayList();
+        list2.add( new ChangeFile( "changefile-2", "123" ) );
+        list2.add( new ChangeFile( "changefile-2", "234" ) );
+
+        assertTrue( "Test compare by name, greater than", comparator.compare( list1, list2
) > 0 );
+    }
+}



Mime
View raw message