You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wagon-commits@maven.apache.org by br...@apache.org on 2008/07/30 23:07:50 UTC

svn commit: r681203 [1/2] - in /maven/wagon/trunk: ./ wagon-provider-test/ wagon-provider-test/src/main/java/org/apache/maven/wagon/ wagon-provider-test/src/main/java/org/apache/maven/wagon/http/ wagon-providers/wagon-http-lightweight/ wagon-providers/...

Author: brett
Date: Wed Jul 30 14:07:48 2008
New Revision: 681203

URL: http://svn.apache.org/viewvc?rev=681203&view=rev
Log:
authentication and proxying tests for HTTP based wagons

Added:
    maven/wagon/trunk/wagon-provider-test/src/main/java/org/apache/maven/wagon/http/
    maven/wagon/trunk/wagon-provider-test/src/main/java/org/apache/maven/wagon/http/HttpWagonTestCase.java   (with props)
    maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/LightweightHttpsWagonTest.java   (with props)
    maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/test/resources/
    maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/test/resources/ssl/
    maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/test/resources/ssl/keystore   (with props)
    maven/wagon/trunk/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpsWagonTest.java   (with props)
    maven/wagon/trunk/wagon-providers/wagon-http/src/test/resources/
    maven/wagon/trunk/wagon-providers/wagon-http/src/test/resources/ssl/
    maven/wagon/trunk/wagon-providers/wagon-http/src/test/resources/ssl/keystore   (with props)
    maven/wagon/trunk/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavsWagonTest.java   (with props)
    maven/wagon/trunk/wagon-providers/wagon-webdav-jackrabbit/src/test/resources/ssl/
    maven/wagon/trunk/wagon-providers/wagon-webdav-jackrabbit/src/test/resources/ssl/keystore   (with props)
Removed:
    maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/LightweightHttpWagonGzipTest.java
    maven/wagon/trunk/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonGzipTest.java
    maven/wagon/trunk/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/webdav/AuthenticatedWebDavWagonTest.java
    maven/wagon/trunk/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/webdav/Context.java
    maven/wagon/trunk/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/webdav/Servlet.java
    maven/wagon/trunk/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/webdav/ServletServer.java
    maven/wagon/trunk/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavWagonGzipTest.java
    maven/wagon/trunk/wagon-providers/wagon-webdav-jackrabbit/src/test/resources/org/
Modified:
    maven/wagon/trunk/pom.xml
    maven/wagon/trunk/wagon-provider-test/pom.xml
    maven/wagon/trunk/wagon-provider-test/src/main/java/org/apache/maven/wagon/WagonTestCase.java
    maven/wagon/trunk/wagon-providers/wagon-http-lightweight/pom.xml
    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-http/pom.xml
    maven/wagon/trunk/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonHttpServerTestCase.java
    maven/wagon/trunk/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonTest.java
    maven/wagon/trunk/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonTimeoutTest.java
    maven/wagon/trunk/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagonWithProxyTest.java
    maven/wagon/trunk/wagon-providers/wagon-webdav-jackrabbit/pom.xml
    maven/wagon/trunk/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavWagonTest.java

Modified: maven/wagon/trunk/pom.xml
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/pom.xml?rev=681203&r1=681202&r2=681203&view=diff
==============================================================================
--- maven/wagon/trunk/pom.xml (original)
+++ maven/wagon/trunk/pom.xml Wed Jul 30 14:07:48 2008
@@ -105,6 +105,7 @@
       <plugin>
         <groupId>org.codehaus.plexus</groupId>
         <artifactId>plexus-maven-plugin</artifactId>
+        <version>1.3.5</version>
         <executions>
           <execution>
             <id>generate</id>

Modified: maven/wagon/trunk/wagon-provider-test/pom.xml
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-provider-test/pom.xml?rev=681203&r1=681202&r2=681203&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-provider-test/pom.xml (original)
+++ maven/wagon/trunk/wagon-provider-test/pom.xml Wed Jul 30 14:07:48 2008
@@ -27,5 +27,10 @@
       <artifactId>easymock</artifactId>
       <version>1.2_Java1.3</version>
     </dependency>
+    <dependency>
+      <groupId>org.mortbay.jetty</groupId>
+      <artifactId>jetty</artifactId>
+      <version>6.1.11</version>
+    </dependency>
   </dependencies>
 </project>
\ No newline at end of file

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=681203&r1=681202&r2=681203&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 Wed Jul 30 14:07:48 2008
@@ -62,12 +62,12 @@
             }
             if ( actual instanceof Integer )
             {
-                size += ((Integer) actual).intValue();
+                size += ( (Integer) actual ).intValue();
                 return true;
             }
             return super.argumentMatches( expected, actual );
         }
-        
+
         public int getSize()
         {
             return size;
@@ -93,9 +93,9 @@
     protected File artifactDestFile;
 
     protected ChecksumObserver checksumObserver;
-    
+
     protected TransferListener mockTransferListener;
-    
+
     protected MockControl mockTransferListenerControl;
 
     // ----------------------------------------------------------------------
@@ -106,39 +106,38 @@
         throws Exception
     {
         checksumObserver = new ChecksumObserver();
-        
-        mockTransferListenerControl = MockControl.createControl( TransferListener.class ); 
+
+        mockTransferListenerControl = MockControl.createControl( TransferListener.class );
         mockTransferListener = (TransferListener) mockTransferListenerControl.getMock();
 
         super.setUp();
     }
+
     // ----------------------------------------------------------------------
     // Methods that should be provided by subclasses for proper testing
     // ----------------------------------------------------------------------
 
     /**
-     * URL of the repository. For a complete test it should point to a non existing folder so
-     * we also check for the creation of new folders in the remote site.
-     * <p/>
-     * return the URL of the repository as specified by Wagon syntax
+     * URL of the repository. For a complete test it should point to a non existing folder so we also check for the
+     * creation of new folders in the remote site. <p/> return the URL of the repository as specified by Wagon syntax
      */
     protected abstract String getTestRepositoryUrl()
         throws IOException;
 
     /**
      * Protocol id of the Wagon to use, eg. <code>scp</code>, <code>ftp</code>
-     *
+     * 
      * @return the protocol id
      */
     protected abstract String getProtocol();
 
     // ----------------------------------------------------------------------
     // 1. Create a local file repository which mimic a users local file
-    //    Repository.
+    // Repository.
     //
     // 2. Create a test repository for the type of wagon we are testing. So,
-    //    for example, for testing the file wagon we might have a test
-    //    repository url of file://${basedir}/target/file-repository.
+    // for example, for testing the file wagon we might have a test
+    // repository url of file://${basedir}/target/file-repository.
     // ----------------------------------------------------------------------
 
     protected void setupRepositories()
@@ -286,37 +285,37 @@
         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 )
+                                         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 );
@@ -324,11 +323,11 @@
         else
         {
             mockTransferListenerControl.verify();
-            
+
             mockTransferListenerControl.reset();
-            
+
             assertNull( "check checksum is null", checksumObserver.getActualChecksum() );
-            
+
             assertFalse( destFile.exists() );
         }
     }
@@ -337,12 +336,12 @@
         throws NoSuchAlgorithmException, IOException
     {
         checksumObserver = new ChecksumObserver();
-        
+
         destFile = FileTestUtils.createUniqueFile( getName(), getName() );
         destFile.delete();
         assertFalse( destFile.exists() );
         destFile.deleteOnExit();
-        
+
         ProgressArgumentMatcher progressArgumentMatcher = null;
         if ( expectedResult == true )
         {
@@ -364,13 +363,13 @@
         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.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();
     }
 
@@ -416,9 +415,9 @@
     }
 
     /**
-     * Test for putting a directory with a destination that multiple directories deep,
-     * all of which haven't been created.
-     *
+     * Test for putting a directory with a destination that multiple directories deep, all of which haven't been
+     * created.
+     * 
      * @throws Exception
      * @since 1.0-beta-2
      */
@@ -465,7 +464,7 @@
 
     /**
      * Test that when putting a directory that already exists new files get also copied
-     *
+     * 
      * @throws Exception
      * @since 1.0-beta-1
      */
@@ -477,7 +476,7 @@
 
         final String resourceToCreate = "test-resource-1.txt";
 
-        final String[] resources = {"a/test-resource-2.txt", "a/b/test-resource-3.txt", "c/test-resource-4.txt"};
+        final String[] resources = { "a/test-resource-2.txt", "a/b/test-resource-3.txt", "c/test-resource-4.txt" };
 
         setupRepositories();
 
@@ -520,7 +519,7 @@
 
     /**
      * Test that when putting a directory that already exists new files get also copied and destination is "."
-     *
+     * 
      * @throws Exception
      * @since 1.0-beta-1
      */
