maven-wagon-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r662318 - in /maven/wagon/trunk: wagon-provider-api/src/main/java/org/apache/maven/wagon/ wagon-provider-test/src/main/java/org/apache/maven/wagon/ wagon-providers/wagon-file/src/main/java/org/apache/maven/wagon/providers/file/ wagon-provid...
Date Mon, 02 Jun 2008 04:47:37 GMT
Author: brett
Date: Sun Jun  1 21:47:36 2008
New Revision: 662318

URL: http://svn.apache.org/viewvc?rev=662318&view=rev
Log:
[WAGON-101] add streaming for StreamWagon. Additionally add tests for getIfNewer

Added:
    maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/StreamingWagon.java   (with props)
    maven/wagon/trunk/wagon-provider-test/src/main/java/org/apache/maven/wagon/StreamingWagonTestCase.java   (with props)
Modified:
    maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/AbstractWagon.java
    maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/StreamWagon.java
    maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/Wagon.java
    maven/wagon/trunk/wagon-provider-test/src/main/java/org/apache/maven/wagon/WagonTestCase.java
    maven/wagon/trunk/wagon-providers/wagon-file/src/main/java/org/apache/maven/wagon/providers/file/FileWagon.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/main/java/org/apache/maven/wagon/providers/http/LightweightHttpWagon.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-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScmSvnWagonTest.java
    maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagon.java

Modified: maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/AbstractWagon.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/AbstractWagon.java?rev=662318&r1=662317&r2=662318&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/AbstractWagon.java (original)
+++ maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/AbstractWagon.java Sun Jun  1 21:47:36 2008
@@ -277,6 +277,12 @@
         getTransfer( resource, destination, input, true, Integer.MAX_VALUE );
     }
 
+    protected void getTransfer( Resource resource, OutputStream output, InputStream input )
+        throws TransferFailedException
+    {
+        getTransfer( resource, output, input, true, Integer.MAX_VALUE );
+    }
+
     protected void getTransfer( Resource resource, File destination, InputStream input, boolean closeInput,
                                 int maxSize )
         throws TransferFailedException
@@ -285,18 +291,16 @@
         fireTransferDebug( "attempting to create parent directories for destination: " + destination.getName() );
         createParentDirectories( destination );
 
-        fireGetStarted( resource, destination );
-
         OutputStream output = new LazyFileOutputStream( destination );
 
+        fireGetStarted( resource, destination );
+
         try
         {
-            transfer( resource, input, output, TransferEvent.REQUEST_GET, maxSize );
+            getTransfer( resource, output, input, closeInput, maxSize );
         }
-        catch ( IOException e )
+        catch ( TransferFailedException e )
         {
-            fireTransferError( resource, e, TransferEvent.REQUEST_GET );
-
             if ( destination.exists() )
             {
                 boolean deleted = destination.delete();
@@ -306,11 +310,26 @@
                     destination.deleteOnExit();
                 }
             }
+            throw e;
+        }
+
+        fireGetCompleted( resource, destination );
+    }
+
+    protected void getTransfer( Resource resource, OutputStream output, InputStream input, boolean closeInput, int maxSize )
+        throws TransferFailedException
+    {
+        try
+        {
+            transfer( resource, input, output, TransferEvent.REQUEST_GET, maxSize );
+        }
+        catch ( IOException e )
+        {
+            fireTransferError( resource, e, TransferEvent.REQUEST_GET );
 
             String msg = "GET request of: " + resource.getName() + " from " + repository.getName() + " failed";
 
             throw new TransferFailedException( msg, e );
-
         }
         finally
         {
@@ -321,12 +340,10 @@
 
             IOUtil.close( output );
         }
-
-        fireGetCompleted( resource, destination );
     }
 
     protected void putTransfer( Resource resource, File source, OutputStream output, boolean closeOutput )
