[pkg-java] r17890 - in trunk/wagon/debian: . patches

Emmanuel Bourg ebourg-guest at moszumanska.debian.org
Thu Mar 13 15:25:17 UTC 2014


Author: ebourg-guest
Date: 2014-03-13 15:25:17 +0000 (Thu, 13 Mar 2014)
New Revision: 17890

Added:
   trunk/wagon/debian/patches/0005-easymock-compatibility.patch
Modified:
   trunk/wagon/debian/changelog
   trunk/wagon/debian/patches/series
Log:
Added a patch to ensure the compatibility with Easymock 3.x



Modified: trunk/wagon/debian/changelog
===================================================================
--- trunk/wagon/debian/changelog	2014-03-13 09:21:14 UTC (rev 17889)
+++ trunk/wagon/debian/changelog	2014-03-13 15:25:17 UTC (rev 17890)
@@ -1,5 +1,7 @@
 wagon (1.0.0-5) UNRELEASED; urgency=medium
 
+  * Added a patch to ensure the compatibility with Easymock 3.x
+    (Closes: #718872)
   * Switch to debhelper level 9
   * debian/control:
     - Standards-Version updated to 3.9.5 (no changes)

Added: trunk/wagon/debian/patches/0005-easymock-compatibility.patch
===================================================================
--- trunk/wagon/debian/patches/0005-easymock-compatibility.patch	                        (rev 0)
+++ trunk/wagon/debian/patches/0005-easymock-compatibility.patch	2014-03-13 15:25:17 UTC (rev 17890)
@@ -0,0 +1,846 @@
+Description: Ensures the compatibility with Easymock 3.x
+Author: Emmanuel Bourg <ebourg at apache.org>
+Forwarded: yes
+--- a/wagon-provider-api/src/test/java/org/apache/maven/wagon/AbstractWagonTest.java
++++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/AbstractWagonTest.java
+@@ -30,6 +30,7 @@
+ import org.apache.maven.wagon.authentication.AuthenticationException;
+ import org.apache.maven.wagon.authentication.AuthenticationInfo;
+ import org.apache.maven.wagon.authorization.AuthorizationException;
++import org.apache.maven.wagon.events.SessionEvent;
+ import org.apache.maven.wagon.events.SessionListener;
+ import org.apache.maven.wagon.events.TransferEvent;
+ import org.apache.maven.wagon.events.TransferListener;
+@@ -40,8 +41,9 @@
+ import org.apache.maven.wagon.resource.Resource;
+ import org.codehaus.plexus.util.FileUtils;
+ import org.codehaus.plexus.util.IOUtil;
+-import org.easymock.AbstractMatcher;
+-import org.easymock.MockControl;
++import org.easymock.IAnswer;
++
++import static org.easymock.EasyMock.*;
+ 
+ /**
+  * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+@@ -94,10 +96,6 @@
+ 
+     private TransferListener transferListener = null;
+ 
+-    private MockControl transferListenerControl;
+-
+-    private MockControl sessionListenerControl;
+-
+     protected void setUp()
+         throws Exception
+     {
+@@ -111,13 +109,11 @@
+ 
+         wagon = new WagonMock();
+ 
+-        sessionListenerControl = MockControl.createControl( SessionListener.class );
+-        sessionListener = (SessionListener) sessionListenerControl.getMock();
++        sessionListener = createMock( SessionListener.class );
+ 
+         wagon.addSessionListener( sessionListener );
+ 
+-        transferListenerControl = MockControl.createControl( TransferListener.class );
+-        transferListener = (TransferListener) transferListenerControl.getMock();
++        transferListener = createMock( TransferListener.class );
+ 
+         wagon.addTransferListener( transferListener );
+ 
+@@ -237,14 +233,13 @@
+     {
+         Repository repository = new Repository();
+ 
+-        sessionListenerControl.setDefaultMatcher( MockControl.ALWAYS_MATCHER );
+-        sessionListener.sessionOpening( null );
+-        sessionListener.sessionOpened( null );
+-        sessionListenerControl.replay();
++        sessionListener.sessionOpening( anyObject( SessionEvent.class ) );
++        sessionListener.sessionOpened( anyObject( SessionEvent.class ) );
++        replay( sessionListener );
+ 
+         wagon.connect( repository );
+ 
+-        sessionListenerControl.verify();
++        verify( sessionListener );
+ 
+         assertEquals( repository, wagon.getRepository() );
+     }
+@@ -286,10 +281,9 @@
+     {
+         Repository repository = new Repository();
+ 
+-        sessionListenerControl.setDefaultMatcher( MockControl.ALWAYS_MATCHER );
+-        sessionListener.sessionOpening( null );
+-        sessionListener.sessionConnectionRefused( null );
+-        sessionListenerControl.replay();
++        sessionListener.sessionOpening( anyObject( SessionEvent.class ) );
++        sessionListener.sessionConnectionRefused( anyObject( SessionEvent.class ) );
++        replay( sessionListener );
+ 
+         Wagon wagon = new TestWagon()
+         {
+@@ -315,7 +309,7 @@
+         }
+         finally
+         {
+-            sessionListenerControl.verify();
++            verify( sessionListener );
+ 
+             assertEquals( repository, wagon.getRepository() );
+         }
+@@ -324,14 +318,13 @@
+     public void testSessionCloseEvents()
+         throws Exception
+     {
+-        sessionListenerControl.setDefaultMatcher( MockControl.ALWAYS_MATCHER );
+-        sessionListener.sessionDisconnecting( null );
+-        sessionListener.sessionDisconnected( null );
+-        sessionListenerControl.replay();
++        sessionListener.sessionDisconnecting( anyObject( SessionEvent.class ) );
++        sessionListener.sessionDisconnected( anyObject( SessionEvent.class ) );
++        replay( sessionListener );
+ 
+         wagon.disconnect();
+ 
+-        sessionListenerControl.verify();
++        verify( sessionListener );
+     }
+ 
+     public void testSessionCloseRefusedEventConnectionException()
+@@ -339,10 +332,9 @@
+     {
+         Repository repository = new Repository();
+ 
+-        sessionListenerControl.setDefaultMatcher( MockControl.ALWAYS_MATCHER );
+-        sessionListener.sessionDisconnecting( null );
+-        sessionListener.sessionError( null );
+-        sessionListenerControl.replay();
++        sessionListener.sessionDisconnecting( anyObject( SessionEvent.class ) );
++        sessionListener.sessionError( anyObject( SessionEvent.class ) );
++        replay( sessionListener );
+ 
+         Wagon wagon = new TestWagon()
+         {
+@@ -365,7 +357,7 @@
+         }
+         finally
+         {
+-            sessionListenerControl.verify();
++            verify( sessionListener );
+         }
+     }
+ 
+@@ -373,15 +365,14 @@
+         throws Exception
+     {
+         transferListener.debug( "fetch debug message" );
+-        transferListenerControl.setDefaultMatcher( MockControl.ALWAYS_MATCHER );
+-        transferListener.transferInitiated( null );
+-        transferListener.transferStarted( null );
+-        transferListener.debug( null );
+-        transferListenerControl.setVoidCallable( MockControl.ZERO_OR_MORE );
+-        transferListener.transferProgress( null, null, 0 );
+-        transferListenerControl.setVoidCallable( 5 );
+-        transferListener.transferCompleted( null );
+-        transferListenerControl.replay();
++        transferListener.transferInitiated( anyObject( TransferEvent.class ) );
++        transferListener.transferStarted( anyObject( TransferEvent.class ) );
++        transferListener.debug( anyString() );
++        expectLastCall().anyTimes();
++        transferListener.transferProgress( anyObject( TransferEvent.class ), anyObject( byte[].class ), anyInt() );
++        expectLastCall().times( 5 );
++        transferListener.transferCompleted( anyObject( TransferEvent.class ) );
++        replay( transferListener );
+ 
+         wagon.fireTransferDebug( "fetch debug message" );
+ 
+@@ -390,19 +381,18 @@
+ 
+         wagon.get( artifact, destination );
+ 
+-        transferListenerControl.verify();
++        verify( transferListener );
+     }
+ 
+     public void testGetError()
+         throws Exception
+     {
+-        transferListenerControl.setDefaultMatcher( MockControl.ALWAYS_MATCHER );
+-        transferListener.transferInitiated( null );
+-        transferListener.transferStarted( null );
+-        transferListener.debug( null );
+-        transferListenerControl.setVoidCallable( MockControl.ZERO_OR_MORE );
+-        transferListener.transferError( null );
+-        transferListenerControl.replay();
++        transferListener.transferInitiated( anyObject( TransferEvent.class ) );
++        transferListener.transferStarted( anyObject( TransferEvent.class ) );
++        transferListener.debug( anyString() );
++        expectLastCall().anyTimes();
++        transferListener.transferError( anyObject( TransferEvent.class ) );
++        replay( transferListener );
+ 
+         try
+         {
+@@ -423,7 +413,7 @@
+             assertTrue( true );
+         }
+ 
+-        transferListenerControl.verify();
++        verify( transferListener );
+     }
+ 
+     public void testPutTransferEvents()
+@@ -431,12 +421,11 @@
+         AuthorizationException
+     {
+         transferListener.debug( "deploy debug message" );
+-        transferListenerControl.setDefaultMatcher( MockControl.ALWAYS_MATCHER );
+-        transferListener.transferInitiated( null );
+-        transferListener.transferStarted( null );
+-        transferListener.transferProgress( null, null, 0 );
+-        transferListener.transferCompleted( null );
+-        transferListenerControl.replay();
++        transferListener.transferInitiated( anyObject( TransferEvent.class ) );
++        transferListener.transferStarted( anyObject( TransferEvent.class ) );
++        transferListener.transferProgress( anyObject( TransferEvent.class ), anyObject( byte[].class ), anyInt() );
++        transferListener.transferCompleted( anyObject( TransferEvent.class ) );
++        replay( transferListener );
+ 
+         wagon.fireTransferDebug( "deploy debug message" );
+ 
+@@ -446,7 +435,7 @@
+ 
+         wagon.put( source, artifact );
+ 
+-        transferListenerControl.verify();
++        verify( transferListener );
+     }
+ 
+     public void testStreamShutdown()
+@@ -543,52 +532,38 @@
+ 
+         Resource resource = new Resource( "resource" );
+ 
+-        transferListener.transferInitiated( null );
+-        transferListenerControl.setMatcher( MockControl.ALWAYS_MATCHER );
+-        transferListener.transferStarted( null );
+-        transferListenerControl.setMatcher( MockControl.ALWAYS_MATCHER );
++        transferListener.transferInitiated(anyObject(TransferEvent.class));
++        transferListener.transferStarted(anyObject(TransferEvent.class));
+         TransferEvent event =
+             new TransferEvent( wagon, resource, TransferEvent.TRANSFER_PROGRESS, TransferEvent.REQUEST_PUT );
+         event.setLocalFile( tempFile );
+-        transferListener.transferProgress( event, content.getBytes(), content.length() );
+-        ProgressArgumentMatcher matcher = new ProgressArgumentMatcher();
+-        transferListenerControl.setMatcher( matcher );
+-        transferListener.transferCompleted( null );
+-        transferListenerControl.setMatcher( MockControl.ALWAYS_MATCHER );
+-        transferListenerControl.replay();
++        transferListener.transferProgress( eq( event ), anyObject( byte[].class ), eq( content.length() ) );
++        ProgressAnswer answer = new ProgressAnswer();
++        expectLastCall().andAnswer( answer );
++        transferListener.transferCompleted( anyObject( TransferEvent.class ) );
++        replay( transferListener );
+ 
+         wagon.postProcessListeners( resource, tempFile, TransferEvent.REQUEST_PUT );
+ 
+-        assertEquals( content.length(), matcher.getSize() );
+-        assertEquals( new String( content.getBytes() ), new String( matcher.getBytes() ) );
++        assertEquals( content.length(), answer.getSize() );
++        assertEquals( new String( content.getBytes() ), new String( answer.getBytes() ) );
+ 
+         tempFile.delete();
+     }
+ 
+-    static final class ProgressArgumentMatcher
+-        extends AbstractMatcher
++    static final class ProgressAnswer implements IAnswer
+     {
+         private ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ 
+         private int size;
+         
+-        private byte[] lastArray;
+-
+-        protected boolean argumentMatches( Object expected, Object actual )
++        public Object answer() throws Throwable
+         {
+-            if ( actual instanceof byte[] )
+-            {
+-                lastArray = (byte[]) actual;
+-                return true;
+-            }
+-            if ( actual instanceof Integer )
+-            {
+-                int length = ( (Integer) actual ).intValue();
+-                baos.write( lastArray, 0, length );
+-                size += length;
+-                return true;
+-            }
+-            return super.argumentMatches( expected, actual );
++            byte[] buffer = (byte[]) getCurrentArguments()[1];
++            int length = (Integer) getCurrentArguments()[2];
++            baos.write( buffer, 0, length );
++            size += length;
++            return null;
+         }
+ 
+         public int getSize()
+--- a/wagon-provider-api/src/test/java/org/apache/maven/wagon/events/SessionEventSupportTest.java
++++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/events/SessionEventSupportTest.java
+@@ -22,7 +22,7 @@
+ import junit.framework.TestCase;
+ 
+ import org.apache.maven.wagon.Wagon;
+-import org.easymock.MockControl;
++import org.easymock.EasyMock;
+ 
+ /**
+  * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+@@ -34,8 +34,6 @@
+ 
+     private SessionEventSupport eventSupport;
+ 
+-    private MockControl wagonMockControl;
+-    
+     private Wagon wagon;
+ 
+     /**
+@@ -49,9 +47,7 @@
+         eventSupport = new SessionEventSupport();
+         
+         // TODO: actually test it gets called?
+-        wagonMockControl = MockControl.createControl( Wagon.class );
+-        
+-        wagon = (Wagon) wagonMockControl.getMock();
++        wagon = (Wagon) EasyMock.createMock( Wagon.class );
+     }
+ 
+     public void testSessionListenerRegistration()
+--- a/wagon-provider-api/src/test/java/org/apache/maven/wagon/events/SessionEventTest.java
++++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/events/SessionEventTest.java
+@@ -24,7 +24,7 @@
+ import org.apache.maven.wagon.Wagon;
+ import org.apache.maven.wagon.authentication.AuthenticationException;
+ import org.apache.maven.wagon.repository.Repository;
+-import org.easymock.MockControl;
++import org.easymock.EasyMock;
+ 
+ /**
+  * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+@@ -41,7 +41,7 @@
+         throws ConnectionException, AuthenticationException
+     {
+ 
+-        final Wagon wagon = (Wagon) MockControl.createControl( Wagon.class ).getMock();
++        final Wagon wagon = (Wagon) EasyMock.createMock(Wagon.class);
+         final Repository repo = new Repository();
+ 
+         wagon.connect( repo );
+--- a/wagon-provider-api/src/test/java/org/apache/maven/wagon/events/TransferEventSupportTest.java
++++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/events/TransferEventSupportTest.java
+@@ -21,7 +21,7 @@
+ 
+ import junit.framework.TestCase;
+ import org.apache.maven.wagon.Wagon;
+-import org.easymock.MockControl;
++import org.easymock.EasyMock;
+ 
+ /**
+  * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+@@ -33,8 +33,6 @@
+ {
+     private TransferEventSupport eventSupport;
+ 
+-    private MockControl wagonMockControl;
+-    
+     private Wagon wagon;
+ 
+     /**
+@@ -48,9 +46,7 @@
+         eventSupport = new TransferEventSupport();
+         
+         // TODO: actually test it gets called?
+-        wagonMockControl = MockControl.createControl( Wagon.class );
+-        
+-        wagon = (Wagon) wagonMockControl.getMock();
++        wagon = (Wagon) EasyMock.createMock(Wagon.class);
+     }
+ 
+     public void testTransferListenerRegistration()
+--- a/wagon-provider-api/src/test/java/org/apache/maven/wagon/events/TransferEventTest.java
++++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/events/TransferEventTest.java
+@@ -25,7 +25,7 @@
+ import org.apache.maven.wagon.authentication.AuthenticationException;
+ import org.apache.maven.wagon.repository.Repository;
+ import org.apache.maven.wagon.resource.Resource;
+-import org.easymock.MockControl;
++import org.easymock.EasyMock;
+ 
+ /**
+  * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+@@ -41,7 +41,7 @@
+     public void testTransferEventProperties()
+         throws ConnectionException, AuthenticationException
+     {
+-        final Wagon wagon = (Wagon) MockControl.createControl( Wagon.class ).getMock();
++        final Wagon wagon = (Wagon) EasyMock.createMock(Wagon.class);
+ 
+         final Repository repo = new Repository();
+ 
+--- a/wagon-provider-api/src/test/java/org/apache/maven/wagon/StreamWagonTest.java
++++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/StreamWagonTest.java
+@@ -36,7 +36,8 @@
+ import org.codehaus.plexus.util.IOUtil;
+ import org.codehaus.plexus.util.StringInputStream;
+ import org.codehaus.plexus.util.StringOutputStream;
+-import org.easymock.MockControl;
++
++import static org.easymock.EasyMock.*;
+ 
+ public class StreamWagonTest
+     extends TestCase
+@@ -78,15 +79,13 @@
+             }
+         };
+ 
+-        MockControl control = MockControl.createControl( TransferListener.class );
+-        TransferListener listener = (TransferListener) control.getMock();
+-        listener.transferInitiated( null );
+-        control.setMatcher( MockControl.ALWAYS_MATCHER );
++        TransferListener listener = createMock( TransferListener.class );
++        listener.transferInitiated( anyObject( TransferEvent.class ) );
+         TransferEvent transferEvent =
+             new TransferEvent( wagon, new Resource( "resource" ), new TransferFailedException( "" ),
+                                TransferEvent.REQUEST_GET );
+         listener.transferError( transferEvent );
+-        control.replay();
++        replay( listener );
+ 
+         wagon.connect( repository );
+         wagon.addTransferListener( listener );
+@@ -104,7 +103,7 @@
+             wagon.disconnect();
+         }
+ 
+-        control.verify();
++        verify( listener );
+     }
+ 
+     public void testNullOutputStream()
+@@ -118,15 +117,13 @@
+             }
+         };
+ 
+-        MockControl control = MockControl.createControl( TransferListener.class );
+-        TransferListener listener = (TransferListener) control.getMock();
+-        listener.transferInitiated( null );
+-        control.setMatcher( MockControl.ALWAYS_MATCHER );
++        TransferListener listener = createMock( TransferListener.class );
++        listener.transferInitiated( anyObject( TransferEvent.class ) );
+         TransferEvent transferEvent =
+             new TransferEvent( wagon, new Resource( "resource" ), new TransferFailedException( "" ),
+                                TransferEvent.REQUEST_PUT );
+         listener.transferError( transferEvent );
+-        control.replay();
++        replay( listener );
+ 
+         wagon.connect( repository );
+         wagon.addTransferListener( listener );
+@@ -144,7 +141,7 @@
+             wagon.disconnect();
+         }
+ 
+-        control.verify();
++        verify( listener );
+     }
+ 
+     public void testTransferFailedExceptionOnInput()
+@@ -173,15 +170,13 @@
+             }
+         };
+ 
+-        MockControl control = MockControl.createControl( TransferListener.class );
+-        TransferListener listener = (TransferListener) control.getMock();
+-        listener.transferInitiated( null );
+-        control.setMatcher( MockControl.ALWAYS_MATCHER );
++        TransferListener listener = createMock( TransferListener.class );
++        listener.transferInitiated( anyObject( TransferEvent.class ) );
+         TransferEvent transferEvent =
+             new TransferEvent( wagon, new Resource( "resource" ), new TransferFailedException( "" ),
+                                TransferEvent.REQUEST_PUT );
+         listener.transferError( transferEvent );
+-        control.replay();
++        replay( listener );
+ 
+         wagon.connect( repository );
+         wagon.addTransferListener( listener );
+@@ -197,7 +192,7 @@
+         finally
+         {
+             wagon.disconnect();
+-            control.verify();
++            verify( listener );
+         }
+     }
+ 
+@@ -253,14 +248,12 @@
+             }
+         };
+ 
+-        MockControl control = MockControl.createControl( TransferListener.class );
+-        TransferListener listener = (TransferListener) control.getMock();
+-        listener.transferInitiated( null );
+-        control.setMatcher( MockControl.ALWAYS_MATCHER );
++        TransferListener listener = createMock( TransferListener.class );
++        listener.transferInitiated( anyObject( TransferEvent.class ) );
+         TransferEvent transferEvent =
+             new TransferEvent( wagon, new Resource( "resource" ), exception, TransferEvent.REQUEST_GET );
+         listener.transferError( transferEvent );
+-        control.replay();
++        replay( listener );
+ 
+         wagon.connect( repository );
+         wagon.addTransferListener( listener );
+@@ -272,7 +265,7 @@
+         finally
+         {
+             wagon.disconnect();
+-            control.verify();
++            verify( listener );
+         }
+     }
+ 
+--- a/wagon-provider-test/src/main/java/org/apache/maven/wagon/StreamingWagonTestCase.java
++++ b/wagon-provider-test/src/main/java/org/apache/maven/wagon/StreamingWagonTestCase.java
+@@ -143,7 +143,7 @@
+     {
+         StreamingWagon wagon = (StreamingWagon) getWagon();
+ 
+-        ProgressArgumentMatcher progressArgumentMatcher = setupGetIfNewerTest( wagon, expectedResult, expectedSize );
++        ProgressAnswer progressAnswer = setupGetIfNewerTest( wagon, expectedResult, expectedSize );
+ 
+         connectWagon( wagon );
+ 
+@@ -161,7 +161,7 @@
+         
+         disconnectWagon( wagon );
+ 
+-        assertGetIfNewerTest( progressArgumentMatcher, expectedResult, expectedSize );
++        assertGetIfNewerTest( progressAnswer, expectedResult, expectedSize );
+ 
+         tearDownWagonTestingFixtures();
+     }
+@@ -244,7 +244,7 @@
+ 
+         StreamingWagon wagon = (StreamingWagon) getWagon();
+ 
+-        ProgressArgumentMatcher progressArgumentMatcher = replayMockForPut( resource, content, wagon );
++        ProgressAnswer progressAnswer = replayMockForPut( resource, content, wagon );
+ 
+         message( "Putting test artifact: " + resource + " into test repository " + testRepository );
+ 
+@@ -264,7 +264,7 @@
+ 
+         disconnectWagon( wagon );
+ 
+-        verifyMock( progressArgumentMatcher, content.length() );
++        verifyMock( progressAnswer, content.length() );
+         return content.length();
+     }
+ 
+@@ -276,7 +276,7 @@
+ 
+         StreamingWagon wagon = (StreamingWagon) getWagon();
+ 
+-        ProgressArgumentMatcher progressArgumentMatcher = replaceMockForGet( wagon, expectedSize );
++        ProgressAnswer progressAnswer = replaceMockForGet( wagon, expectedSize );
+ 
+         message( "Getting test artifact from test repository " + testRepository );
+ 
+@@ -296,6 +296,6 @@
+ 
+         disconnectWagon( wagon );
+ 
+-        verifyMock( progressArgumentMatcher, expectedSize );
++        verifyMock( progressAnswer, expectedSize );
+     }
+ }
+--- 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
+@@ -40,8 +40,9 @@
+ import org.apache.maven.wagon.resource.Resource;
+ import org.codehaus.plexus.PlexusTestCase;
+ import org.codehaus.plexus.util.FileUtils;
+-import org.easymock.AbstractMatcher;
+-import org.easymock.MockControl;
++import org.easymock.IAnswer;
++
++import static org.easymock.EasyMock.*;
+ 
+ /**
+  * @author <a href="mailto:jason at maven.org">Jason van Zyl</a>
+@@ -50,23 +51,15 @@
+ public abstract class WagonTestCase
+     extends PlexusTestCase
+ {
+-    static final class ProgressArgumentMatcher
+-        extends AbstractMatcher
++    static final class ProgressAnswer implements IAnswer
+     {
+         private int size;
+ 
+-        protected boolean argumentMatches( Object expected, Object actual )
++        public Object answer() throws Throwable
+         {
+-            if ( actual instanceof byte[] )
+-            {
+-                return true;
+-            }
+-            if ( actual instanceof Integer )
+-            {
+-                size += ( (Integer) actual ).intValue();
+-                return true;
+-            }
+-            return super.argumentMatches( expected, actual );
++            int length = (Integer) getCurrentArguments()[2];
++            size += length;
++            return null;
+         }
+ 
+         public int getSize()
+@@ -97,8 +90,6 @@
+ 
+     protected TransferListener mockTransferListener;
+ 
+-    protected MockControl mockTransferListenerControl;
+-
+     // ----------------------------------------------------------------------
+     // Constructors
+     // ----------------------------------------------------------------------
+@@ -108,8 +99,7 @@
+     {
+         checksumObserver = new ChecksumObserver();
+ 
+-        mockTransferListenerControl = MockControl.createControl( TransferListener.class );
+-        mockTransferListener = (TransferListener) mockTransferListenerControl.getMock();
++        mockTransferListener = createMock( TransferListener.class );
+ 
+         super.setUp();
+     }
+@@ -294,7 +284,7 @@
+     {
+         Wagon wagon = getWagon();
+ 
+-        ProgressArgumentMatcher progressArgumentMatcher = setupGetIfNewerTest( wagon, expectedResult, expectedSize );
++        ProgressAnswer progressAnswer = setupGetIfNewerTest( wagon, expectedResult, expectedSize );
+ 
+         connectWagon( wagon );
+ 
+@@ -303,18 +293,18 @@
+ 
+         disconnectWagon( wagon );
+ 
+-        assertGetIfNewerTest( progressArgumentMatcher, expectedResult, expectedSize );
++        assertGetIfNewerTest( progressAnswer, expectedResult, expectedSize );
+ 
+         tearDownWagonTestingFixtures();
+     }
+ 
+-    protected void assertGetIfNewerTest( ProgressArgumentMatcher progressArgumentMatcher, boolean expectedResult,
++    protected void assertGetIfNewerTest( ProgressAnswer progressAnswer, boolean expectedResult,
+                                          int expectedSize )
+         throws IOException
+     {
+         if ( expectedResult == true )
+         {
+-            verifyMock( progressArgumentMatcher, expectedSize );
++            verifyMock( progressAnswer, expectedSize );
+ 
+             assertNotNull( "check checksum is not null", checksumObserver.getActualChecksum() );
+ 
+@@ -330,9 +320,9 @@
+         }
+         else
+         {
+-            mockTransferListenerControl.verify();
++            verify( mockTransferListener );
+ 
+-            mockTransferListenerControl.reset();
++            reset( mockTransferListener );
+ 
+             assertNull( "check checksum is null", checksumObserver.getActualChecksum() );
+ 
+@@ -340,7 +330,7 @@
+         }
+     }
+ 
+-    protected ProgressArgumentMatcher setupGetIfNewerTest( Wagon wagon, boolean expectedResult, int expectedSize )
++    protected ProgressAnswer setupGetIfNewerTest( Wagon wagon, boolean expectedResult, int expectedSize )
+         throws NoSuchAlgorithmException, IOException
+     {
+         checksumObserver = new ChecksumObserver();
+@@ -350,16 +340,16 @@
+         assertFalse( destFile.exists() );
+         destFile.deleteOnExit();
+ 
+-        ProgressArgumentMatcher progressArgumentMatcher = null;
++        ProgressAnswer progressAnswer = null;
+         if ( expectedResult == true )
+         {
+-            progressArgumentMatcher = replaceMockForGet( wagon, expectedSize );
++            progressAnswer = replaceMockForGet( wagon, expectedSize );
+         }
+         else
+         {
+             replaceMockForSkippedGetIfNewer( wagon, expectedSize );
+         }
+-        return progressArgumentMatcher;
++        return progressAnswer;
+     }
+ 
+     private void replaceMockForSkippedGetIfNewer( Wagon wagon, int expectedSize )
+@@ -374,11 +364,10 @@
+         // mockTransferListener.transferSkipped( createTransferEvent( wagon, resource, TransferEvent.TRANSFER_STARTED,
+         // TransferEvent.REQUEST_GET, destFile ) );
+ 
+-        mockTransferListener.debug( null );
+-        mockTransferListenerControl.setMatcher( MockControl.ALWAYS_MATCHER );
+-        mockTransferListenerControl.setVoidCallable( MockControl.ZERO_OR_MORE );
++        mockTransferListener.debug( anyString() );
++        expectLastCall().anyTimes();
+ 
+-        mockTransferListenerControl.replay();
++        replay( mockTransferListener );
+     }
+ 
+     public void testWagonPutDirectory()
+@@ -873,7 +862,7 @@
+ 
+         Wagon wagon = getWagon();
+ 
+-        ProgressArgumentMatcher progressArgumentMatcher = replayMockForPut( resourceName, content, wagon );
++        ProgressAnswer progressAnswer = replayMockForPut( resourceName, content, wagon );
+ 
+         message( "Putting test artifact: " + resourceName + " into test repository " + testRepository );
+ 
+@@ -883,10 +872,10 @@
+ 
+         disconnectWagon( wagon );
+ 
+-        verifyMock( progressArgumentMatcher, content.length() );
++        verifyMock( progressAnswer, content.length() );
+     }
+ 
+-    protected ProgressArgumentMatcher replayMockForPut( String resourceName, String content, Wagon wagon )
++    protected ProgressAnswer replayMockForPut( String resourceName, String content, Wagon wagon )
+     {
+         Resource resource = new Resource( resourceName );
+         mockTransferListener.transferInitiated( createTransferEvent( wagon, resource, TransferEvent.TRANSFER_INITIATED,
+@@ -896,21 +885,20 @@
+         resource.setLastModified( sourceFile.lastModified() );
+         mockTransferListener.transferStarted( createTransferEvent( wagon, resource, TransferEvent.TRANSFER_STARTED,
+                                                                    TransferEvent.REQUEST_PUT, sourceFile ) );
+-        mockTransferListener.transferProgress( createTransferEvent( wagon, resource, TransferEvent.TRANSFER_PROGRESS,
+-                                                                    TransferEvent.REQUEST_PUT, sourceFile ),
+-                                               new byte[] {}, 0 );
+-        ProgressArgumentMatcher progressArgumentMatcher = new ProgressArgumentMatcher();
+-        mockTransferListenerControl.setMatcher( progressArgumentMatcher );
+-
+-        mockTransferListener.debug( null );
+-        mockTransferListenerControl.setMatcher( MockControl.ALWAYS_MATCHER );
+-        mockTransferListenerControl.setVoidCallable( MockControl.ZERO_OR_MORE );
++        mockTransferListener.transferProgress(
++            eq( createTransferEvent( wagon, resource, TransferEvent.TRANSFER_PROGRESS, TransferEvent.REQUEST_PUT,
++                                     sourceFile ) ), anyObject( byte[].class ), anyInt() );
++        ProgressAnswer progressAnswer = new ProgressAnswer();
++        expectLastCall().andStubAnswer( progressAnswer );
++
++        mockTransferListener.debug( anyString() );
++        expectLastCall().anyTimes();
+ 
+         mockTransferListener.transferCompleted( createTransferEvent( wagon, resource, TransferEvent.TRANSFER_COMPLETED,
+                                                                      TransferEvent.REQUEST_PUT, sourceFile ) );
+ 
+-        mockTransferListenerControl.replay();
+-        return progressArgumentMatcher;
++        replay( mockTransferListener );
++        return progressAnswer;
+     }
+ 
+     protected TransferEvent createTransferEvent( Wagon wagon, Resource resource, int eventType, int requestType,
+@@ -937,7 +925,7 @@
+ 
+         Wagon wagon = getWagon();
+ 
+-        ProgressArgumentMatcher progressArgumentMatcher = replaceMockForGet( wagon, expectedSize );
++        ProgressAnswer progressAnswer = replaceMockForGet( wagon, expectedSize );
+ 
+         message( "Getting test artifact from test repository " + testRepository );
+ 
+@@ -947,16 +935,16 @@
+ 
+         disconnectWagon( wagon );
+ 
+-        verifyMock( progressArgumentMatcher, expectedSize );
++        verifyMock( progressAnswer, expectedSize );
+     }
+ 
+-    protected void verifyMock( ProgressArgumentMatcher progressArgumentMatcher, int length )
++    protected void verifyMock( ProgressAnswer progressAnswer, int length )
+     {
+-        mockTransferListenerControl.verify();
++        verify( mockTransferListener );
+ 
+-        assertEquals( length, progressArgumentMatcher.getSize() );
++        assertEquals(length, progressAnswer.getSize());
+ 
+-        mockTransferListenerControl.reset();
++        reset( mockTransferListener );
+     }
+ 
+     protected void disconnectWagon( Wagon wagon )
+@@ -979,7 +967,7 @@
+         wagon.connect( testRepository, getAuthInfo() );
+     }
+ 
+-    protected ProgressArgumentMatcher replaceMockForGet( Wagon wagon, int expectedSize )
++    protected ProgressAnswer replaceMockForGet( Wagon wagon, int expectedSize )
+     {
+         Resource resource = new Resource( this.resource );
+         mockTransferListener.transferInitiated( createTransferEvent( wagon, resource, TransferEvent.TRANSFER_INITIATED,
+@@ -989,20 +977,20 @@
+         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,
+-                                                                  TransferEvent.REQUEST_GET ), new byte[] {}, 0 );
+-        ProgressArgumentMatcher progressArgumentMatcher = new ProgressArgumentMatcher();
+-        mockTransferListenerControl.setMatcher( progressArgumentMatcher );
+-
+-        mockTransferListener.debug( null );
+-        mockTransferListenerControl.setMatcher( MockControl.ALWAYS_MATCHER );
+-        mockTransferListenerControl.setVoidCallable( MockControl.ZERO_OR_MORE );
++        mockTransferListener.transferProgress( 
++            eq( new TransferEvent( wagon, resource, TransferEvent.TRANSFER_PROGRESS, TransferEvent.REQUEST_GET ) ),
++            anyObject( byte[].class ), anyInt() );
++        ProgressAnswer progressAnswer = new ProgressAnswer();
++        expectLastCall().andAnswer( progressAnswer );
++
++        mockTransferListener.debug( anyString() );
++        expectLastCall().anyTimes();
+ 
+         mockTransferListener.transferCompleted( createTransferEvent( wagon, resource, TransferEvent.TRANSFER_COMPLETED,
+                                                                      TransferEvent.REQUEST_GET, destFile ) );
+ 
+-        mockTransferListenerControl.replay();
+-        return progressArgumentMatcher;
++        replay( mockTransferListener );
++        return progressAnswer;
+     }
+ 
+     protected int getExpectedContentLengthOnGet( int expectedSize )

Modified: trunk/wagon/debian/patches/series
===================================================================
--- trunk/wagon/debian/patches/series	2014-03-13 09:21:14 UTC (rev 17889)
+++ trunk/wagon/debian/patches/series	2014-03-13 15:25:17 UTC (rev 17890)
@@ -2,3 +2,4 @@
 0002-disable-webdav-jackrabbit-module.patch
 0003-do-not-run-https-tests.patch
 0004-fix-tests-parrallel-run.diff
+0005-easymock-compatibility.patch




More information about the pkg-java-commits mailing list