maven-wagon-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r659032 - in /maven/wagon/trunk: wagon-provider-api/src/main/java/org/apache/maven/wagon/events/ wagon-provider-api/src/main/java/org/apache/maven/wagon/resource/ wagon-provider-test/src/main/java/org/apache/maven/wagon/ wagon-providers/wag...
Date Thu, 22 May 2008 07:50:36 GMT
Author: brett
Date: Thu May 22 00:50:35 2008
New Revision: 659032

URL: http://svn.apache.org/viewvc?rev=659032&view=rev
Log:
[WAGON-212] make tests deterministic based on times

Modified:
    maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/TransferEvent.java
    maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/resource/Resource.java
    maven/wagon/trunk/wagon-provider-test/src/main/java/org/apache/maven/wagon/WagonTestCase.java
    maven/wagon/trunk/wagon-providers/wagon-file/src/test/java/org/apache/maven/wagon/providers/file/FileWagonTest.java
    maven/wagon/trunk/wagon-providers/wagon-ftp/src/test/java/org/apache/maven/wagon/providers/ftp/FtpWagonTest.java
    maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/LightweightHttpWagonTest.java
    maven/wagon/trunk/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonTest.java
    maven/wagon/trunk/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScmCvsWagonTest.java
    maven/wagon/trunk/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScmSvnWagonTest.java
    maven/wagon/trunk/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScmWagonTest.java
    maven/wagon/trunk/wagon-providers/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/AuthenticatedWebDavWagonTest.java
    maven/wagon/trunk/wagon-providers/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavWagonTest.java

Modified: maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/TransferEvent.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/TransferEvent.java?rev=659032&r1=659031&r2=659032&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/TransferEvent.java
(original)
+++ maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/TransferEvent.java
Thu May 22 00:50:35 2008
@@ -254,7 +254,7 @@
 
         sb.append( this.getWagon().getRepository() ).append( "|" );
         sb.append( this.getLocalFile() ).append( "|" );
-        sb.append( this.getResource() );
+        sb.append( this.getResource().inspect() );
         sb.append( "]" );
 
         return sb.toString();

Modified: maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/resource/Resource.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/resource/Resource.java?rev=659032&r1=659031&r2=659032&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/resource/Resource.java
(original)
+++ maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/resource/Resource.java
Thu May 22 00:50:35 2008
@@ -91,6 +91,11 @@
     {
         return name;
     }
+    
+    public String inspect()
+    {
+        return name + "[len = " + contentLength + "; mod = " + lastModified + "]";
+    }
 
     public int hashCode()
     {

Modified: maven/wagon/trunk/wagon-provider-test/src/main/java/org/apache/maven/wagon/WagonTestCase.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-provider-test/src/main/java/org/apache/maven/wagon/WagonTestCase.java?rev=659032&r1=659031&r2=659032&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-provider-test/src/main/java/org/apache/maven/wagon/WagonTestCase.java
(original)
+++ maven/wagon/trunk/wagon-provider-test/src/main/java/org/apache/maven/wagon/WagonTestCase.java
Thu May 22 00:50:35 2008
@@ -703,7 +703,7 @@
     {
         destFile = FileTestUtils.createUniqueFile( getName(), getName() );
         destFile.deleteOnExit();
-
+        
         Wagon wagon = getWagon();
 
         Resource resource = new Resource( this.resource );
@@ -711,7 +711,7 @@
                                                                      TransferEvent.REQUEST_GET,
destFile ) );
         resource = new Resource( this.resource );
         resource.setContentLength( getExpectedContentLengthOnGet( expectedSize ) );
