Updated Branches:
  refs/heads/master 5e7fb012f -> fe938fbcd

[WAGON-386] build failure with jdk 1.7.


Project: http://git-wip-us.apache.org/repos/asf/maven-wagon/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-wagon/commit/fe938fbc
Tree: http://git-wip-us.apache.org/repos/asf/maven-wagon/tree/fe938fbc
Diff: http://git-wip-us.apache.org/repos/asf/maven-wagon/diff/fe938fbc

Branch: refs/heads/master
Commit: fe938fbcdcbf0847788f2f442f344f2817fd1455
Parents: 5e7fb01
Author: olivier lamy <ol...@apache.org>
Authored: Fri Feb 1 18:23:54 2013 +0100
Committer: olivier lamy <ol...@apache.org>
Committed: Fri Feb 1 18:24:39 2013 +0100

----------------------------------------------------------------------
 .../java/org/apache/maven/wagon/WagonTestCase.java |   75 +++++++++-----
 .../providers/http/HttpsWagonPreemptiveTest.java   |    6 +
 .../maven/wagon/providers/http/HttpsWagonTest.java |    5 +
 3 files changed, 59 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-wagon/blob/fe938fbc/wagon-provider-test/src/main/java/org/apache/maven/wagon/WagonTestCase.java
----------------------------------------------------------------------
diff --git 
a/wagon-provider-test/src/main/java/org/apache/maven/wagon/WagonTestCase.java 
b/wagon-provider-test/src/main/java/org/apache/maven/wagon/WagonTestCase.java
index 90f413b..4abb767 100644
--- 
a/wagon-provider-test/src/main/java/org/apache/maven/wagon/WagonTestCase.java
+++ 
b/wagon-provider-test/src/main/java/org/apache/maven/wagon/WagonTestCase.java
@@ -45,7 +45,6 @@ import java.util.List;
 
 /**
  * @author <a href="mailto:ja...@maven.org";>Jason van Zyl</a>
- *
  */
 public abstract class WagonTestCase
     extends PlexusTestCase
@@ -270,7 +269,8 @@ public abstract class WagonTestCase
         return true;
     }
 
-    public void testWagonGetIfNewerIsOlder()
+
+    public void testWagonGetIfNewerIsSame()
         throws Exception
     {
         if ( supportsGetIfNewer() )
@@ -278,11 +278,11 @@ public abstract class WagonTestCase
             setupRepositories();
             setupWagonTestingFixtures();
             int expectedSize = putFile();
-            getIfNewer( new SimpleDateFormat( "yyyy-MM-dd" ).parse( 
"2006-01-01" ).getTime(), true, expectedSize );
+            getIfNewer( getExpectedLastModifiedOnGet( testRepository, new 
Resource( resource ) ), false, expectedSize );
         }
     }
 
-    public void testWagonGetIfNewerIsSame()
+    public void testWagonGetIfNewerIsOlder()
         throws Exception
     {
         if ( supportsGetIfNewer() )
@@ -290,7 +290,7 @@ public abstract class WagonTestCase
             setupRepositories();
             setupWagonTestingFixtures();
             int expectedSize = putFile();
-            getIfNewer( getExpectedLastModifiedOnGet( testRepository, new 
Resource( resource ) ), false, expectedSize );
+            getIfNewer( new SimpleDateFormat( "yyyy-MM-dd" ).parse( 
"2006-01-01" ).getTime(), true, expectedSize );
         }
     }
 
@@ -313,6 +313,28 @@ public abstract class WagonTestCase
         tearDownWagonTestingFixtures();
     }
 
+    protected ProgressArgumentMatcher setupGetIfNewerTest( Wagon wagon, 
boolean expectedResult, int expectedSize )
+        throws NoSuchAlgorithmException, IOException
+    {
+        checksumObserver = new ChecksumObserver();
+
+        destFile = FileTestUtils.createUniqueFile( getName(), getName() );
+        destFile.delete();
+        assertFalse( destFile.exists() );
+        destFile.deleteOnExit();
+
+        ProgressArgumentMatcher progressArgumentMatcher = null;
+        if ( expectedResult )
+        {
+            progressArgumentMatcher = replaceMockForGet( wagon, expectedSize );
+        }
+        else
+        {
+            replaceMockForSkippedGetIfNewer( wagon, expectedSize );
+        }
+        return progressArgumentMatcher;
+    }
+
     protected void assertGetIfNewerTest( ProgressArgumentMatcher 
progressArgumentMatcher, boolean expectedResult,
                                          int expectedSize )
         throws IOException
