maven-wagon-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joak...@apache.org
Subject svn commit: r631492 [1/2] - in /maven/wagon/branches/wagon-http-with-webdav: ./ src/main/java/org/apache/maven/wagon/providers/http/ src/main/java/org/apache/maven/wagon/providers/http/dav/ src/main/java/org/apache/maven/wagon/providers/http/links/ src...
Date Wed, 27 Feb 2008 05:56:33 GMT
Author: joakime
Date: Tue Feb 26 21:56:17 2008
New Revision: 631492

URL: http://svn.apache.org/viewvc?rev=631492&view=rev
Log:
Creating experimental branch of wagon-http that eliminates the need for wagon-webdav and slide-webdavclient and all of the dependencies contained within.
This branch implements the 2 needed HTTP methods MKCOL and PROPFIND for wagon deploy and file listing.
This branch also eliminates the need for wagon-http-shared


Added:
    maven/wagon/branches/wagon-http-with-webdav/
      - copied from r628937, maven/wagon/trunk/wagon-providers/wagon-http/
    maven/wagon/branches/wagon-http-with-webdav/src/main/java/org/apache/maven/wagon/providers/http/dav/
    maven/wagon/branches/wagon-http-with-webdav/src/main/java/org/apache/maven/wagon/providers/http/dav/AbstractPropertiesMethodBase.java   (with props)
    maven/wagon/branches/wagon-http-with-webdav/src/main/java/org/apache/maven/wagon/providers/http/dav/DavResource.java   (with props)
    maven/wagon/branches/wagon-http-with-webdav/src/main/java/org/apache/maven/wagon/providers/http/dav/MkColMethod.java   (with props)
    maven/wagon/branches/wagon-http-with-webdav/src/main/java/org/apache/maven/wagon/providers/http/dav/MultiStatus.java   (with props)
    maven/wagon/branches/wagon-http-with-webdav/src/main/java/org/apache/maven/wagon/providers/http/dav/PropFindMethod.java   (with props)
    maven/wagon/branches/wagon-http-with-webdav/src/main/java/org/apache/maven/wagon/providers/http/links/
    maven/wagon/branches/wagon-http-with-webdav/src/main/java/org/apache/maven/wagon/providers/http/links/LinkParser.java   (with props)
    maven/wagon/branches/wagon-http-with-webdav/src/test/java/org/apache/maven/wagon/providers/http/dav/
    maven/wagon/branches/wagon-http-with-webdav/src/test/java/org/apache/maven/wagon/providers/http/dav/AbstractDavTestCase.java   (with props)
    maven/wagon/branches/wagon-http-with-webdav/src/test/java/org/apache/maven/wagon/providers/http/dav/MkColMethodTest.java   (with props)
    maven/wagon/branches/wagon-http-with-webdav/src/test/java/org/apache/maven/wagon/providers/http/dav/MultiStatusTest.java   (with props)
    maven/wagon/branches/wagon-http-with-webdav/src/test/java/org/apache/maven/wagon/providers/http/dav/PropFindMethodTest.java   (with props)
    maven/wagon/branches/wagon-http-with-webdav/src/test/java/org/apache/maven/wagon/providers/http/links/
    maven/wagon/branches/wagon-http-with-webdav/src/test/java/org/apache/maven/wagon/providers/http/links/LinkParserTest.java   (with props)
    maven/wagon/branches/wagon-http-with-webdav/src/test/resources/MarkTwain.txt   (with props)
    maven/wagon/branches/wagon-http-with-webdav/src/test/resources/dav/
    maven/wagon/branches/wagon-http-with-webdav/src/test/resources/dav/multistatus-1.xml   (with props)
    maven/wagon/branches/wagon-http-with-webdav/src/test/resources/dav/multistatus-2.xml   (with props)
    maven/wagon/branches/wagon-http-with-webdav/src/test/resources/dav/multistatus-3.xml   (with props)
    maven/wagon/branches/wagon-http-with-webdav/src/test/resources/links/
    maven/wagon/branches/wagon-http-with-webdav/src/test/resources/links/archiva-1.0.1.html   (with props)
    maven/wagon/branches/wagon-http-with-webdav/src/test/resources/links/commons-lang.html   (with props)
    maven/wagon/branches/wagon-http-with-webdav/src/test/resources/links/mevenide.html   (with props)
    maven/wagon/branches/wagon-http-with-webdav/src/test/resources/links/nekohtml.html   (with props)
    maven/wagon/branches/wagon-http-with-webdav/src/test/resources/links/net_sf.html   (with props)
    maven/wagon/branches/wagon-http-with-webdav/src/test/resources/links/org.codehaus.html   (with props)
    maven/wagon/branches/wagon-http-with-webdav/src/test/resources/more/
    maven/wagon/branches/wagon-http-with-webdav/src/test/resources/more/quotes/
    maven/wagon/branches/wagon-http-with-webdav/src/test/resources/more/quotes/from/
    maven/wagon/branches/wagon-http-with-webdav/src/test/resources/more/quotes/from/BenFranklin.txt   (with props)
Modified:
    maven/wagon/branches/wagon-http-with-webdav/pom.xml
    maven/wagon/branches/wagon-http-with-webdav/src/main/java/org/apache/maven/wagon/providers/http/HttpWagon.java
    maven/wagon/branches/wagon-http-with-webdav/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonTest.java
    maven/wagon/branches/wagon-http-with-webdav/src/test/resources/org/apache/maven/wagon/providers/http/HttpWagonTest.xml

Modified: maven/wagon/branches/wagon-http-with-webdav/pom.xml
URL: http://svn.apache.org/viewvc/maven/wagon/branches/wagon-http-with-webdav/pom.xml?rev=631492&r1=628937&r2=631492&view=diff
==============================================================================
--- maven/wagon/branches/wagon-http-with-webdav/pom.xml (original)
+++ maven/wagon/branches/wagon-http-with-webdav/pom.xml Tue Feb 26 21:56:17 2008
@@ -41,9 +41,20 @@
 
   <dependencies>
     <dependency>
-      <groupId>${pom.groupId}</groupId>
-      <artifactId>wagon-http-shared</artifactId>
-      <version>1.0-rc1-SNAPSHOT</version>
+      <groupId>commons-logging</groupId>
+      <artifactId>commons-logging</artifactId>
+      <version>1.0.4</version>
+      <scope>runtime</scope>
+    </dependency>
+    <dependency>
+      <groupId>commons-httpclient</groupId>
+      <artifactId>commons-httpclient</artifactId>
+      <version>3.1</version>
+    </dependency>
+    <dependency>
+      <groupId>nekohtml</groupId>
+      <artifactId>nekohtml</artifactId>
+      <version>1.9.6.1</version>
     </dependency>
     <dependency>
       <groupId>plexus</groupId>
@@ -58,15 +69,10 @@
       </exclusions>
     </dependency>
     <dependency>
-      <groupId>commons-logging</groupId>
-      <artifactId>commons-logging</artifactId>
-      <version>1.0.4</version>
-      <scope>runtime</scope>
-    </dependency>
-    <dependency>
-      <groupId>commons-httpclient</groupId>
-      <artifactId>commons-httpclient</artifactId>
-      <version>3.1</version>
+      <groupId>it.could</groupId>
+      <artifactId>webdav</artifactId>
+      <version>0.4</version>
+      <scope>test</scope>
     </dependency>
   </dependencies>
   <build>

Modified: maven/wagon/branches/wagon-http-with-webdav/src/main/java/org/apache/maven/wagon/providers/http/HttpWagon.java
URL: http://svn.apache.org/viewvc/maven/wagon/branches/wagon-http-with-webdav/src/main/java/org/apache/maven/wagon/providers/http/HttpWagon.java?rev=631492&r1=628937&r2=631492&view=diff
==============================================================================
--- maven/wagon/branches/wagon-http-with-webdav/src/main/java/org/apache/maven/wagon/providers/http/HttpWagon.java (original)
+++ maven/wagon/branches/wagon-http-with-webdav/src/main/java/org/apache/maven/wagon/providers/http/HttpWagon.java Tue Feb 26 21:56:17 2008
@@ -19,19 +19,38 @@
  * under the License.
  */
 
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Set;
+import java.util.TimeZone;
+import java.util.zip.GZIPInputStream;
+
 import org.apache.commons.httpclient.Credentials;
 import org.apache.commons.httpclient.Header;
 import org.apache.commons.httpclient.HostConfiguration;
 import org.apache.commons.httpclient.HttpClient;
 import org.apache.commons.httpclient.HttpConnectionManager;
+import org.apache.commons.httpclient.HttpException;
 import org.apache.commons.httpclient.HttpMethod;
 import org.apache.commons.httpclient.HttpStatus;
-import org.apache.commons.httpclient.UsernamePasswordCredentials;
 import org.apache.commons.httpclient.NTCredentials;
+import org.apache.commons.httpclient.UsernamePasswordCredentials;
 import org.apache.commons.httpclient.methods.GetMethod;
 import org.apache.commons.httpclient.methods.HeadMethod;
+import org.apache.commons.httpclient.methods.OptionsMethod;
 import org.apache.commons.httpclient.methods.PutMethod;