-        throws TransferFailedException
+        throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
     {
         resource.setContentLength( source.length() );
 
@@ -349,9 +366,11 @@
      * @param output output stream
      * @param closeOutput whether the output stream should be closed or not
      * @throws TransferFailedException
+     * @throws ResourceDoesNotExistException 
+     * @throws AuthorizationException 
      */
     protected void transfer( Resource resource, File source, OutputStream output, boolean closeOutput )
-        throws TransferFailedException
+        throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
     {
         InputStream input = null;
 
@@ -359,7 +378,7 @@
         {
             input = new FileInputStream( source );
 
-            transfer( resource, input, output, TransferEvent.REQUEST_PUT );
+            putTransfer( resource, input, output, closeOutput );
         }
         catch ( FileNotFoundException e )
         {
@@ -367,18 +386,29 @@
 
             throw new TransferFailedException( "Specified source file does not exist: " + source, e );
         }
+        finally
+        {
+            IOUtil.close( input );
+        }
+    }
+
+    protected void putTransfer( Resource resource, InputStream input, OutputStream output, boolean closeOutput )
+        throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
+    {
+        try
+        {
+            transfer( resource, input, output, TransferEvent.REQUEST_PUT );
+        }
         catch ( IOException e )
         {
             fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
 
-            String msg = "PUT request for: " + resource + " to " + source.getName() + "failed";
+            String msg = "PUT request to: " + resource.getName() + " in " + repository.getName() + " failed";
 
             throw new TransferFailedException( msg, e );
         }
         finally
         {
-            IOUtil.close( input );
-
             if ( closeOutput )
             {
                 IOUtil.close( output );
@@ -437,6 +467,7 @@
 
             remaining -= n;
         }
+        output.flush();
     }
 
     // ----------------------------------------------------------------------

Modified: maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/StreamWagon.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/StreamWagon.java?rev=662318&r1=662317&r2=662318&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/StreamWagon.java (original)
+++ maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/StreamWagon.java Sun Jun  1 21:47:36 2008
@@ -36,6 +36,7 @@
  */
 public abstract class StreamWagon
     extends AbstractWagon
+    implements StreamingWagon
 {
     // ----------------------------------------------------------------------
     //
@@ -57,31 +58,22 @@
     public void get( String resourceName, File destination )
         throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
     {
-        InputData inputData = new InputData();
-
         Resource resource = new Resource( resourceName );
 
         fireGetInitiated( resource, destination );
 
-        inputData.setResource( resource );
+        InputStream is = getInputStream( resource );
 
-        try
-        {
-            fillInputData( inputData );
-        }
-        catch ( TransferFailedException e )
-        {
-            fireTransferError( resource, e, TransferEvent.REQUEST_GET );
-            throw e;
-        }
-        catch ( ResourceDoesNotExistException e )
-        {
-            fireTransferError( resource, e, TransferEvent.REQUEST_GET );
-            throw e;
-        }
+        checkInputStream( is, resource );
 
-        InputStream is = inputData.getInputStream();
+        createParentDirectories( destination );
 
+        getTransfer( resource, destination, is );
+    }
+
+    protected void checkInputStream( InputStream is, Resource resource )
+        throws TransferFailedException
+    {
         if ( is == null )
         {
             TransferFailedException e =
@@ -90,10 +82,6 @@
             fireTransferError( resource, e, TransferEvent.REQUEST_GET );
             throw e;
         }
-
-        createParentDirectories( destination );
-
-        getTransfer( inputData.getResource(), destination, is );
     }
 
     public boolean getIfNewer( String resourceName, File destination, long timestamp )
@@ -101,10 +89,36 @@
     {
         boolean retValue = false;
 
-        InputData inputData = new InputData();
-
         Resource resource = new Resource( resourceName );
 
+        fireGetInitiated( resource, destination );
+
+        InputStream is = getInputStream( resource );
+
+        // always get if timestamp is 0 (ie, target doesn't exist), otherwise only if older than the remote file
+        if ( timestamp == 0 || timestamp < resource.getLastModified() )
+        {
+            retValue = true;
+
+            checkInputStream( is, resource );
+
+            createParentDirectories( destination );
+
+            getTransfer( resource, destination, is );
+        }
+        else
+        {
+            IOUtil.close( is );
+        }
+
+        return retValue;
+    }
+
+    protected InputStream getInputStream( Resource resource )
+        throws TransferFailedException, ResourceDoesNotExistException
+    {
+        InputData inputData = new InputData();
+
         inputData.setResource( resource );
 
         try
@@ -122,44 +136,42 @@
             throw e;
         }
 
-        InputStream is = inputData.getInputStream();
+        return inputData.getInputStream();
+    }
 
-        // always get if timestamp is 0 (ie, target doesn't exist), otherwise only if older than the remote file
-        if ( timestamp == 0 || timestamp < resource.getLastModified() )
-        {
-            retValue = true;
+    // source doesn't exist exception
+    public void put( File source, String resourceName )
+        throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+    {
+        Resource resource = new Resource( resourceName );
 
-            if ( is == null )
-            {
-                TransferFailedException e =
-                    new TransferFailedException( getRepository().getUrl()
-                        + " - Could not open input stream for resource: '" + resource + "'" );
-                fireTransferError( resource, e, TransferEvent.REQUEST_GET );
-                throw e;
-            }
+        firePutInitiated( resource, source );
 
-            createParentDirectories( destination );
+        OutputStream os = getOutputStream( resource );
 
-            getTransfer( inputData.getResource(), destination, is );
-        }
-        else
+        checkOutputStream( resource, os );
+
+        putTransfer( resource, source, os, true );
+    }
+
+    protected void checkOutputStream( Resource resource, OutputStream os )
+        throws TransferFailedException
+    {
+        if ( os == null )
         {
-            IOUtil.close( is );
+            TransferFailedException e =
+                new TransferFailedException( getRepository().getUrl()
+                    + " - Could not open output stream for resource: '" + resource + "'" );
+            fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
+            throw e;
         }
-
-        return retValue;
     }
 
-    // source doesn't exist exception
-    public void put( File source, String resourceName )
-        throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+    protected OutputStream getOutputStream( Resource resource )
+        throws TransferFailedException
     {
         OutputData outputData = new OutputData();
 
-        Resource resource = new Resource( resourceName );
-
-        firePutInitiated( resource, source );
-
         outputData.setResource( resource );
 
         try
@@ -174,16 +186,94 @@
         }
 
         OutputStream os = outputData.getOutputStream();
+        return os;
+    }
 
-        if ( os == null )
+    public boolean getIfNewerToStream( String resourceName, OutputStream stream, long timestamp )
+        throws ResourceDoesNotExistException, TransferFailedException
+    {
+        boolean retValue = false;
+
+        Resource resource = new Resource( resourceName );
+
+        fireGetInitiated( resource, null );
+
+        InputStream is = getInputStream( resource );
+
+        // always get if timestamp is 0 (ie, target doesn't exist), otherwise only if older than the remote file
+        if ( timestamp == 0 || timestamp < resource.getLastModified() )
         {
-            TransferFailedException e =
-                new TransferFailedException( getRepository().getUrl()
-                    + " - Could not open output stream for resource: '" + resource + "'" );
-            fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
-            throw e;
+            retValue = true;
+
+            checkInputStream( is, resource );
+
+            fireGetStarted( resource, null );
+
+            getTransfer( resource, stream, is, true, Integer.MAX_VALUE );
+
+            fireGetCompleted( resource, null );
         }
+        else
+        {
+            IOUtil.close( is );
+        }
+        
+        return retValue;
+    }
+
+    public void getToStream( String resourceName, OutputStream stream )
+        throws ResourceDoesNotExistException, TransferFailedException
+    {
+        Resource resource = new Resource( resourceName );
+
+        fireGetInitiated( resource, null );
+
+        InputStream is = getInputStream( resource );
+
+        checkInputStream( is, resource );
+
+        fireGetStarted( resource, null );
+
+        getTransfer( resource, stream, is );
+
+        fireGetCompleted( resource, null );
+    }
+
+    public void putFromStream( InputStream stream, String destination )
+        throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+    {
+        Resource resource = new Resource( destination );
+
+        firePutInitiated( resource, null );
+
+        putFromStream( stream, resource );
+    }
+
+    public void putFromStream( InputStream stream, String destination, long contentLength, long lastModified )
+        throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+    {
+        Resource resource = new Resource( destination );
+
+        firePutInitiated( resource, null );
+
+        resource.setContentLength( contentLength );
+
+        resource.setLastModified( lastModified );
+
+        putFromStream( stream, resource );
+    }
+
+    private void putFromStream( InputStream stream, Resource resource )
+        throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
+    {
+        OutputStream os = getOutputStream( resource );
+
+        checkOutputStream( resource, os );
+
+        firePutStarted( resource, null );
+
+        putTransfer( resource, stream, os, true );
 
-        putTransfer( outputData.getResource(), source, os, true );
+        firePutCompleted( resource, null );
     }
 }

