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/http/src/test/java/org/apache/maven/wagon/providers/http HttpWagonTest.java
Date Sat, 24 Apr 2004 15:53:09 GMT
jvanzyl     2004/04/24 08:53:09

  Modified:    wagon-providers/http project.xml
               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
  Log:
  o modifications for file-file transfers
  o using the multi-threaded mode for httpclient as it's not thread
    safe by default. Discovered while running multiple tests, would be
    nice to have a multi threaded test which people could use to make
    sure everything is ok.
  
  Revision  Changes    Path
  1.2       +1 -2      maven-wagon/wagon-providers/http/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/maven-wagon/wagon-providers/http/project.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- project.xml	30 Mar 2004 14:43:06 -0000	1.1
  +++ project.xml	24 Apr 2004 15:53:09 -0000	1.2
  @@ -4,12 +4,11 @@
     <extend>../../project.xml</extend>
     <groupId>maven</groupId>
     <pomVersion>3</pomVersion>
  -  <id>wagon-http</id>
     <groupId>maven</groupId>
     <artifactId>wagon-http</artifactId>
     <type>jar</type>
     <name>Wagon HTTP provider</name>
  -  <currentVersion>0.9-SNAPSHOT</currentVersion>
  +  <version>0.9-SNAPSHOT</version>
     <shortDescription>Wagon Provider for HTTP/HTTPS protocols based on jakarta-commons-httpclient</shortDescription>
     <package>org.apache.maven.wagon.providers.http</package>
     <inceptionYear>2003</inceptionYear>
  
  
  
  1.2       +17 -17    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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- HttpWagon.java	30 Mar 2004 14:43:06 -0000	1.1
  +++ HttpWagon.java	24 Apr 2004 15:53:09 -0000	1.2
  @@ -23,13 +23,13 @@
   import org.apache.commons.httpclient.HttpRecoverableException;
   import org.apache.commons.httpclient.HttpStatus;
   import org.apache.commons.httpclient.UsernamePasswordCredentials;
  +import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
   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.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;
  @@ -58,7 +58,7 @@
   
       public void openConnection()
       {
  -        client = new HttpClient();
  +        client = new HttpClient( new MultiThreadedHttpConnectionManager() );
   
           final AuthenticationInfo authInfo = getRepository().getAuthenticationInfo();
   
  @@ -110,22 +110,23 @@
           client.setHostConfiguration( hc );
       }
   
  -    public OutputStream getOutputStream( Artifact artifact )
  +    public OutputStream getOutputStream( String resource )
           throws Exception
       {
           return null;
       }
   
  -    public void put( File source, Artifact artifact )
  +    // put
  +    public void put( File source, String resource )
           throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
       {
  -        String url = artifactUrl( artifact );
  +        String url = getRepository().getUrl() + "/" + resource;
   
  -        PutMethod method = new PutMethod( url );
  +        PutMethod putMethod = new PutMethod( url );
   
           try
           {
  -            method.setRequestBody( new FileInputStream( source ) );
  +            putMethod.setRequestBody( new FileInputStream( source ) );
           }
           catch ( FileNotFoundException e )
           {
  @@ -143,7 +144,7 @@
           {
               try
               {
  -                statusCode = client.executeMethod( method );
  +                statusCode = client.executeMethod( putMethod );
               }
               catch ( HttpRecoverableException e )
               {
  @@ -189,14 +190,14 @@
           return new String[]{"http", "https"};
       }
   
  -    public InputStream getInputStream( Artifact artifact )
  +    // get
  +    public InputStream getInputStream( String resource )
           throws Exception
       {
  -        String url = artifactUrl( artifact );
  +        String url = getRepository().getUrl() + "/" + resource;
   
  -        final HttpMethod method = new GetMethod( url );
  +        GetMethod getMethod = new GetMethod( url );
   
  -        //      Execute the method.
           int statusCode = SC_NULL;
   
           int attempt = 0;
  @@ -206,8 +207,8 @@
           {
               try
               {
  -                // execute the method.
  -                statusCode = client.executeMethod( method );
  +                // execute the getMethod.
  +                statusCode = client.executeMethod( getMethod );
               }
               catch ( HttpRecoverableException e )
               {
  @@ -246,7 +247,7 @@
                                                      + statusCode );
           }
   
  -        return method.getResponseBodyAsStream();
  +        return getMethod.getResponseBodyAsStream();
       }
   
       public int getNumberOfAttempts()
  @@ -258,5 +259,4 @@
       {
           this.numberOfAttempts = numberOfAttempts;
       }
  -
   }
  
  
  
  1.2       +34 -6     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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- HttpWagonTest.java	30 Mar 2004 14:43:06 -0000	1.1
  +++ HttpWagonTest.java	24 Apr 2004 15:53:09 -0000	1.2
  @@ -17,8 +17,8 @@
    */
   
   import org.apache.maven.wagon.WagonTestCase;
  -import org.apache.maven.wagon.repository.Repository;
   import org.apache.maven.wagon.artifact.Artifact;
  +import org.apache.maven.wagon.repository.Repository;
   import org.codehaus.plexus.jetty.Httpd;
   
   import java.io.File;
  @@ -30,6 +30,8 @@
   public class HttpWagonTest
       extends WagonTestCase
   {
  +    private Httpd httpd;
  +
       protected String getProtocol()
       {
           return "http";
  @@ -45,18 +47,44 @@
       {
           super.setUp();
   
  +        httpd = (Httpd) lookup( Httpd.ROLE );               
  +    }
  +
  +    protected void tearDown()
  +        throws Exception
  +    {
  +        release( httpd );
  +    }
  +
  +    protected void setupFileRoundTripTesting()
  +        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.
  +
  +        // File round trip testing
  +        File f = new File( basedir, "/target/http-repository/test-resource.txt" );
  +
  +        f.getParentFile().mkdirs();
  +
  +        generateFile( f.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.
  -        
  +
  +        // Artifact round trip testing
           Artifact artifact = getTestArtifact();
   
           File f = new File( basedir, "/target/http-repository/" + new Repository().artifactPath(
artifact ) );
   
           f.getParentFile().mkdirs();
   
  -        generateFile( f.getAbsolutePath(), "dummy" );
  -
  -        Httpd httpd = (Httpd) lookup( Httpd.ROLE );
  +        generateFile( f.getAbsolutePath(), "aritfact-dummy" );
       }
   }
  
  
  

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