-import org.apache.commons.httpclient.params.HttpConnectionParams;
 import org.apache.commons.httpclient.util.DateParseException;
 import org.apache.commons.httpclient.util.DateParser;
 import org.apache.maven.wagon.AbstractWagon;
@@ -39,21 +58,14 @@
 import org.apache.maven.wagon.TransferFailedException;
 import org.apache.maven.wagon.authorization.AuthorizationException;
 import org.apache.maven.wagon.events.TransferEvent;
+import org.apache.maven.wagon.providers.http.dav.DavResource;
+import org.apache.maven.wagon.providers.http.dav.MultiStatus;
+import org.apache.maven.wagon.providers.http.dav.PropFindMethod;
+import org.apache.maven.wagon.providers.http.links.LinkParser;
 import org.apache.maven.wagon.resource.Resource;
-import org.apache.maven.wagon.shared.http.HtmlFileListParser;
 import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.StringUtils;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.List;
-import java.util.Locale;
-import java.util.TimeZone;
-import java.util.zip.GZIPInputStream;
+import org.xml.sax.SAXException;
 
 /**
  * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
@@ -69,6 +81,10 @@
     private static final TimeZone GMT_TIME_ZONE = TimeZone.getTimeZone( "GMT" );
 
     private HttpConnectionManager connectionManager;
+    
+    private LinkParser linkParser = new LinkParser();
+
+    protected boolean isDav;
 
     public void openConnection()
     {
@@ -165,7 +181,7 @@
         }
 
         int statusCode = execute( putMethod );
-        
+
         fireTransferDebug( url + " - Status code: " + statusCode );
 
         // Check that we didn't run out of retries.
@@ -175,7 +191,7 @@
             case HttpStatus.SC_OK: // 200
             case HttpStatus.SC_CREATED: // 201
             case HttpStatus.SC_ACCEPTED: // 202
-            case HttpStatus.SC_NO_CONTENT:  // 204
+            case HttpStatus.SC_NO_CONTENT: // 204
                 break;
 
             case SC_NULL:
@@ -188,9 +204,9 @@
                 throw new ResourceDoesNotExistException( "File: " + url + " does not exist" );
 
                 //add more entries here
-            default :
-                throw new TransferFailedException(
-                    "Failed to transfer file: " + url + ". Return code is: " + statusCode );
+            default:
+                throw new TransferFailedException( "Failed to transfer file: " + url + ". Return code is: "
+                    + statusCode );
         }
 
         putMethod.releaseConnection();
@@ -285,9 +301,9 @@
                     throw new ResourceDoesNotExistException( "File: " + url + " does not exist" );
 
                     //add more entries here
-                default :
-                    throw new TransferFailedException(
-                        "Failed to transfer file: " + url + ". Return code is: " + statusCode );
+                default:
+                    throw new TransferFailedException( "Failed to transfer file: " + url + ". Return code is: "
+                        + statusCode );
             }
 
             InputStream is = null;
@@ -304,8 +320,8 @@
                 }
                 catch ( NumberFormatException e )
                 {
-                    fireTransferDebug(
-                        "error parsing content length header '" + contentLengthHeader.getValue() + "' " + e );
+                    fireTransferDebug( "error parsing content length header '" + contentLengthHeader.getValue() + "' "
+                        + e );
                 }
             }
 
@@ -331,14 +347,15 @@
             if ( timestamp == 0 || timestamp < lastModified )
             {
                 retValue = true;
-                
+
                 Header contentEncoding = getMethod.getResponseHeader( "Content-Encoding" );
-                boolean isGZipped = contentEncoding == null ? false : "gzip".equalsIgnoreCase(contentEncoding.getValue());
+                boolean isGZipped = contentEncoding == null ? false : "gzip".equalsIgnoreCase( contentEncoding
+                    .getValue() );
 
                 try
                 {
                     is = getMethod.getResponseBodyAsStream();
-                    if (isGZipped)
+                    if ( isGZipped )
                     {
                         is = new GZIPInputStream( is );
                     }
@@ -387,7 +404,7 @@
     }
 
     public List getFileList( String destinationDirectory )
-        throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException 
+        throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
     {
         if ( !destinationDirectory.endsWith( "/" ) )
         {
@@ -396,6 +413,71 @@
 
         String url = getRepository().getUrl() + "/" + destinationDirectory;
 
+        if ( isDav )
+        {
+            return getDavListing( url );
+        }
+        else
+        {
+            return getHttpListing( url );
+        }
+    }
+
+    private List getDavListing( String url )
+        throws TransferFailedException
+    {
+        URI absoluteURI = toURI( url );
+
+        PropFindMethod method = new PropFindMethod( absoluteURI );
+        try
+        {
+            int status = client.executeMethod( method );
+            if ( ( status == HttpStatus.SC_MULTI_STATUS ) || ( status == HttpStatus.SC_OK ) )
+            {
+                MultiStatus multistatus = method.getMultiStatus();
+                Set/*<String>*/listing = new HashSet/*<String>*/();
+
+                Iterator itresources = multistatus.getResources().iterator();
+                while ( itresources.hasNext() )
+                {
+                    DavResource resource = (DavResource) itresources.next();
+                    if ( resource.isCollection() )
+                    {
+                        continue;
+                    }
+                    String href = resource.getHref();
+
+                    int idx = href.lastIndexOf( '/' );
+                    if ( idx < 0 )
+                    {
+                        listing.add( href );
+                    }
+                    else
+                    {
+                        listing.add( href.substring( idx + 1 ) );
+                    }
+                }
+
+                return new ArrayList( listing );
+            }
+
+            return Collections.emptyList();
+        }
+        catch ( IOException e )
+        {
+            throw new TransferFailedException( "Could not read response body.", e );
+        }
+        finally
+        {
+            method.releaseConnection();
+        }
+
+    }
+
+    private List getHttpListing( String url ) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+    {
+        URI absoluteURI = toURI( url );
+        
         GetMethod getMethod = new GetMethod( url );
         getMethod.getParams().setSoTimeout( getTimeout() );
 
@@ -434,37 +516,56 @@
                     throw new ResourceDoesNotExistException( "File: " + url + " does not exist" );
 
                     //add more entries here
-                default :
-                    throw new TransferFailedException(
-                        "Failed to transfer file: " + url + ". Return code is: " + statusCode );
+                default:
+                    throw new TransferFailedException( "Failed to transfer file: " + url + ". Return code is: "
+                        + statusCode );
             }
 
             InputStream is = null;
-            
+
             is = getMethod.getResponseBodyAsStream();
 
-            return HtmlFileListParser.parseFileList( url, is );
+            Set/*<String>*/links = linkParser.collectLinks( absoluteURI, is );
+
+            return new ArrayList(links);
         }
         catch ( IOException e )
         {
             throw new TransferFailedException( "Could not read response body.", e );
         }
+        catch ( SAXException e )
+        {
+            throw new TransferFailedException( "Could not parse response body.", e );
+        }
         finally
         {
             getMethod.releaseConnection();
         }
     }
 
+    private URI toURI( String url )
+        throws TransferFailedException
+    {
+        try
+        {
+            return new URI( url );
+        }
+        catch ( URISyntaxException e )
+        {
+            throw new TransferFailedException( "Invalid uri: " + url );
+        }
+    }
+
     public boolean resourceExists( String resourceName )
         throws TransferFailedException, AuthorizationException
     {
         String url = getRepository().getUrl() + "/" + resourceName;
-        
+
         HeadMethod headMethod = new HeadMethod( url );
         headMethod.getParams().setSoTimeout( getTimeout() );
-        
+
         int statusCode = execute( headMethod );
-        
+
         try
         {
             switch ( statusCode )
@@ -476,7 +577,7 @@
                     return true;
 
                 case SC_NULL:
-                    throw new TransferFailedException( "Failed to transfer file: " + url);
+                    throw new TransferFailedException( "Failed to transfer file: " + url );
 
                 case HttpStatus.SC_FORBIDDEN:
                     throw new AuthorizationException( "Access denied to: " + url );
@@ -502,7 +603,7 @@
         }
     }
 
-    private int execute(HttpMethod httpMethod)
+    private int execute( HttpMethod httpMethod )
         throws TransferFailedException
     {
         int statusCode = SC_NULL;
@@ -518,7 +619,76 @@
         return statusCode;
     }
 