@@ -529,7 +528,7 @@
     {
         final String resourceToCreate = "test-resource-1.txt";
 
-        final String[] resources = {"a/test-resource-2.txt", "a/b/test-resource-3.txt", "c/test-resource-4.txt"};
+        final String[] resources = { "a/test-resource-2.txt", "a/b/test-resource-3.txt", "c/test-resource-4.txt" };
 
         setupRepositories();
 
@@ -540,7 +539,7 @@
         if ( wagon.supportsDirectoryCopy() )
         {
             sourceFile = new File( FileTestUtils.getTestOutputDir(), "dot-repo" );
-            
+
             FileUtils.deleteDirectory( sourceFile );
 
             createDirectory( wagon, resourceToCreate, "." );
@@ -572,10 +571,10 @@
 
     /**
      * Create a directory with a resource and check that the other ones don't exist
-     *
+     * 
      * @param wagon
      * @param resourceToCreate name of the resource to be created
-     * @param dirName          directory name to create
+     * @param dirName directory name to create
      * @throws Exception
      */
     protected void createDirectory( Wagon wagon, String resourceToCreate, String dirName )
@@ -602,10 +601,10 @@
 
     /**
      * Assert that a resource does not exist in the remote wagon system
-     *
-     * @param wagon        wagon to get the resource from
+     * 
+     * @param wagon wagon to get the resource from
      * @param resourceName name of the resource
-     * @throws IOException             if a temp file can't be created
+     * @throws IOException if a temp file can't be created
      * @throws AuthorizationException
      * @throws TransferFailedException
      * @since 1.0-beta-1
@@ -712,7 +711,7 @@
 
     /**
      * Test {@link Wagon#getFileList(String)}.
-     *
+     * 
      * @throws Exception
      * @since 1.0-beta-2
      */
@@ -726,7 +725,7 @@
         String dirName = "file-list";
 
         String filenames[] =
-            new String[]{"test-resource.txt", "test-resource b.txt", "test-resource.pom", "more-resources.dat"};
+            new String[] { "test-resource.txt", "test-resource.pom", "test-resource b.txt", "more-resources.dat" };
 
         for ( int i = 0; i < filenames.length; i++ )
         {
@@ -739,8 +738,8 @@
 
         List list = wagon.getFileList( dirName );
         assertNotNull( "file list should not be null.", list );
-        assertTrue( "file list should contain 4 or more items (actually contains " + list.size() + " elements).", list
-            .size() >= 4 );
+        assertTrue( "file list should contain 4 or more items (actually contains " + list.size() + " elements).",
+                    list.size() >= 4 );
 
         for ( int i = 0; i < filenames.length; i++ )
         {
@@ -754,7 +753,7 @@
 
     /**
      * Test {@link Wagon#getFileList(String)} when the directory does not exist.
-     *
+     * 
      * @throws Exception
      * @since 1.0-beta-2
      */
@@ -790,7 +789,7 @@
 
     /**
      * Test for an existing resource.
-     *
+     * 
      * @throws Exception
      * @since 1.0-beta-2
      */
@@ -816,7 +815,7 @@
 
     /**
      * Test for an invalid resource.
-     *
+     * 
      * @throws Exception
      * @since 1.0-beta-2
      */
@@ -855,7 +854,7 @@
         Wagon wagon = getWagon();
 
         ProgressArgumentMatcher progressArgumentMatcher = replayMockForPut( resourceName, content, wagon );
-        
+
         message( "Putting test artifact: " + resourceName + " into test repository " + testRepository );
 
         connectWagon( wagon );
@@ -863,7 +862,7 @@
         wagon.put( sourceFile, resourceName );
 
         disconnectWagon( wagon );
-        
+
         verifyMock( progressArgumentMatcher, content.length() );
     }
 
@@ -886,16 +885,16 @@
         mockTransferListener.debug( null );
         mockTransferListenerControl.setMatcher( MockControl.ALWAYS_MATCHER );
         mockTransferListenerControl.setVoidCallable( MockControl.ZERO_OR_MORE );
-        
+
         mockTransferListener.transferCompleted( createTransferEvent( wagon, resource, TransferEvent.TRANSFER_COMPLETED,
                                                                      TransferEvent.REQUEST_PUT, sourceFile ) );
-        
+
         mockTransferListenerControl.replay();
         return progressArgumentMatcher;
     }
 
     protected TransferEvent createTransferEvent( Wagon wagon, Resource resource, int eventType, int requestType,
-                                               File file )
+                                                 File file )
     {
         TransferEvent transferEvent = new TransferEvent( wagon, resource, eventType, requestType );
         transferEvent.setLocalFile( file );
@@ -910,16 +909,16 @@
         return content.length();
     }
 
-    protected void getFile(int expectedSize)
+    protected void getFile( int expectedSize )
         throws Exception
     {
         destFile = FileTestUtils.createUniqueFile( getName(), getName() );
         destFile.deleteOnExit();
-        
+
         Wagon wagon = getWagon();
 
         ProgressArgumentMatcher progressArgumentMatcher = replaceMockForGet( wagon, expectedSize );
-        
+
         message( "Getting test artifact from test repository " + testRepository );
 
         connectWagon( wagon );
@@ -927,16 +926,16 @@
         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();
     }
 
@@ -944,7 +943,7 @@
         throws ConnectionException
     {
         wagon.removeTransferListener( mockTransferListener );
-        
+
         wagon.removeTransferListener( checksumObserver );
 
         wagon.disconnect();
@@ -954,7 +953,7 @@
         throws ConnectionException, AuthenticationException
     {
         wagon.addTransferListener( checksumObserver );
-        
+
         wagon.addTransferListener( mockTransferListener );
 
         wagon.connect( testRepository, getAuthInfo() );
@@ -974,14 +973,14 @@
                                                                   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.transferCompleted( createTransferEvent( wagon, resource, TransferEvent.TRANSFER_COMPLETED,
                                                                      TransferEvent.REQUEST_GET, destFile ) );
-        
+
         mockTransferListenerControl.replay();
         return progressArgumentMatcher;
     }

Added: maven/wagon/trunk/wagon-provider-test/src/main/java/org/apache/maven/wagon/http/HttpWagonTestCase.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-provider-test/src/main/java/org/apache/maven/wagon/http/HttpWagonTestCase.java?rev=681203&view=auto
==============================================================================
--- maven/wagon/trunk/wagon-provider-test/src/main/java/org/apache/maven/wagon/http/HttpWagonTestCase.java (added)
+++ maven/wagon/trunk/wagon-provider-test/src/main/java/org/apache/maven/wagon/http/HttpWagonTestCase.java Wed Jul 30 14:07:48 2008
@@ -0,0 +1,921 @@
+package org.apache.maven.wagon.http;
+
+/*
+ * 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.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.URLDecoder;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.zip.GZIPOutputStream;
+
+import javax.servlet.ServletException;
+import javax.servlet.ServletInputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.maven.wagon.ConnectionException;
+import org.apache.maven.wagon.FileTestUtils;
+import org.apache.maven.wagon.ResourceDoesNotExistException;
+import org.apache.maven.wagon.StreamingWagon;
+import org.apache.maven.wagon.StreamingWagonTestCase;
+import org.apache.maven.wagon.TransferFailedException;
+import org.apache.maven.wagon.Wagon;
+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.proxy.ProxyInfo;
+import org.apache.maven.wagon.repository.Repository;
+import org.apache.maven.wagon.resource.Resource;
+import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.StringOutputStream;
+import org.mortbay.jetty.Handler;
+import org.mortbay.jetty.HttpConnection;
+import org.mortbay.jetty.Request;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.handler.AbstractHandler;
+import org.mortbay.jetty.handler.HandlerCollection;
+import org.mortbay.jetty.security.Constraint;
+import org.mortbay.jetty.security.ConstraintMapping;
+import org.mortbay.jetty.security.HashUserRealm;
+import org.mortbay.jetty.security.SecurityHandler;
+import org.mortbay.jetty.servlet.Context;
+import org.mortbay.jetty.servlet.DefaultServlet;
+import org.mortbay.jetty.servlet.ServletHolder;
+
+/**
+ * @version $Id: LightweightHttpWagonTest.java 680764 2008-07-29 16:45:51Z brett $
+ */
+public abstract class HttpWagonTestCase
+    extends StreamingWagonTestCase
+{
+    private Server server;
+
+    protected void setupWagonTestingFixtures()
+        throws Exception
+    {
+        // File round trip testing
+
+        File file = FileTestUtils.createUniqueFile( "local-repository", "test-resource" );
+
+        file.delete();
+
+        file.getParentFile().mkdirs();
+
+        File repositoryDirectory = getRepositoryDirectory();
+        FileUtils.deleteDirectory( repositoryDirectory );
+        repositoryDirectory.mkdirs();
+
+        server = new Server( 10007 );
+
+        PutHandler putHandler = new PutHandler( repositoryDirectory );
+        server.addHandler( putHandler );
+
+        createContext( server, repositoryDirectory );
+
+        addConnectors( server );
+
+        server.start();
+    }
+
+    protected void createContext( Server server, File repositoryDirectory )
+        throws IOException
+    {
+        Context root = new Context( server, "/", Context.SESSIONS );
+        root.setResourceBase( repositoryDirectory.getAbsolutePath() );
+        ServletHolder servletHolder = new ServletHolder( new DefaultServlet() );
+        root.addServlet( servletHolder, "/*" );
+    }
+
+    protected void tearDownWagonTestingFixtures()
+        throws Exception
+    {
+        server.stop();
+    }
+
+    public void testWagonGetFileList()
+        throws Exception
+    {
+        File dir = getRepositoryDirectory();
+        FileUtils.deleteDirectory( dir );
+
+        File f = new File( dir, "file-list" );
+        f.mkdirs();
+
+        super.testWagonGetFileList();
+    }
+
+    public void testHttpHeaders()
+        throws Exception
+    {
+        Properties properties = new Properties();
+        properties.setProperty( "User-Agent", "Maven-Wagon/1.0" );
+
+        StreamingWagon wagon = (StreamingWagon) getWagon();
+
+        setHttpHeaders( wagon, properties );
+
+        Server server = new Server( 0 );
+        TestHeaderHandler handler = new TestHeaderHandler();
+        server.setHandler( handler );
+        addConnectors( server );
+        server.start();
+
+        wagon.connect( new Repository( "id", getProtocol() + "://localhost:" + server.getConnectors()[0].getLocalPort() ) );
+
+        wagon.getToStream( "resource", new StringOutputStream() );
+
+        wagon.disconnect();
+
+        server.stop();
+
+        assertEquals( "Maven-Wagon/1.0", handler.headers.get( "User-Agent" ) );
+    }
+
+    protected abstract void setHttpHeaders( StreamingWagon wagon, Properties properties );
+
+    protected void addConnectors( Server server )
+    {
+    }
+
+    protected String getRepositoryUrl( Server server )
+    {
+        int localPort = server.getConnectors()[0].getLocalPort();
+        return getProtocol() + "://localhost:" + localPort;
+    }
+
+    public void testGetForbidden()
+        throws Exception
+    {
+        try
+        {
+            runTestGet( HttpServletResponse.SC_FORBIDDEN );
+            fail();
+        }
+        catch ( AuthorizationException e )
+        {
+            assertTrue( true );
+        }
+    }
+
+    public void testGet404()
+        throws Exception
+    {
+        try
+        {
+            runTestGet( HttpServletResponse.SC_NOT_FOUND );
+            fail();
+        }
+        catch ( ResourceDoesNotExistException e )
+        {
+            assertTrue( true );
+        }
+    }
+
+    public void testGet500()
+        throws Exception
+    {
+        try
+        {
+            runTestGet( HttpServletResponse.SC_INTERNAL_SERVER_ERROR );
+            fail();
+        }
+        catch ( TransferFailedException e )
+        {
+            assertTrue( true );
+        }
+    }
+
+    private void runTestGet( int status )
+        throws Exception, ConnectionException, AuthenticationException, TransferFailedException,
+        ResourceDoesNotExistException, AuthorizationException
+    {
+        StreamingWagon wagon = (StreamingWagon) getWagon();
+
+        Server server = new Server( 0 );
+        StatusHandler handler = new StatusHandler();
+        handler.setStatusToReturn( status );
+        server.setHandler( handler );
+        addConnectors( server );
+        server.start();
+
+        wagon.connect( new Repository( "id", getRepositoryUrl( server ) ) );
+
+        try
+        {
+            wagon.getToStream( "resource", new StringOutputStream() );
+            fail();
+        }
+        finally
+        {
+            wagon.disconnect();
+
+            server.stop();
+        }
+    }
+
+    public void testResourceExistsForbidden()
+        throws Exception
+    {
+        try
+        {
+            runTestResourceExists( HttpServletResponse.SC_FORBIDDEN );
+            fail();
+        }
+        catch ( AuthorizationException e )
+        {
+            assertTrue( true );
+        }
+    }
+
+    public void testResourceExists404()
+        throws Exception
+    {
+        try
+        {
+            assertFalse( runTestResourceExists( HttpServletResponse.SC_NOT_FOUND ) );
+        }
+        catch ( ResourceDoesNotExistException e )
+        {
+            assertTrue( true );
+        }
+    }
+
+    public void testResourceExists500()
+        throws Exception
+    {
+        try
+        {
+            runTestResourceExists( HttpServletResponse.SC_INTERNAL_SERVER_ERROR );
+            fail();
+        }
+        catch ( TransferFailedException e )
+        {
+            assertTrue( true );
+        }
+    }
+
+    private boolean runTestResourceExists( int status )
+        throws Exception, ConnectionException, AuthenticationException, TransferFailedException,
+        ResourceDoesNotExistException, AuthorizationException
+    {
+        StreamingWagon wagon = (StreamingWagon) getWagon();
+
+        Server server = new Server( 0 );
+        StatusHandler handler = new StatusHandler();
+        handler.setStatusToReturn( status );
+        server.setHandler( handler );
+        addConnectors( server );
+        server.start();
+
+        wagon.connect( new Repository( "id", getRepositoryUrl( server ) ) );
+
+        try
+        {
+            return wagon.resourceExists( "resource" );
+        }
+        finally
+        {
+            wagon.disconnect();
+
+            server.stop();
+        }
+    }
+
+    protected long getExpectedLastModifiedOnGet( Repository repository, Resource resource )
+    {
+        File file = new File( getRepositoryDirectory(), resource.getName() );
+        return file.lastModified();
+    }
+
+    private File getRepositoryDirectory()
+    {
+        return getTestFile( "target/test-output/http-repository" );
+    }
+
+    public void testGzipGet()
+        throws Exception
+    {
+        Server server = new Server( 10008 );
+
+        String localRepositoryPath = FileTestUtils.getTestOutputDir().toString();
+        Context root = new Context( server, "/", Context.SESSIONS );
+        root.setResourceBase( localRepositoryPath );
+        ServletHolder servletHolder = new ServletHolder( new DefaultServlet() );
+        servletHolder.setInitParameter( "gzip", "true" );
+        root.addServlet( servletHolder, "/*" );
+        addConnectors( server );
+        server.start();
+
+        try
+        {
+            Wagon wagon = getWagon();
+
+            Repository testRepository = new Repository( "id", getRepositoryUrl( server ) );
+
+            File sourceFile = new File( localRepositoryPath + "/gzip" );
+
+            sourceFile.deleteOnExit();
+
+            String resName = "gzip-res.txt";
+            String sourceContent = writeTestFileGzip( sourceFile, resName );
+
+            wagon.connect( testRepository );
+
+            File destFile = FileTestUtils.createUniqueFile( getName(), getName() );
+
+            destFile.deleteOnExit();
+
+            wagon.get( "gzip/" + resName, destFile );
+
+            wagon.disconnect();
+
+            String destContent = FileUtils.fileRead( destFile );
+
+            assertEquals( sourceContent, destContent );
+        }
+        finally
+        {
+            server.stop();
+        }
+    }
+
+    public void testProxiedRequest()
+        throws Exception
+    {
+        ProxyInfo proxyInfo = createProxyInfo();
+        TestHeaderHandler handler = new TestHeaderHandler();
+
+        runTestProxiedRequest( proxyInfo, handler );
+    }
+
+    public void testProxiedRequestWithAuthentication()
+        throws Exception
+    {
+        ProxyInfo proxyInfo = createProxyInfo();
+        proxyInfo.setUserName( "user" );
+        proxyInfo.setPassword( "secret" );
+        TestHeaderHandler handler = new AuthorizingProxyHandler();
+
+        runTestProxiedRequest( proxyInfo, handler );
+
+        assertTrue( handler.headers.containsKey( "Proxy-Authorization" ) );
+    }
+
+    private void runTestProxiedRequest( ProxyInfo proxyInfo, TestHeaderHandler handler )
+        throws Exception, IOException, ConnectionException, AuthenticationException, ResourceDoesNotExistException,
+        TransferFailedException, AuthorizationException
+    {
+        Server proxyServer = new Server( 10007 );
+
+        proxyServer.setHandler( handler );
+        proxyServer.start();
+
+        proxyInfo.setPort( 10007 );
+
+        try
+        {
+            StreamingWagon wagon = (StreamingWagon) getWagon();
+
+            Repository testRepository = new Repository( "id", "http://www.example.com/" );
+
+            String localRepositoryPath = FileTestUtils.getTestOutputDir().toString();
+            File sourceFile = new File( localRepositoryPath, "test-proxied-resource" );
+            FileUtils.fileWrite( sourceFile.getAbsolutePath(), "content" );
+
+            wagon.connect( testRepository, proxyInfo );
+
+            StringOutputStream out = new StringOutputStream();
+            try
+            {
+                wagon.getToStream( "test-proxied-resource", out );
+
+                assertTrue( handler.headers.containsKey( "Proxy-Connection" ) );
+            }
+            finally
+            {
+                wagon.disconnect();
+            }
+        }
+        finally
+        {
+            proxyServer.stop();
+        }
+    }
+
+    private ProxyInfo createProxyInfo()
+    {
+        ProxyInfo proxyInfo = new ProxyInfo();
+        proxyInfo.setHost( "localhost" );
+        proxyInfo.setNonProxyHosts( null );
+        proxyInfo.setType( "http" );
+        return proxyInfo;
+    }
+
+    public void testSecuredGetUnauthorized()
+        throws Exception
+    {
+        try
+        {
+            runTestSecuredGet( null );
+            fail();
+        }
+        catch ( AuthorizationException e )
+        {
+            assertTrue( true );
+        }
+    }
+
+    public void testSecuredGetWrongPassword()
+        throws Exception
+    {
+        try
+        {
+            AuthenticationInfo authInfo = new AuthenticationInfo();
+            authInfo.setUserName( "user" );
+            authInfo.setPassword( "admin" );
+            runTestSecuredGet( authInfo );
+            fail();
+        }
+        catch ( AuthorizationException e )
+        {
+            assertTrue( true );
+        }
+    }
+
+    public void testSecuredGet()
+        throws Exception
+    {
+        AuthenticationInfo authInfo = new AuthenticationInfo();
+        authInfo.setUserName( "user" );
+        authInfo.setPassword( "secret" );
+        runTestSecuredGet( authInfo );
+    }
+
+    public void runTestSecuredGet( AuthenticationInfo authInfo )
+        throws Exception
+    {
+        String localRepositoryPath = FileTestUtils.getTestOutputDir().toString();
+        Server server = createSecurityServer( localRepositoryPath );
+        server.start();
+
+        try
+        {
+            StreamingWagon wagon = (StreamingWagon) getWagon();
+
+            Repository testRepository = new Repository( "id", getRepositoryUrl( server ) );
+
+            File sourceFile = new File( localRepositoryPath, "test-secured-resource" );
+            FileUtils.fileWrite( sourceFile.getAbsolutePath(), "top secret" );
+
+            wagon.connect( testRepository, authInfo );
+
+            StringOutputStream out = new StringOutputStream();
+            try
+            {
+                wagon.getToStream( "test-secured-resource", out );
+            }
+            finally
+            {
+                wagon.disconnect();
+            }
+
+            assertEquals( "top secret", out.toString() );
+        }
+        finally
+        {
+            server.stop();
+        }
+    }
+
+    public void testSecuredResourceExistsUnauthorized()
+        throws Exception
+    {
+        try
+        {
+            runTestSecuredResourceExists( null );
+            fail();
+        }
+        catch ( AuthorizationException e )
+        {
+            assertTrue( true );
+        }
+    }
+
+    public void testSecuredResourceExistsWrongPassword()
+        throws Exception
+    {
+        try
+        {
+            AuthenticationInfo authInfo = new AuthenticationInfo();
+            authInfo.setUserName( "user" );
+            authInfo.setPassword( "admin" );
+            runTestSecuredResourceExists( authInfo );
+        }
+        catch ( AuthorizationException e )
+        {
+            assertTrue( true );
+        }
+    }
+
+    public void testSecuredResourceExists()
+        throws Exception
+    {
+        AuthenticationInfo authInfo = new AuthenticationInfo();
+        authInfo.setUserName( "user" );
+        authInfo.setPassword( "secret" );
+        runTestSecuredResourceExists( authInfo );
+    }
+
+    public void runTestSecuredResourceExists( AuthenticationInfo authInfo )
+        throws Exception
+    {
+        String localRepositoryPath = FileTestUtils.getTestOutputDir().toString();
+        Server server = createSecurityServer( localRepositoryPath );
+        server.start();
+
+        try
+        {
+            StreamingWagon wagon = (StreamingWagon) getWagon();
+
+            Repository testRepository = new Repository( "id", getRepositoryUrl( server ) );
+
+            File sourceFile = new File( localRepositoryPath, "test-secured-resource-exists" );
+            FileUtils.fileWrite( sourceFile.getAbsolutePath(), "top secret" );
+
+            wagon.connect( testRepository, authInfo );
+
+            try
+            {
+                assertTrue( wagon.resourceExists( "test-secured-resource-exists" ) );
+
+                assertFalse( wagon.resourceExists( "test-secured-resource-not-exists" ) );
+            }
+            finally
+            {
+                wagon.disconnect();
+            }
+        }
+        finally
+        {
+            server.stop();
+        }
+    }
+
+    private Server createSecurityServer( String localRepositoryPath )
+    {
+        Server server = new Server( 0 );
+
+        SecurityHandler sh = createSecurityHandler();
+
+        Context root = new Context( Context.SESSIONS );
+        root.setContextPath( "/" );
+        root.addHandler( sh );
+        root.setResourceBase( localRepositoryPath );
+        ServletHolder servletHolder = new ServletHolder( new DefaultServlet() );
+        root.addServlet( servletHolder, "/*" );
+
+        server.setHandler( root );
+        addConnectors( server );
+        return server;
+    }
+
+    protected SecurityHandler createSecurityHandler()
+    {
+        Constraint constraint = new Constraint();
+        constraint.setName( Constraint.__BASIC_AUTH );
+        constraint.setRoles( new String[] { "admin" } );
+        constraint.setAuthenticate( true );
+
+        ConstraintMapping cm = new ConstraintMapping();
+        cm.setConstraint( constraint );
+        cm.setPathSpec( "/*" );
+
+        SecurityHandler sh = new SecurityHandler();
+        HashUserRealm hashUserRealm = new HashUserRealm( "MyRealm" );
+        hashUserRealm.put( "user", "secret" );
+        hashUserRealm.addUserToRole( "user", "admin" );
+        sh.setUserRealm( hashUserRealm );
+        sh.setConstraintMappings( new ConstraintMapping[] { cm } );
+        return sh;
+    }
+
+    private String writeTestFileGzip( File parent, String child )
+        throws IOException
+    {
+        File file = new File( parent, child );
+        file.getParentFile().mkdirs();
+        file.deleteOnExit();
+        OutputStream out = new FileOutputStream( file );
+        out.write( child.getBytes() );
+        out.close();
+
+        file = new File( parent, child + ".gz" );
+        file.deleteOnExit();
+        out = new FileOutputStream( file );
+        out = new GZIPOutputStream( out );
+        // write out different data than non-gz file, so we can
+        // assert the gz version was returned
+        String content = file.getAbsolutePath();
+        out.write( content.getBytes() );
+        out.close();
+        return content;
+    }
+
+    public void testPutForbidden()
+        throws Exception
+    {
+        try
+        {
+            runTestPut( HttpServletResponse.SC_FORBIDDEN );
+            fail();
+        }
+        catch ( AuthorizationException e )
+        {
+            assertTrue( true );
+        }
+    }
+
+    public void testPut404()
+        throws Exception
+    {
+        try
+        {
+            runTestPut( HttpServletResponse.SC_NOT_FOUND );
+            fail();
+        }
+        catch ( ResourceDoesNotExistException e )
+        {
+            assertTrue( true );
+        }
+    }
+
+    public void testPut500()
+        throws Exception
+    {
+        try
+        {
+            runTestPut( HttpServletResponse.SC_INTERNAL_SERVER_ERROR );
+            fail();
+        }
+        catch ( TransferFailedException e )
+        {
+            assertTrue( true );
+        }
+    }
+
+    private void runTestPut( int status )
+        throws Exception, ConnectionException, AuthenticationException, TransferFailedException,
+        ResourceDoesNotExistException, AuthorizationException
+    {
+        StreamingWagon wagon = (StreamingWagon) getWagon();
+
+        Server server = new Server( 0 );
+        StatusHandler handler = new StatusHandler();
+        handler.setStatusToReturn( status );
+        server.setHandler( handler );
+        addConnectors( server );
+        server.start();
+
+        wagon.connect( new Repository( "id", getRepositoryUrl( server ) ) );
+
+        File tempFile = File.createTempFile( "wagon", "tmp" );
+        tempFile.deleteOnExit();
+        FileUtils.fileWrite( tempFile.getAbsolutePath(), "content" );
+
+        try
+        {
+            wagon.put( tempFile, "resource" );
+            fail();
+        }
+        finally
+        {
+            wagon.disconnect();
+
+            server.stop();
+
+            tempFile.delete();
+        }
+    }
+
+    public void testSecuredPutUnauthorized()
+        throws Exception
+    {
+        try
+        {
+            runTestSecuredPut( null );
+            fail();
+        }
+        catch ( TransferFailedException e )
+        {
+            assertTrue( true );
+        }
+    }
+
+    public void testSecuredPutWrongPassword()
+        throws Exception
+    {
+        try
+        {
+            AuthenticationInfo authInfo = new AuthenticationInfo();
+            authInfo.setUserName( "user" );
+            authInfo.setPassword( "admin" );
+            runTestSecuredPut( authInfo );
+            fail();
+        }
+        catch ( TransferFailedException e )
+        {
+            assertTrue( true );
+        }
+    }
+
+    public void testSecuredPut()
+        throws Exception
+    {
+        AuthenticationInfo authInfo = new AuthenticationInfo();
+        authInfo.setUserName( "user" );
+        authInfo.setPassword( "secret" );
+        runTestSecuredPut( authInfo );
+    }
+
+    public void runTestSecuredPut( AuthenticationInfo authInfo )
+        throws Exception
+    {
+        String localRepositoryPath = FileTestUtils.getTestOutputDir().toString();
+        Server server = new Server( 0 );
+
+        SecurityHandler sh = createSecurityHandler();
+
+        PutHandler handler = new PutHandler( new File( localRepositoryPath ) );
+
+        HandlerCollection handlers = new HandlerCollection();
+        handlers.setHandlers( new Handler[] { sh, handler } );
+
+        server.setHandler( handlers );
+        addConnectors( server );
+        server.start();
+
+        try
+        {
+            StreamingWagon wagon = (StreamingWagon) getWagon();
+
+            Repository testRepository = new Repository( "id", getRepositoryUrl( server ) );
+
+            wagon.connect( testRepository, authInfo );
+
+            File sourceFile = new File( localRepositoryPath, "test-secured-put-resource" );
+            sourceFile.delete();
+            assertFalse( sourceFile.exists() );
+
+            File tempFile = File.createTempFile( "wagon", "tmp" );
+            tempFile.deleteOnExit();
+            FileUtils.fileWrite( tempFile.getAbsolutePath(), "put top secret" );
+
+            try
+            {
+                wagon.put( tempFile, "test-secured-put-resource" );
+            }
+            finally
+            {
+                wagon.disconnect();
+                tempFile.delete();
+            }
+
+            assertEquals( "put top secret", FileUtils.fileRead( sourceFile.getAbsolutePath() ) );
+        }
+        finally
+        {
+            server.stop();
+        }
+    }
+
+    static class StatusHandler
+        extends AbstractHandler
+    {
+        private int status;
+
+        public void setStatusToReturn( int status )
+        {
+            this.status = status;
+        }
+
+        public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch )
+            throws IOException, ServletException
+        {
+            if ( status != 0 )
+            {
+                response.setStatus( status );
+                ( (Request) request ).setHandled( true );
+            }
+        }
+    }
+
+    static class PutHandler
+        extends AbstractHandler
+    {
+        private final File resourceBase;
+
+        public PutHandler( File repositoryDirectory )
+        {
+            this.resourceBase = repositoryDirectory;
+        }
+
+        public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch )
+            throws IOException, ServletException
+        {
+            Request base_request =
+                request instanceof Request ? (Request) request : HttpConnection.getCurrentConnection().getRequest();
+
+            if ( base_request.isHandled() || !"PUT".equals( base_request.getMethod() ) )
+            {
+                return;
+            }
+
+            base_request.setHandled( true );
+
+            File file = new File( resourceBase, URLDecoder.decode( request.getPathInfo() ) );
+            file.getParentFile().mkdirs();
+            FileOutputStream out = new FileOutputStream( file );
+            ServletInputStream in = request.getInputStream();
+            try
+            {
+                IOUtil.copy( in, out );
+            }
+            finally
+            {
+                in.close();
+                out.close();
+            }
+
+            response.setStatus( HttpServletResponse.SC_CREATED );
+        }
+    }
+
+    private static class AuthorizingProxyHandler
+        extends TestHeaderHandler
+    {
+        public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch )
+            throws IOException, ServletException
+        {
+            if ( request.getHeader( "Proxy-Authorization" ) == null )
+            {
+                response.setStatus( 407 );
+                response.addHeader( "Proxy-Authenticate", "Basic realm=\"Squid proxy-caching web server\"" );
+
+                ( (Request) request ).setHandled( true );
+                return;
+            }
+            super.handle( target, request, response, dispatch );
+        }
+    }
+
+    private static class TestHeaderHandler
+        extends AbstractHandler
+    {
+        private Map headers;
+
+        public TestHeaderHandler()
+        {
+        }
+
+        public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch )
+            throws IOException, ServletException
+        {
+            headers = new HashMap();
+            for ( Enumeration e = request.getHeaderNames(); e.hasMoreElements(); )
+            {
+                String name = (String) e.nextElement();
+                headers.put( name, request.getHeader( name ) );
+            }
+
+            response.setContentType( "text/plain" );
+            response.setStatus( HttpServletResponse.SC_OK );
+            response.getWriter().println( "Hello, World!" );
+
+            ( (Request) request ).setHandled( true );
+        }
+
+    }
+}

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

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