Added: maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/StreamingWagon.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/StreamingWagon.java?rev=662318&view=auto
==============================================================================
--- maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/StreamingWagon.java (added)
+++ maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/StreamingWagon.java Sun Jun  1 21:47:36 2008
@@ -0,0 +1,81 @@
+package org.apache.maven.wagon;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 java.io.InputStream;
+import java.io.OutputStream;
+
+import org.apache.maven.wagon.authorization.AuthorizationException;
+
+public interface StreamingWagon
+    extends Wagon
+{
+    /**
+     * Downloads specified resource from the repository to given output stream.
+     * 
+     * @param resourceName
+     * @param destination
+     * @throws TransferFailedException
+     * @throws ResourceDoesNotExistException
+     * @throws AuthorizationException
+     */
+    void getToStream( String resourceName, OutputStream stream )
+        throws ResourceDoesNotExistException, TransferFailedException;
+
+    /**
+     * Downloads specified resource from the repository if it was modified since specified date. The date is measured in
+     * milliseconds, between the current time and midnight, January 1, 1970 UTC and aligned to GMT timezone.
+     * 
+     * @param resourceName
+     * @param destination
+     * @param timestamp
+     * @return <code>true</code> if newer resource has been downloaded, <code>false</code> if resource in the
+     *         repository is older or has the same age.
+     * @throws TransferFailedException
+     * @throws ResourceDoesNotExistException
+     * @throws AuthorizationException
+     */
+    boolean getIfNewerToStream( String resourceName, OutputStream stream, long timestamp )
+        throws ResourceDoesNotExistException, TransferFailedException;
+
+    /**
+     * Copy from a local input stream to remote.
+     * 
+     * @param source the local file
+     * @param destination the remote destination
+     * @throws TransferFailedException
+     * @throws ResourceDoesNotExistException
+     * @throws AuthorizationException
+     */
+    void putFromStream( InputStream stream, String destination )
+        throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException;
+
+    /**
+     * Copy from a local input stream to remote.
+     * 
+     * @param source the local file
+     * @param destination the remote destination
+     * @throws TransferFailedException
+     * @throws ResourceDoesNotExistException
+     * @throws AuthorizationException
+     */
+    void putFromStream( InputStream stream, String destination, long contentLength, long size )
+        throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException;
+}

Propchange: maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/StreamingWagon.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/StreamingWagon.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/Wagon.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/Wagon.java?rev=662318&r1=662317&r2=662318&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/Wagon.java (original)
+++ maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/Wagon.java Sun Jun  1 21:47:36 2008
@@ -65,8 +65,6 @@
      * @throws TransferFailedException
      * @throws ResourceDoesNotExistException
      * @throws AuthorizationException
-     * @todo michal: I have to learn more about timezones!
-     * Specifically how to convert time for UTC to time for GMT and if such conversioin is needed.
      */
     boolean getIfNewer( String resourceName, File destination, long timestamp )
         throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException;