-    public void setConnectionManager(HttpConnectionManager connectionManager) {
+    public void setConnectionManager( HttpConnectionManager connectionManager )
+    {
         this.connectionManager = connectionManager;
     }
+
+    public boolean isWebDavCapableServer()
+    {
+        String baseurl = getRepository().getUrl() + "/";
+
+        OptionsMethod method = new OptionsMethod( baseurl );
+        try
+        {
+            int status = client.executeMethod( method );
+            if ( status == HttpStatus.SC_OK )
+            {
+                // Test DAV Header Options
+                boolean supportsDav1 = false;
+
+                Header davOptionHeader = method.getResponseHeader( "dav" );
+                if ( davOptionHeader != null )
+                {
+                    String davSupport[] = StringUtils.split( davOptionHeader.getValue(), "," );
+                    for ( int i = 0; i < davSupport.length; i++ )
+                    {
+                        String support = davSupport[i].trim();
+                        support = support.trim();
+                        if ( "1".equals( support ) )
+                        {
+                            supportsDav1 = true;
+                        }
+                    }
+                }
+
+                if ( !supportsDav1 )
+                {
+                    fireTransferDebug( "No DAV Support: " + baseurl );
+                    return false;
+                }
+
+                // Not validate.
+                String requiredMethods[] = new String[] { "HEAD", "GET", "MKCOL", "PROPFIND", "PUT", "OPTIONS" };
+
+                boolean supportsRequired = true;
+                for ( int i = 0; i < requiredMethods.length; i++ )
+                {
+                    String required = requiredMethods[i];
+                    if ( !method.isAllowed( required ) )
+                    {
+                        fireTransferDebug( "No " + required + " Support: " + baseurl );
+                        supportsRequired = false;
+                    }
+                }
+
+                return supportsRequired;
+            }
+        }
+        catch ( HttpException e )
+        {
+            fireTransferDebug( "Unable to get OPTIONS from " + baseurl + " : " + e.getMessage() );
+        }
+        catch ( IOException e )
+        {
+            fireTransferDebug( "Unable to get OPTIONS from " + baseurl + " : " + e.getMessage() );
+        }
+        finally
+        {
+            method.releaseConnection();
+        }
+
+        return false;
+    }
+
 }

Added: maven/wagon/branches/wagon-http-with-webdav/src/main/java/org/apache/maven/wagon/providers/http/dav/AbstractPropertiesMethodBase.java
URL: http://svn.apache.org/viewvc/maven/wagon/branches/wagon-http-with-webdav/src/main/java/org/apache/maven/wagon/providers/http/dav/AbstractPropertiesMethodBase.java?rev=631492&view=auto
==============================================================================
--- maven/wagon/branches/wagon-http-with-webdav/src/main/java/org/apache/maven/wagon/providers/http/dav/AbstractPropertiesMethodBase.java (added)
+++ maven/wagon/branches/wagon-http-with-webdav/src/main/java/org/apache/maven/wagon/providers/http/dav/AbstractPropertiesMethodBase.java Tue Feb 26 21:56:17 2008
@@ -0,0 +1,108 @@
+package org.apache.maven.wagon.providers.http.dav;
+
+/*
+ * 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.IOException;
+import java.io.InputStream;
+
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.commons.httpclient.HttpConnection;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.HttpMethodBase;
+import org.apache.commons.httpclient.HttpState;
+import org.codehaus.plexus.util.IOUtil;
+import org.xml.sax.SAXException;
+
+/**
+ * AbstractPropertiesMethodBase
+ *
+ * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public abstract class AbstractPropertiesMethodBase
+    extends HttpMethodBase
+{
+
+    public static final int DEPTH_0 = 0;
+
+    public static final int DEPTH_1 = 1;
+
+    public static final int DEPTH_INFINITY = Integer.MAX_VALUE;
+
+    private int depth = 0;
+
+    private MultiStatus multiStatus;
+
+    public AbstractPropertiesMethodBase()
+    {
+        super();
+    }
+
+    public AbstractPropertiesMethodBase( String uri )
+        throws IllegalArgumentException, IllegalStateException
+    {
+        super( uri );
+    }
+
+    public MultiStatus getMultiStatus()
+    {
+        return multiStatus;
+    }
+
+    public int getDepth()
+    {
+        return depth;
+    }
+
+    public void setDepth( int depth )
+    {
+        this.depth = depth;
+    }
+
+    protected void readResponseBody( HttpState state, HttpConnection conn )
+        throws IOException, HttpException
+    {
+        super.readResponseBody( state, conn );
+
+        InputStream input = getResponseBodyAsStream();
+        if ( input == null )
+        {
+            return;
+        }
+
+        try
+        {
+            this.multiStatus = MultiStatus.parse( input );
+        }
+        catch ( SAXException e )
+        {
+            throw new IOException( "Unable to parse multistatus: " + e.getMessage() );
+        }
+        catch ( ParserConfigurationException e )
+        {
+            throw new IOException( "Unable to parse multistatus: " + e.getMessage() );
+        }
+        finally
+        {
+            IOUtil.close( input );
+        }
+    }
+}

Propchange: maven/wagon/branches/wagon-http-with-webdav/src/main/java/org/apache/maven/wagon/providers/http/dav/AbstractPropertiesMethodBase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/wagon/branches/wagon-http-with-webdav/src/main/java/org/apache/maven/wagon/providers/http/dav/AbstractPropertiesMethodBase.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/wagon/branches/wagon-http-with-webdav/src/main/java/org/apache/maven/wagon/providers/http/dav/DavResource.java
URL: http://svn.apache.org/viewvc/maven/wagon/branches/wagon-http-with-webdav/src/main/java/org/apache/maven/wagon/providers/http/dav/DavResource.java?rev=631492&view=auto
==============================================================================
--- maven/wagon/branches/wagon-http-with-webdav/src/main/java/org/apache/maven/wagon/providers/http/dav/DavResource.java (added)
+++ maven/wagon/branches/wagon-http-with-webdav/src/main/java/org/apache/maven/wagon/providers/http/dav/DavResource.java Tue Feb 26 21:56:17 2008
@@ -0,0 +1,149 @@
+package org.apache.maven.wagon.providers.http.dav;
+
+/*
+ * 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.codehaus.plexus.util.StringUtils;
+
+/**
+ * DavResource
+ *
+ * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class DavResource
+{
+    private boolean collection = false;
+
+    private String contentType;
+
+    private String creationDate;
+
+    private String etag;
+
+    private String href;
+
+    private String lastModified;
+
+    private int status;
+
+    public DavResource()
+    {
+        /* default */
+    }
+
+    public DavResource( String href )
+    {
+        this.href = href;
+    }
+
+    public String getContentType()
+    {
+        return contentType;
+    }
+
+    public String getCreationDate()
+    {
+        return creationDate;
+    }
+
+    public String getEtag()
+    {
+        return etag;
+    }
+
+    public String getHref()
+    {
+        return href;
+    }
+
+    public String getLastModified()
+    {
+        return lastModified;
+    }
+
+    public int getStatus()
+    {
+        return status;
+    }
+
+    public boolean isCollection()
+    {
+        return collection;
+    }
+
+    public void parseStatus( String statusLine )
+    {
+        if ( StringUtils.isNotEmpty( statusLine ) )
+        {
+            String chunks[] = StringUtils.split( statusLine, " " );
+            if ( chunks.length >= 2 )
+            {
+                try
+                {
+                    status = Integer.parseInt( chunks[1], 10 );
+                }
+                catch ( NumberFormatException e )
+                {
+                    status = 0;
+                }
+            }
+        }
+    }
+
+    public void setAsCollection()
+    {
+        this.collection = true;
+    }
+
+    public void setCollection( boolean collection )
+    {
+        this.collection = collection;
+    }
+
+    public void setContentType( String contentType )
+    {
+        this.contentType = contentType;
+    }
+
+    public void setCreationDate( String creationDate )
+    {
+        this.creationDate = creationDate;
+    }
+
+    public void setEtag( String etag )
+    {
+        this.etag = etag;
+    }
+
+    public void setHref( String href )
+    {
+        this.href = href;
+    }
+
+    public void setLastModified( String lastModified )
+    {
+        this.lastModified = lastModified;
+    }
+
+    public void setStatus( int status )
+    {
+        this.status = status;
+    }
+}