Modified: maven/wagon/trunk/wagon-providers/wagon-http-lightweight/pom.xml
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-http-lightweight/pom.xml?rev=681203&r1=681202&r2=681203&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-http-lightweight/pom.xml (original)
+++ maven/wagon/trunk/wagon-providers/wagon-http-lightweight/pom.xml Wed Jul 30 14:07:48 2008
@@ -24,17 +24,5 @@
         </exclusion>
       </exclusions>
     </dependency>
-    <dependency>
-      <groupId>plexus</groupId>
-      <artifactId>plexus-jetty-httpd</artifactId>
-      <version>1.0-beta-1</version>
-      <scope>test</scope>
-      <exclusions>
-        <exclusion>
-          <artifactId>plexus-container-default</artifactId>
-          <groupId>plexus</groupId>
-        </exclusion>
-      </exclusions>
-    </dependency>
   </dependencies>
 </project>
\ No newline at end of file

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=681203&r1=681202&r2=681203&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 Wed Jul 30 14:07:48 2008
@@ -52,10 +52,7 @@
  * 
  * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
  * @version $Id$
- * 
- * @plexus.component role="org.apache.maven.wagon.Wagon" 
- *   role-hint="http"
- *   instantiation-strategy="per-lookup"
+ * @plexus.component role="org.apache.maven.wagon.Wagon" role-hint="http" instantiation-strategy="per-lookup"
  */
 public class LightweightHttpWagon
     extends StreamWagon
