maven-scm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r774941 - in /maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm: ScmTckTestCase.java tck/command/checkin/CheckInCommandTckTest.java
Date Thu, 14 May 2009 21:50:43 GMT
Author: olamy
Date: Thu May 14 21:50:43 2009
New Revision: 774941

URL: http://svn.apache.org/viewvc?rev=774941&view=rev
Log:
[SCM-471] some TCK tests check for files in a position dependent way
Submitted by Mark Struberg

Modified:
    maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/ScmTckTestCase.java
    maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/checkin/CheckInCommandTckTest.java

Modified: maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/ScmTckTestCase.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/ScmTckTestCase.java?rev=774941&r1=774940&r2=774941&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/ScmTckTestCase.java
(original)
+++ maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/ScmTckTestCase.java
Thu May 14 21:50:43 2009
@@ -23,11 +23,14 @@
 import org.apache.maven.scm.command.checkout.CheckOutScmResult;
 import org.apache.maven.scm.provider.ScmProvider;
 import org.apache.maven.scm.repository.ScmRepository;
+import org.codehaus.plexus.util.StringUtils;
 
 import java.io.File;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
 
 /**
  * <p/>
@@ -165,4 +168,35 @@
             assertEquals( "Expected 1 file in the added files list " + addedFiles, 1, addedFiles.size()
);
         }
     }
+    
+    /**
+     * take the files of the given list, add them to a TreeMap and
+     * use the pathName String as key for the Map.
+     * This function is useful for every TCK which has to check for the
+     * existence of more than 1 file of the returned ScmResult, regardless
+     * of their order in the list.
+     * All backslashes in the path will be replaced by forward slashes 
+     * for Windows compatibility.
+     *     
+     * @param files List with {@code ScmFile}s
+     * @return Map key=pathName, value=ScmFile
+     */
+    protected Map/*<String, ScmFile>*/ mapFilesByPath( List/*<ScmFile>*/ files
)
+    {
+        if ( files == null )
+        {
+            return null;
+        }
+        
+        Map mappedFiles = new TreeMap();
+        Iterator it = files.iterator();
+        while ( it.hasNext() )
+        {
+            ScmFile scmFile = (ScmFile) it.next();
+            String path = StringUtils.replace( scmFile.getPath(), "\\", "/" );
+            mappedFiles.put( path, scmFile );
+        }
+        
+        return mappedFiles;
+    }
 }

Modified: maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/checkin/CheckInCommandTckTest.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/checkin/CheckInCommandTckTest.java?rev=774941&r1=774940&r2=774941&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/checkin/CheckInCommandTckTest.java
(original)
+++ maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/checkin/CheckInCommandTckTest.java
Thu May 14 21:50:43 2009
@@ -32,6 +32,7 @@
 import java.io.FileWriter;
 import java.io.PrintWriter;
 import java.util.List;
+import java.util.Map;
 
 /**
  * This test tests the check out command.
@@ -82,17 +83,16 @@
 
         assertEquals( 2, files.size() );
 
-        ScmFile file1 = (ScmFile) files.get( 0 );
-
+        Map fileMap = mapFilesByPath( files );
+        ScmFile file1 = (ScmFile) fileMap.get( "src/main/java/Foo.java" );
+        assertNotNull( file1 );
         assertEquals( ScmFileStatus.CHECKED_IN, file1.getStatus() );
 
-        assertPath( "/test-repo/check-in/Foo.java", file1.getPath() );
-
-        ScmFile file2 = (ScmFile) files.get( 1 );
 
+        ScmFile file2 = (ScmFile) fileMap.get( "readme.txt" );
+        assertNotNull( file2 );
         assertEquals( ScmFileStatus.CHECKED_IN, file2.getStatus() );
 
-        assertPath( "/test-repo/check-in/readme.txt", file2.getPath() );
 
         CheckOutScmResult checkoutResult =
             getScmManager().checkOut( getScmRepository(), new ScmFileSet( getAssertionCopy()
) );



Mime
View raw message