Propchange: maven/wagon/branches/wagon-http-with-webdav/src/main/java/org/apache/maven/wagon/providers/http/dav/DavResource.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/wagon/branches/wagon-http-with-webdav/src/main/java/org/apache/maven/wagon/providers/http/dav/DavResource.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/wagon/branches/wagon-http-with-webdav/src/main/java/org/apache/maven/wagon/providers/http/dav/MkColMethod.java
URL: http://svn.apache.org/viewvc/maven/wagon/branches/wagon-http-with-webdav/src/main/java/org/apache/maven/wagon/providers/http/dav/MkColMethod.java?rev=631492&view=auto
==============================================================================
--- maven/wagon/branches/wagon-http-with-webdav/src/main/java/org/apache/maven/wagon/providers/http/dav/MkColMethod.java (added)
+++ maven/wagon/branches/wagon-http-with-webdav/src/main/java/org/apache/maven/wagon/providers/http/dav/MkColMethod.java Tue Feb 26 21:56:17 2008
@@ -0,0 +1,52 @@
+package org.apache.maven.wagon.providers.http.dav;
+
+/*
+ * 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.net.URI;
+
+import org.apache.commons.httpclient.HttpMethodBase;
+
+/**
+ * MkColMethod
+ *
+ * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class MkColMethod
+    extends HttpMethodBase
+{
+
+    public MkColMethod( String uri )
+        throws IllegalArgumentException, IllegalStateException
+    {
+        super( uri );
+    }
+
+    public MkColMethod( URI uri )
+        throws IllegalArgumentException, IllegalStateException
+    {
+        super( uri.toASCIIString() );
+    }
+
+    public String getName()
+    {
+        return "MKCOL";
+    }
+}

Propchange: maven/wagon/branches/wagon-http-with-webdav/src/main/java/org/apache/maven/wagon/providers/http/dav/MkColMethod.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/wagon/branches/wagon-http-with-webdav/src/main/java/org/apache/maven/wagon/providers/http/dav/MkColMethod.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/wagon/branches/wagon-http-with-webdav/src/main/java/org/apache/maven/wagon/providers/http/dav/MultiStatus.java
URL: http://svn.apache.org/viewvc/maven/wagon/branches/wagon-http-with-webdav/src/main/java/org/apache/maven/wagon/providers/http/dav/MultiStatus.java?rev=631492&view=auto
==============================================================================
--- maven/wagon/branches/wagon-http-with-webdav/src/main/java/org/apache/maven/wagon/providers/http/dav/MultiStatus.java (added)
+++ maven/wagon/branches/wagon-http-with-webdav/src/main/java/org/apache/maven/wagon/providers/http/dav/MultiStatus.java Tue Feb 26 21:56:17 2008
@@ -0,0 +1,265 @@
+package org.apache.maven.wagon.providers.http.dav;
+
+/*
+ * 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.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+/**
+ * MultiStatus
+ *
+ * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class MultiStatus
+{
+    private static DocumentBuilderFactory documentFactory;
+
+    private static Element getChildElement( Element elem, String childNodeName )
+    {
+        NodeList nodelist = elem.getChildNodes();
+        int len = nodelist.getLength();
+        for ( int i = 0; i < len; i++ )
+        {
+            Node node = nodelist.item( i );
+            if ( ( node.getNodeType() == Node.ELEMENT_NODE ) && ( childNodeName.equals( node.getNodeName() ) ) )
+            {
+                return (Element) node;
+            }
+        }
+
+        return null;
+    }
+
+    private static List/*<Element>*/getChildElements( Element elem, String childNodeName )
+    {
+        List/*<Element>*/elems = new ArrayList/*<Element>*/();
+
+        NodeList nodelist = elem.getChildNodes();
+        int len = nodelist.getLength();
+        for ( int i = 0; i < len; i++ )
+        {
+            Node node = nodelist.item( i );
+            if ( ( node.getNodeType() == Node.ELEMENT_NODE ) && ( childNodeName.equals( node.getNodeName() ) ) )
+            {
+                elems.add( node );
+            }
+        }
+
+        return elems;
+    }
+
+    private static String getChildText( Element elem, String childNodeName )
+    {
+        return getElementText( getChildElement( elem, childNodeName ) );
+    }
+
+    private static String getElementText( Element elem )
+    {
+        if ( elem == null )
+        {
+            return null;
+        }
+
+        StringBuffer text = new StringBuffer();
+        NodeList nodelist = elem.getChildNodes();
+        int len = nodelist.getLength();
+        for ( int i = 0; i < len; i++ )
+        {
+            Node node = nodelist.item( i );
+            if ( node.getNodeType() == Node.TEXT_NODE )
+            {
+                text.append( node.getNodeValue() );
+            }
+        }
+
+        if ( text.length() <= 0 )
+        {
+            return null;
+        }
+
+        return text.toString();
+    }
+
+    public static MultiStatus parse( InputStream stream )
+        throws IOException, SAXException, ParserConfigurationException
+    {
+        if ( documentFactory == null )
+        {
+            documentFactory = DocumentBuilderFactory.newInstance();
+            documentFactory.setNamespaceAware( true );
+            documentFactory.setValidating( false );
+        }
+        DocumentBuilder db = documentFactory.newDocumentBuilder();
+        Document doc = db.parse( stream );
+
+        MultiStatus multistatus = new MultiStatus();
+
+        Element root = doc.getDocumentElement();
+        String namespaceURI = root.getNamespaceURI();
+
+        String rootNodeName = root.getNodeName();
+
+        if ( !"DAV:".equals( namespaceURI ) )
+        {
+            /* Typically means that the response code was valid, but the response contents 
+             * are not in the form of DAV response.
+             * This can happen if you request props via PROPFIND on a non-existant URL and the
+             * server responds with a custom 404 handler (for example)
+             */
+            // TODO: getLogger().info( "Encountered invalid namespace <" + namespaceURI + ">, expected <DAV:>" );
+            return null;
+        }
+
+        String prefix = root.getPrefix();
+
+        if ( prefix != null )
+        {
+            rootNodeName = rootNodeName.substring( prefix.length() + 1 );
+        }
+
+        if ( !"multistatus".equals( rootNodeName ) )
+        {
+            /* Typically means that the response code was valid, but the response contents 
+             * are not in the form of DAV response.
+             * This can happen if you request props via PROPFIND on a non-existant URL and the
+             * server responds with a custom 404 handler (for example)
+             */
+            // TODO: getLogger().info( "Encountered unexpected <" + rootNodeName + ">, expected <" + "multistatus" + ">" );
+            return null;
+        }
+
+        List/*<Element>*/responses = getChildElements( root, prefix + ":response" );
+
+        Element propstat;
+        Element prop;
+        Element resourceType;
+        Element status;
+        for ( Iterator itresponses = responses.iterator(); itresponses.hasNext(); )
+        {
+            Element response = (Element) itresponses.next();
+            DavResource resource = new DavResource();
+
+            resource.setHref( getChildText( response, prefix + ":href" ) );
+
+            propstat = getChildElement( response, prefix + ":propstat" );
+            if ( propstat != null )
+            {
+                prop = getChildElement( propstat, prefix + ":prop" );
+                if ( prop != null )
+                {
+                    resource.setContentType( getChildText( prop, prefix + ":getcontentType" ) );
+                    resource.setEtag( getChildText( prop, prefix + ":getetag" ) );
+                    resource.setCreationDate( getChildText( prop, prefix + ":creationdate" ) );
+                    resource.setLastModified( getChildText( prop, prefix + ":getlastmodified" ) );
+
+                    resourceType = getChildElement( prop, prefix + ":resourcetype" );
+                    if ( resourceType != null )
+                    {
+                        if ( getChildElement( resourceType, prefix + ":collection" ) != null )
+                        {
+                            resource.setAsCollection();
+                        }
+                    }
+                }
+
+                status = getChildElement( propstat, prefix + ":status" );
+                if ( status != null )
+                {
+                    resource.parseStatus( getElementText( status ) );
+                }
+            }
+
+            multistatus.addResource( resource );
+        }
+
+        return multistatus;
+    }
+
+    private Map/*<String, DavResource>*/resources = new HashMap/*<String, DavResource>*/();
+
+    public MultiStatus()
+    {
+        /* ignore */
+    }
+
+    public void addResource( DavResource resource )
+    {
+        this.resources.put( resource.getHref(), resource );
+    }
+
+    public List/*<DavResource>*/getCollectionResources()
+    {
+        List/*<DavResource>*/dirs = new ArrayList/*<DavResource>*/();
+
+        for ( Iterator it = resources.values().iterator(); it.hasNext(); )
+        {
+            DavResource resource = (DavResource) it.next();
+            if ( resource.isCollection() )
+            {
+                dirs.add( resource );
+            }
+        }
+
+        return dirs;
+    }
+
+    public List/*<DavResource>*/getFileResources()
+    {
+        List/*<DavResource>*/files = new ArrayList/*<DavResource>*/();
+
+        for ( Iterator it = resources.values().iterator(); it.hasNext(); )
+        {
+            DavResource resource = (DavResource) it.next();
+            if ( !resource.isCollection() )
+            {
+                files.add( resource );
+            }
+        }
+
+        return files;
+    }
+
+    public DavResource getResource( String href )
+    {
+        return (DavResource) resources.get( href );
+    }
+
+    public Collection/*<DavResource>*/getResources()
+    {
+        return resources.values();
+    }
+}