@@ -65,12 +62,12 @@
     private String previousHttpProxyHost;
 
     private String previousHttpProxyPort;
-    
+
     private HttpURLConnection putConnection;
 
     /**
      * Whether to use any proxy cache or not.
-     *
+     * 
      * @plexus.configuration default="false"
      */
     private boolean useCache;
@@ -88,34 +85,44 @@
     {
         final String repoUrl = getRepository().getUrl();
 
+        path = path.replace( ' ', '+' );
+
         if ( repoUrl.charAt( repoUrl.length() - 1 ) != '/' )
         {
             return repoUrl + '/' + path;
         }
 
         return repoUrl + path;
-    }    
+    }
 
     public void fillInputData( InputData inputData )
-        throws TransferFailedException, ResourceDoesNotExistException
+        throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
     {
         Resource resource = inputData.getResource();
         try
         {
             URL url = new URL( buildUrl( resource.getName() ) );
-            URLConnection urlConnection = url.openConnection();
+            HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
             urlConnection.setRequestProperty( "Accept-Encoding", "gzip" );
             if ( !useCache )
             {
                 urlConnection.setRequestProperty( "Pragma", "no-cache" );
             }
-            
+
             addHeaders( urlConnection );
-            
+
+            // TODO: handle all response codes
+            int responseCode = urlConnection.getResponseCode();
+            if ( responseCode == HttpURLConnection.HTTP_FORBIDDEN
+                || responseCode == HttpURLConnection.HTTP_UNAUTHORIZED )
+            {
+                throw new AuthorizationException( "Access denied to: " + buildUrl( resource.getName() ) );
+            }
+
             InputStream is = urlConnection.getInputStream();
             String contentEncoding = urlConnection.getHeaderField( "Content-Encoding" );
-            boolean isGZipped = contentEncoding == null ? false : "gzip".equalsIgnoreCase(contentEncoding);
-            if (isGZipped)
+            boolean isGZipped = contentEncoding == null ? false : "gzip".equalsIgnoreCase( contentEncoding );
+            if ( isGZipped )
             {
                 is = new GZIPInputStream( is );
             }
@@ -145,7 +152,7 @@
             {
                 String header = (String) i.next();
                 urlConnection.setRequestProperty( header, httpHeaders.getProperty( header ) );
-            }                
+            }
         }
     }
 
