You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ca...@apache.org on 2006/04/10 22:15:34 UTC
svn commit: r393043 - in /maven/sandbox/wagon-webdav: ./ src/ src/main/
src/main/java/ src/main/java/org/ src/main/java/org/apache/
src/main/java/org/apache/maven/ src/main/java/org/apache/maven/wagon/
src/main/java/org/apache/maven/wagon/providers/ sr...
Author: carlos
Date: Mon Apr 10 13:15:31 2006
New Revision: 393043
URL: http://svn.apache.org/viewcvs?rev=393043&view=rev
Log:
[WAGON-32] Implement WebDAV Wagon Provider
Submitted By: Joakim Erdfelt, Henry Isidro
Added:
maven/sandbox/wagon-webdav/
maven/sandbox/wagon-webdav/pom.xml (with props)
maven/sandbox/wagon-webdav/src/
maven/sandbox/wagon-webdav/src/main/
maven/sandbox/wagon-webdav/src/main/java/
maven/sandbox/wagon-webdav/src/main/java/org/
maven/sandbox/wagon-webdav/src/main/java/org/apache/
maven/sandbox/wagon-webdav/src/main/java/org/apache/maven/
maven/sandbox/wagon-webdav/src/main/java/org/apache/maven/wagon/
maven/sandbox/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/
maven/sandbox/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/
maven/sandbox/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/CorrectedWebdavResource.java (with props)
maven/sandbox/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/PutInputStream.java (with props)
maven/sandbox/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/WebDavWagon.java (with props)
maven/sandbox/wagon-webdav/src/main/resources/
maven/sandbox/wagon-webdav/src/main/resources/META-INF/
maven/sandbox/wagon-webdav/src/main/resources/META-INF/plexus/
maven/sandbox/wagon-webdav/src/main/resources/META-INF/plexus/components.xml (with props)
maven/sandbox/wagon-webdav/src/site/
maven/sandbox/wagon-webdav/src/site/site.xml (with props)
maven/sandbox/wagon-webdav/src/test/
maven/sandbox/wagon-webdav/src/test/java/
maven/sandbox/wagon-webdav/src/test/java/org/
maven/sandbox/wagon-webdav/src/test/java/org/apache/
maven/sandbox/wagon-webdav/src/test/java/org/apache/maven/
maven/sandbox/wagon-webdav/src/test/java/org/apache/maven/wagon/
maven/sandbox/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/
maven/sandbox/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/
maven/sandbox/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/Context.java (with props)
maven/sandbox/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/PutInputStreamTest.java (with props)
maven/sandbox/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/Servlet.java (with props)
maven/sandbox/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/ServletServer.java (with props)
maven/sandbox/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavWagonTest.java (with props)
maven/sandbox/wagon-webdav/src/test/resources/
maven/sandbox/wagon-webdav/src/test/resources/org/
maven/sandbox/wagon-webdav/src/test/resources/org/apache/
maven/sandbox/wagon-webdav/src/test/resources/org/apache/maven/
maven/sandbox/wagon-webdav/src/test/resources/org/apache/maven/wagon/
maven/sandbox/wagon-webdav/src/test/resources/org/apache/maven/wagon/providers/
maven/sandbox/wagon-webdav/src/test/resources/org/apache/maven/wagon/providers/webdav/
maven/sandbox/wagon-webdav/src/test/resources/org/apache/maven/wagon/providers/webdav/WebDavWagonTest.xml (with props)
Added: maven/sandbox/wagon-webdav/pom.xml
URL: http://svn.apache.org/viewcvs/maven/sandbox/wagon-webdav/pom.xml?rev=393043&view=auto
==============================================================================
--- maven/sandbox/wagon-webdav/pom.xml (added)
+++ maven/sandbox/wagon-webdav/pom.xml Mon Apr 10 13:15:31 2006
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project
+ xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <artifactId>wagon-providers</artifactId>
+ <groupId>org.apache.maven.wagon</groupId>
+ <version>1.0-alpha-7-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>wagon-webdav</artifactId>
+ <version>1.0-alpha-7-SNAPSHOT</version>
+ <name>Maven Wagon WebDav Provider</name>
+ <description>
+ Wagon that gets and puts artifacts through webdav protocol
+ </description>
+
+ <contributors>
+ <contributor>
+ <name>Henry Isidro</name>
+ <email>hisidro@exist.com</email>
+ </contributor>
+ <contributor>
+ <name>Joakim Erdfelt</name>
+ <email>joakim@erdfelt.com</email>
+ </contributor>
+ </contributors>
+
+ <dependencies>
+ <dependency>
+ <groupId>slide</groupId>
+ <artifactId>slide-webdavlib</artifactId>
+ <version>2.1</version>
+ </dependency>
+ <dependency>
+ <groupId>it.could</groupId>
+ <artifactId>webdav</artifactId>
+ <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>
+
+</project>
Propchange: maven/sandbox/wagon-webdav/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/wagon-webdav/pom.xml
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/sandbox/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/CorrectedWebdavResource.java
URL: http://svn.apache.org/viewcvs/maven/sandbox/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/CorrectedWebdavResource.java?rev=393043&view=auto
==============================================================================
--- maven/sandbox/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/CorrectedWebdavResource.java (added)
+++ maven/sandbox/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/CorrectedWebdavResource.java Mon Apr 10 13:15:31 2006
@@ -0,0 +1,136 @@
+package org.apache.maven.wagon.providers.webdav;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.HttpURL;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.PutMethod;
+import org.apache.commons.httpclient.util.URIUtil;
+import org.apache.webdav.lib.WebdavResource;
+
+/**
+ * Corrected Webdav Resource.
+ *
+ * This extension to the WebdavResource object corrects a Content-Length
+ * bug in the WebdavLib.
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ */
+public class CorrectedWebdavResource
+ extends WebdavResource
+{
+ /**
+ * Map of additional headers
+ */
+ protected Map headers = new HashMap();
+
+ public CorrectedWebdavResource( HttpURL url )
+ throws HttpException, IOException
+ {
+ super( url );
+ }
+
+ /**
+ * Add all additionals headers that have been previously registered
+ * with addRequestHeader to the method
+ */
+ protected void generateAdditionalHeaders( HttpMethod method )
+ {
+ for ( Iterator iterator = headers.keySet().iterator(); iterator.hasNext(); )
+ {
+ String header = (String) iterator.next();
+ method.setRequestHeader( header, (String) headers.get( header ) );
+ }
+ }
+
+ /**
+ * Get InputStream for the GET method for the given path.
+ *
+ * @param path the server relative path of the resource to get
+ * @return InputStream
+ * @exception HttpException
+ * @exception IOException
+ */
+ public InputStream getMethodData( String path )
+ throws HttpException, IOException
+ {
+
+ setClient();
+
+ GetMethod method = new GetMethod( URIUtil.encodePathQuery( path ) );
+
+ generateTransactionHeader( method );
+ generateAdditionalHeaders( method );
+ client.executeMethod( method );
+
+ int statusCode = method.getStatusLine().getStatusCode();
+ setStatusCode( statusCode );
+
+ if ( statusCode >= 200 && statusCode < 300 )
+ return method.getResponseBodyAsStream();
+ else
+ throw new IOException( "Couldn't get file" );
+ }
+
+ /**
+ * Add a header in the request sent to the webdav server
+ *
+ * @param header Header name
+ * @param value Value
+ */
+ public void addRequestHeader( String header, String value )
+ {
+ headers.put( header, value );
+ }
+
+ /**
+ * Execute the PUT method for the given path.
+ *
+ * @param path the server relative path to put the data
+ * @param is The input stream.
+ * @return true if the method is succeeded.
+ * @exception HttpException
+ * @exception IOException
+ */
+ public boolean putMethod( String path, InputStream is, int contentLength )
+ throws HttpException, IOException
+ {
+
+ setClient();
+ PutMethod method = new PutMethod( URIUtil.encodePathQuery( path ) );
+ generateIfHeader( method );
+ if ( getGetContentType() != null && !getGetContentType().equals( "" ) )
+ method.setRequestHeader( "Content-Type", getGetContentType() );
+ method.setRequestContentLength( contentLength );
+ method.setRequestBody( is );
+ generateTransactionHeader( method );
+ generateAdditionalHeaders( method );
+ int statusCode = client.executeMethod( method );
+
+ setStatusCode( statusCode );
+ return ( statusCode >= 200 && statusCode < 300 ) ? true : false;
+ }
+
+}
Propchange: maven/sandbox/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/CorrectedWebdavResource.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/CorrectedWebdavResource.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/sandbox/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/PutInputStream.java
URL: http://svn.apache.org/viewcvs/maven/sandbox/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/PutInputStream.java?rev=393043&view=auto
==============================================================================
--- maven/sandbox/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/PutInputStream.java (added)
+++ maven/sandbox/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/PutInputStream.java Mon Apr 10 13:15:31 2006
@@ -0,0 +1,82 @@
+package org.apache.maven.wagon.providers.webdav;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+import org.apache.maven.wagon.Wagon;
+import org.apache.maven.wagon.events.TransferEvent;
+import org.apache.maven.wagon.events.TransferEventSupport;
+import org.apache.maven.wagon.resource.Resource;
+
+/**
+ * Put Input Stream is borrowed from wagon-http, and is used to properly
+ * notify the listeners of transfer events on a put request.
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ */
+public class PutInputStream
+ extends FileInputStream
+{
+ private TransferEventSupport eventSupport;
+
+ private TransferEvent event;
+
+ public PutInputStream( File file, Resource resource, Wagon wagon, TransferEventSupport eventSupport )
+ throws FileNotFoundException
+ {
+ super( file );
+
+ this.eventSupport = eventSupport;
+
+ event = new TransferEvent( wagon, resource, TransferEvent.TRANSFER_PROGRESS, TransferEvent.REQUEST_PUT );
+
+ event.setLocalFile( file );
+ }
+
+ public int read( byte b[] )
+ throws IOException
+ {
+ return read( b, 0, b.length );
+ }
+
+ public int read()
+ throws IOException
+ {
+ byte b[] = new byte[1];
+
+ return read( b );
+ }
+
+ public int read( byte b[], int off, int len )
+ throws IOException
+ {
+ int retValue = super.read( b, off, len );
+
+ if ( retValue > 0 )
+ {
+ System.out.println("read():" + new String(b, off, len));
+ event.setTimestamp( System.currentTimeMillis() );
+
+ eventSupport.fireTransferProgress( event, b, retValue );
+ }
+ return retValue;
+ }
+}
Propchange: maven/sandbox/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/PutInputStream.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/PutInputStream.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/sandbox/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/WebDavWagon.java
URL: http://svn.apache.org/viewcvs/maven/sandbox/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/WebDavWagon.java?rev=393043&view=auto
==============================================================================
--- maven/sandbox/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/WebDavWagon.java (added)
+++ maven/sandbox/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/WebDavWagon.java Mon Apr 10 13:15:31 2006
@@ -0,0 +1,486 @@
+package org.apache.maven.wagon.providers.webdav;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URL;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+import java.util.Properties;
+import java.util.TimeZone;
+
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.HttpStatus;
+import org.apache.commons.httpclient.HttpURL;
+import org.apache.commons.httpclient.HttpsURL;
+import org.apache.commons.httpclient.URIException;
+import org.apache.maven.wagon.AbstractWagon;
+import org.apache.maven.wagon.ConnectionException;
+import org.apache.maven.wagon.LazyFileOutputStream;
+import org.apache.maven.wagon.PathUtils;
+import org.apache.maven.wagon.ResourceDoesNotExistException;
+import org.apache.maven.wagon.TransferFailedException;
+import org.apache.maven.wagon.authentication.AuthenticationException;
+import org.apache.maven.wagon.authorization.AuthorizationException;
+import org.apache.maven.wagon.events.TransferEvent;
+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.StringUtils;
+
+/**
+ * <p>WebDavWagon</p>
+ *
+ * <p>Allows using a webdav remote repository for downloads and deployments</p>
+ *
+ * <p>TODO: webdav https server is not tested</p>
+ *
+ * @author <a href="mailto:hisidro@exist.com">Henry Isidro</a>
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ */
+public class WebDavWagon
+ extends AbstractWagon
+{
+ private static final TimeZone GMT_TIME_ZONE = TimeZone.getTimeZone( "GMT" );
+
+ private CorrectedWebdavResource wdresource;
+
+ private static String WAGON_VERSION;
+
+ public WebDavWagon()
+ {
+ if ( WAGON_VERSION == null )
+ {
+ URL pomUrl = this.getClass()
+ .getResource( "/META-INF/maven/org.apache.maven.wagon/wagon-webdav/pom.properties" );
+ if ( pomUrl == null )
+ {
+ WAGON_VERSION = "";
+ }
+ else
+ {
+ Properties props = new Properties();
+ try
+ {
+ props.load( pomUrl.openStream() );
+ WAGON_VERSION = props.getProperty( "version" );
+ System.out.println( "WAGON_VERSION: " + WAGON_VERSION );
+ }
+ catch ( IOException e )
+ {
+ WAGON_VERSION = "";
+ }
+ }
+ }
+ }
+
+ /**
+ * Opens a connection via web-dav resource
+ * @throws AuthenticationException
+ */
+ public void openConnection()
+ throws AuthenticationException, ConnectionException
+ {
+ String url = getURL( repository );
+
+ repository.setUrl( url );
+
+ HttpURL httpURL = null;
+
+ try
+ {
+ httpURL = urlToHttpURL( url );
+
+ wdresource = new CorrectedWebdavResource( httpURL );
+ }
+ catch ( HttpException he )
+ {
+ if ( he.getReasonCode() == HttpStatus.SC_UNAUTHORIZED )
+ {
+ try
+ {
+ httpURL.setUserinfo( authenticationInfo.getUserName(), authenticationInfo.getPassword() );
+
+ wdresource = new CorrectedWebdavResource( httpURL );
+ }
+ catch ( URIException urie )
+ {
+ throw new AuthenticationException( "Authentication Exception: " + urie.getReason() );
+ }
+ catch ( IOException ioe )
+ {
+ throw new ConnectionException( "Connection Exception: " + ioe.getMessage() );
+ }
+ }
+ }
+ catch ( URIException urie )
+ {
+ throw new ConnectionException( "Connection Exception: " + urie.getReason(), urie );
+ }
+ catch ( IOException ioe )
+ {
+ throw new ConnectionException( "Connection Exception: " + ioe.getMessage(), ioe );
+ }
+ }
+
+ /**
+ * Closes the connection
+ * @throws ConnectionException
+ */
+ public void closeConnection()
+ throws ConnectionException
+ {
+ try
+ {
+ wdresource.close();
+ }
+ catch ( IOException ioe )
+ {
+ throw new ConnectionException( "Connection Exception: " + ioe.getMessage() );
+ }
+ finally
+ {
+ wdresource = null;
+ }
+ }
+
+ /**
+ * Puts a file into the remote repository
+ *
+ *
+ * @param source the file to transfer
+ * @param resourceName the name of the resource
+ * @throws TransferFailedException
+ * @throws ResourceDoesNotExistException
+ * @throws AuthorizationException
+ */
+ public void put( File source, String resourceName )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ Repository repository = getRepository();
+
+ String basedir = repository.getBasedir();
+
+ resourceName = StringUtils.replace( resourceName, "\\", "/" );
+ String dir = PathUtils.dirname( resourceName );
+ dir = StringUtils.replace( dir, "\\", "/" );
+
+ String dest = repository.getUrl();
+ Resource resource = new Resource( resourceName );
+
+ if ( dest.endsWith( "/" ) )
+ {
+ dest = dest + resource.getName();
+ }
+ else
+ {
+ dest = dest + "/" + resource.getName();
+ }
+
+ firePutInitiated( resource, source );
+ String oldpath = wdresource.getPath();
+
+ String relpath = getPath( basedir, dir );
+
+ try
+ {
+ // Test if dest resource path exist.
+ String cdpath = checkUri( relpath + "/" );
+ wdresource.setPath( cdpath );
+
+ if ( wdresource.exists() && !wdresource.isCollection() )
+ {
+ throw new TransferFailedException(
+ "Destination path exists and is not a WebDAV collection (directory): "
+ + cdpath );
+ }
+
+ wdresource.setPath( oldpath );
+ }
+ // if dest resource path does not exist, create it
+ catch ( HttpException e )
+ {
+ if ( e.getReasonCode() == HttpStatus.SC_NOT_FOUND )
+ {
+ // mkcolMethod() cannot create a directory heirarchy at once,
+ // it has to create each directory one at a time
+ try
+ {
+ String[] dirs = relpath.split( "/" );
+ String create_dir = "";
+
+ // start at 1 because first element of dirs[] from split() is ""
+ for ( int count = 1; count < dirs.length; count++ )
+ {
+ create_dir = create_dir + "/" + dirs[count];
+ wdresource.mkcolMethod( create_dir );
+ }
+ wdresource.setPath( oldpath );
+ }
+ catch ( IOException ioe )
+ {
+ throw new TransferFailedException( "Failed to create destination WebDAV collection (directory): "
+ + relpath );
+ }
+ }
+ else
+ {
+ throw new TransferFailedException( "Failed to create destination WebDAV collection (directory): "
+ + relpath );
+ }
+ }
+ catch ( IOException e )
+ {
+ throw new TransferFailedException( "Failed to create destination WebDAV collection (directory): " + relpath );
+ }
+
+ try
+ {
+ // Put source into destination path.
+ firePutStarted( resource, source );
+
+ InputStream is = new PutInputStream( source, resource, this, getTransferEventSupport() );
+ boolean success = wdresource.putMethod( dest, is, (int) source.length() );
+ int statusCode = wdresource.getStatusCode();
+
+ switch ( statusCode )
+ {
+ case HttpStatus.SC_OK:
+ break;
+
+ case HttpStatus.SC_CREATED:
+ break;
+
+ case HttpStatus.SC_FORBIDDEN:
+ throw new AuthorizationException( "Access denided to: " + dest );
+
+ case HttpStatus.SC_NOT_FOUND:
+ throw new ResourceDoesNotExistException( "File: " + dest + " does not exist" );
+
+ case HttpStatus.SC_LENGTH_REQUIRED:
+ throw new ResourceDoesNotExistException( "Transfer failed, server requires Content-Length." );
+
+ //add more entries here
+ default:
+ if ( !success )
+ {
+ throw new TransferFailedException( "Failed to transfer file: " + dest + ". Return code is: "
+ + statusCode );
+ }
+ }
+ }
+ catch ( FileNotFoundException e )
+ {
+ throw new TransferFailedException( "Specified source file does not exist: " + source, e );
+ }
+ catch ( IOException e )
+ {
+ fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
+
+ String msg = "PUT request for: " + resource + " to " + source.getName() + " failed";
+
+ throw new TransferFailedException( msg, e );
+ }
+ firePutCompleted( resource, source );
+ }
+
+ /**
+ * Converts a String url to an HttpURL
+ *
+ * @param url String url to conver to an HttpURL
+ * @return an HttpURL object created from the String url
+ * @throws URIException
+ */
+ private HttpURL urlToHttpURL( String url )
+ throws URIException
+ {
+ return url.startsWith( "https" ) ? new HttpsURL( url ) : new HttpURL( url );
+ }
+
+ /**
+ * Determine which URI to use at the prompt.
+ *
+ * @param uri the path to be set.
+ * @return the absolute path.
+ */
+ private String checkUri( String uri )
+ throws IOException
+ {
+
+ if ( wdresource == null )
+ {
+ throw new IOException( "Not connected yet." );
+ }
+
+ if ( uri == null )
+ {
+ uri = wdresource.getPath();
+ }
+
+ return FileUtils.normalize( uri );
+ }
+
+ public void get( String resourceName, File destination )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ get( resourceName, destination, 0 );
+
+ }
+
+ public boolean getIfNewer( String resourceName, File destination, long timestamp )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ return get( resourceName, destination, timestamp );
+ }
+
+ /**
+ * @param resourceName
+ * @param destination
+ * @param timestamp the timestamp to check against, only downloading if newer. If <code>0</code>, always download
+ * @return <code>true</code> if newer version was downloaded, <code>false</code> otherwise.
+ * @throws TransferFailedException
+ * @throws ResourceDoesNotExistException
+ * @throws AuthorizationException
+ */
+ public boolean get( String resourceName, File destination, long timestamp )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ Resource resource = new Resource( resourceName );
+
+ fireGetInitiated( resource, destination );
+
+ String url = getRepository().getUrl() + "/" + resourceName;
+
+ wdresource.addRequestHeader( "X-wagon-provider", "wagon-webdav" );
+ wdresource.addRequestHeader( "X-wagon-version", WAGON_VERSION );
+
+ wdresource.addRequestHeader( "Cache-control", "no-cache" );
+ wdresource.addRequestHeader( "Cache-store", "no-store" );
+ wdresource.addRequestHeader( "Pragma", "no-cache" );
+ wdresource.addRequestHeader( "Expires", "0" );
+
+ if ( timestamp > 0 )
+ {
+ SimpleDateFormat fmt = new SimpleDateFormat( "EEE, dd-MMM-yy HH:mm:ss zzz", Locale.US );
+ fmt.setTimeZone( GMT_TIME_ZONE );
+ wdresource.addRequestHeader( "If-Modified-Since", fmt.format( new Date( timestamp ) ) );
+ }
+
+ InputStream is = null;
+ OutputStream output = new LazyFileOutputStream( destination );
+ try
+ {
+ is = wdresource.getMethodData( url );
+ getTransfer( resource, destination, is );
+ }
+ catch ( HttpException e )
+ {
+ fireTransferError( resource, e, TransferEvent.REQUEST_GET );
+ throw new TransferFailedException( "Failed to transfer file: " + url + ". Return code is: "
+ + e.getReasonCode(), e );
+ }
+ catch ( IOException e )
+ {
+ fireTransferError( resource, e, TransferEvent.REQUEST_GET );
+
+ if ( destination.exists() )
+ {
+ boolean deleted = destination.delete();
+
+ if ( !deleted )
+ {
+ destination.deleteOnExit();
+ }
+ }
+
+ int statusCode = wdresource.getStatusCode();
+ switch ( statusCode )
+ {
+ case HttpStatus.SC_NOT_MODIFIED:
+ return false;
+
+ case HttpStatus.SC_FORBIDDEN:
+ throw new AuthorizationException( "Access denided to: " + url );
+
+ case HttpStatus.SC_UNAUTHORIZED:
+ throw new AuthorizationException( "Not authorized." );
+
+ case HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED:
+ throw new AuthorizationException( "Not authorized by proxy." );
+
+ case HttpStatus.SC_NOT_FOUND:
+ throw new ResourceDoesNotExistException( "File: " + url + " does not exist" );
+
+ default:
+ throw new TransferFailedException( "Failed to trasfer file: " + url + ". Return code is: "
+ + statusCode );
+ }
+ }
+ finally
+ {
+ IOUtil.close( is );
+ IOUtil.close( output );
+ }
+
+ int statusCode = wdresource.getStatusCode();
+
+ switch ( statusCode )
+ {
+ case HttpStatus.SC_OK:
+ return true;
+
+ case HttpStatus.SC_NOT_MODIFIED:
+ return false;
+
+ case HttpStatus.SC_FORBIDDEN:
+ throw new AuthorizationException( "Access denided to: " + url );
+
+ case HttpStatus.SC_UNAUTHORIZED:
+ throw new AuthorizationException( "Not authorized." );
+
+ case HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED:
+ throw new AuthorizationException( "Not authorized by proxy." );
+
+ case HttpStatus.SC_NOT_FOUND:
+ throw new ResourceDoesNotExistException( "File: " + url + " does not exist" );
+
+ default:
+ throw new TransferFailedException( "Failed to trasfer file: " + url + ". Return code is: "
+ + statusCode );
+ }
+
+ }
+
+ private String getURL( Repository repository )
+ {
+ String url = repository.getUrl();
+ if ( url.startsWith( "dav:" ) )
+ {
+ return url.substring( 4 );
+ }
+ else
+ {
+ return url;
+ }
+ }
+}
Propchange: maven/sandbox/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/WebDavWagon.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/WebDavWagon.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/sandbox/wagon-webdav/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewcvs/maven/sandbox/wagon-webdav/src/main/resources/META-INF/plexus/components.xml?rev=393043&view=auto
==============================================================================
--- maven/sandbox/wagon-webdav/src/main/resources/META-INF/plexus/components.xml (added)
+++ maven/sandbox/wagon-webdav/src/main/resources/META-INF/plexus/components.xml Mon Apr 10 13:15:31 2006
@@ -0,0 +1,10 @@
+<component-set>
+ <components>
+ <component>
+ <role>org.apache.maven.wagon.Wagon</role>
+ <role-hint>dav</role-hint>
+ <implementation>org.apache.maven.wagon.providers.webdav.WebDavWagon</implementation>
+ <instantiation-strategy>per-lookup</instantiation-strategy>
+ </component>
+ </components>
+</component-set>
Propchange: maven/sandbox/wagon-webdav/src/main/resources/META-INF/plexus/components.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/wagon-webdav/src/main/resources/META-INF/plexus/components.xml
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/sandbox/wagon-webdav/src/site/site.xml
URL: http://svn.apache.org/viewcvs/maven/sandbox/wagon-webdav/src/site/site.xml?rev=393043&view=auto
==============================================================================
--- maven/sandbox/wagon-webdav/src/site/site.xml (added)
+++ maven/sandbox/wagon-webdav/src/site/site.xml Mon Apr 10 13:15:31 2006
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<project name="Wagon WebDav Provider">
+ <skin>
+ <groupId>org.apache.maven.skins</groupId>
+ <artifactId>maven-default-skin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </skin>
+ <body>
+ <links>
+ <item name="Apache" href="http://www.apache.org/" />
+ <item name="Maven 2" href="http://maven.apache.org/maven2/"/>
+ </links>
+
+ ${parentProject}
+ ${reports}
+ </body>
+</project>
\ No newline at end of file
Propchange: maven/sandbox/wagon-webdav/src/site/site.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/wagon-webdav/src/site/site.xml
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/sandbox/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/Context.java
URL: http://svn.apache.org/viewcvs/maven/sandbox/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/Context.java?rev=393043&view=auto
==============================================================================
--- maven/sandbox/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/Context.java (added)
+++ maven/sandbox/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/Context.java Mon Apr 10 13:15:31 2006
@@ -0,0 +1,43 @@
+package org.apache.maven.wagon.providers.webdav;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.util.List;
+
+/**
+ * Context
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ */
+public class Context
+{
+ private String id;
+
+ private List servlets;
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public List getServlets()
+ {
+ return servlets;
+ }
+
+
+}
Propchange: maven/sandbox/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/Context.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/Context.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/sandbox/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/PutInputStreamTest.java
URL: http://svn.apache.org/viewcvs/maven/sandbox/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/PutInputStreamTest.java?rev=393043&view=auto
==============================================================================
--- maven/sandbox/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/PutInputStreamTest.java (added)
+++ maven/sandbox/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/PutInputStreamTest.java Mon Apr 10 13:15:31 2006
@@ -0,0 +1,143 @@
+package org.apache.maven.wagon.providers.webdav;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+import junit.framework.TestCase;
+
+import org.apache.maven.wagon.AbstractWagon;
+import org.apache.maven.wagon.ConnectionException;
+import org.apache.maven.wagon.FileTestUtils;
+import org.apache.maven.wagon.ResourceDoesNotExistException;
+import org.apache.maven.wagon.TransferFailedException;
+import org.apache.maven.wagon.authentication.AuthenticationException;
+import org.apache.maven.wagon.authorization.AuthorizationException;
+import org.apache.maven.wagon.resource.Resource;
+import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.IOUtil;
+
+/**
+ * PutInputStream Test
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ */
+public class PutInputStreamTest
+ extends TestCase
+{
+ private static final int BUFFER_SIZE = 8096;
+
+ public void testStream() throws IOException, NoSuchAlgorithmException
+ {
+ File sourceFile = new File( FileTestUtils.getTestOutputDir(), "test-source" );
+ FileUtils.fileWrite( sourceFile.getAbsolutePath(), "test-source.txt\n" );
+
+ File destFile = new File( FileTestUtils.getTestOutputDir(), "test-dest" );
+
+ Resource resource = new Resource();
+ AbstractWagon wagon = new NullWagon();
+
+ InputStream input = new PutInputStream(sourceFile, resource, wagon, wagon.getTransferEventSupport() );
+
+ FileOutputStream output = new FileOutputStream(destFile);
+ byte buf[] = new byte[BUFFER_SIZE];
+ int n = -1;
+ while( (n = input.read(buf)) != (-1))
+ {
+ output.write(buf, 0, n);
+ }
+ IOUtil.close(output);
+ IOUtil.close(input);
+
+ String sourceHash = generateHash(sourceFile);
+ String destHash = generateHash(destFile);
+
+ assertEquals("Hash comparision", sourceHash, destHash);
+ }
+
+ private String generateHash(File file) throws NoSuchAlgorithmException, IOException
+ {
+ MessageDigest md = MessageDigest.getInstance( "SHA1" );
+
+ byte buffer[] = new byte[BUFFER_SIZE];
+ FileInputStream fis = new FileInputStream(file);
+ md.reset();
+
+ int size = fis.read( buffer, 0, BUFFER_SIZE );
+ while ( size >= 0 )
+ {
+ md.update( buffer, 0, size );
+ size = fis.read( buffer, 0, BUFFER_SIZE );
+ }
+
+ return toHex(md.digest());
+ }
+
+ private String toHex( byte buf[] )
+ {
+ final char pseudo[] = new char[] {
+ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
+
+ char[] hash = new char[buf.length * 2];
+ for ( int i = 0; i < buf.length; i++ )
+ {
+ hash[i * 2] = ( pseudo[( buf[i] & 0xF0 ) >> 4] );
+ hash[( i * 2 ) + 1] = ( pseudo[( buf[i] & 0x0F )] );
+ }
+ return new String( hash );
+ }
+
+
+ public class NullWagon extends AbstractWagon
+ {
+ protected void closeConnection()
+ throws ConnectionException
+ {
+
+ }
+
+ public void get( String resourceName, File destination )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+
+ }
+
+ public boolean getIfNewer( String resourceName, File destination, long timestamp )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ return false;
+ }
+
+ public void put( File source, String destination )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+
+ }
+
+ public void openConnection()
+ throws ConnectionException, AuthenticationException
+ {
+
+ }
+ }
+}
Propchange: maven/sandbox/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/PutInputStreamTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/PutInputStreamTest.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/sandbox/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/Servlet.java
URL: http://svn.apache.org/viewcvs/maven/sandbox/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/Servlet.java?rev=393043&view=auto
==============================================================================
--- maven/sandbox/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/Servlet.java (added)
+++ maven/sandbox/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/Servlet.java Mon Apr 10 13:15:31 2006
@@ -0,0 +1,55 @@
+package org.apache.maven.wagon.providers.webdav;
+
+import java.util.Properties;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+/**
+ * Servlet
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ */
+public class Servlet
+{
+ private String id;
+
+ private Properties parameters;
+
+ private String path;
+
+ private String servlet;
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public Properties getParameters()
+ {
+ return parameters;
+ }
+
+ public String getPath()
+ {
+ return path;
+ }
+
+ public String getServlet()
+ {
+ return servlet;
+ }
+}
Propchange: maven/sandbox/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/Servlet.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/Servlet.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/sandbox/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/ServletServer.java
URL: http://svn.apache.org/viewcvs/maven/sandbox/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/ServletServer.java?rev=393043&view=auto
==============================================================================
--- maven/sandbox/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/ServletServer.java (added)
+++ maven/sandbox/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/ServletServer.java Mon Apr 10 13:15:31 2006
@@ -0,0 +1,132 @@
+package org.apache.maven.wagon.providers.webdav;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Startable;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.StartingException;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.StoppingException;
+import org.mortbay.http.SocketListener;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.servlet.ServletHolder;
+import org.mortbay.jetty.servlet.ServletHttpContext;
+import org.mortbay.util.MultiException;
+
+/**
+ * Plexus Component to start a Jetty Server with servlet settings.
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ */
+public class ServletServer
+ implements Initializable, Startable
+{
+ public static final String ROLE = ServletServer.class.getName();
+
+ private Server server;
+
+ private int port;
+
+ private List contexts;
+
+ public void initialize()
+ throws InitializationException
+ {
+ server = new Server();
+
+ SocketListener listener = new SocketListener();
+ listener.setPort( port );
+
+ server.addListener( listener );
+
+ if ( contexts != null )
+ {
+ try
+ {
+ Iterator itcontext = contexts.iterator();
+
+ while ( itcontext.hasNext() )
+ {
+ Context wdc = (Context) itcontext.next();
+
+ ServletHttpContext context = (ServletHttpContext) server.getContext( wdc.getId() );
+
+ initContext( wdc, context );
+ }
+ }
+ catch ( Exception e )
+ {
+ throw new InitializationException( "Unable to initialize.", e );
+ }
+ }
+ }
+
+ private void initContext( Context wdc, ServletHttpContext context )
+ throws ClassNotFoundException, InstantiationException, IllegalAccessException
+ {
+ Iterator itpaths = wdc.getServlets().iterator();
+ while ( itpaths.hasNext() )
+ {
+ Servlet servlet = (Servlet) itpaths.next();
+ initServlet( context, servlet );
+ }
+ }
+
+ private void initServlet( ServletHttpContext context, Servlet path )
+ throws ClassNotFoundException, InstantiationException, IllegalAccessException
+ {
+ ServletHolder servlet = context.addServlet( path.getId(), path.getPath(), path.getServlet() );
+
+ Iterator itparams = path.getParameters().entrySet().iterator();
+ while ( itparams.hasNext() )
+ {
+ Map.Entry entry = (Entry) itparams.next();
+ servlet.setInitParameter( (String) entry.getKey(), (String) entry.getValue() );
+ }
+ }
+
+ public void start()
+ throws StartingException
+ {
+ try
+ {
+ server.start();
+ }
+ catch ( MultiException e )
+ {
+ throw new StartingException( "Error starting the jetty webdav server: ", e );
+ }
+ }
+
+ public void stop()
+ throws StoppingException
+ {
+ try
+ {
+ server.stop();
+ }
+ catch ( InterruptedException e )
+ {
+ throw new StoppingException( "Error stopping the jetty webdav server: ", e );
+ }
+ }
+}
Propchange: maven/sandbox/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/ServletServer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/ServletServer.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/sandbox/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavWagonTest.java
URL: http://svn.apache.org/viewcvs/maven/sandbox/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavWagonTest.java?rev=393043&view=auto
==============================================================================
--- maven/sandbox/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavWagonTest.java (added)
+++ maven/sandbox/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavWagonTest.java Mon Apr 10 13:15:31 2006
@@ -0,0 +1,64 @@
+package org.apache.maven.wagon.providers.webdav;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.IOException;
+
+import org.apache.maven.wagon.FileTestUtils;
+import org.apache.maven.wagon.WagonTestCase;
+
+/**
+ * WebDAV Wagon Test
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ */
+public class WebDavWagonTest
+ extends WagonTestCase
+{
+ private ServletServer server;
+
+ protected String getTestRepositoryUrl()
+ throws IOException
+ {
+ return "dav:http://localhost:10007/dav";
+ }
+
+ protected String getProtocol()
+ {
+ return "dav";
+ }
+
+ protected void setupWagonTestingFixtures()
+ throws Exception
+ {
+ 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
+ {
+ release( server );
+ }
+}
Propchange: maven/sandbox/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavWagonTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavWagonTest.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/sandbox/wagon-webdav/src/test/resources/org/apache/maven/wagon/providers/webdav/WebDavWagonTest.xml
URL: http://svn.apache.org/viewcvs/maven/sandbox/wagon-webdav/src/test/resources/org/apache/maven/wagon/providers/webdav/WebDavWagonTest.xml?rev=393043&view=auto
==============================================================================
--- maven/sandbox/wagon-webdav/src/test/resources/org/apache/maven/wagon/providers/webdav/WebDavWagonTest.xml (added)
+++ maven/sandbox/wagon-webdav/src/test/resources/org/apache/maven/wagon/providers/webdav/WebDavWagonTest.xml Mon Apr 10 13:15:31 2006
@@ -0,0 +1,33 @@
+<plexus>
+ <components>
+ <component>
+ <role>org.apache.maven.wagon.providers.webdav.ServletServer</role>
+ <implementation>org.apache.maven.wagon.providers.webdav.ServletServer</implementation>
+ <configuration>
+ <port>10007</port>
+ <contexts>
+ <context>
+ <id>/dav</id>
+ <servlets>
+ <servlet>
+ <id>LOCALREPO</id>
+ <path>/*</path>
+ <servlet>it.could.webdav.DAVServlet</servlet>
+ <parameters>
+ <property>
+ <name>rootPath</name>
+ <value>${basedir}/target/test-output/dav-repository</value>
+ </property>
+ <property>
+ <name>xmlOnly</name>
+ <value>false</value>
+ </property>
+ </parameters>
+ </servlet>
+ </servlets>
+ </context>
+ </contexts>
+ </configuration>
+ </component>
+ </components>
+</plexus>
\ No newline at end of file
Propchange: maven/sandbox/wagon-webdav/src/test/resources/org/apache/maven/wagon/providers/webdav/WebDavWagonTest.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/wagon-webdav/src/test/resources/org/apache/maven/wagon/providers/webdav/WebDavWagonTest.xml
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"