Propchange: maven/wagon/branches/wagon-http-with-webdav/src/main/java/org/apache/maven/wagon/providers/http/dav/MultiStatus.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/wagon/branches/wagon-http-with-webdav/src/main/java/org/apache/maven/wagon/providers/http/dav/MultiStatus.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/wagon/branches/wagon-http-with-webdav/src/main/java/org/apache/maven/wagon/providers/http/dav/PropFindMethod.java
URL: http://svn.apache.org/viewvc/maven/wagon/branches/wagon-http-with-webdav/src/main/java/org/apache/maven/wagon/providers/http/dav/PropFindMethod.java?rev=631492&view=auto
==============================================================================
--- maven/wagon/branches/wagon-http-with-webdav/src/main/java/org/apache/maven/wagon/providers/http/dav/PropFindMethod.java (added)
+++ maven/wagon/branches/wagon-http-with-webdav/src/main/java/org/apache/maven/wagon/providers/http/dav/PropFindMethod.java Tue Feb 26 21:56:17 2008
@@ -0,0 +1,50 @@
+package org.apache.maven.wagon.providers.http.dav;
+
+/*
+ * 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.net.URI;
+
+/**
+ * PropFindMethod
+ *
+ * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class PropFindMethod
+    extends AbstractPropertiesMethodBase
+{
+
+    public PropFindMethod( String uri )
+        throws IllegalArgumentException, IllegalStateException
+    {
+        super( uri );
+    }
+
+    public PropFindMethod( URI uri )
+        throws IllegalArgumentException, IllegalStateException
+    {
+        super( uri.toASCIIString() );
+    }
+
+    public String getName()
+    {
+        return "PROPFIND";
+    }
+}

Propchange: maven/wagon/branches/wagon-http-with-webdav/src/main/java/org/apache/maven/wagon/providers/http/dav/PropFindMethod.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/wagon/branches/wagon-http-with-webdav/src/main/java/org/apache/maven/wagon/providers/http/dav/PropFindMethod.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/wagon/branches/wagon-http-with-webdav/src/main/java/org/apache/maven/wagon/providers/http/links/LinkParser.java
URL: http://svn.apache.org/viewvc/maven/wagon/branches/wagon-http-with-webdav/src/main/java/org/apache/maven/wagon/providers/http/links/LinkParser.java?rev=631492&view=auto
==============================================================================
--- maven/wagon/branches/wagon-http-with-webdav/src/main/java/org/apache/maven/wagon/providers/http/links/LinkParser.java (added)
+++ maven/wagon/branches/wagon-http-with-webdav/src/main/java/org/apache/maven/wagon/providers/http/links/LinkParser.java Tue Feb 26 21:56:17 2008
@@ -0,0 +1,120 @@
+package org.apache.maven.wagon.providers.http.links;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.regex.Pattern;
+
+import org.codehaus.plexus.util.StringUtils;
+import org.cyberneko.html.parsers.DOMParser;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+public class LinkParser {
+    private Set/*<Pattern>*/ skips = new HashSet/*<Pattern>*/();
+
+    public LinkParser() {
+        // Apache Fancy Index Sort Headers
+        skips.add(Pattern.compile("\\?C.*=.*"));
+
+        // URLs with excessive paths.
+        skips.add(Pattern.compile("/[^/]*/"));
+
+        // URLs that to a parent directory.
+        skips.add(Pattern.compile("\\.\\./"));
+    }
+
+    public Set/*<String>*/ collectLinks(URI baseURI, InputStream stream) throws SAXException,
+            IOException {
+        DOMParser parser = new DOMParser();
+        parser.setFeature("http://cyberneko.org/html/features/augmentations", true);
+        parser.setProperty("http://cyberneko.org/html/properties/names/elems", "upper");
+        parser.setProperty("http://cyberneko.org/html/properties/names/attrs", "upper");
+        parser.parse(new InputSource(stream));
+
+        Set/*<String>*/ links = new HashSet/*<String>*/();
+
+        recursiveLinkCollector(parser.getDocument(), baseURI, links);
+
+        return links;
+    }
+
+    private void recursiveLinkCollector(Node node, URI baseURI, Set/*<String>*/ links) {
+        if (node.getNodeType() == Node.ELEMENT_NODE) {
+//            System.out.println("Element <" + node.getNodeName() + dumpAttributes((Element) node) + ">");
+            if ("A".equals(node.getNodeName())) {
+                Element anchor = (Element) node;
+                NamedNodeMap nodemap = anchor.getAttributes();
+                Node href = nodemap.getNamedItem("HREF");
+                if (href != null) {
+                    String link = cleanLink(baseURI, href.getNodeValue());
+//                    System.out.println("HREF (" + href.getNodeValue() + " => " + link + ")");
+                    if (isAcceptableLink(link)) {
+                        links.add(link);
+                    }
+                }
+            }
+        }
+
+        Node child = node.getFirstChild();
+        while (child != null) {
+            recursiveLinkCollector(child, baseURI, links);
+            child = child.getNextSibling();
+        }
+    }
+
+//    private String dumpAttributes(Element elem) {
+//        StringBuffer buf = new StringBuffer();
+//        NamedNodeMap nodemap = elem.getAttributes();
+//        int len = nodemap.getLength();
+//        for (int i = 0; i < len; i++) {
+//            Node att = nodemap.item(i);
+//            buf.append(" ");
+//            buf.append(att.getNodeName()).append("=\"");
+//            buf.append(att.getNodeValue()).append("\"");
+//        }
+//        return buf.toString();
+//    }
+
+    public String cleanLink(URI baseURI, String link) {
+        if (StringUtils.isEmpty(link)) {
+            return "";
+        }
+
+        String ret = link;
+
+        try {
+            URI linkuri = new URI(ret);
+            URI relativeURI = baseURI.relativize(linkuri).normalize();
+            ret = relativeURI.toASCIIString();
+            if (ret.startsWith(baseURI.getPath())) {
+                ret = ret.substring(baseURI.getPath().length());
+            }
+        } catch (URISyntaxException e) {
+        }
+
+        return ret;
+    }
+
+    private boolean isAcceptableLink(String link) {
+        if (StringUtils.isEmpty(link)) {
+            return false;
+        }
+
+        for (Iterator it = skips.iterator(); it.hasNext(); ) {
+            Pattern skipPat = (Pattern) it.next();
+            if (skipPat.matcher(link).find()) {
+                return false;
+            }
+        }
+
+        return true;
+    }
+}

Propchange: maven/wagon/branches/wagon-http-with-webdav/src/main/java/org/apache/maven/wagon/providers/http/links/LinkParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/wagon/branches/wagon-http-with-webdav/src/main/java/org/apache/maven/wagon/providers/http/links/LinkParser.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: maven/wagon/branches/wagon-http-with-webdav/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonTest.java
URL: http://svn.apache.org/viewvc/maven/wagon/branches/wagon-http-with-webdav/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonTest.java?rev=631492&r1=628937&r2=631492&view=diff
==============================================================================
--- maven/wagon/branches/wagon-http-with-webdav/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonTest.java (original)
+++ maven/wagon/branches/wagon-http-with-webdav/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonTest.java Tue Feb 26 21:56:17 2008
@@ -21,7 +21,6 @@
 
 import org.apache.maven.wagon.FileTestUtils;
 import org.apache.maven.wagon.WagonTestCase;
-import org.codehaus.plexus.jetty.Httpd;
 
 import java.io.File;
 
@@ -32,8 +31,6 @@
 public class HttpWagonTest
     extends WagonTestCase
 {
-    private Httpd httpd;
-
     protected String getProtocol()
     {
         return "http";
@@ -72,8 +69,6 @@
         f.getParentFile().mkdirs();
 
         FileTestUtils.generateFile( f.getAbsolutePath(), "artifact-dummy" );
-
-        httpd = (Httpd) lookup( Httpd.ROLE );
     }
 
     public void testWagonGetFileList()
@@ -88,6 +83,6 @@
     protected void tearDownWagonTestingFixtures()
         throws Exception
     {
-        release( httpd );
+
     }
 }