@@ -159,7 +166,7 @@
             putConnection = (HttpURLConnection) url.openConnection();
 
             addHeaders( putConnection );
-            
+
             putConnection.setRequestMethod( "PUT" );
             putConnection.setDoOutput( true );
             outputData.setOutputStream( putConnection.getOutputStream() );
@@ -183,25 +190,26 @@
                 case HttpURLConnection.HTTP_OK: // 200
                 case HttpURLConnection.HTTP_CREATED: // 201
                 case HttpURLConnection.HTTP_ACCEPTED: // 202
-                case HttpURLConnection.HTTP_NO_CONTENT:  // 204
+                case HttpURLConnection.HTTP_NO_CONTENT: // 204
                     break;
 
                 case HttpURLConnection.HTTP_FORBIDDEN:
                     throw new AuthorizationException( "Access denied to: " + buildUrl( resource.getName() ) );
 
                 case HttpURLConnection.HTTP_NOT_FOUND:
-                    throw new ResourceDoesNotExistException( "File: " + buildUrl( resource.getName() ) + " 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: " + buildUrl( resource.getName() ) + ". Return code is: " + statusCode );
+                    // add more entries here
+                default:
+                    throw new TransferFailedException( "Failed to transfer file: " + buildUrl( resource.getName() )
+                        + ". Return code is: " + statusCode );
             }
         }
         catch ( IOException e )
         {
             fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
-            
+
             throw new TransferFailedException( "Error transferring file", e );
         }
     }
