You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wagon-commits@maven.apache.org by br...@apache.org on 2008/05/20 07:03:58 UTC
svn commit: r658099 [2/2] - in /maven/wagon/trunk:
wagon-provider-api/src/main/java/org/apache/maven/wagon/
wagon-provider-api/src/main/java/org/apache/maven/wagon/events/
wagon-provider-api/src/main/java/org/apache/maven/wagon/resource/
wagon-provider...
Modified: maven/wagon/trunk/wagon-providers/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/WebDavWagon.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/WebDavWagon.java?rev=658099&r1=658098&r2=658099&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/WebDavWagon.java (original)
+++ maven/wagon/trunk/wagon-providers/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/WebDavWagon.java Mon May 19 22:03:57 2008
@@ -19,45 +19,33 @@
* under the License.
*/
-import org.apache.commons.httpclient.HttpException;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
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.commons.httpclient.UsernamePasswordCredentials;
-import org.apache.maven.wagon.AbstractWagon;
-import org.apache.maven.wagon.ConnectionException;
-import org.apache.maven.wagon.LazyFileOutputStream;
+import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
+import org.apache.jackrabbit.webdav.DavConstants;
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.MultiStatus;
+import org.apache.jackrabbit.webdav.MultiStatusResponse;
+import org.apache.jackrabbit.webdav.client.methods.MkColMethod;
+import org.apache.jackrabbit.webdav.client.methods.PropFindMethod;
+import org.apache.jackrabbit.webdav.property.DavProperty;
+import org.apache.jackrabbit.webdav.property.DavPropertyName;
+import org.apache.jackrabbit.webdav.property.DavPropertyNameSet;
+import org.apache.jackrabbit.webdav.property.DavPropertySet;
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.apache.webdav.lib.WebdavResource;
-import org.apache.webdav.lib.methods.DepthSupport;
+import org.apache.maven.wagon.shared.http.AbstractHttpClientWagon;
import org.codehaus.plexus.util.FileUtils;
-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.io.OutputStream;
-import java.net.URL;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
-import java.util.Locale;
-import java.util.Properties;
-import java.util.Stack;
-import java.util.TimeZone;
+import org.w3c.dom.Node;
/**
* <p>WebDavWagon</p>
@@ -67,138 +55,15 @@
* @author <a href="mailto:hisidro@exist.com">Henry Isidro</a>
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
* @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
- * @plexus.component role="org.apache.maven.wagon.Wagon"
- * role-hint="dav"
- * instantiation-strategy="per-lookup"
+ * @author <a href="mailto:james@atlassian.com>James William Dumay</a>
+ *
+ * @plexus.component role="org.apache.maven.wagon.Wagon"
+ * role-hint="dav"
+ * instantiation-strategy="per-lookup"
*/
public class WebDavWagon
- extends AbstractWagon
+ extends AbstractHttpClientWagon
{
- private static final TimeZone TIMESTAMP_TIME_ZONE = TimeZone.getTimeZone( "GMT" );
-
- private static String wagonVersion;
-
- private DateFormat dateFormat = new SimpleDateFormat( "EEE, dd-MMM-yy HH:mm:ss zzz", Locale.US );
-
- private CorrectedWebdavResource webdavResource;
-
- public WebDavWagon()
- {
- dateFormat.setTimeZone( TIMESTAMP_TIME_ZONE );
-
- if ( wagonVersion == null )
- {
- URL pomUrl = this.getClass()
- .getResource( "/META-INF/maven/org.apache.maven.wagon/wagon-webdav/pom.properties" );
- if ( pomUrl == null )
- {
- wagonVersion = "";
- }
- else
- {
- Properties props = new Properties();
- try
- {
- props.load( pomUrl.openStream() );
- wagonVersion = props.getProperty( "version" );
- }
- catch ( IOException e )
- {
- wagonVersion = "";
- }
- }
- }
- }
-
- /**
- * Opens a connection via web-dav resource
- *
- * @throws AuthenticationException
- * @throws ConnectionException
- */
- public void openConnectionInternal()
- throws AuthenticationException, ConnectionException
- {
- final boolean hasProxy = ( proxyInfo != null && proxyInfo.getUserName() != null );
- final boolean hasAuthentication = ( authenticationInfo != null && authenticationInfo.getUserName() != null );
-
- String url = getURL( repository );
-
- repository.setUrl( url );
-
- HttpURL httpURL = null;
-
- try
- {
- httpURL = urlToHttpURL( url );
-
- if ( hasAuthentication )
- {
- String userName = authenticationInfo.getUserName();
- String password = authenticationInfo.getPassword();
-
- if ( userName != null && password != null )
- {
- httpURL.setUserinfo( userName, password );
- }
- }
-
- CorrectedWebdavResource.setDefaultAction( CorrectedWebdavResource.NOACTION );
- webdavResource = new CorrectedWebdavResource( httpURL );
- webdavResource.setConnectionTimeout(getTimeout());
-
- if ( hasProxy )
- {
- webdavResource.setProxy( proxyInfo.getHost(), proxyInfo.getPort() );
- if ( !StringUtils.isEmpty( proxyInfo.getUserName() ) )
- {
- UsernamePasswordCredentials proxyCredentials = new UsernamePasswordCredentials();
- proxyCredentials.setUserName( proxyInfo.getUserName() );
- proxyCredentials.setPassword( proxyInfo.getPassword() );
- webdavResource.setProxyCredentials( proxyCredentials );
- }
- }
- }
- catch ( HttpException he )
- {
- throw new ConnectionException( "Connection Exception: " + url + " " + he.getReasonCode() + " " +
- HttpStatus.getStatusText( he.getReasonCode() ), he );
- }
- 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
- {
- if ( webdavResource != null )
- {
- webdavResource.close();
- }
- }
- catch ( IOException ioe )
- {
- throw new ConnectionException( "Connection Exception: " + ioe.getMessage(), ioe );
- }
- finally
- {
- webdavResource = null;
- }
- }
-
/**
* Puts a file into the remote repository
*
@@ -231,57 +96,20 @@
firePutInitiated( resource, source );
+ //Parent directories need to be created before posting
mkdirs( dir );
- try
- {
- // Put source into destination path.
- firePutStarted( resource, source );
-
- InputStream is = new PutInputStream( source, resource, this, getTransferEventSupport() );
- boolean success = webdavResource.putMethod( dest, is, (int) source.length() );
- int statusCode = webdavResource.getStatusCode();
-
- switch ( statusCode )
- {
- case HttpStatus.SC_OK:
- break;
-
- case HttpStatus.SC_CREATED:
- break;
-
- case HttpStatus.SC_FORBIDDEN:
- throw new AuthorizationException( "Access denied to: " + dest );
-
- case HttpStatus.SC_NOT_FOUND:
- // should never happen as the destination is created before or fail
- throw new TransferFailedException( "Destination folder could not be created: " + dest );
-
- case HttpStatus.SC_LENGTH_REQUIRED:
- throw new TransferFailedException( "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 + " " + HttpStatus.getStatusText( 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";
+ super.put(source, resource);
+ }
- throw new TransferFailedException( msg, e );
- }
- firePutCompleted( resource, source );
+ /**
+ * This wagon supports directory copying
+ *
+ * @return <code>true</code> always
+ */
+ public boolean supportsDirectoryCopy()
+ {
+ return true;
}
/**
@@ -296,289 +124,55 @@
{
Repository repository = getRepository();
String basedir = repository.getBasedir();
- String destinationPath = webdavResource.getPath();
String relpath = FileUtils.normalize( getPath( basedir, dir ) + "/" );
- String currentPath = relpath;
- Stack directoriesToBeCreated = new Stack();
-
- try
+ PathNavigator navigator = new PathNavigator(relpath);
+
+ // traverse backwards until we hit a directory that already exists (OK/NOT_ALLOWED), or that we were able to
+ // create (CREATED), or until we get to the top of the path
+ int status = SC_NULL;
+ while ( navigator.backward() )
{
- while ( currentPath != null )
- {
- webdavResource.setPath( currentPath );
-
- /* needed to call webdavResource.exists() later */
- try
- {
- webdavResource.setProperties( WebdavResource.NAME, DepthSupport.DEPTH_0 );
- }
- catch ( HttpException e )
- {
- // ignore exceptions thrown when the path does not exist ( 404 errors )
- }
-
- if ( webdavResource.exists() )
- {
- if ( webdavResource.isCollection() )
- {
- /* path exists and it's a directory */
- break;
- }
- else
- {
- throw new TransferFailedException(
- "Destination path exists and is not a WebDAV collection (directory): " +
- webdavResource.toString() );
- }
- }
-
- /* if dest resource path does not exist, create it later */
- directoriesToBeCreated.push( currentPath );
-
- /* go down a folder */
- currentPath += "/../";
- currentPath = FileUtils.normalize( currentPath );
- }
-
- // mkcolMethod() cannot create a directory hierarchy at once,
- // it has to create each directory one at a time
- while ( !directoriesToBeCreated.empty() )
+ String url = getUrl( navigator );
+ status = doMkCol( url );
+ if ( status == HttpStatus.SC_OK || status == HttpStatus.SC_CREATED
+ || status == HttpStatus.SC_METHOD_NOT_ALLOWED )
{
- currentPath = (String) directoriesToBeCreated.pop();
- if ( currentPath.equals( "/" ) )
- {
- /* Impossible to create root directory, skip */
- continue;
- }
- webdavResource.setPath( currentPath );
-
- try
- {
- boolean destinationCreated = webdavResource.mkcolMethod( currentPath );
- if ( !destinationCreated )
- {
- throw new TransferFailedException( "Destination folder [" + currentPath +
- "] could not be created: " + webdavResource.toString() + " - Server returned error: " +
- webdavResource.getStatusCode() + ": " +
- HttpStatus.getStatusText( webdavResource.getStatusCode() ) );
- }
- }
- catch ( IOException e )
- {
- throw new TransferFailedException( "Failed to create destination WebDAV collection (directory) [" +
- currentPath + "]: " + webdavResource.toString(), e );
- }
+ break;
}
-
- webdavResource.setPath( destinationPath );
- }
- catch ( HttpException e )
- {
- throw new TransferFailedException( "Unknown error creating destination WebDAV collection (directory): " +
- webdavResource.toString() + ". Server returned error: " + HttpStatus.getStatusText( e.getReasonCode() ),
- e );
}
- catch ( IOException e )
- {
- throw new TransferFailedException(
- "Unknown error creating destination WebDAV collection (directory): " + webdavResource.toString(), e );
- }
- }
- /**
- * Converts a String url to an HttpURL
- *
- * @param url String url to convert to an HttpURL
- * @return an HttpURL object created from the String url
- * @throws URIException
- */
- private HttpURL urlToHttpURL( String url )
- throws URIException
- {
- if ( url.startsWith( "https" ) )
+ // traverse forward creating missing directories
+ while ( navigator.forward() )
{
- return new HttpsURL( url );
- }
- else
- {
- return new HttpURL( url );
- }
- }
-
- /**
- * Determine which URI to use at the prompt.
- *
- * @param uri the path to be set.
- * @return the normalized path.
- * @see FileUtils#normalize(String)
- */
- private String checkUri( String uri )
- throws IOException
- {
-
- if ( webdavResource == null )
- {
- throw new IOException( "Not connected yet." );
- }
-
- if ( uri == null )
- {
- uri = webdavResource.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 );
- }
-
- /**
- * Get a file from remote server
- *
- * @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;
-
- addRequestHeaders();
- webdavResource.addRequestHeader( "Accept-Encoding", "gzip" );
-
- if ( timestamp > 0 )
- {
- webdavResource.addRequestHeader( "If-Modified-Since", dateFormat.format( new Date( timestamp ) ) );
- }
-
- InputStream is = null;
- OutputStream output = new LazyFileOutputStream( destination );
- try
- {
- is = webdavResource.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 = webdavResource.getStatusCode();
- switch ( statusCode )
+ String url = getUrl( navigator );
+ status = doMkCol( url );
+ if ( status != HttpStatus.SC_OK && status != HttpStatus.SC_CREATED )
{
- case HttpStatus.SC_NOT_MODIFIED:
- return false;
-
- case HttpStatus.SC_FORBIDDEN:
- throw new AuthorizationException( "Access denied 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 transfer file: " + url + ". Return code is: " + statusCode, e );
+ throw new TransferFailedException( "Unable to create collection: " + url + "; status code = " + status );
}
}
- finally
- {
- IOUtil.close( is );
- IOUtil.close( output );
- }
-
- int statusCode = webdavResource.getStatusCode();
-
- switch ( statusCode )
- {
- case HttpStatus.SC_OK:
- return true;
-
- case HttpStatus.SC_NOT_MODIFIED:
- return false;
-
- case HttpStatus.SC_FORBIDDEN:
- throw new AuthorizationException( "Access denied 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 transfer file: " + url + ". Return code is: " + statusCode );
- }
-
}
- private String getURL( Repository repository )
+ private int doMkCol(String url) throws TransferFailedException
{
- String url = repository.getUrl();
- String s = "dav:";
- if ( url.startsWith( s ) )
+ MkColMethod method = null;
+ try
{
- return url.substring( s.length() );
+ method = new MkColMethod(url);
+ return execute(method);
}
- else
+ finally
{
- return url;
+ if (method != null) method.releaseConnection();
}
}
- /**
- * This wagon supports directory copying
- *
- * @return <code>true</code> always
- */
- public boolean supportsDirectoryCopy()
+ private String getUrl(PathNavigator navigator)
{
- return true;
+ String url = getRepository().getUrl().replaceAll(getRepository().getBasedir(), "");
+ return url + '/' + navigator.getPath();
}
/**
@@ -611,104 +205,107 @@
}
- public List getFileList( String destinationDirectory )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ private boolean isDirectory(String url) throws TransferFailedException
{
- addRequestHeaders();
-
- String basedir = repository.getBasedir();
+ DavPropertyNameSet nameSet = new DavPropertyNameSet();
+ nameSet.add(DavPropertyName.create(DavConstants.PROPERTY_RESOURCETYPE));
- if ( !destinationDirectory.endsWith( "/" ) )
+ PropFindMethod method = null;
+ try
{
- destinationDirectory += "/";
+ method = new PropFindMethod(url, nameSet, DavConstants.DEPTH_0);
+ execute(method);
+ if (method.succeeded())
+ {
+ MultiStatus multiStatus = method.getResponseBodyAsMultiStatus();
+ MultiStatusResponse response = multiStatus.getResponses()[0];
+ DavPropertySet propertySet = response.getProperties(HttpStatus.SC_OK);
+ DavProperty property = propertySet.get(DavConstants.PROPERTY_RESOURCETYPE);
+ if (property != null)
+ {
+ Node node = (Node)property.getValue();
+ return node.getLocalName().equals(DavConstants.XML_COLLECTION);
+ }
+ }
+ return false;
}
-
- String cleanDestDir = StringUtils.replace( destinationDirectory, "\\", "/" );
- String dir = PathUtils.dirname( cleanDestDir );
- dir = StringUtils.replace( dir, "\\", "/" );
-
- String oldpath = webdavResource.getPath();
- String relpath = getPath( basedir, dir );
-
- try
+ catch (DavException e)
+ {
+ throw new TransferFailedException(e.getMessage(), e);
+ }
+ catch (IOException e)
+ {
+ throw new TransferFailedException(e.getMessage(), e);
+ }
+ finally
{
- // Test if dest resource path exist.
- String cdpath = checkUri( relpath + "/" );
- webdavResource.setPath( cdpath );
+ if (method != null) method.releaseConnection();
+ }
+ }
+ public List getFileList( String destinationDirectory )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ final String url = getRepository().getUrl() + '/' + destinationDirectory;
+ if (isDirectory(url))
+ {
+ PropFindMethod method = null;
try
{
- webdavResource.setProperties( WebdavResource.NAME, DepthSupport.DEPTH_0 );
+ DavPropertyNameSet nameSet = new DavPropertyNameSet();
+ nameSet.add(DavPropertyName.create(DavConstants.PROPERTY_DISPLAYNAME));
- /* seems this is not needed as Webdav client causes a 404 error in webdavResource.setProperties */
- if ( !webdavResource.exists() )
+ method = new PropFindMethod(url, nameSet, DavConstants.DEPTH_1);
+ int status = execute(method);
+ if (method.succeeded())
{
- throw new ResourceDoesNotExistException( "Destination directory does not exist: " + cdpath );
- }
+ ArrayList dirs = new ArrayList();
+ MultiStatus multiStatus = method.getResponseBodyAsMultiStatus();
- if ( !webdavResource.isCollection() )
- {
- throw new ResourceDoesNotExistException(
- "Destination path exists but is not a " + "WebDAV collection (directory): " + cdpath );
+ for (int i = 0; i < multiStatus.getResponses().length; i++)
+ {
+ MultiStatusResponse response = multiStatus.getResponses()[i];
+ String fileName = PathUtils.filename(response.getHref());
+ if (!StringUtils.isEmpty(fileName))
+ {
+ dirs.add(fileName);
+ }
+ }
+ return dirs;
}
-
- String[] entries = webdavResource.list();
-
- List filelist = new ArrayList();
- if ( entries != null )
+
+ if (status == HttpStatus.SC_NOT_FOUND)
{
- filelist.addAll( Arrays.asList( entries ) );
+ throw new ResourceDoesNotExistException( "Destination directory does not exist: " + url );
}
-
- return filelist;
}
- catch ( HttpException e )
+ catch (DavException e)
{
- if ( e.getReasonCode() == HttpStatus.SC_NOT_FOUND )
- {
- throw new ResourceDoesNotExistException( "Destination directory does not exist: " + cdpath, e );
- }
- else
- {
- throw new TransferFailedException( "Unable to obtain file list from WebDAV collection, " +
- "HTTP error: " + HttpStatus.getStatusText( e.getReasonCode() ), e );
- }
+ throw new TransferFailedException(e.getMessage(), e);
+ }
+ catch (IOException e)
+ {
+ throw new TransferFailedException(e.getMessage(), e);
}
finally
{
- webdavResource.setPath( oldpath );
+ if (method != null) method.releaseConnection();
}
-
- }
- catch ( IOException e )
- {
- throw new TransferFailedException( "Unable to obtain file list from WebDAV collection.", e );
}
+ throw new ResourceDoesNotExistException("Destination path exists but is not a " + "WebDAV collection (directory): " + url );
}
-
- private void addRequestHeaders()
- {
- webdavResource.addRequestHeader( "X-wagon-provider", "wagon-webdav" );
- webdavResource.addRequestHeader( "X-wagon-version", wagonVersion );
-
- webdavResource.addRequestHeader( "Cache-control", "no-cache" );
- webdavResource.addRequestHeader( "Cache-store", "no-store" );
- webdavResource.addRequestHeader( "Pragma", "no-cache" );
- webdavResource.addRequestHeader( "Expires", "0" );
- }
-
- public boolean resourceExists( String resourceName )
- throws TransferFailedException, AuthorizationException
+
+ protected String getURL( Repository repository )
{
- try
+ String url = repository.getUrl();
+ String s = "dav:";
+ if ( url.startsWith( s ) )
{
- String parentDirectory = PathUtils.dirname( resourceName );
- List entries = getFileList( parentDirectory );
- return entries.contains( resourceName );
+ return url.substring( s.length() );
}
- catch ( ResourceDoesNotExistException e )
+ else
{
- return false;
+ return url;
}
}
}
Modified: maven/wagon/trunk/wagon-providers/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavWagonGzipTest.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavWagonGzipTest.java?rev=658099&r1=658098&r2=658099&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavWagonGzipTest.java (original)
+++ maven/wagon/trunk/wagon-providers/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavWagonGzipTest.java Mon May 19 22:03:57 2008
@@ -28,15 +28,14 @@
import org.apache.maven.wagon.FileTestUtils;
import org.apache.maven.wagon.Wagon;
import org.apache.maven.wagon.repository.Repository;
+import org.codehaus.plexus.PlexusTestCase;
import org.codehaus.plexus.util.FileUtils;
import org.mortbay.http.HttpContext;
import org.mortbay.http.HttpServer;
import org.mortbay.http.SocketListener;
import org.mortbay.http.handler.ResourceHandler;
-import junit.framework.TestCase;
-
-public class WebDavWagonGzipTest extends TestCase
+public class WebDavWagonGzipTest extends PlexusTestCase
{
public void testGzipGet() throws Exception
{
@@ -57,7 +56,7 @@
try
{
- Wagon wagon = new WebDavWagon();
+ Wagon wagon = (Wagon)lookup("org.apache.maven.wagon.Wagon", "dav");
Repository testRepository = new Repository();
Modified: maven/wagon/trunk/wagon-providers/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavWagonTest.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavWagonTest.java?rev=658099&r1=658098&r2=658099&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavWagonTest.java (original)
+++ maven/wagon/trunk/wagon-providers/wagon-webdav/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavWagonTest.java Mon May 19 22:03:57 2008
@@ -19,16 +19,12 @@
* under the License.
*/
-import org.apache.maven.wagon.FileTestUtils;
-import org.apache.maven.wagon.TransferFailedException;
-import org.apache.maven.wagon.Wagon;
-import org.apache.maven.wagon.WagonTestCase;
-import org.apache.maven.wagon.authentication.AuthenticationInfo;
-import org.codehaus.plexus.util.FileUtils;
-
import java.io.File;
import java.io.IOException;
+import org.apache.maven.wagon.FileTestUtils;
+import org.apache.maven.wagon.WagonTestCase;
+
/**
* WebDAV Wagon Test
*
@@ -74,31 +70,4 @@
{
release( server );
}
-
- public void testWagonPutToNonWebdav()
- throws Exception
- {
- setupRepositories();
-
- String url = "http://localhost:10007";
-
- testRepository.setUrl( "dav:" + url );
-
- setupWagonTestingFixtures();
-
- try
- {
- putFile();
- fail( "Expected and not thrown " + TransferFailedException.class.getName() );
- }
- catch ( TransferFailedException e )
- {
- assertEquals( "Exception message doesn't match expected",
- "Destination folder could not be created: " + url + "/test-resource", e.getMessage() );
- }
-
- testRepository.setUrl( getTestRepositoryUrl() );
-
- tearDownWagonTestingFixtures();
- }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: wagon-commits-unsubscribe@maven.apache.org
For additional commands, e-mail: wagon-commits-help@maven.apache.org