Added: maven/wagon/branches/wagon-http-with-webdav/src/test/java/org/apache/maven/wagon/providers/http/dav/AbstractDavTestCase.java
URL: http://svn.apache.org/viewvc/maven/wagon/branches/wagon-http-with-webdav/src/test/java/org/apache/maven/wagon/providers/http/dav/AbstractDavTestCase.java?rev=631492&view=auto
==============================================================================
--- maven/wagon/branches/wagon-http-with-webdav/src/test/java/org/apache/maven/wagon/providers/http/dav/AbstractDavTestCase.java (added)
+++ maven/wagon/branches/wagon-http-with-webdav/src/test/java/org/apache/maven/wagon/providers/http/dav/AbstractDavTestCase.java Tue Feb 26 21:56:17 2008
@@ -0,0 +1,53 @@
+package org.apache.maven.wagon.providers.http.dav;
+
+/*
+ * 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 it.could.webdav.DAVServlet;
+
+import java.io.File;
+import java.net.URI;
+
+import org.apache.maven.wagon.providers.http.HttpWagonHttpServerTestCase;
+import org.mortbay.jetty.servlet.ServletHandler;
+import org.mortbay.jetty.servlet.ServletHolder;
+
+/**
+ * AbstractDavTestCase
+ *
+ * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class AbstractDavTestCase
+    extends HttpWagonHttpServerTestCase
+{
+    protected URI startDavServer( File serverRoot )
+        throws Exception
+    {
+        super.setUp();
+        ServletHandler servlets = new ServletHandler();
+        ServletHolder servletHolder = servlets.addServlet( "/dav/*", DAVServlet.class.getName() );
+        servletHolder.setInitParameter( "rootPath", serverRoot.getAbsolutePath() );
+        context.addHandler( servlets );
+        startServer();
+
+        return new URI( "http://localhost:" + httpServerPort + "/dav/" );
+    }
+
+}

Propchange: maven/wagon/branches/wagon-http-with-webdav/src/test/java/org/apache/maven/wagon/providers/http/dav/AbstractDavTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/wagon/branches/wagon-http-with-webdav/src/test/java/org/apache/maven/wagon/providers/http/dav/AbstractDavTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/wagon/branches/wagon-http-with-webdav/src/test/java/org/apache/maven/wagon/providers/http/dav/MkColMethodTest.java
URL: http://svn.apache.org/viewvc/maven/wagon/branches/wagon-http-with-webdav/src/test/java/org/apache/maven/wagon/providers/http/dav/MkColMethodTest.java?rev=631492&view=auto
==============================================================================
--- maven/wagon/branches/wagon-http-with-webdav/src/test/java/org/apache/maven/wagon/providers/http/dav/MkColMethodTest.java (added)
+++ maven/wagon/branches/wagon-http-with-webdav/src/test/java/org/apache/maven/wagon/providers/http/dav/MkColMethodTest.java Tue Feb 26 21:56:17 2008
@@ -0,0 +1,169 @@
+package org.apache.maven.wagon.providers.http.dav;
+
+/*
+ * 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.net.URI;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpStatus;
+import org.codehaus.plexus.util.FileUtils;
+
+/**
+ * MkColMethodTest
+ *
+ * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class MkColMethodTest
+    extends AbstractDavTestCase
+{
+    public void testMkColSimple()
+        throws Exception
+    {
+        // Setup
+        File serverRoot = new File( "target/dav-tests/mkcol-simple" );
+        FileUtils.deleteDirectory( serverRoot );
+        serverRoot.mkdirs();
+        URI davServerURI = startDavServer( serverRoot );
+
+        try
+        {
+            // Execute Test
+            URI testURI = davServerURI.resolve( "quotes" );
+            MkColMethod method = new MkColMethod( testURI );
+            HttpClient client = new HttpClient();
+            int status = client.executeMethod( method );
+
+            // Verify Results
+            assertEquals( "Status", HttpStatus.SC_CREATED, status );
+            assertTrue( "Created Directory", new File( serverRoot, "quotes" ).exists() );
+        }
+        finally
+        {
+            stopServer();
+        }
+    }
+
+    public void testMkColMultipleDeep()
+        throws Exception
+    {
+        // Setup
+        File serverRoot = new File( "target/dav-tests/mkcol-multideep" );
+        FileUtils.deleteDirectory( serverRoot );
+        serverRoot.mkdirs();
+        URI davServerURI = startDavServer( serverRoot );
+
+        try
+        {
+            // Execute Test
+            String paths[] = new String[] {
+                "quotes",
+                "quotes/twain",
+                "quotes/twain/mark",
+                "quotes/franklin",
+                "quotes/franklin/benjamin" };
+
+            HttpClient client = new HttpClient();
+            for ( int i = 0; i < paths.length; i++ )
+            {
+                URI testURI = davServerURI.resolve( paths[i] );
+                MkColMethod method = new MkColMethod( testURI );
+                int status = client.executeMethod( method );
+                // Verify Results
+                assertEquals( "Status (" + paths[i] + ")", HttpStatus.SC_CREATED, status );
+                assertTrue( "Created Directory (" + paths[i] + ")", new File( serverRoot, paths[i] ).exists() );
+            }
+        }
+        finally
+        {
+            stopServer();
+        }
+    }
+
+    public void testMkColTwice()
+        throws Exception
+    {
+        // Setup
+        File serverRoot = new File( "target/dav-tests/mkcol-twice" );
+        FileUtils.deleteDirectory( serverRoot );
+        serverRoot.mkdirs();
+        URI davServerURI = startDavServer( serverRoot );
+
+        try
+        {
+            // Execute Test
+            URI testURI = davServerURI.resolve( "quotes" );
+            HttpClient client = new HttpClient();
+
+            MkColMethod method;
+            int status;
+
+            // Create first one normally
+            method = new MkColMethod( testURI );
+            status = client.executeMethod( method );
+
+            // Verify Results
+            assertEquals( "Status: first create", HttpStatus.SC_CREATED, status );
+            assertTrue( "Created Directory: first create", new File( serverRoot, "quotes" ).exists() );
+
+            // Create second time (with error)
+            method = new MkColMethod( testURI );
+            status = client.executeMethod( method );
+
+            // Verify Results (should have been a 405/Method Not Allowed result.
+            assertEquals( "Status: second create", HttpStatus.SC_METHOD_NOT_ALLOWED, status );
+            assertTrue( "Created Directory: second create", new File( serverRoot, "quotes" ).exists() );
+        }
+        finally
+        {
+            stopServer();
+        }
+    }
+
+    public void testMkColDeepNoParent()
+        throws Exception
+    {
+        // Setup
+        File serverRoot = new File( "target/dav-tests/mkcol-deep-noparent" );
+        FileUtils.deleteDirectory( serverRoot );
+        serverRoot.mkdirs();
+        URI davServerURI = startDavServer( serverRoot );
+
+        try
+        {
+            // Execute Test
+            URI testURI = davServerURI.resolve( "quotes/franklin/benjamin" );
+            HttpClient client = new HttpClient();
+
+            // Create deep collection (should fail as 'quotes/franklin' do not exist)
+            MkColMethod method = new MkColMethod( testURI );
+            int status = client.executeMethod( method );
+
+            // Verify Results (should have been a conflict)
+            assertEquals( "Status:", HttpStatus.SC_CONFLICT, status );
+            assertFalse( "Directory should not have been created.", new File( serverRoot, "quotes" ).exists() );
+        }
+        finally
+        {
+            stopServer();
+        }
+    }
+}

Propchange: maven/wagon/branches/wagon-http-with-webdav/src/test/java/org/apache/maven/wagon/providers/http/dav/MkColMethodTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/wagon/branches/wagon-http-with-webdav/src/test/java/org/apache/maven/wagon/providers/http/dav/MkColMethodTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/wagon/branches/wagon-http-with-webdav/src/test/java/org/apache/maven/wagon/providers/http/dav/MultiStatusTest.java
URL: http://svn.apache.org/viewvc/maven/wagon/branches/wagon-http-with-webdav/src/test/java/org/apache/maven/wagon/providers/http/dav/MultiStatusTest.java?rev=631492&view=auto
==============================================================================
--- maven/wagon/branches/wagon-http-with-webdav/src/test/java/org/apache/maven/wagon/providers/http/dav/MultiStatusTest.java (added)
+++ maven/wagon/branches/wagon-http-with-webdav/src/test/java/org/apache/maven/wagon/providers/http/dav/MultiStatusTest.java Tue Feb 26 21:56:17 2008
@@ -0,0 +1,73 @@
+package org.apache.maven.wagon.providers.http.dav;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+/**
+ * MultiStatusTest
+ *
+ * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class MultiStatusTest
+    extends TestCase
+{
+    public void testParseMulti3()
+        throws Exception
+    {
+        File multifile = new File( "src/test/resources/dav/multistatus-3.xml" );
+        FileInputStream stream = new FileInputStream( multifile );
+        MultiStatus multistatus = MultiStatus.parse( stream );
+        assertNotNull( "Should not be null.", multistatus );
+        assertEquals( "Resources.size", 7, multistatus.getResources().size() );
+
+        DavResource resource;
+        String resourceRoot = "/archiva/repository/commons-httpclient/commons-httpclient/commons-httpclient/commons-httpclient/";
+
+        resource = multistatus.getResource( resourceRoot );
+        assertNotNull( "Resource root should not be null.", resource );
+        assertTrue( "Resource root should be a collection.", resource.isCollection() );
+
+        resource = multistatus.getResource( resourceRoot + "2.0.2/" );
+        assertNotNull( "Resource '2.0.2/' should not be null.", resource );
+        assertTrue( "Resource '2.0.2/' should be a collection.", resource.isCollection() );
+
+        resource = multistatus.getResource( resourceRoot + "commons-httpclient-2.0.2.pom" );
+        assertNotNull( "Resource 'commons-httpclient-2.0.2.pom' should not be null.", resource );
+        assertFalse( "Resource 'commons-httpclient-2.0.2.pom' should not be a collection.", resource.isCollection() );
+        assertEquals( "Resource 'commons-httpclient-2.0.2.pom' status", 200, resource.getStatus() );
+
+        resource = multistatus.getResource( resourceRoot + "invalid.txt" );
+        assertNull( "Resource 'invalid.txt' should be null.", resource );
+
+        List/*<DavResource>*/files = multistatus.getFileResources();
+        assertNotNull( "Files should not be null", files );
+        assertEquals( "Files.size", 4, files.size() );
+
+        List/*<DavResource>*/dirs = multistatus.getCollectionResources();
+        assertNotNull( "Dirs should not be null", dirs );
+        assertEquals( "Dirs.size", 3, dirs.size() );
+    }
+}