@@ -222,6 +230,10 @@
             {
                 System.setProperty( "http.nonProxyHosts", proxyInfo.getNonProxyHosts() );
             }
+            else
+            {
+                System.getProperties().remove( "http.nonProxyHosts" );
+            }
         }
         else
         {
@@ -238,8 +250,8 @@
                 protected PasswordAuthentication getPasswordAuthentication()
                 {
                     // TODO: ideally use getRequestorType() from JDK1.5 here...
-                    if ( hasProxy && getRequestingHost().equals( proxyInfo.getHost() ) &&
-                        getRequestingPort() == proxyInfo.getPort() )
+                    if ( hasProxy && getRequestingHost().equals( proxyInfo.getHost() )
+                        && getRequestingPort() == proxyInfo.getPort() )
                     {
                         String password = "";
                         if ( proxyInfo.getPassword() != null )
@@ -263,6 +275,10 @@
                 }
             } );
         }
+        else
+        {
+            Authenticator.setDefault( null );
+        }
     }
 
     public void closeConnection()
@@ -330,17 +346,17 @@
         throws TransferFailedException, AuthorizationException
     {
         HttpURLConnection headConnection;
-        
+
         try
         {
-            URL url = new URL( buildUrl( new Resource(resourceName).getName() ) );
+            URL url = new URL( buildUrl( new Resource( resourceName ).getName() ) );
             headConnection = (HttpURLConnection) url.openConnection();
-    
+
             addHeaders( headConnection );
 
             headConnection.setRequestMethod( "HEAD" );
             headConnection.setDoOutput( true );
-            
+
             int statusCode = headConnection.getResponseCode();
 
             switch ( statusCode )
@@ -349,17 +365,23 @@
                     return true;
 
                 case HttpURLConnection.HTTP_FORBIDDEN:
-                    throw new AuthorizationException( "Access denided to: " + url );
+                    throw new AuthorizationException( "Access denied to: " + url );
 
                 case HttpURLConnection.HTTP_NOT_FOUND:
                     return false;
+
+                case HttpURLConnection.HTTP_UNAUTHORIZED:
+                    throw new AuthorizationException( "Access denied to: " + url );
+
+                default:
+                    throw new TransferFailedException( "Failed to look for file: " + buildUrl( resourceName )
+                        + ". Return code is: " + statusCode );
             }
-        } catch ( IOException e )
+        }
+        catch ( IOException e )
         {
             throw new TransferFailedException( "Error transferring file", e );
         }
-        
-        return false;
     }
 
     public boolean isUseCache()
@@ -382,4 +404,3 @@
         this.httpHeaders = httpHeaders;
     }
 }
-

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=681203&r1=681202&r2=681203&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 Wed Jul 30 14:07:48 2008
@@ -19,25 +19,21 @@
  * under the License.
  */
 
-import java.io.File;
+import java.util.Properties;
 
-import org.apache.maven.wagon.FileTestUtils;
-import org.apache.maven.wagon.StreamingWagonTestCase;
+import org.apache.maven.wagon.StreamingWagon;
 import org.apache.maven.wagon.Wagon;
+import org.apache.maven.wagon.http.HttpWagonTestCase;
 import org.apache.maven.wagon.proxy.ProxyInfo;
 import org.apache.maven.wagon.repository.Repository;
-import org.apache.maven.wagon.resource.Resource;
-import org.codehaus.plexus.jetty.Httpd;
 
 /**
  * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
  * @version $Id$
  */
 public class LightweightHttpWagonTest