@@ -346,27 +368,6 @@ public abstract class WagonTestCase
         }
     }
 
-    protected ProgressArgumentMatcher setupGetIfNewerTest( Wagon wagon, 
boolean expectedResult, int expectedSize )
-        throws NoSuchAlgorithmException, IOException
-    {
-        checksumObserver = new ChecksumObserver();
-
-        destFile = FileTestUtils.createUniqueFile( getName(), getName() );
-        destFile.delete();
-        assertFalse( destFile.exists() );
-        destFile.deleteOnExit();
-
-        ProgressArgumentMatcher progressArgumentMatcher = null;
-        if ( expectedResult )
-        {
-            progressArgumentMatcher = replaceMockForGet( wagon, expectedSize );
-        }
-        else
-        {
-            replaceMockForSkippedGetIfNewer( wagon, expectedSize );
-        }
-        return progressArgumentMatcher;
-    }
 
     private void replaceMockForSkippedGetIfNewer( Wagon wagon, int 
expectedSize )
     {
@@ -960,6 +961,7 @@ public abstract class WagonTestCase
         verifyMock( progressArgumentMatcher, expectedSize );
     }
 
+
     protected void verifyMock( ProgressArgumentMatcher 
progressArgumentMatcher, int length )
     {
         mockTransferListenerControl.verify();
@@ -989,6 +991,16 @@ public abstract class WagonTestCase
         wagon.connect( testRepository, getAuthInfo() );
     }
 
+    /**
+     *
+     * some test (mock on transfertprogress call) relies on the fact that 
InputStream #read(byte[] b, int off, int len)
+     * read all bytes. But javadoc says: ""
+     */
+    protected boolean assertOnTransferProgress()
+    {
+        return true;
+    }
+
     protected ProgressArgumentMatcher replaceMockForGet( Wagon wagon, int 
expectedSize )
     {
         Resource resource = new Resource( this.resource );
@@ -1004,9 +1016,18 @@ public abstract class WagonTestCase
         mockTransferListener.transferProgress(
             new TransferEvent( wagon, resource, 
TransferEvent.TRANSFER_PROGRESS, TransferEvent.REQUEST_GET ),
             new byte[]{ }, 0 );
+
         ProgressArgumentMatcher progressArgumentMatcher = new 
ProgressArgumentMatcher();
-        mockTransferListenerControl.setMatcher( progressArgumentMatcher );
 
+        if ( assertOnTransferProgress() )
+        {
+            mockTransferListenerControl.setMatcher( progressArgumentMatcher );
+        }
+        else
+        {
+            mockTransferListenerControl.setMatcher( progressArgumentMatcher );
+            mockTransferListenerControl.setVoidCallable( 
MockControl.ZERO_OR_MORE );
+        }
         mockTransferListener.debug( null );
         mockTransferListenerControl.setMatcher( MockControl.ALWAYS_MATCHER );
         mockTransferListenerControl.setVoidCallable( MockControl.ZERO_OR_MORE 
);

http://git-wip-us.apache.org/repos/asf/maven-wagon/blob/fe938fbc/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpsWagonPreemptiveTest.java
----------------------------------------------------------------------
diff --git 
a/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpsWagonPreemptiveTest.java
 
b/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpsWagonPreemptiveTest.java
index 743dc5f..6f5179a 100644
--- 
a/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpsWagonPreemptiveTest.java
+++ 
b/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpsWagonPreemptiveTest.java
@@ -76,4 +76,10 @@ public class HttpsWagonPreemptiveTest
     {
         return true;
     }
+
+    @Override
+    protected boolean assertOnTransferProgress()
+    {
+        return false;
+    }
 }

http://git-wip-us.apache.org/repos/asf/maven-wagon/blob/fe938fbc/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpsWagonTest.java
----------------------------------------------------------------------
diff --git 
a/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpsWagonTest.java
 
b/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpsWagonTest.java
index b9e5127..c22b3ef 100644
--- 
a/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpsWagonTest.java
+++ 
b/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpsWagonTest.java
@@ -31,6 +31,11 @@ public class HttpsWagonTest
         return "https";
     }
 
+    protected boolean assertOnTransferProgress()
+    {
+        return false;
+    }
+
     protected void addConnectors( Server server )
     {
         System.setProperty( "javax.net.ssl.trustStore",

Reply via email to