-        resource.setLastModified( getExpectedLastModifiedOnGet() );
+        resource.setLastModified( getExpectedLastModifiedOnGet( testRepository, resource
) );
         mockTransferListener.transferStarted( createTransferEvent( wagon, resource, TransferEvent.TRANSFER_STARTED,
                                                                    TransferEvent.REQUEST_GET,
destFile ) );
         mockTransferListener.transferProgress( new TransferEvent( wagon, resource, TransferEvent.TRANSFER_PROGRESS,
@@ -756,8 +756,11 @@
         return expectedSize;
     }
 
-    protected long getExpectedLastModifiedOnGet()
+    protected long getExpectedLastModifiedOnGet( Repository repository, Resource resource
)
     {
+        // default implementation - prone to failing if the time between test file creation
and completion of putFile()
+        // cross the "second" boundary, causing the "remote" and local files to have different
times.
+
         return sourceFile.lastModified();
     }
 

Modified: maven/wagon/trunk/wagon-providers/wagon-file/src/test/java/org/apache/maven/wagon/providers/file/FileWagonTest.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-file/src/test/java/org/apache/maven/wagon/providers/file/FileWagonTest.java?rev=659032&r1=659031&r2=659032&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-file/src/test/java/org/apache/maven/wagon/providers/file/FileWagonTest.java
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-file/src/test/java/org/apache/maven/wagon/providers/file/FileWagonTest.java
Thu May 22 00:50:35 2008
@@ -65,4 +65,9 @@
         Repository repository = new Repository();
         wagon.connect( repository );
     }
+
+    protected long getExpectedLastModifiedOnGet( Repository repository, Resource resource
)
+    {
+        return new File( repository.getBasedir(), resource.getName() ).lastModified();
+    }
 }

Modified: maven/wagon/trunk/wagon-providers/wagon-ftp/src/test/java/org/apache/maven/wagon/providers/ftp/FtpWagonTest.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-ftp/src/test/java/org/apache/maven/wagon/providers/ftp/FtpWagonTest.java?rev=659032&r1=659031&r2=659032&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-ftp/src/test/java/org/apache/maven/wagon/providers/ftp/FtpWagonTest.java
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-ftp/src/test/java/org/apache/maven/wagon/providers/ftp/FtpWagonTest.java
Thu May 22 00:50:35 2008
@@ -19,9 +19,13 @@
  * under the License.
  */
 
+import java.io.File;
+
 import org.apache.ftpserver.interfaces.FtpServerInterface;
 import org.apache.maven.wagon.WagonTestCase;
 import org.apache.maven.wagon.authentication.AuthenticationInfo;
+import org.apache.maven.wagon.repository.Repository;
+import org.apache.maven.wagon.resource.Resource;
 
 /**
  * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
@@ -37,12 +41,6 @@
         return "ftp";
     }
 
-    protected long getExpectedLastModifiedOnGet()
-    {
-        // granularity for FTP is minutes
-        return ( sourceFile.lastModified() / 60000 ) * 60000;
-    }
-
     protected void setupWagonTestingFixtures()
         throws Exception
     {
@@ -73,4 +71,12 @@
 
         return authInfo;
     }
+
+    protected long getExpectedLastModifiedOnGet( Repository repository, Resource resource
)
+    {
+        File file = getTestFile( "target/test-output/local-repository", resource.getName()
);
+        
+        // granularity for FTP is minutes
+        return ( file.lastModified() / 60000 ) * 60000;
+    }
 }

Modified: maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/LightweightHttpWagonTest.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/LightweightHttpWagonTest.java?rev=659032&r1=659031&r2=659032&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/LightweightHttpWagonTest.java
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/LightweightHttpWagonTest.java
Thu May 22 00:50:35 2008
@@ -21,6 +21,8 @@
 
 import org.apache.maven.wagon.FileTestUtils;
 import org.apache.maven.wagon.WagonTestCase;
+import org.apache.maven.wagon.repository.Repository;
+import org.apache.maven.wagon.resource.Resource;
 import org.codehaus.plexus.jetty.Httpd;
 
 import java.io.File;
@@ -78,4 +80,10 @@
         
         super.testWagonGetFileList();
     }
+
+    protected long getExpectedLastModifiedOnGet( Repository repository, Resource resource
)
+    {
+        File file = getTestFile( "target/test-output/http-repository", resource.getName()
);
+        return file.lastModified();
+    }
 }

Modified: maven/wagon/trunk/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonTest.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonTest.java?rev=659032&r1=659031&r2=659032&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonTest.java
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonTest.java
Thu May 22 00:50:35 2008
@@ -21,6 +21,8 @@
 
 import org.apache.maven.wagon.FileTestUtils;
 import org.apache.maven.wagon.WagonTestCase;
+import org.apache.maven.wagon.repository.Repository;
+import org.apache.maven.wagon.resource.Resource;
 import org.codehaus.plexus.jetty.Httpd;
 
 import java.io.File;
@@ -90,4 +92,10 @@
     {
         release( httpd );
     }
+
+    protected long getExpectedLastModifiedOnGet( Repository repository, Resource resource
)
+    {
+        File file = getTestFile( "target/test-output/http-repository", resource.getName()
);
+        return file.lastModified();
+    }
 }

Modified: maven/wagon/trunk/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScmCvsWagonTest.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScmCvsWagonTest.java?rev=659032&r1=659031&r2=659032&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScmCvsWagonTest.java
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScmCvsWagonTest.java
Thu May 22 00:50:35 2008
@@ -27,7 +27,7 @@
  * @author <a href="brett@apache.org">Brett Porter</a>
  * @version $Id$
  */