Added: maven/wagon/trunk/wagon-provider-test/src/main/java/org/apache/maven/wagon/StreamingWagonTestCase.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-provider-test/src/main/java/org/apache/maven/wagon/StreamingWagonTestCase.java?rev=662318&view=auto
==============================================================================
--- maven/wagon/trunk/wagon-provider-test/src/main/java/org/apache/maven/wagon/StreamingWagonTestCase.java (added)
+++ maven/wagon/trunk/wagon-provider-test/src/main/java/org/apache/maven/wagon/StreamingWagonTestCase.java Sun Jun  1 21:47:36 2008
@@ -0,0 +1,297 @@
+package org.apache.maven.wagon;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.security.NoSuchAlgorithmException;
+import java.text.SimpleDateFormat;
+
+import org.apache.maven.wagon.authentication.AuthenticationException;
+import org.apache.maven.wagon.authorization.AuthorizationException;
+import org.apache.maven.wagon.observers.ChecksumObserver;
+import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.IOUtil;
+
+/**
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ * @version $Id: WagonTestCase.java 660462 2008-05-27 10:52:46Z brett $
+ */
+public abstract class StreamingWagonTestCase
+    extends WagonTestCase
+{
+    public void testStreamingWagon()
+        throws Exception
+    {
+        setupRepositories();
+
+        setupWagonTestingFixtures();
+
+        streamRoundTripTesting();
+
+        tearDownWagonTestingFixtures();
+    }
+
+    public void testFailedGetToStream()
+        throws Exception
+    {
+        setupRepositories();
+
+        setupWagonTestingFixtures();
+
+        message( "Getting test artifact from test repository " + testRepository );
+
+        StreamingWagon wagon = (StreamingWagon) getWagon();
+
+        wagon.addTransferListener( checksumObserver );
+
+        wagon.connect( testRepository, getAuthInfo() );
+
+        destFile = FileTestUtils.createUniqueFile( getName(), getName() );
+
+        destFile.deleteOnExit();
+
+        OutputStream stream = null;
+
+        try
+        {
+            stream = new FileOutputStream( destFile );
+            wagon.getToStream( "fubar.txt", stream );
+            fail( "File was found when it shouldn't have been" );
+        }
+        catch ( ResourceDoesNotExistException e )
+        {
+            // expected
+            assertTrue( true );
+        }
+        finally
+        {
+            wagon.removeTransferListener( checksumObserver );
+
+            wagon.disconnect();
+
+            IOUtil.close( stream );
+
+            tearDownWagonTestingFixtures();
+        }
+    }
+
+    public void testWagonGetIfNewerToStreamIsNewer()
+        throws Exception
+    {
+        setupRepositories();
+
+        setupWagonTestingFixtures();
+
+        int expectedSize = putFile();
+
+        getIfNewerToStream( sourceFile.lastModified() + 30000, false, expectedSize );
+    }
+
+    public void testWagonGetIfNewerToStreamIsOlder()
+        throws Exception
+    {
+        setupRepositories();
+
+        setupWagonTestingFixtures();
+
+        int expectedSize = putFile();
+
+        getIfNewerToStream( new SimpleDateFormat( "yyyy-MM-dd" ).parse( "2006-01-01" ).getTime(), true, expectedSize );
+    }
+
+    public void testWagonGetIfNewerToStreamIsSame()
+        throws Exception
+    {
+        setupRepositories();
+
+        setupWagonTestingFixtures();
+
+        int expectedSize = putFile();
+
+        getIfNewerToStream( sourceFile.lastModified(), false, expectedSize );
+    }
+
+    private void getIfNewerToStream( long timestamp, boolean expectedResult, int expectedSize )
+        throws Exception, NoSuchAlgorithmException, IOException, ConnectionException, AuthenticationException,
+        TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+    {
+        StreamingWagon wagon = (StreamingWagon) getWagon();
+
+        ProgressArgumentMatcher progressArgumentMatcher = setupGetIfNewerTest( wagon, expectedResult, expectedSize );
+
+        connectWagon( wagon );
+
+        OutputStream stream = new LazyFileOutputStream( destFile );
+        
+        try
+        {
+            boolean result = wagon.getIfNewerToStream( this.resource, stream, timestamp );
+            assertEquals( expectedResult, result );
+        }
+        finally
+        {
+            IOUtil.close( stream );
+        }
+        
+        disconnectWagon( wagon );
+
+        assertGetIfNewerTest( progressArgumentMatcher, expectedResult, expectedSize );
+
+        tearDownWagonTestingFixtures();
+    }
+
+    public void testFailedGetIfNewerToStream()
+        throws Exception
+    {
+        if ( supportsGetIfNewer() )
+        {
+            setupRepositories();
+            setupWagonTestingFixtures();
+            message( "Getting test artifact from test repository " + testRepository );
+            StreamingWagon wagon = (StreamingWagon) getWagon();
+            wagon.addTransferListener( checksumObserver );
+            wagon.connect( testRepository, getAuthInfo() );
+            destFile = FileTestUtils.createUniqueFile( getName(), getName() );
+            destFile.deleteOnExit();
+            OutputStream stream = null;
+            try
+            {
+                stream = new FileOutputStream( destFile );
+                wagon.getIfNewerToStream( "fubar.txt", stream, 0 );
+                fail( "File was found when it shouldn't have been" );
+            }
+            catch ( ResourceDoesNotExistException e )
+            {
+                // expected
+                assertTrue( true );
+            }
+            finally
+            {
+                wagon.removeTransferListener( checksumObserver );
+
+                wagon.disconnect();
+
+                IOUtil.close( stream );
+
+                tearDownWagonTestingFixtures();
+            }
+        }
+    }
+
+    protected void streamRoundTripTesting()
+        throws Exception
+    {
+        message( "Stream round trip testing ..." );
+
+        int expectedSize = putStream();
+
+        assertNotNull( "check checksum is not null", checksumObserver.getActualChecksum() );
+
+        assertEquals( "compare checksums", "6b144b7285ffd6b0bc8300da162120b9", checksumObserver.getActualChecksum() );
+
+        checksumObserver = new ChecksumObserver();
+
+        getStream( expectedSize );
+
+        assertNotNull( "check checksum is not null", checksumObserver.getActualChecksum() );
+
+        assertEquals( "compare checksums", "6b144b7285ffd6b0bc8300da162120b9", checksumObserver.getActualChecksum() );
+
+        // Now compare the conents of the artifact that was placed in
+        // the repository with the contents of the artifact that was
+        // retrieved from the repository.
+
+        String sourceContent = FileUtils.fileRead( sourceFile );
+
+        String destContent = FileUtils.fileRead( destFile );
+
+        assertEquals( sourceContent, destContent );
+    }
+
+    private int putStream()
+        throws Exception
+    {
+        String content = "test-resource.txt\n";
+        sourceFile = new File( FileTestUtils.getTestOutputDir(), "test-resource" );
+        sourceFile.getParentFile().mkdirs();
+        FileUtils.fileWrite( sourceFile.getAbsolutePath(), content );
+
+        StreamingWagon wagon = (StreamingWagon) getWagon();
+
+        ProgressArgumentMatcher progressArgumentMatcher = replayMockForPut( resource, content, wagon );
+
+        message( "Putting test artifact: " + resource + " into test repository " + testRepository );
+
+        connectWagon( wagon );
+
+        InputStream stream = null;
+
+        try
+        {
+            stream = new FileInputStream( sourceFile );
+            wagon.putFromStream( stream, resource, sourceFile.length(), sourceFile.lastModified() );
+        }
+        finally
+        {
+            IOUtil.close( stream );
+        }
+
+        disconnectWagon( wagon );
+
+        verifyMock( progressArgumentMatcher, content.length() );
+        return content.length();
+    }
+
+    private void getStream( int expectedSize )
+        throws Exception
+    {
+        destFile = FileTestUtils.createUniqueFile( getName(), getName() );
+        destFile.deleteOnExit();
+
+        StreamingWagon wagon = (StreamingWagon) getWagon();
+
+        ProgressArgumentMatcher progressArgumentMatcher = replaceMockForGet( wagon, expectedSize );
+
+        message( "Getting test artifact from test repository " + testRepository );
+
+        connectWagon( wagon );
+
+        OutputStream stream = null;
+
+        try
+        {
+            stream = new FileOutputStream( destFile );
+            wagon.getToStream( this.resource, stream );
+        }
+        finally
+        {
+            IOUtil.close( stream );
+        }
+
+        disconnectWagon( wagon );
+
+        verifyMock( progressArgumentMatcher, expectedSize );
+    }
+}