Propchange: maven/wagon/branches/wagon-http-with-webdav/src/test/java/org/apache/maven/wagon/providers/http/dav/MultiStatusTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/wagon/branches/wagon-http-with-webdav/src/test/java/org/apache/maven/wagon/providers/http/dav/MultiStatusTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/wagon/branches/wagon-http-with-webdav/src/test/java/org/apache/maven/wagon/providers/http/dav/PropFindMethodTest.java
URL: http://svn.apache.org/viewvc/maven/wagon/branches/wagon-http-with-webdav/src/test/java/org/apache/maven/wagon/providers/http/dav/PropFindMethodTest.java?rev=631492&view=auto
==============================================================================
--- maven/wagon/branches/wagon-http-with-webdav/src/test/java/org/apache/maven/wagon/providers/http/dav/PropFindMethodTest.java (added)
+++ maven/wagon/branches/wagon-http-with-webdav/src/test/java/org/apache/maven/wagon/providers/http/dav/PropFindMethodTest.java Tue Feb 26 21:56:17 2008
@@ -0,0 +1,142 @@
+package org.apache.maven.wagon.providers.http.dav;
+
+/*
+ * 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.net.URI;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpStatus;
+
+/**
+ * PropFindMethodTest
+ *
+ * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class PropFindMethodTest
+    extends AbstractDavTestCase
+{
+    public void testPropFindOnDir()
+        throws Exception
+    {
+        // Setup
+        File serverRoot = new File( "src/test/resources" );
+        URI davServerURI = startDavServer( serverRoot );
+
+        try
+        {
+            // Execute Test
+            URI testURI = davServerURI.resolve( "links" );
+            PropFindMethod method = new PropFindMethod( testURI );
+            HttpClient client = new HttpClient();
+            int status = client.executeMethod( method );
+
+            // Verify Results
+            assertEquals( "Status", HttpStatus.SC_MULTI_STATUS, status );
+            MultiStatus multistatus = method.getMultiStatus();
+            assertNotNull( "MultiStatus", multistatus );
+
+            File expected[] = new File( serverRoot, "links" ).listFiles();
+            // expectation is the files/directories + directory itself.
+            int expectedResourceCount = expected.length + 1;
+
+            assertEquals( "MultiStatus.resources.size", expectedResourceCount, multistatus.getResources().size() );
+            for ( int i = 0; i < expected.length; i++ )
+            {
+                File expectation = expected[i];
+                String href = "/dav/links/" + expectation.getName();
+                if ( expectation.isDirectory() )
+                {
+                    href += "/";
+                }
+                DavResource resource = multistatus.getResource( href );
+                assertNotNull( "MultiStatus.resource[" + href + "] should not be null", resource );
+                assertEquals( "Resource[" + href + "].href", href, resource.getHref() );
+                assertEquals( "Resource[" + href + "].collection", expectation.isDirectory(), resource.isCollection() );
+                assertEquals( "Resource[" + href + "].status", 200, resource.getStatus() );
+            }
+        }
+        finally
+        {
+            stopServer();
+        }
+    }
+
+    public void testPropFindOnFile()
+        throws Exception
+    {
+        // Setup
+        File serverRoot = new File( "src/test/resources" );
+        URI davServerURI = startDavServer( serverRoot );
+
+        try
+        {
+            // Execute Test
+            URI testURI = davServerURI.resolve( "links/commons-lang.html" );
+            PropFindMethod method = new PropFindMethod( testURI );
+            HttpClient client = new HttpClient();
+            int status = client.executeMethod( method );
+
+            // Verify Results
+            assertEquals( "Status", HttpStatus.SC_MULTI_STATUS, status );
+            MultiStatus multistatus = method.getMultiStatus();
+            assertNotNull( "MultiStatus", multistatus );
+
+            assertEquals( "MultiStatus.resources.size", 1, multistatus.getResources().size() );
+
+            String href = "/dav/links/commons-lang.html";
+            DavResource resource = multistatus.getResource( "/dav/links/commons-lang.html" );
+            assertNotNull( "MultiStatus.resource[" + href + "] should not be null", resource );
+            assertEquals( "Resource[" + href + "].href", href, resource.getHref() );
+            assertEquals( "Resource[" + href + "].collection", false, resource.isCollection() );
+            assertEquals( "Resource[" + href + "].status", 200, resource.getStatus() );
+        }
+        finally
+        {
+            stopServer();
+        }
+    }
+
+    public void testPropFindOnInvalid()
+        throws Exception
+    {
+        // Setup
+        File serverRoot = new File( "src/test/resources" );
+        URI davServerURI = startDavServer( serverRoot );
+
+        try
+        {
+            // Execute Test
+            URI testURI = davServerURI.resolve( "invalid/resource.txt" );
+            PropFindMethod method = new PropFindMethod( testURI );
+            HttpClient client = new HttpClient();
+            int status = client.executeMethod( method );
+
+            // Verify Results
+            assertEquals( "Status", HttpStatus.SC_NOT_FOUND, status );
+            assertNull( "MultiStatus should be null", method.getMultiStatus() );
+        }
+        finally
+        {
+            stopServer();
+        }
+    }
+}

Propchange: maven/wagon/branches/wagon-http-with-webdav/src/test/java/org/apache/maven/wagon/providers/http/dav/PropFindMethodTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/wagon/branches/wagon-http-with-webdav/src/test/java/org/apache/maven/wagon/providers/http/dav/PropFindMethodTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/wagon/branches/wagon-http-with-webdav/src/test/java/org/apache/maven/wagon/providers/http/links/LinkParserTest.java
URL: http://svn.apache.org/viewvc/maven/wagon/branches/wagon-http-with-webdav/src/test/java/org/apache/maven/wagon/providers/http/links/LinkParserTest.java?rev=631492&view=auto
==============================================================================
--- maven/wagon/branches/wagon-http-with-webdav/src/test/java/org/apache/maven/wagon/providers/http/links/LinkParserTest.java (added)
+++ maven/wagon/branches/wagon-http-with-webdav/src/test/java/org/apache/maven/wagon/providers/http/links/LinkParserTest.java Tue Feb 26 21:56:17 2008
@@ -0,0 +1,254 @@
+package org.apache.maven.wagon.providers.http.links;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.codehaus.plexus.util.IOUtil;
+import org.xml.sax.SAXException;
+
+public class LinkParserTest
+    extends TestCase
+{
+    public void testLinkParseArchiva101()
+        throws IOException, SAXException, URISyntaxException
+    {
+        Set/*<String>*/links = parseLinks( "archiva-1.0.1.html" );
+
+        String[] expected = new String[] {
+            "archiva-plexus-runtime-1.0.1-bin.zip",
+            "archiva-plexus-runtime-1.0.1-bin.tar.gz",
+            "archiva-plexus-runtime-1.0.1.jar",
+            "archiva-plexus-runtime-1.0.1.pom",
+            "archiva-plexus-runtime-1.0.1-sources.jar" };
+
+        assertContainsExpected( links, expected );
+
+        String[] avoided = new String[] {
+            "/repo/m2-ibiblio-rsync-repository/org/apache/maven/archiva/archiva-plexus-runtime/",
+            "?C=S;O=A",
+            "?C=D;O=A",
+            "?C=M;O=A" };
+
+        assertNotContainingAvoided( links, avoided );
+    }
+
+    public void testLinkParseMevenIde()
+        throws IOException, SAXException, URISyntaxException
+    {
+        Set/*<String>*/links = parseLinks( "mevenide.html" );
+
+        String[] expected = new String[] {
+            "feature/",
+            "maven-metadata.xml",
+            "nb-project/",
+            "deployment-bridge/",
+            "indexer/",
+            "autoupdate/" };
+
+        assertContainsExpected( links, expected );
+
+        String[] avoided = new String[] { "/org/codehaus/", "?C=S;O=A", "?C=D;O=A", "?C=M;O=A" };
+
+        assertNotContainingAvoided( links, avoided );
+    }
+
+    public void testLinkParseNekoHtml()
+        throws IOException, SAXException, URISyntaxException
+    {
+        Set/*<String>*/links = parseLinks( "nekohtml.html" );
+
+        String[] expected = new String[] {
+            "nekohtml-1.9.6.pom",
+            "nekohtml-1.9.6.jar",
+            "nekohtml-1.9.6-javadoc.jar",
+            "nekohtml-1.9.6-sources.jar.sha1",
+            "nekohtml-1.9.6-sources.jar",
+            "nekohtml-1.9.6.pom.sha1" };
+
+        assertContainsExpected( links, expected );
+
+        String[] avoided = new String[] { "/maven2/nekohtml/nekohtml/", "?C=S;O=A", "?C=D;O=A", "?C=M;O=A" };
+
+        assertNotContainingAvoided( links, avoided );
+    }
+
+    public void testLinkParseNetSourceforge()
+        throws IOException, SAXException, URISyntaxException
+    {
+        Set/*<String>*/links = parseLinks( "net_sf.html" );
+
+        String[] expected = new String[] {
+            "speculoos/",
+            "saxon/",
+            "clirr/",
+            "antenna/",
+            "json-lib/",
+            "jour/",
+            "jsr107cache/",
+            "kxml/",
+            "aislib/",
+            "opencsv/",
+            "maven-sar/",
+            "gwt-widget/",
+            "ldaptemplate/",
+            "mapasuta/",
+            "click/",
+            "proguard/",
+            "locale4j/",
+            "jlynx/",
+            "alchim/",
+            "jcharts/",
+            "ezmorph/",
+            "dozer/",
+            "jxls/",
+            "smc/",
+            "hibernate/",
+            "tacos/",
+            "resultsetmapper/",
+            "stat-scm/",
+            "beanlib/" };
+
+        assertContainsExpected( links, expected );
+
+        String[] avoided = new String[] { "/maven2/net/", "?C=S;O=A", "?C=D;O=A", "?C=M;O=A" };
+
+        assertNotContainingAvoided( links, avoided );
+    }
+
+    public void testLinkParseOrgCodehaus()
+        throws IOException, SAXException, URISyntaxException
+    {
+        Set/*<String>*/links = parseLinks( "org.codehaus.html" );
+
+        String[] expected = new String[] {
+            "xdoclet/",
+            "labs-ng/",
+            "droolsdotnet/",
+            "testdox/",
+            "prometheus/",
+            "cargo/",
+            "staxmate/",
+            "groovy/",
+            "bruce/",
+            "redback/",
+            "mvel/",
+            "waffle/",
+            "fabric3/",
+            "rvm/",
+            "quaere/",
+            "enunciate/",
+            "prophit/",
+            "gant/",
+            "benji/",
+            "jremoting/",
+            "xsite/",
+            "savana/",
+            "dataforge/",
+            "rulessandpit/",
+            "castor-spring/",
+            "jet/",
+            "openim/",
+            "senro/",
+            "sonar/",
+            "gwt-openlayers/",
+            "wadi/",
+            "swiby/",
+            "izpack/",
+            "mojo/",
+            "plexus/",
+            "stomp/",
+            "gumtree/",
+            "mvflex/",
+            "grails-plugins/",
+            "svn4j/",
+            "scala-ide/",
+            "sxc/",
+            "xstream/" };
+
+        assertContainsExpected( links, expected );
+
+        String[] avoided = new String[] { "/org/", "?C=S;O=A", "?C=D;O=A", "?C=M;O=A" };
+
+        assertNotContainingAvoided( links, avoided );
+    }
+
+    public void testLinkParseCommonsLang()
+        throws IOException, SAXException, URISyntaxException
+    {
+        Set/*<String>*/links = parseLinks( "commons-lang.html" );
+
+        String[] expected = new String[] {
+            "maven-metadata.xml",
+            "commons-lang-2.3-sources.jar",
+            "commons-lang-2.3.jar.asc",
+            "commons-lang-2.3.jar",
+            "commons-lang-2.3.pom",
+            "maven-metadata.xml.sha1",
+            "commons-lang-2.3-javadoc.jar",
+            "commons-lang-2.3.jar.sha1" };
+
+        assertContainsExpected( links, expected );
+
+        String[] avoided = new String[] { "../" };
+
+        assertNotContainingAvoided( links, avoided );
+    }
+
+    private void assertNotContainingAvoided( Set/*<String>*/links, String[] avoided )
+    {
+        for ( int i = 0; i < avoided.length; i++ )
+        {
+            assertFalse( "Should not find [" + avoided[i] + "] in link list", links.contains( avoided[i] ) );
+        }
+    }
+
+    private void assertContainsExpected( Set/*<String>*/links, String[] expected )
+    {
+        for ( int i = 0; i < expected.length; i++ )
+        {
+            assertTrue( "Should find [" + expected[i] + "] in link list", links.contains( expected[i] ) );
+        }
+    }
+
+    private Set/*<String>*/parseLinks( String testfilename )
+        throws IOException, SAXException, URISyntaxException
+    {
+        File testFile = new File( "src/test/resources/links", testfilename );
+        Set/*<String>*/links = null;
+
+        FileInputStream stream = null;
+        try
+        {
+            stream = new FileInputStream( testFile );
+            LinkParser linkParser = new LinkParser();
+            links = linkParser.collectLinks( new URI( "http://localhost/" ), stream );
+        }
+        finally
+        {
+            IOUtil.close( stream );
+        }
+
+        assertNotNull( "Set/*<String>*/ links should not be null.", links );
+        return links;
+    }
+
+    public void testCleanLink()
+        throws URISyntaxException
+    {
+        LinkParser lp = new LinkParser();
+        URI baseURI = new URI( "http://localhost/content/" );
+
+        assertEquals( "", lp.cleanLink( baseURI, null ) );
+        assertEquals( "", lp.cleanLink( baseURI, "" ) );
+        assertEquals( "apache-archiva-1.0.1.jar", lp.cleanLink( baseURI, "./apache-archiva-1.0.1.jar" ) );
+        assertEquals( "apache-archiva-1.0.1-sources.jar", lp.cleanLink( baseURI,
+                                                                        "/content/apache-archiva-1.0.1-sources.jar" ) );
+    }
+
+}