-public class AbstractScmCvsWagonTest
+public abstract class AbstractScmCvsWagonTest
     extends AbstractScmWagonTest
 {
 

Modified: maven/wagon/trunk/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScmSvnWagonTest.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScmSvnWagonTest.java?rev=659032&r1=659031&r2=659032&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScmSvnWagonTest.java
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScmSvnWagonTest.java
Thu May 22 00:50:35 2008
@@ -29,7 +29,7 @@
  * @author <a href="brett@apache.org">Brett Porter</a>
  * @version $Id$
  */
-public class AbstractScmSvnWagonTest
+public abstract class AbstractScmSvnWagonTest
     extends AbstractScmWagonTest
 {
     private String repository;

Modified: maven/wagon/trunk/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScmWagonTest.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScmWagonTest.java?rev=659032&r1=659031&r2=659032&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScmWagonTest.java
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScmWagonTest.java
Thu May 22 00:50:35 2008
@@ -32,6 +32,8 @@
 import org.apache.maven.wagon.WagonConstants;
 import org.apache.maven.wagon.WagonTestCase;
 import org.apache.maven.wagon.authorization.AuthorizationException;
+import org.apache.maven.wagon.repository.Repository;
+import org.apache.maven.wagon.resource.Resource;
 import org.codehaus.plexus.util.FileUtils;
 
 /**
@@ -104,7 +106,7 @@
         return WagonConstants.UNKNOWN_LENGTH;
     }
     
-    protected long getExpectedLastModifiedOnGet()
+    protected long getExpectedLastModifiedOnGet( Repository repository, Resource resource
)
     {
         return 0;
     }

Modified: maven/wagon/trunk/wagon-providers/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/AuthenticatedWebDavWagonTest.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/AuthenticatedWebDavWagonTest.java?rev=659032&r1=659031&r2=659032&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/AuthenticatedWebDavWagonTest.java
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/AuthenticatedWebDavWagonTest.java
Thu May 22 00:50:35 2008
@@ -25,6 +25,8 @@
 import org.apache.maven.wagon.FileTestUtils;
 import org.apache.maven.wagon.WagonTestCase;
 import org.apache.maven.wagon.authentication.AuthenticationInfo;
+import org.apache.maven.wagon.repository.Repository;
+import org.apache.maven.wagon.resource.Resource;
 
 /**
  * Authenticated WebDAV Wagon Test 
@@ -81,4 +83,10 @@
     {
         release( server );
     }
+
+    protected long getExpectedLastModifiedOnGet( Repository repository, Resource resource
)
+    {
+        File file = getTestFile( "target/test-output/authdav-repository/newfolder/folder2",
resource.getName() );
+        return file.lastModified();
+    }
 }

Modified: maven/wagon/trunk/wagon-providers/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavWagonTest.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavWagonTest.java?rev=659032&r1=659031&r2=659032&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavWagonTest.java
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavWagonTest.java
Thu May 22 00:50:35 2008
@@ -24,6 +24,8 @@
 
 import org.apache.maven.wagon.FileTestUtils;
 import org.apache.maven.wagon.WagonTestCase;
+import org.apache.maven.wagon.repository.Repository;
+import org.apache.maven.wagon.resource.Resource;
 
 /**
  * WebDAV Wagon Test
@@ -70,4 +72,10 @@
     {
         release( server );
     }
+
+    protected long getExpectedLastModifiedOnGet( Repository repository, Resource resource
)
+    {
+        File file = getTestFile( "target/test-output/dav-repository/newfolder/folder2", resource.getName()
);
+        return file.lastModified();
+    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: wagon-commits-unsubscribe@maven.apache.org
For additional commands, e-mail: wagon-commits-help@maven.apache.org


Mime
View raw message