Propchange: maven/wagon/trunk/wagon-provider-test/src/main/java/org/apache/maven/wagon/StreamingWagonTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/wagon/trunk/wagon-provider-test/src/main/java/org/apache/maven/wagon/StreamingWagonTestCase.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

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=662318&r1=662317&r2=662318&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 Sun Jun  1 21:47:36 2008
@@ -21,10 +21,13 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.security.NoSuchAlgorithmException;
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 
+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.TransferEvent;
@@ -46,7 +49,7 @@
 public abstract class WagonTestCase
     extends PlexusTestCase
 {
-    private static final class ProgressArgumentMatcher
+    static final class ProgressArgumentMatcher
         extends AbstractMatcher
     {
         private int size;
@@ -215,7 +218,7 @@
         return wagon;
     }
 
-    private void message( String message )
+    protected void message( String message )
     {
         System.out.println( message );
     }
@@ -236,6 +239,140 @@
         tearDownWagonTestingFixtures();
     }
 
+    public void testWagonGetIfNewerIsNewer()
+        throws Exception
+    {
+        if ( supportsGetIfNewer() )
+        {
+            setupRepositories();
+            setupWagonTestingFixtures();
+            int expectedSize = putFile();
+            getIfNewer( sourceFile.lastModified() + 30000, false, expectedSize );
+        }
+    }
+
+    protected boolean supportsGetIfNewer()
+    {
+        return true;
+    }
+
+    public void testWagonGetIfNewerIsOlder()
+        throws Exception
+    {
+        if ( supportsGetIfNewer() )
+        {
+            setupRepositories();
+            setupWagonTestingFixtures();
+            int expectedSize = putFile();
+            getIfNewer( new SimpleDateFormat( "yyyy-MM-dd" ).parse( "2006-01-01" ).getTime(), true, expectedSize );
+        }
+    }
+
+    public void testWagonGetIfNewerIsSame()
+        throws Exception
+    {
+        if ( supportsGetIfNewer() )
+        {
+            setupRepositories();
+            setupWagonTestingFixtures();
+            int expectedSize = putFile();
+            getIfNewer( sourceFile.lastModified(), false, expectedSize );
+        }
+    }
+
+    private void getIfNewer( long timestamp, boolean expectedResult, int expectedSize )
+        throws Exception, NoSuchAlgorithmException, IOException, ConnectionException, AuthenticationException,
+        TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+    {
+        Wagon wagon = getWagon();
+        
+        ProgressArgumentMatcher progressArgumentMatcher = setupGetIfNewerTest( wagon, expectedResult, expectedSize );
+        
+        connectWagon( wagon );
+        
+        boolean result = wagon.getIfNewer( this.resource, destFile, timestamp );
+        assertEquals( expectedResult, result );
+        
+        disconnectWagon( wagon );
+        
+        assertGetIfNewerTest( progressArgumentMatcher, expectedResult, expectedSize );
+        
+        tearDownWagonTestingFixtures();
+    }
+
+    protected void assertGetIfNewerTest( ProgressArgumentMatcher progressArgumentMatcher, boolean expectedResult,
+                                       int expectedSize )
+        throws IOException
+    {
+        if ( expectedResult == true )
+        {
+            verifyMock( progressArgumentMatcher, expectedSize );
+            
+            assertNotNull( "check checksum is not null", checksumObserver.getActualChecksum() );
+            
+            assertEquals( "compare checksums", "6b144b7285ffd6b0bc8300da162120b9", checksumObserver.getActualChecksum() );
+            
+            // Now compare the contents of the artifact that was placed in
+            // the repository with the contents of the artifact that was
+            // retrieved from the repository.
+            
+            String sourceContent = FileUtils.fileRead( sourceFile );
+            String destContent = FileUtils.fileRead( destFile );
+            assertEquals( sourceContent, destContent );
+        }
+        else
+        {
+            mockTransferListenerControl.verify();
+            
+            mockTransferListenerControl.reset();
+            
+            assertNull( "check checksum is null", checksumObserver.getActualChecksum() );
+            
+            assertFalse( destFile.exists() );
+        }
+    }
+
+    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 == true )
+        {
+            progressArgumentMatcher = replaceMockForGet( wagon, expectedSize );
+        }
+        else
+        {
+            replaceMockForSkippedGetIfNewer( wagon, expectedSize );
+        }
+        return progressArgumentMatcher;
+    }
+
+    private void replaceMockForSkippedGetIfNewer( Wagon wagon, int expectedSize )
+    {
+        Resource resource = new Resource( this.resource );
+        mockTransferListener.transferInitiated( createTransferEvent( wagon, resource, TransferEvent.TRANSFER_INITIATED,
+                                                                     TransferEvent.REQUEST_GET, destFile ) );
+        resource = new Resource( this.resource );
+        resource.setContentLength( getExpectedContentLengthOnGet( expectedSize ) );
+        resource.setLastModified( getExpectedLastModifiedOnGet( testRepository, resource ) );
+        // TODO: transfer skipped event?
+//        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 );
+        
+        mockTransferListenerControl.replay();
+    }
+
     public void testWagonPutDirectory()
         throws Exception
     {
@@ -521,7 +658,7 @@
         try
         {
             wagon.get( "fubar.txt", destFile );
-            fail( "File was found when it sohuldn't have been" );
+            fail( "File was found when it shouldn't have been" );
         }
         catch ( ResourceDoesNotExistException e )
         {
@@ -538,6 +675,40 @@
         }
     }
 
