maven-wagon-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jvan...@apache.org
Subject cvs commit: maven-wagon/wagon-providers/ssh/src/main/java/org/apache/maven/wagon/providers/ssh ScpWagon.java
Date Sat, 24 Apr 2004 17:38:44 GMT
jvanzyl     2004/04/24 10:38:44

  Modified:    wagon-providers/ftp/src/test/java/org/apache/maven/wagon/providers/ftp
                        FtpWagonTest.java
               wagon-providers/http/src/main/java/org/apache/maven/wagon/providers/http
                        HttpWagon.java
               wagon-providers/http/src/test/java/org/apache/maven/wagon/providers/http
                        HttpWagonTest.java
               wagon-providers/ssh/src/main/java/org/apache/maven/wagon/providers/ssh
                        ScpWagon.java
  Log:
  o adjusting for change in abstract test case.
  
  Revision  Changes    Path
  1.4       +3 -3      maven-wagon/wagon-providers/ftp/src/test/java/org/apache/maven/wagon/providers/ftp/FtpWagonTest.java
  
  Index: FtpWagonTest.java
  ===================================================================
  RCS file: /home/cvs/maven-wagon/wagon-providers/ftp/src/test/java/org/apache/maven/wagon/providers/ftp/FtpWagonTest.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- FtpWagonTest.java	24 Apr 2004 15:54:04 -0000	1.3
  +++ FtpWagonTest.java	24 Apr 2004 17:38:44 -0000	1.4
  @@ -42,7 +42,7 @@
           return "ftp";
       }
   
  -    protected void setUp()
  +    protected void setupWagonTestingFixtures()
           throws Exception
       {
           super.setUp();
  @@ -50,7 +50,7 @@
           server = (FtpServerInterface)lookup( FtpServerInterface.ROLE );
       }
   
  -    protected void tearDown()
  +    protected void tearDownWagonTestingFixtures()
           throws Exception
       {
           release( server );
  
  
  
  1.4       +54 -19    maven-wagon/wagon-providers/http/src/main/java/org/apache/maven/wagon/providers/http/HttpWagon.java
  
  Index: HttpWagon.java
  ===================================================================
  RCS file: /home/cvs/maven-wagon/wagon-providers/http/src/main/java/org/apache/maven/wagon/providers/http/HttpWagon.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- HttpWagon.java	24 Apr 2004 16:24:41 -0000	1.3
  +++ HttpWagon.java	24 Apr 2004 17:38:44 -0000	1.4
  @@ -26,9 +26,10 @@
   import org.apache.commons.httpclient.methods.GetMethod;
   import org.apache.commons.httpclient.methods.PutMethod;
   import org.apache.commons.lang.StringUtils;
  +import org.apache.maven.wagon.AbstractWagon;
   import org.apache.maven.wagon.ResourceDoesNotExistException;
  -import org.apache.maven.wagon.StreamWagon;
   import org.apache.maven.wagon.TransferFailedException;
  +import org.apache.maven.wagon.artifact.Artifact;
   import org.apache.maven.wagon.authentication.AuthenticationInfo;
   import org.apache.maven.wagon.authorization.AuthorizationException;
   import org.apache.maven.wagon.proxy.ProxyInfo;
  @@ -37,15 +38,16 @@
   import java.io.FileInputStream;
   import java.io.FileNotFoundException;
   import java.io.IOException;
  -import java.io.InputStream;
   import java.io.OutputStream;
  +import java.io.FileOutputStream;
  +import java.io.InputStream;
   
   /**
    * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
    * @version $Id$
    */
   public class HttpWagon
  -    extends StreamWagon
  +    extends AbstractWagon
   {
       private final static int DEFAULT_NUMBER_OF_ATTEMPTS = 3;
   
  @@ -72,32 +74,32 @@
               password = authInfo.getPassword();
           }
   
  -         String host = getRepository().getHost();
  +        String host = getRepository().getHost();
   
           if ( StringUtils.isNotEmpty( username ) && StringUtils.isNotEmpty( password
) )
           {
  -             Credentials creds = new UsernamePasswordCredentials( username, password );
  +            Credentials creds = new UsernamePasswordCredentials( username, password );
   
               client.getState().setCredentials( null, host, creds );
           }
   
  -         HostConfiguration hc = new HostConfiguration();
  +        HostConfiguration hc = new HostConfiguration();
   
  -         ProxyInfo proxyInfo = getRepository().getProxyInfo();
  +        ProxyInfo proxyInfo = getRepository().getProxyInfo();
   
           if ( proxyInfo != null )
           {
  -             String proxyUsername = proxyInfo.getUserName();
  +            String proxyUsername = proxyInfo.getUserName();
   
  -             String proxyPassword = proxyInfo.getPassword();
  +            String proxyPassword = proxyInfo.getPassword();
   
  -             String proxyHost = proxyInfo.getHost();
  +            String proxyHost = proxyInfo.getHost();
   
               if ( StringUtils.isNotEmpty( proxyUsername )
                   && StringUtils.isNotEmpty( proxyPassword )
                   && StringUtils.isNotEmpty( proxyHost ) )
               {
  -                 Credentials creds = new UsernamePasswordCredentials( username, password
);
  +                Credentials creds = new UsernamePasswordCredentials( username, password
);
   
                   client.getState().setProxyCredentials( null, proxyHost, creds );
               }
  @@ -108,10 +110,10 @@
           client.setHostConfiguration( hc );
       }
   
  -    public OutputStream getOutputStream( String resource )
  -        throws Exception
  +    public void put( File source, Artifact artifact )
  +        throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
       {
  -        return null;
  +        put( source, artifactPath( artifact ) );
       }
   
       // put
  @@ -177,6 +179,8 @@
               default :
                   throw new TransferFailedException( "Failed to trasfer file: " + url + ".
Return code is: " + statusCode );
           }
  +
  +        putMethod.releaseConnection();
       }
   
       public void closeConnection()
  @@ -189,13 +193,29 @@
       }
   
       // get
  -    public InputStream getInputStream( String resource )
  -        throws Exception
  +
  +    public void get( Artifact artifact, File destination )
  +        throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
  +    {
  +        get( artifactPath( artifact ), destination );
  +    }
  +
  +    public void get( String resource, File destination )
  +        throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
       {
           String url = getRepository().getUrl() + "/" + resource;
   
           GetMethod getMethod = new GetMethod( url );
   
  +        getMethod.addRequestHeader( "Cache-control", "no-cache" );
  +
  +        getMethod.addRequestHeader( "Cache-store", "no-store" );
  +
  +        getMethod.addRequestHeader( "Pragma", "no-cache" );
  +
  +        getMethod.addRequestHeader( "Expires", "0" );
  +
  +
           int statusCode = SC_NULL;
   
           int attempt = 0;
  @@ -245,7 +265,22 @@
                                                      + statusCode );
           }
   
  -        return getMethod.getResponseBodyAsStream();
  +        try
  +        {
  +            OutputStream os = new FileOutputStream( destination );
  +
  +            InputStream is = getMethod.getResponseBodyAsStream();
  +
  +            getTransfer( resource, is, os );
  +
  +            closeTransferStreams( is, os );
  +        }
  +        catch ( Exception e )
  +        {
  +            throw new TransferFailedException( "Cannot transfer!", e );
  +        }
  +
  +        getMethod.releaseConnection();
       }
   
       public int getNumberOfAttempts()
  @@ -253,7 +288,7 @@
           return numberOfAttempts;
       }
   
  -    public void setNumberOfAttempts(  int numberOfAttempts )
  +    public void setNumberOfAttempts( int numberOfAttempts )
       {
           this.numberOfAttempts = numberOfAttempts;
       }
  
  
  
  1.3       +16 -22    maven-wagon/wagon-providers/http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonTest.java
  
  Index: HttpWagonTest.java
  ===================================================================
  RCS file: /home/cvs/maven-wagon/wagon-providers/http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- HttpWagonTest.java	24 Apr 2004 15:53:09 -0000	1.2
  +++ HttpWagonTest.java	24 Apr 2004 17:38:44 -0000	1.3
  @@ -42,21 +42,7 @@
           return "http://localhost:10007";
       }
   
  -    protected void setUp()
  -        throws Exception
  -    {
  -        super.setUp();
  -
  -        httpd = (Httpd) lookup( Httpd.ROLE );               
  -    }
  -
  -    protected void tearDown()
  -        throws Exception
  -    {
  -        release( httpd );
  -    }
  -
  -    protected void setupFileRoundTripTesting()
  +    protected void setupWagonTestingFixtures()
           throws Exception
       {
           // For a PUT the artifact must exist already which is how a PUT works by
  @@ -64,16 +50,14 @@
           // the actual PUT operation.
   
           // File round trip testing
  -        File f = new File( basedir, "/target/http-repository/test-resource.txt" );
  +        File file = new File( basedir, "/target/http-repository/test-resource.txt" );
   
  -        f.getParentFile().mkdirs();
  +        file.delete();
   
  -        generateFile( f.getAbsolutePath(), "file-dummy" );
  -    }
  +        file.getParentFile().mkdirs();
  +
  +        generateFile( file.getAbsolutePath(), "file-dummy" );
   
  -    protected void setupArtifactRoundTripTesting()
  -        throws Exception
  -    {
           // For a PUT the artifact must exist already which is how a PUT works by
           // default so we must place a dummy artifact in the http repo first before
           // the actual PUT operation.
  @@ -83,8 +67,18 @@
   
           File f = new File( basedir, "/target/http-repository/" + new Repository().artifactPath(
artifact ) );
   
  +        f.delete();
  +
           f.getParentFile().mkdirs();
   
           generateFile( f.getAbsolutePath(), "aritfact-dummy" );
  +
  +        httpd = (Httpd) lookup( Httpd.ROLE );
  +    }
  +
  +    protected void tearDownWagonTestingFixtures()
  +        throws Exception
  +    {
  +        release( httpd );
       }
   }
  
  
  
  1.4       +1 -5      maven-wagon/wagon-providers/ssh/src/main/java/org/apache/maven/wagon/providers/ssh/ScpWagon.java
  
  Index: ScpWagon.java
  ===================================================================
  RCS file: /home/cvs/maven-wagon/wagon-providers/ssh/src/main/java/org/apache/maven/wagon/providers/ssh/ScpWagon.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ScpWagon.java	24 Apr 2004 15:51:52 -0000	1.3
  +++ ScpWagon.java	24 Apr 2004 17:38:44 -0000	1.4
  @@ -233,8 +233,6 @@
       public void put( File source, String resource )
           throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
       {
  -        //String resource = fullArtifactPath( artifact );
  -
           String mkdirCmd = "mkdir -p " + getRepository().getBasedir() + "/" + PathUtils.dirname(
resource ) + "\n";
   
           executeSimpleCommand( session, mkdirCmd );
  @@ -356,8 +354,6 @@
   
           try
           {
  -            //String resource = fullArtifactPath( artifact );
  -
               String cmd = "scp -f " + resource;
   
               fireTransferDebug( "Executing command: " + cmd );
  
  
  

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


Mime
View raw message