-    extends StreamingWagonTestCase
+    extends HttpWagonTestCase
 {
-    private Httpd httpd;
-
     protected String getProtocol()
     {
         return "http";
@@ -45,48 +41,12 @@
 
     protected String getTestRepositoryUrl()
     {
-        return "http://localhost:10007/";
+        return getProtocol() + "://localhost:10007/";
     }
 
-    protected void setupWagonTestingFixtures()
-        throws Exception
+    protected void setHttpHeaders( StreamingWagon wagon, Properties properties )
     {
-        // File round trip testing
-        
-        File file = FileTestUtils.createUniqueFile( "local-repository", "test-resource" );
-
-        file.delete();
-
-        file.getParentFile().mkdirs();
-
-        File f = new File( FileTestUtils.createDir( "http-repository" ), "test-resource" );
-
-        f.delete();
-
-        f.getParentFile().mkdirs();
-
-        httpd = (Httpd) lookup( Httpd.ROLE );
-    }
-    
-    protected void tearDownWagonTestingFixtures()
-        throws Exception
-    {
-        release( httpd );
-    }
-
-    public void testWagonGetFileList()
-        throws Exception
-    {
-        File f = new File( FileTestUtils.createDir( "http-repository" ), "file-list" );
-        f.mkdirs();
-        
-        super.testWagonGetFileList();
-    }
-
-    protected long getExpectedLastModifiedOnGet( Repository repository, Resource resource )
-    {
-        File file = getTestFile( "target/test-output/http-repository", resource.getName() );
-        return file.lastModified();
+        ( (LightweightHttpWagon) wagon ).setHttpHeaders( properties );
     }
 
     public void testProxyReset()
@@ -103,7 +63,7 @@
         String proxyHost = System.getProperty( "http.proxyHost" );
         String proxyPort = System.getProperty( "http.proxyPort" );
         String nonProxyHosts = System.getProperty( "http.nonProxyHosts" );
-  
+
         System.getProperties().remove( "http.proxyHost" );
         System.getProperties().remove( "http.proxyPort" );
 
@@ -114,12 +74,12 @@
         assertEquals( "proxyhost", System.getProperty( "http.proxyHost" ) );
         assertEquals( "1234", System.getProperty( "http.proxyPort" ) );
         assertEquals( "non", System.getProperty( "http.nonProxyHosts" ) );
-        
+
         wagon.disconnect();
 
         assertNull( System.getProperty( "http.proxyHost" ) );
         assertNull( System.getProperty( "http.proxyPort" ) );
-        
+
         System.setProperty( "http.proxyHost", "host" );
         System.setProperty( "http.proxyPort", "port" );
         System.setProperty( "http.nonProxyHosts", "hosts" );
@@ -131,26 +91,26 @@
         assertEquals( "proxyhost", System.getProperty( "http.proxyHost" ) );
         assertEquals( "1234", System.getProperty( "http.proxyPort" ) );
         assertEquals( "non", System.getProperty( "http.nonProxyHosts" ) );
-        
+
         wagon.disconnect();
 
         assertEquals( "host", System.getProperty( "http.proxyHost" ) );
         assertEquals( "port", System.getProperty( "http.proxyPort" ) );
         assertEquals( "hosts", System.getProperty( "http.nonProxyHosts" ) );
-        
+
         wagon = getWagon();
 
         wagon.connect( repository );
 
         assertNull( System.getProperty( "http.proxyHost" ) );
         assertNull( System.getProperty( "http.proxyPort" ) );
-        
+
         wagon.disconnect();
 
         assertEquals( "host", System.getProperty( "http.proxyHost" ) );
         assertEquals( "port", System.getProperty( "http.proxyPort" ) );
         assertEquals( "hosts", System.getProperty( "http.nonProxyHosts" ) );
-        
+
         if ( proxyHost != null )
         {
             System.setProperty( "http.proxyHost", proxyHost );

Added: maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/LightweightHttpsWagonTest.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/LightweightHttpsWagonTest.java?rev=681203&view=auto
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/LightweightHttpsWagonTest.java (added)
+++ maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/LightweightHttpsWagonTest.java Wed Jul 30 14:07:48 2008
@@ -0,0 +1,48 @@
+package org.apache.maven.wagon.providers.http;
+
+/*
+ * 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 org.mortbay.jetty.Connector;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.security.SslSocketConnector;
+
+public class LightweightHttpsWagonTest
+    extends LightweightHttpWagonTest
+{
+    protected String getProtocol()
+    {
+        return "https";
+    }
+
+    protected void addConnectors( Server server )
+    {
+        System.setProperty( "javax.net.ssl.trustStore",
+                            getTestFile( "src/test/resources/ssl/keystore" ).getAbsolutePath() );
+
+        SslSocketConnector connector = new SslSocketConnector();
+        connector.setPort( server.getConnectors()[0].getPort() );
+        connector.setKeystore( getTestPath( "src/test/resources/ssl/keystore" ) );
+        connector.setPassword( "wagonhttp" );
+        connector.setKeyPassword( "wagonhttp" );
+        connector.setTruststore( getTestPath( "src/test/resources/ssl/keystore" ) );
+        connector.setTrustPassword( "wagonhttp" );
+        server.setConnectors( new Connector[] { connector } );
+    }
+}

Propchange: maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/LightweightHttpsWagonTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/LightweightHttpsWagonTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/test/resources/ssl/keystore
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/test/resources/ssl/keystore?rev=681203&view=auto
==============================================================================
Binary file - no diff available.

Propchange: maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/test/resources/ssl/keystore
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: maven/wagon/trunk/wagon-providers/wagon-http/pom.xml
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-http/pom.xml?rev=681203&r1=681202&r2=681203&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-http/pom.xml (original)
+++ maven/wagon/trunk/wagon-providers/wagon-http/pom.xml Wed Jul 30 14:07:48 2008
@@ -17,30 +17,6 @@
       <artifactId>wagon-http-shared</artifactId>
       <version>1.0-beta-5-SNAPSHOT</version>
     </dependency>
-    <dependency>
-      <groupId>plexus</groupId>
-      <artifactId>plexus-jetty-httpd</artifactId>
-      <version>1.0-beta-1</version>
-      <scope>test</scope>
-      <exclusions>
-        <exclusion>
-          <artifactId>plexus-container-default</artifactId>
-          <groupId>plexus</groupId>
-        </exclusion>
-      </exclusions>
-    </dependency>
-    <dependency>
-      <groupId>javax.servlet</groupId>
-      <artifactId>servlet-api</artifactId>
-      <version>2.3</version>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.mortbay.jetty</groupId>
-      <artifactId>jetty</artifactId>
-      <version>4.2.12</version>
-      <scope>test</scope>
-    </dependency>
   </dependencies>
     <!-- I believe we can shade this in Maven itself
   <build>

Modified: maven/wagon/trunk/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonHttpServerTestCase.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonHttpServerTestCase.java?rev=681203&r1=681202&r2=681203&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonHttpServerTestCase.java (original)
+++ maven/wagon/trunk/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonHttpServerTestCase.java Wed Jul 30 14:07:48 2008
@@ -18,44 +18,37 @@
  * specific language governing permissions and limitations
  * under the License.
  */
- 
-import org.codehaus.plexus.PlexusTestCase;
-import org.mortbay.http.HttpServer;
-import org.mortbay.http.SocketListener;
-import org.mortbay.http.HttpContext;
-import org.mortbay.http.handler.ResourceHandler;
+
 import org.apache.maven.wagon.Wagon;
+import org.codehaus.plexus.PlexusTestCase;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.handler.ResourceHandler;
+import org.mortbay.jetty.servlet.Context;
 
 /**
- * User: jdumay
- * Date: 24/01/2008
- * Time: 18:15:53
+ * User: jdumay Date: 24/01/2008 Time: 18:15:53
  */
-public abstract class HttpWagonHttpServerTestCase extends PlexusTestCase
+public abstract class HttpWagonHttpServerTestCase
+    extends PlexusTestCase
 {
     protected final int httpServerPort = 10008;
 
-    private HttpServer server;
-
-    protected HttpContext context;
+    private Server server;
 
     protected ResourceHandler resourceHandler;
 
+    protected Context context;
+
     protected void setUp()
         throws Exception
     {
         super.setUp();
-        server = new HttpServer();
-        SocketListener listener = new SocketListener();
-        listener.setPort( httpServerPort );
-        server.addListener( listener );
-        
-        context = new HttpContext();
-        context.setContextPath( "/" );
-        server.addContext( context );
-        
+        server = new Server( httpServerPort );
+
+        context = new Context( server, "/", Context.SESSIONS );
+
         resourceHandler = new ResourceHandler();
-        context.addHandler( resourceHandler );
+        server.addHandler( resourceHandler );
     }
 
     protected Wagon getWagon()

Modified: maven/wagon/trunk/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonTest.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonTest.java?rev=681203&r1=681202&r2=681203&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonTest.java (original)
+++ maven/wagon/trunk/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonTest.java Wed Jul 30 14:07:48 2008
@@ -19,23 +19,18 @@
  * under the License.
  */
 
-import java.io.File;
+import java.util.Properties;
 
-import org.apache.maven.wagon.FileTestUtils;
-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 org.apache.maven.wagon.StreamingWagon;
+import org.apache.maven.wagon.http.HttpWagonTestCase;
 
 /**
  * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
  * @version $Id$
  */
 public class HttpWagonTest
-    extends StreamingWagonTestCase
+    extends HttpWagonTestCase
 {
-    private Httpd httpd;
-
     protected String getProtocol()
     {
         return "http";
@@ -43,59 +38,11 @@
 
     protected String getTestRepositoryUrl()
     {
-        return "http://localhost:10007/";
-    }
-
-    protected void setupWagonTestingFixtures()
-        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 file = FileTestUtils.createUniqueFile( "local-repository", "test-resource.txt" );
-
-        file.delete();
-
-        file.getParentFile().mkdirs();
-
-        FileTestUtils.generateFile( file.getAbsolutePath(), "file-dummy" );
-
-        // 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 f = new File( FileTestUtils.createDir( "http-repository" ), "test-resource.txt" );
-
-        f.delete();
-
-        f.getParentFile().mkdirs();
-
-        FileTestUtils.generateFile( f.getAbsolutePath(), "artifact-dummy" );
-
-        httpd = (Httpd) lookup( Httpd.ROLE );
-    }
-
-    public void testWagonGetFileList()
-        throws Exception
-    {
-        File f = new File( FileTestUtils.createDir( "http-repository" ), "file-list" );
-        f.mkdirs();
-
-        super.testWagonGetFileList();
-    }
-
-    protected void tearDownWagonTestingFixtures()
-        throws Exception
-    {
-        release( httpd );
+        return getProtocol() + "://localhost:10007";
     }
 
-    protected long getExpectedLastModifiedOnGet( Repository repository, Resource resource )
+    protected void setHttpHeaders( StreamingWagon wagon, Properties properties )
     {
-        File file = getTestFile( "target/test-output/http-repository", resource.getName() );
-        return file.lastModified();
+        ( (HttpWagon) wagon ).setHttpHeaders( properties );
     }
 }

Modified: maven/wagon/trunk/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonTimeoutTest.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonTimeoutTest.java?rev=681203&r1=681202&r2=681203&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonTimeoutTest.java (original)
+++ maven/wagon/trunk/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonTimeoutTest.java Wed Jul 30 14:07:48 2008
@@ -18,33 +18,32 @@
  * specific language governing permissions and limitations
  * under the License.
  */
- 
+
 import java.io.File;
 
 import org.apache.maven.wagon.FileTestUtils;
 import org.apache.maven.wagon.TransferFailedException;
 import org.apache.maven.wagon.Wagon;
 import org.apache.maven.wagon.repository.Repository;
-import org.mortbay.jetty.servlet.ServletHandler;
+import org.mortbay.jetty.servlet.ServletHolder;
 
 /**
- * User: jdumay
- * Date: 24/01/2008
- * Time: 17:17:34
+ * User: jdumay Date: 24/01/2008 Time: 17:17:34
  */
-public class HttpWagonTimeoutTest extends HttpWagonHttpServerTestCase
+public class HttpWagonTimeoutTest
+    extends HttpWagonHttpServerTestCase
 {
     protected void setUp()
         throws Exception
     {
         super.setUp();
-        ServletHandler servlets = new ServletHandler();
-        servlets.addServlet( "/", "org.apache.maven.wagon.providers.http.WaitForeverServlet" );
-        context.addHandler( servlets );
+        ServletHolder servlets = new ServletHolder( new WaitForeverServlet() );
+        context.addServlet( servlets, "/*" );
         startServer();
     }
 
-    public void testGetTimeout() throws Exception
+    public void testGetTimeout()
+        throws Exception
     {
         Exception thrown = null;
 
@@ -55,7 +54,7 @@
 
             Repository testRepository = new Repository();
             testRepository.setUrl( "http://localhost:" + httpServerPort );
-            
+
             wagon.connect( testRepository );
 
             File destFile = FileTestUtils.createUniqueFile( getName(), getName() );
@@ -65,7 +64,7 @@
 
             wagon.disconnect();
         }
-        catch (Exception e)
+        catch ( Exception e )
         {
             thrown = e;
         }
@@ -77,8 +76,9 @@
         assertNotNull( thrown );
         assertEquals( TransferFailedException.class, thrown.getClass() );
     }
-    
-    public void testResourceExits() throws Exception
+
+    public void testResourceExits()
+        throws Exception
     {
         Exception thrown = null;
 
@@ -96,7 +96,7 @@
 
             wagon.disconnect();
         }
-        catch (Exception e)
+        catch ( Exception e )
         {
             thrown = e;
         }
@@ -109,7 +109,8 @@
         assertEquals( TransferFailedException.class, thrown.getClass() );
     }
 
-    public void testGetFileList() throws Exception
+    public void testGetFileList()
+        throws Exception
     {
         Exception thrown = null;
 
@@ -127,7 +128,7 @@
 
             wagon.disconnect();
         }
-        catch (Exception e)
+        catch ( Exception e )
         {
             thrown = e;
         }
@@ -140,7 +141,8 @@
         assertEquals( TransferFailedException.class, thrown.getClass() );
     }
 
-    public void testPutTimeout() throws Exception
+    public void testPutTimeout()
+        throws Exception
     {
         Exception thrown = null;
 
@@ -161,7 +163,7 @@
 
             wagon.disconnect();
         }
-        catch (Exception e)
+        catch ( Exception e )
         {
             thrown = e;
         }

Added: maven/wagon/trunk/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpsWagonTest.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpsWagonTest.java?rev=681203&view=auto
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpsWagonTest.java (added)
+++ maven/wagon/trunk/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpsWagonTest.java Wed Jul 30 14:07:48 2008
@@ -0,0 +1,48 @@
+package org.apache.maven.wagon.providers.http;
+
+/*
+ * 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 org.mortbay.jetty.Connector;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.security.SslSocketConnector;
+
+public class HttpsWagonTest
+    extends HttpWagonTest
+{
+    protected String getProtocol()
+    {
+        return "https";
+    }
+
+    protected void addConnectors( Server server )
+    {
+        System.setProperty( "javax.net.ssl.trustStore",
+                            getTestFile( "src/test/resources/ssl/keystore" ).getAbsolutePath() );
+
+        SslSocketConnector connector = new SslSocketConnector();
+        connector.setPort( server.getConnectors()[0].getPort() );
+        connector.setKeystore( getTestPath( "src/test/resources/ssl/keystore" ) );
+        connector.setPassword( "wagonhttp" );
+        connector.setKeyPassword( "wagonhttp" );
+        connector.setTruststore( getTestPath( "src/test/resources/ssl/keystore" ) );
+        connector.setTrustPassword( "wagonhttp" );
+        server.setConnectors( new Connector[] { connector } );
+    }
+}

Propchange: maven/wagon/trunk/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpsWagonTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/wagon/trunk/wagon-providers/wagon-http/src/test/resources/ssl/keystore
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-http/src/test/resources/ssl/keystore?rev=681203&view=auto
==============================================================================
Binary file - no diff available.

Propchange: maven/wagon/trunk/wagon-providers/wagon-http/src/test/resources/ssl/keystore
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: maven/wagon/trunk/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagonWithProxyTest.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagonWithProxyTest.java?rev=681203&r1=681202&r2=681203&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagonWithProxyTest.java (original)
+++ maven/wagon/trunk/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagonWithProxyTest.java Wed Jul 30 14:07:48 2008
@@ -19,9 +19,7 @@
  * under the License.
  */
 
-import java.io.BufferedReader;
 import java.io.IOException;
-import java.io.InputStreamReader;
 import java.net.ServerSocket;
 import java.net.Socket;
 import java.net.SocketTimeoutException;

Modified: maven/wagon/trunk/wagon-providers/wagon-webdav-jackrabbit/pom.xml
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-webdav-jackrabbit/pom.xml?rev=681203&r1=681202&r2=681203&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-webdav-jackrabbit/pom.xml (original)
+++ maven/wagon/trunk/wagon-providers/wagon-webdav-jackrabbit/pom.xml Wed Jul 30 14:07:48 2008
@@ -63,11 +63,27 @@
       <version>0.4</version>
       <scope>test</scope>
     </dependency>
-    <dependency>
-      <groupId>org.mortbay.jetty</groupId>
-      <artifactId>jetty</artifactId>
-      <version>4.2.12</version>
-      <scope>test</scope>
-    </dependency>
   </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.codehaus.plexus</groupId>
+        <artifactId>plexus-maven-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>merge-descriptors</id>
+            <configuration>
+              <descriptors>
+                <descriptor>${basedir}/src/main/resources/META-INF/plexus/components.xml</descriptor>
+                <descriptor>${project.build.directory}/generated-resources/plexus/META-INF/plexus/components.xml</descriptor>
+              </descriptors>
+            </configuration>
+            <goals>
+              <goal>merge-descriptors</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>  
 </project>
\ No newline at end of file

Modified: maven/wagon/trunk/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavWagonTest.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavWagonTest.java?rev=681203&r1=681202&r2=681203&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavWagonTest.java (original)
+++ maven/wagon/trunk/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavWagonTest.java Wed Jul 30 14:07:48 2008
@@ -19,66 +19,62 @@
  * under the License.
  */
 
+import it.could.webdav.DAVServlet;
+
 import java.io.File;
 import java.io.IOException;
+import java.util.Properties;
 
-import org.apache.maven.wagon.FileTestUtils;
-import org.apache.maven.wagon.StreamingWagonTestCase;
+import org.apache.maven.wagon.StreamingWagon;
+import org.apache.maven.wagon.http.HttpWagonTestCase;
 import org.apache.maven.wagon.repository.Repository;
 import org.apache.maven.wagon.resource.Resource;
+import org.codehaus.plexus.util.FileUtils;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.servlet.Context;
+import org.mortbay.jetty.servlet.ServletHolder;
 
 /**
  * WebDAV Wagon Test
- *
+ * 
  * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
  * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
  */
 public class WebDavWagonTest
-    extends StreamingWagonTestCase
+    extends HttpWagonTestCase
 {
-    private ServletServer server;
-
     protected String getTestRepositoryUrl()
         throws IOException
     {
-        return "dav:http://localhost:10007/dav/newfolder/folder2";
+        return getProtocol() + "://localhost:10007/newfolder/folder2";
     }
 
     protected String getProtocol()
     {
         return "dav";
     }
-    
-    protected void setupWagonTestingFixtures()
-        throws Exception
-    {
-        if ( System.getProperty( "basedir" ) == null )
-        {
-            System.setProperty( "basedir", System.getProperty( "user.dir" ) );
-        }
-
-        File file = FileTestUtils.createUniqueFile( "dav-repository", "test-resource" );
-
-        file.delete();
 
-        File davDir = file.getParentFile();
-        davDir.mkdirs();
-
-        server = (ServletServer) lookup( ServletServer.ROLE );
-    }
-
-    protected void tearDownWagonTestingFixtures()
-        throws Exception
+    protected void createContext( Server server, File repositoryDirectory )
+        throws IOException
     {
-        release( server );
+        Context dav = new Context( server, "/", Context.SESSIONS );
+        ServletHolder davServletHolder = new ServletHolder( new DAVServlet() );
+        davServletHolder.setInitParameter( "rootPath", repositoryDirectory.getAbsolutePath() );
+        davServletHolder.setInitParameter( "xmlOnly", "false" );
+        dav.addServlet( davServletHolder, "/*" );
     }
 
     protected long getExpectedLastModifiedOnGet( Repository repository, Resource resource )
     {
-        File file = getTestFile( "target/test-output/dav-repository/newfolder/folder2", resource.getName() );
+        File file = new File( getDavRepository(), resource.getName() );
         return file.lastModified();
     }
-    
+
+    private File getDavRepository()
+    {
+        return getTestFile( "target/test-output/http-repository/newfolder/folder2" );
+    }
+
     private void assertURL( String userUrl, String expectedUrl )
     {
         Repository repo = new Repository( "test-geturl", userUrl );
@@ -93,7 +89,7 @@
     {
         assertURL( "dav:http://localhost:10007/dav/", "http://localhost:10007/dav/" );
     }
-    
+
     /**
      * Tests the maven 2.0.x way to define a webdav URL with SSL.
      */
@@ -133,4 +129,9 @@
     {
         assertURL( "dav+https://localhost:10007/dav/", "https://localhost:10007/dav/" );
     }
+
+    protected void setHttpHeaders( StreamingWagon wagon, Properties properties )
+    {
+        ( (WebDavWagon) wagon ).setHttpHeaders( properties );
+    }
 }



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