+    public void testFailedGetIfNewer()
+        throws Exception
+    {
+        if ( supportsGetIfNewer() )
+        {
+            setupRepositories();
+            setupWagonTestingFixtures();
+            message( "Getting test artifact from test repository " + testRepository );
+            Wagon wagon = getWagon();
+            wagon.addTransferListener( checksumObserver );
+            wagon.connect( testRepository, getAuthInfo() );
+            destFile = FileTestUtils.createUniqueFile( getName(), getName() );
+            destFile.deleteOnExit();
+            try
+            {
+                wagon.getIfNewer( "fubar.txt", destFile, 0 );
+                fail( "File was found when it shouldn't have been" );
+            }
+            catch ( ResourceDoesNotExistException e )
+            {
+                // expected
+                assertTrue( true );
+            }
+            finally
+            {
+                wagon.removeTransferListener( checksumObserver );
+
+                wagon.disconnect();
+
+                tearDownWagonTestingFixtures();
+            }
+        }
+    }
+
     /**
      * Test {@link Wagon#getFileList(String)}.
      *
@@ -682,6 +853,21 @@
 
         Wagon wagon = getWagon();
 
+        ProgressArgumentMatcher progressArgumentMatcher = replayMockForPut( resourceName, content, wagon );
+        
+        message( "Putting test artifact: " + resourceName + " into test repository " + testRepository );
+
+        connectWagon( wagon );
+
+        wagon.put( sourceFile, resourceName );
+
+        disconnectWagon( wagon );
+        
+        verifyMock( progressArgumentMatcher, content.length() );
+    }
+
+    protected ProgressArgumentMatcher replayMockForPut( String resourceName, String content, Wagon wagon )
+    {
         Resource resource = new Resource( resourceName );
         mockTransferListener.transferInitiated( createTransferEvent( wagon, resource, TransferEvent.TRANSFER_INITIATED,
                                                                      TransferEvent.REQUEST_PUT, sourceFile ) );
@@ -704,31 +890,10 @@
                                                                      TransferEvent.REQUEST_PUT, sourceFile ) );
         
         mockTransferListenerControl.replay();
-        
-        message( "Putting test artifact: " + resourceName + " into test repository " + testRepository );
-
-        wagon.addTransferListener( checksumObserver );
-
-        wagon.addTransferListener( mockTransferListener );
-
-        wagon.connect( testRepository, getAuthInfo() );
-
-        wagon.put( sourceFile, resourceName );
-
-        wagon.removeTransferListener( mockTransferListener );
-        
-        wagon.removeTransferListener( checksumObserver );
-
-        wagon.disconnect();
-        
-        mockTransferListenerControl.verify();
-        
-        assertEquals( content.length(), progressArgumentMatcher.getSize() );
-        
-        mockTransferListenerControl.reset();
+        return progressArgumentMatcher;
     }
 
-    private TransferEvent createTransferEvent( Wagon wagon, Resource resource, int eventType, int requestType,
+    protected TransferEvent createTransferEvent( Wagon wagon, Resource resource, int eventType, int requestType,
                                                File file )
     {
         TransferEvent transferEvent = new TransferEvent( wagon, resource, eventType, requestType );
@@ -752,6 +917,50 @@
         
         Wagon wagon = getWagon();
 
+        ProgressArgumentMatcher progressArgumentMatcher = replaceMockForGet( wagon, expectedSize );
+        
+        message( "Getting test artifact from test repository " + testRepository );
+
+        connectWagon( wagon );
+
+        wagon.get( this.resource, destFile );
+
+        disconnectWagon( wagon );
+        
+        verifyMock( progressArgumentMatcher, expectedSize );
+    }
+
+    protected void verifyMock( ProgressArgumentMatcher progressArgumentMatcher, int length )
+    {
+        mockTransferListenerControl.verify();
+        
+        assertEquals( length, progressArgumentMatcher.getSize() );
+        
+        mockTransferListenerControl.reset();
+    }
+
+    protected void disconnectWagon( Wagon wagon )
+        throws ConnectionException
+    {
+        wagon.removeTransferListener( mockTransferListener );
+        
+        wagon.removeTransferListener( checksumObserver );
+
+        wagon.disconnect();
+    }
+
+    protected void connectWagon( Wagon wagon )
+        throws ConnectionException, AuthenticationException
+    {
+        wagon.addTransferListener( checksumObserver );
+        
+        wagon.addTransferListener( mockTransferListener );
+
+        wagon.connect( testRepository, getAuthInfo() );
+    }
+
+    protected ProgressArgumentMatcher replaceMockForGet( Wagon wagon, int expectedSize )
+    {
         Resource resource = new Resource( this.resource );
         mockTransferListener.transferInitiated( createTransferEvent( wagon, resource, TransferEvent.TRANSFER_INITIATED,
                                                                      TransferEvent.REQUEST_GET, destFile ) );
@@ -773,28 +982,7 @@
                                                                      TransferEvent.REQUEST_GET, destFile ) );
         
         mockTransferListenerControl.replay();
-        
-        message( "Getting test artifact from test repository " + testRepository );
-
-        wagon.addTransferListener( checksumObserver );
-        
-        wagon.addTransferListener( mockTransferListener );
-
-        wagon.connect( testRepository, getAuthInfo() );
-
-        wagon.get( this.resource, destFile );
-
-        wagon.removeTransferListener( mockTransferListener );
-        
-        wagon.removeTransferListener( checksumObserver );
-
-        wagon.disconnect();
-        
-        mockTransferListenerControl.verify();
-        
-        assertEquals( expectedSize, progressArgumentMatcher.getSize() );
-        
-        mockTransferListenerControl.reset();
+        return progressArgumentMatcher;
     }
 
     protected int getExpectedContentLengthOnGet( int expectedSize )

Modified: maven/wagon/trunk/wagon-providers/wagon-file/src/main/java/org/apache/maven/wagon/providers/file/FileWagon.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-file/src/main/java/org/apache/maven/wagon/providers/file/FileWagon.java?rev=662318&r1=662317&r2=662318&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-file/src/main/java/org/apache/maven/wagon/providers/file/FileWagon.java (original)
+++ maven/wagon/trunk/wagon-providers/wagon-file/src/main/java/org/apache/maven/wagon/providers/file/FileWagon.java Sun Jun  1 21:47:36 2008
@@ -19,6 +19,17 @@
  * under the License.
  */
 
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Arrays;
+import java.util.List;
+
 import org.apache.maven.wagon.ConnectionException;
 import org.apache.maven.wagon.InputData;
 import org.apache.maven.wagon.LazyFileOutputStream;