Propchange: maven/wagon/branches/wagon-http-with-webdav/src/test/java/org/apache/maven/wagon/providers/http/links/LinkParserTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/wagon/branches/wagon-http-with-webdav/src/test/java/org/apache/maven/wagon/providers/http/links/LinkParserTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/wagon/branches/wagon-http-with-webdav/src/test/resources/MarkTwain.txt
URL: http://svn.apache.org/viewvc/maven/wagon/branches/wagon-http-with-webdav/src/test/resources/MarkTwain.txt?rev=631492&view=auto
==============================================================================
--- maven/wagon/branches/wagon-http-with-webdav/src/test/resources/MarkTwain.txt (added)
+++ maven/wagon/branches/wagon-http-with-webdav/src/test/resources/MarkTwain.txt Tue Feb 26 21:56:17 2008
@@ -0,0 +1,11 @@
+When people do not respect us we are sharply offended; yet deep down in his private heart no man much respects himself.
+    Mark Twain
+
+When we remember we are all mad, the mysteries disappear and life stands explained.
+    Mark Twain
+
+When you cannot get a compliment any other way pay yourself one.
+    Mark Twain
+
+Whenever you find that you are on the side of the majority, it is time to reform.
+    Mark Twain
\ No newline at end of file

Propchange: maven/wagon/branches/wagon-http-with-webdav/src/test/resources/MarkTwain.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/wagon/branches/wagon-http-with-webdav/src/test/resources/MarkTwain.txt
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/wagon/branches/wagon-http-with-webdav/src/test/resources/dav/multistatus-1.xml
URL: http://svn.apache.org/viewvc/maven/wagon/branches/wagon-http-with-webdav/src/test/resources/dav/multistatus-1.xml?rev=631492&view=auto
==============================================================================
--- maven/wagon/branches/wagon-http-with-webdav/src/test/resources/dav/multistatus-1.xml (added)
+++ maven/wagon/branches/wagon-http-with-webdav/src/test/resources/dav/multistatus-1.xml Tue Feb 26 21:56:17 2008
@@ -0,0 +1,32 @@
+<?xml version="1.0" ?>
+<D:multistatus xmlns:D="DAV:" xmlns:J="http://example.com/jsprops/">
+	<D:response>
+		<D:href>/MyCollection/</D:href>
+		<D:propstat>
+			<D:prop>
+				<D:resourcetype>
+					<D:collection />
+				</D:resourcetype>
+				<J:keywords>diary, interests, hobbies</J:keywords>
+			</D:prop>
+			<D:status>HTTP/1.1 200 OK</D:status>
+		</D:propstat>
+	</D:response>
+	<D:response>
+		<D:href>/MyCollection/diary.html</D:href>
+		<D:propstat>
+			<D:prop>
+				<D:resourcetype />
+				<J:keywords>diary, travel, family, history</J:keywords>
+			</D:prop>
+			<D:status>HTTP/1.1 200 OK</D:status>
+		</D:propstat>
+	</D:response>
+	<D:response>
+		<D:href>/MyCollection/nunavut</D:href>
+		<D:status>HTTP/1.1 302 Found</D:status>
+		<D:location>
+			<D:href>http://example.ca/art/inuit/</D:href>
+		</D:location>
+	</D:response>
+</D:multistatus>
\ No newline at end of file

Propchange: maven/wagon/branches/wagon-http-with-webdav/src/test/resources/dav/multistatus-1.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/wagon/branches/wagon-http-with-webdav/src/test/resources/dav/multistatus-1.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Propchange: maven/wagon/branches/wagon-http-with-webdav/src/test/resources/dav/multistatus-1.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: maven/wagon/branches/wagon-http-with-webdav/src/test/resources/dav/multistatus-2.xml
URL: http://svn.apache.org/viewvc/maven/wagon/branches/wagon-http-with-webdav/src/test/resources/dav/multistatus-2.xml?rev=631492&view=auto
==============================================================================
--- maven/wagon/branches/wagon-http-with-webdav/src/test/resources/dav/multistatus-2.xml (added)
+++ maven/wagon/branches/wagon-http-with-webdav/src/test/resources/dav/multistatus-2.xml Tue Feb 26 21:56:17 2008
@@ -0,0 +1,16 @@
+<?xml version="1.0" ?>
+<D:multistatus xmlns:D="DAV:">
+ <D:response>
+  <D:href>/archiva/repository/</D:href>
+  <D:propstat>
+   <D:prop>
+    <D:resourcetype><D:collection/></D:resourcetype>
+    <D:getcontenttype>httpd/unix-directory</D:getcontenttype>
+    <D:getetag>"D41D8CD98F00B204E9800998ECF8427E-00000000-000001181418F217"</D:getetag>
+    <D:creationdate>2008-02-13T18:40:22Z</D:creationdate>
+    <D:getlastmodified>Wed, 13 Feb 2008 18:40:22 GMT</D:getlastmodified>
+   </D:prop>
+   <D:status>HTTP/1.1 200 OK</D:status>
+  </D:propstat>
+ </D:response>
+</D:multistatus>

Propchange: maven/wagon/branches/wagon-http-with-webdav/src/test/resources/dav/multistatus-2.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/wagon/branches/wagon-http-with-webdav/src/test/resources/dav/multistatus-2.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Propchange: maven/wagon/branches/wagon-http-with-webdav/src/test/resources/dav/multistatus-2.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml



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


Mime
View raw message