@@ -28,29 +39,16 @@
 import org.apache.maven.wagon.TransferFailedException;
 import org.apache.maven.wagon.authorization.AuthorizationException;
 import org.apache.maven.wagon.resource.Resource;
-import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.FileUtils;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.IOException;
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.util.Arrays;
-import java.util.List;
+import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.StringUtils;
 
 /**
  * Wagon Provider for Local File System
- *
+ * 
  * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
  * @version $Id$
- * 
- * @plexus.component role="org.apache.maven.wagon.Wagon" 
- *   role-hint="file"
- *   instantiation-strategy="per-lookup"
+ * @plexus.component role="org.apache.maven.wagon.Wagon" role-hint="file" instantiation-strategy="per-lookup"
  */
 public class FileWagon
     extends StreamWagon
@@ -74,7 +72,7 @@
 
         try
         {
-            InputStream in = new BufferedInputStream(new FileInputStream( file ));
+            InputStream in = new BufferedInputStream( new FileInputStream( file ) );
 
             inputData.setInputStream( in );
 
@@ -95,14 +93,14 @@
         {
             throw new TransferFailedException( "Unable to operate with a null basedir." );
         }
-        
+
         Resource resource = outputData.getResource();
 
         File file = new File( getRepository().getBasedir(), resource.getName() );
 
         createParentDirectories( file );
 
-        OutputStream outputStream = new BufferedOutputStream(new LazyFileOutputStream( file ));
+        OutputStream outputStream = new BufferedOutputStream( new LazyFileOutputStream( file ) );
 
         outputData.setOutputStream( outputStream );
     }
@@ -122,7 +120,7 @@
             return;
         }
 
-        // Check the File repository exists 
+        // Check the File repository exists
         File basedir = new File( getRepository().getBasedir() );
         if ( !basedir.exists() )
         {
@@ -160,16 +158,13 @@
 
         try
         {
-            /* Done to address issue found in HP-UX with regards to "." directory references.
-             * Details found in ..
-             * WAGON-30 - wagon-file failed when used by maven-site-plugin
-             * WAGON-33 - FileWagon#putDirectory() fails in HP-UX if destinationDirectory is "."
-             * http://www.nabble.com/With-maven-2.0.2-site%3Adeploy-doesn%27t-work-t934716.html for details.
-             * 
-             * Using path.getCanonicalFile() ensures that the path is fully 
-             * resolved before an attempt to create it.
-             * 
-             * TODO: consider moving this to FileUtils.mkdirs()
+            /*
+             * Done to address issue found in HP-UX with regards to "." directory references. Details found in ..
+             * WAGON-30 - wagon-file failed when used by maven-site-plugin WAGON-33 - FileWagon#putDirectory() fails in
+             * HP-UX if destinationDirectory is "."
+             * http://www.nabble.com/With-maven-2.0.2-site%3Adeploy-doesn%27t-work-t934716.html for details. Using
+             * path.getCanonicalFile() ensures that the path is fully resolved before an attempt to create it. TODO:
+             * consider moving this to FileUtils.mkdirs()
              */
             File realFile = path.getCanonicalFile();
             realFile.mkdirs();
@@ -225,13 +220,13 @@
     }
 
     public List getFileList( String destinationDirectory )
-        throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException 
+        throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
     {
         if ( getRepository().getBasedir() == null )
         {
             throw new TransferFailedException( "Unable to getFileList() with a null basedir." );
         }
-        
+
         File path = resolveDestinationPath( destinationDirectory );
 
         if ( !path.exists() )
@@ -256,7 +251,7 @@
         {
             throw new TransferFailedException( "Unable to getFileList() with a null basedir." );
         }
-        
+
         File file = resolveDestinationPath( resourceName );
 
         return file.exists();

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=662318&r1=662317&r2=662318&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 Sun Jun  1 21:47:36 2008
@@ -21,6 +21,7 @@
 
 import org.apache.maven.wagon.ConnectionException;
 import org.apache.maven.wagon.FileTestUtils;
+import org.apache.maven.wagon.StreamingWagonTestCase;
 import org.apache.maven.wagon.Wagon;
 import org.apache.maven.wagon.WagonTestCase;
 import org.apache.maven.wagon.authentication.AuthenticationException;
@@ -35,7 +36,7 @@
  * @version $Id$
  */
 public class FileWagonTest
-    extends WagonTestCase
+    extends StreamingWagonTestCase
 {
     protected String getProtocol()
     {

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=662318&r1=662317&r2=662318&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 Sun Jun  1 21:47:36 2008
@@ -22,8 +22,8 @@
 import java.io.File;
 
 import org.apache.ftpserver.interfaces.FtpServerInterface;
+import org.apache.maven.wagon.StreamingWagonTestCase;
 import org.apache.maven.wagon.Wagon;
-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;
@@ -33,7 +33,7 @@
  * @version $Id$
  */
 public class FtpWagonTest
-    extends WagonTestCase
+    extends StreamingWagonTestCase
 {
     private FtpServerInterface server;
 

Modified: maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/http/LightweightHttpWagon.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/http/LightweightHttpWagon.java?rev=662318&r1=662317&r2=662318&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/http/LightweightHttpWagon.java (original)
+++ maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/http/LightweightHttpWagon.java Sun Jun  1 21:47:36 2008
@@ -23,6 +23,7 @@
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.OutputStream;
 import java.net.Authenticator;
 import java.net.HttpURLConnection;
 import java.net.MalformedURLException;
@@ -170,14 +171,13 @@
         }
     }
 
-    public void put( File source, String resourceName )
-        throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+    protected void putTransfer( Resource resource, InputStream input, OutputStream output, boolean closeOutput )
+        throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
     {
-        super.put( source, resourceName );
+        super.putTransfer( resource, input, output, closeOutput );
 
         try
         {
-            String url = buildUrl( resourceName );
             int statusCode = putConnection.getResponseCode();
 
             switch ( statusCode )
@@ -190,20 +190,20 @@
                     break;
 
                 case HttpURLConnection.HTTP_FORBIDDEN:
-                    throw new AuthorizationException( "Access denied to: " + url );
+                    throw new AuthorizationException( "Access denied to: " + buildUrl( resource.getName() ) );
 
                 case HttpURLConnection.HTTP_NOT_FOUND:
-                    throw new ResourceDoesNotExistException( "File: " + url + " does not exist" );
+                    throw new ResourceDoesNotExistException( "File: " + buildUrl( resource.getName() ) + " does not exist" );
 
                 //add more entries here
                 default :
                     throw new TransferFailedException(
-                        "Failed to transfer file: " + url + ". Return code is: " + statusCode );
+                        "Failed to transfer file: " + buildUrl( resource.getName() ) + ". Return code is: " + statusCode );
             }
         }
         catch ( IOException e )
         {
-            fireTransferError( new Resource( resourceName ), e, TransferEvent.REQUEST_PUT );
+            fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
             
             throw new TransferFailedException( "Error transferring file", e );
         }

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=662318&r1=662317&r2=662318&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 Sun Jun  1 21:47:36 2008
@@ -19,20 +19,20 @@
  * under the License.
  */
 
+import java.io.File;
+
 import org.apache.maven.wagon.FileTestUtils;
-import org.apache.maven.wagon.WagonTestCase;
+import org.apache.maven.wagon.StreamingWagonTestCase;
 import org.apache.maven.wagon.repository.Repository;
 import org.apache.maven.wagon.resource.Resource;
 import org.codehaus.plexus.jetty.Httpd;
 
-import java.io.File;
-
 /**
  * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
  * @version $Id$
  */
 public class LightweightHttpWagonTest
-    extends WagonTestCase
+    extends StreamingWagonTestCase
 {
     private Httpd httpd;
 

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=662318&r1=662317&r2=662318&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 Sun Jun  1 21:47:36 2008
@@ -71,4 +71,9 @@
     {
         return repository;
     }
+
+    protected boolean supportsGetIfNewer()
+    {
+        return false;
+    }
 }

Modified: maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagon.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagon.java?rev=662318&r1=662317&r2=662318&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagon.java (original)
+++ maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagon.java Sun Jun  1 21:47:36 2008
@@ -122,7 +122,7 @@
     private static final byte LF = '\n';
 
     public void put( File source, String basedir, Resource resource, String octalMode )
-        throws TransferFailedException
+        throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
     {
         String path = getPath( basedir, resource.getName() );
 



---------------------------------------------------------------------
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