Initial revision
git-svn-id: https://svn.apache.org/repos/asf/maven/wagon/trunk@162318 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/.cvsignore b/.cvsignore
new file mode 100644
index 0000000..db40082
--- /dev/null
+++ b/.cvsignore
@@ -0,0 +1,10 @@
+*.log
+target
+.classpath
+.project
+default.lst
+test.out
+default.ajsym
+*.iml
+*.ipr
+*.iws
diff --git a/project.properties b/project.properties
new file mode 100644
index 0000000..c950f58
--- /dev/null
+++ b/project.properties
@@ -0,0 +1,3 @@
+maven.multiproject.includes=wagon-api/project.xml,wagon-providers/file/project.xml,wagon-providers/http/project.xml,wagon-providers/ftp/project.xml,wagon-providers/ssh/project.xml,wagon-plexus-bindings/project.xml
+maven.idea.project.multiproject.includes=wagon-api/project.xml,wagon-providers/file/project.xml,wagon-providers/http/project.xml,wagon-providers/ftp/project.xml,wagon-providers/ssh/project.xml,wagon-maven-bindings/project.xml
+maven.idea.project.multiproject.basedir=.
\ No newline at end of file
diff --git a/project.xml b/project.xml
new file mode 100644
index 0000000..7c09c30
--- /dev/null
+++ b/project.xml
@@ -0,0 +1,116 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project>
+ <pomVersion>3</pomVersion>
+ <id>wagon</id>
+ <groupId>maven</groupId>
+ <artifactId>wagon</artifactId>
+ <name>Wagon</name>
+ <currentVersion>1.0-beta-1</currentVersion>
+ <description></description>
+ <shortDescription>Tools to manage artifacts and deployment</shortDescription>
+ <package>org.apache.maven.wagon</package>
+ <inceptionYear>2003</inceptionYear>
+
+ <organization>
+ <name>Apache Software Foundation</name>
+ <url>http://www.apache.org/</url>
+ <logo>http://maven.apache.org/images/apache-maven-project.png</logo>
+ </organization>
+
+ <mailingLists>
+ <mailingList>
+ <name>Wgaon User List</name>
+ <subscribe>wagon-users-subscribe@maven.apache.org</subscribe>
+ <unsubscribe>wagon-users-unsubscribe@maven.apache.org</unsubscribe>
+ <archive>http://nagoya.apache.org/eyebrowse/SummarizeList?listName=wagon-users@maven.apache.org</archive>
+ </mailingList>
+ <mailingList>
+ <name>Wagon Developer List</name>
+ <subscribe>wagon-dev-subscribe@maven.apache.org</subscribe>
+ <unsubscribe>wagon-dev-unsubscribe@maven.apache.org</unsubscribe>
+ <archive>http://nagoya.apache.org/eyebrowse/SummarizeList?listName=wagon-dev@maven.apache.org</archive>
+ </mailingList>
+ </mailingLists>
+
+ <developers>
+ <developer>
+ <name>Michal Maczka</name>
+ <id>michal</id>
+ <email>michal@dimatics.com</email>
+ <organization>Dimatics</organization>
+ <roles>
+ <role>Architect</role>
+ </roles>
+ </developer>
+ </developers>
+
+ <licenses>
+ <license>
+ <name>The Apache Software License, Version 1.1</name>
+ <url>http://cvs.apache.org/viewcvs.cgi/*checkout*/maven/LICENSE.txt</url>
+ <distribution>repo</distribution>
+ </license>
+ </licenses>
+
+ <dependencies>
+ <dependency>
+ <groupId>plexus</groupId>
+ <artifactId>plexus</artifactId>
+ <version>0.14-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>xpp3</groupId>
+ <artifactId>xpp3</artifactId>
+ <version>1.1.3.3</version>
+ </dependency>
+ <dependency>
+ <groupId>classworlds</groupId>
+ <artifactId>classworlds</artifactId>
+ <version>1.1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>xstream</groupId>
+ <artifactId>xstream</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+ <!-- Testing -->
+ <dependency>
+ <groupId>maven</groupId>
+ <artifactId>maven-model</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <sourceDirectory>src/main/java</sourceDirectory>
+ <unitTestSourceDirectory>src/test/java</unitTestSourceDirectory>
+ <unitTest>
+ <includes>
+ <include>**/*Test.java</include>
+ </includes>
+ <resources>
+ <resource>
+ <directory>src/test/resources</directory>
+ </resource>
+ <resource>
+ <directory>src/test/java</directory>
+ <includes>
+ <include>**/*.xml</include>
+ </includes>
+ </resource>
+ </resources>
+ </unitTest>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ </resource>
+ </resources>
+ </build>
+
+</project>
diff --git a/wagon-provider-api/.cvsignore b/wagon-provider-api/.cvsignore
new file mode 100644
index 0000000..db40082
--- /dev/null
+++ b/wagon-provider-api/.cvsignore
@@ -0,0 +1,10 @@
+*.log
+target
+.classpath
+.project
+default.lst
+test.out
+default.ajsym
+*.iml
+*.ipr
+*.iws
diff --git a/wagon-provider-api/LICENSE.txt b/wagon-provider-api/LICENSE.txt
new file mode 100644
index 0000000..d645695
--- /dev/null
+++ b/wagon-provider-api/LICENSE.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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.
diff --git a/wagon-provider-api/checkstyle.xml b/wagon-provider-api/checkstyle.xml
new file mode 100644
index 0000000..bf04220
--- /dev/null
+++ b/wagon-provider-api/checkstyle.xml
@@ -0,0 +1,153 @@
+<?xml version="1.0"?>
+<!DOCTYPE module PUBLIC
+ "-//Puppy Crawl//DTD Check Configuration 1.1//EN"
+ "http://www.puppycrawl.com/dtds/configuration_1_1.dtd">
+
+<!--
+ Checkstyle checks configured for Maven.
+-->
+
+<module name="Checker">
+
+ <!-- Checks that a package.html file exists for each package. -->
+ <!-- See http://checkstyle.sf.net/config_javadoc.html#PackageHtml -->
+ <module name="PackageHtml"/>
+
+ <!-- Checks whether files end with a new line. -->
+ <!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile -->
+ <module name="NewlineAtEndOfFile"/>
+
+ <!-- Checks that property files contain the same keys. -->
+ <!-- See http://checkstyle.sf.net/config_misc.html#Translation -->
+ <module name="Translation"/>
+
+ <module name="TreeWalker">
+
+ <property name="cacheFile" value="${checkstyle.cache.file}"/>
+
+ <!-- ************************************************************** -->
+ <!-- Checks that are different from the sun coding conventions ones -->
+ <!-- ************************************************************** -->
+ <module name="Header">
+ <property name="headerFile" value="${basedir}/LICENSE.txt"/>
+ <property name="ignoreLines" value="1,2,3,4,5,6"/>
+ </module>
+ <property name="tabWidth" value="4"/>
+ <module name="LeftCurly">
+ <property name="option" value="nl"/>
+ </module>
+ <module name="RightCurly">
+ <property name="option" value="alone"/>
+ </module>
+ <module name="LineLength">
+ <property name="max" value="132"/>
+ </module>
+ <module name="MethodLength">
+ <property name="max" value="175"/>
+ </module>
+ <!-- No Paren pad check
+ <module name="ParenPad"/>
+ -->
+ <module name="ConstantName">
+ <property name="format" value="log|^[a-zA-Z][a-zA-Z0-9_]*$"/>
+ </module>
+
+ <!-- ************************************************************** -->
+ <!-- Default Sun coding conventions checks -->
+ <!-- ************************************************************** -->
+
+ <!-- Checks for Javadoc comments. -->
+ <!-- See http://checkstyle.sf.net/config_javadoc.html -->
+ <module name="JavadocMethod"/>
+ <module name="JavadocType"/>
+ <module name="JavadocVariable"/>
+
+
+ <!-- Checks for Naming Conventions. -->
+ <!-- See http://checkstyle.sf.net/config_naming.html -->
+ <module name="LocalFinalVariableName"/>
+ <module name="LocalVariableName"/>
+ <module name="MethodName"/>
+ <module name="PackageName"/>
+ <module name="ParameterName"/>
+ <module name="StaticVariableName"/>
+ <module name="TypeName"/>
+ <module name="MemberName"/>
+
+ <!-- Checks for imports -->
+ <!-- See http://checkstyle.sf.net/config_import.html -->
+ <module name="AvoidStarImport"/>
+ <module name="IllegalImport"/> <!-- defaults to sun.* packages -->
+ <module name="RedundantImport"/>
+ <module name="UnusedImports"/>
+
+
+ <!-- Checks for Size Violations. -->
+ <!-- See http://checkstyle.sf.net/config_sizes.html -->
+ <module name="FileLength"/>
+ <module name="ParameterNumber"/>
+
+
+ <!-- Checks for whitespace -->
+ <!-- See http://checkstyle.sf.net/config_whitespace.html -->
+ <module name="EmptyForIteratorPad"/>
+ <module name="NoWhitespaceAfter"/>
+ <module name="NoWhitespaceBefore"/>
+ <module name="OperatorWrap"/>
+ <module name="TabCharacter"/>
+ <module name="WhitespaceAfter"/>
+ <module name="WhitespaceAround"/>
+
+
+ <!-- Modifier Checks -->
+ <!-- See http://checkstyle.sf.net/config_modifiers.html -->
+ <module name="ModifierOrder"/>
+ <module name="RedundantModifier"/>
+
+
+ <!-- Checks for blocks. You know, those {}'s -->
+ <!-- See http://checkstyle.sf.net/config_blocks.html -->
+ <module name="AvoidNestedBlocks"/>
+ <module name="EmptyBlock"/>
+
+ <module name="NeedBraces"/>
+
+
+ <!-- Checks for common coding problems -->
+ <!-- See http://checkstyle.sf.net/config_coding.html -->
+ <module name="AvoidInlineConditionals"/>
+ <module name="DoubleCheckedLocking"/> <!-- MY FAVOURITE -->
+ <module name="EmptyStatement"/>
+ <module name="EqualsHashCode"/>
+ <module name="HiddenField"/>
+ <module name="IllegalInstantiation"/>
+ <module name="InnerAssignment"/>
+ <module name="MagicNumber"/>
+ <module name="MissingSwitchDefault"/>
+ <!--<module name="RedundantThrows"/>-->
+ <module name="SimplifyBooleanExpression"/>
+ <module name="SimplifyBooleanReturn"/>
+
+ <!-- Checks for class design -->
+ <!-- See http://checkstyle.sf.net/config_design.html -->
+ <!--<module name="DesignForExtension"/>-->
+ <module name="FinalClass"/>
+ <module name="HideUtilityClassConstructor"/>
+ <module name="InterfaceIsType"/>
+ <module name="VisibilityModifier"/>
+
+
+ <!-- Miscellaneous other checks. -->
+ <!-- See http://checkstyle.sf.net/config_misc.html -->
+ <module name="ArrayTypeStyle"/>
+ <!-- <module name="FinalParameters"/> -->
+ <module name="GenericIllegalRegexp">
+ <property name="format" value="\s+$"/>
+ <property name="message" value="Line has trailing spaces."/>
+ </module>
+ <module name="TodoComment"/>
+ <module name="UpperEll"/>
+
+ </module>
+
+</module>
diff --git a/wagon-provider-api/destination b/wagon-provider-api/destination
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/wagon-provider-api/destination
diff --git a/wagon-provider-api/project.properties b/wagon-provider-api/project.properties
new file mode 100644
index 0000000..840882e
--- /dev/null
+++ b/wagon-provider-api/project.properties
@@ -0,0 +1,7 @@
+maven.junit.fork=true
+maven.repo.remote=http://dist.codehaus.org,http://www.ibiblio.org/maven
+
+# -------------------------------------------------------------------
+# C H E C K S T Y L E P R O P E R T I E S
+# -------------------------------------------------------------------
+maven.checkstyle.properties = ${basedir}/checkstyle.xml
diff --git a/wagon-provider-api/project.xml b/wagon-provider-api/project.xml
new file mode 100644
index 0000000..707a9cb
--- /dev/null
+++ b/wagon-provider-api/project.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project>
+ <extend>../project.xml</extend>
+ <groupId>maven</groupId>
+ <pomVersion>3</pomVersion>
+ <id>wagon-api</id>
+ <artifactId>wagon-api</artifactId>
+ <type>jar</type>
+ <name>Wagon API</name>
+ <currentVersion>0.9-SNAPSHOT</currentVersion>
+ <organization>
+ <name>Apache Software Foundation</name>
+ <url>http://www.apache.org/</url>
+ <logo>http://maven.apache.org/images/apache-maven-project.png</logo>
+ </organization>
+ <description></description>
+ <shortDescription>Tools to manage artifacts and deployment</shortDescription>
+ <description>
+ Wagon in general utility resource transport framework.
+ The Wagon API defines
+ the interfaces, clasess and their respective roles.
+ </description>
+ <package>org.apache.maven.wagon</package>
+ <inceptionYear>2003</inceptionYear>
+ <url>http://maven.apache.org/wagon/wagon-api</url>
+ <issueTrackingUrl>http://jira.codehaus.org/BrowseProject.jspa?id=10319</issueTrackingUrl>
+ <repository>
+ <connection>scm:cvs:pserver:anoncvs@cvs.apache.org:/home/cvspublic:maven-wagon/wagon-api</connection>
+ <url>http://cvs.apache.org/viewcvs/maven-wagon/wagon-api/</url>
+ </repository>
+
+ <dependencies>
+ </dependencies>
+
+ <developers>
+ <developer>
+ <name>Michal Maczka</name>
+ <id>michal</id>
+ <email>michal@dimatics.com</email>
+ <organization>Dimatics</organization>
+ <roles>
+ <role>Architect</role>
+ </roles>
+ </developer>
+ <developer>
+ <name>Jason van Zyl</name>
+ <id>jvanzyl</id>
+ <email>jason@maven.org</email>
+ <roles>
+ <role>Developer</role>
+ </roles>
+ </developer>
+ </developers>
+
+</project>
diff --git a/wagon-provider-api/repositories.xml b/wagon-provider-api/repositories.xml
new file mode 100644
index 0000000..ba8d3ad
--- /dev/null
+++ b/wagon-provider-api/repositories.xml
@@ -0,0 +1,14 @@
+<repositories>
+ <repository>
+ <id>test-source</id>
+ <name>Test source repository</name>
+ <url>file://target/test-source-repo</url>
+ <layout>${groupId}/${type}s/${artifactId}-${version}.${type}</layout>
+ </repository>
+ <repository>
+ <id>test-destination</id>
+ <name>Test destination repository</name>
+ <url>file://target/test-destination-repo</url>
+ <layout>${groupId}/${type}s/${artifactId}-${version}.${type}</layout>
+ </repository>
+</repositories>
\ No newline at end of file
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/AbstractWagon.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/AbstractWagon.java
new file mode 100644
index 0000000..97124d8
--- /dev/null
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/AbstractWagon.java
@@ -0,0 +1,440 @@
+package org.apache.maven.wagon;
+
+/*
+ * Copyright 2001-2004 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 org.apache.maven.wagon.artifact.Artifact;
+import org.apache.maven.wagon.events.SessionEvent;
+import org.apache.maven.wagon.events.SessionEventSupport;
+import org.apache.maven.wagon.events.SessionListener;
+import org.apache.maven.wagon.events.TransferEvent;
+import org.apache.maven.wagon.events.TransferEventSupport;
+import org.apache.maven.wagon.events.TransferListener;
+import org.apache.maven.wagon.repository.Repository;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+
+/**
+ * Implementation of common facilties for Wagon providers.
+ *
+ * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
+ * @version $Id$
+ */
+public abstract class AbstractWagon
+ implements Wagon
+{
+ private static final int DEFAULT_BUFFER_SIZE = 1024 * 4;
+
+ protected Repository source;
+
+ protected SessionEventSupport sessionEventSupport = new SessionEventSupport();
+
+ protected TransferEventSupport transferEventSupport = new TransferEventSupport();
+
+ // ----------------------------------------------------------------------
+ // Repository
+ // ----------------------------------------------------------------------
+
+ public Repository getRepository()
+ {
+ return source;
+ }
+
+ // ----------------------------------------------------------------------
+ // Connection
+ // ----------------------------------------------------------------------
+
+ public void connect( Repository source )
+ throws Exception
+ {
+ if ( source == null )
+ {
+ throw new IllegalStateException( "The repository specified cannot be null." );
+ }
+
+ this.source = source;
+
+ fireSessionOpening();
+
+ openConnection();
+
+ fireSessionOpened();
+ }
+
+ public void disconnect()
+ throws Exception
+ {
+ fireSessionDisconnecting();
+
+ closeConnection();
+
+ fireSessionDisconnected();
+ }
+
+ // ----------------------------------------------------------------------
+ // Stream i/o
+ // ----------------------------------------------------------------------
+
+ protected void getTransfer( String resource, InputStream input, OutputStream output )
+ throws TransferFailedException
+ {
+ fireGetStarted( resource );
+
+ try
+ {
+ transfer( resource, input, output, TransferEvent.REQUEST_GET );
+
+ closeGetTransferStreams( input, output );
+ }
+ catch ( IOException e )
+ {
+ fireTransferError( resource, e );
+
+ String msg = "GET request of: " + resource + " from " + source.getName() + "failed";
+
+ throw new TransferFailedException( msg, e );
+ }
+
+ fireGetCompleted( resource );
+ }
+
+ protected void putTransfer( String resource, InputStream input, OutputStream output )
+ throws TransferFailedException
+ {
+ firePutStarted( resource );
+
+ try
+ {
+ transfer( resource, input, output, TransferEvent.REQUEST_PUT );
+
+ closePutTransferStreams( input, output );
+ }
+ catch ( IOException e )
+ {
+ fireTransferError( resource, e );
+
+ String msg = "PUT request for: " + resource + " to " + source.getName() + "failed";
+
+ throw new TransferFailedException( msg, e );
+ }
+
+ firePutCompleted( resource );
+ }
+
+ protected void transfer( String resource, InputStream input, OutputStream output, int requestType )
+ throws IOException
+ {
+ byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
+
+ int n;
+
+ TransferEvent transferEvent = new TransferEvent( this, resource, TransferEvent.TRANSFER_PROGRESS, requestType );
+
+ while ( -1 != ( n = input.read( buffer ) ) )
+ {
+ // @todo probably new event should be created!!
+
+ transferEvent.setProgress( n );
+
+ transferEvent.setData( buffer, n );
+
+ output.write( buffer, 0, n );
+
+ fireTransferProgress( transferEvent );
+ }
+ }
+
+ protected void closeGetTransferStreams( InputStream is, OutputStream os )
+ {
+ closeTransferStreams( is, os );
+ }
+
+ protected void closePutTransferStreams( InputStream is, OutputStream os )
+ {
+ closeTransferStreams( is, os );
+ }
+
+ protected void closeTransferStreams( InputStream is, OutputStream os )
+ {
+ shutdownStream( is );
+
+ shutdownStream( os );
+ }
+
+ protected void shutdownStream( InputStream inputStream )
+ {
+ if ( inputStream != null )
+ {
+ try
+ {
+ inputStream.close();
+ }
+ catch ( Exception e )
+ {
+ }
+ }
+ }
+
+ protected void shutdownStream( OutputStream outputStream )
+ {
+ if ( outputStream != null )
+ {
+ try
+ {
+ outputStream.close();
+ }
+ catch ( Exception e )
+ {
+ }
+ }
+ }
+
+ // ----------------------------------------------------------------------
+ //
+ // ----------------------------------------------------------------------
+
+ protected String artifactUrl( Artifact artifact )
+ {
+ return source.artifactUrl( artifact );
+ }
+
+ protected String artifactPath( Artifact artifact )
+ {
+ return source.artifactPath( artifact );
+ }
+
+ protected String fullArtifactPath( Artifact artifact )
+ {
+ return source.fullArtifactPath( artifact );
+ }
+
+ // ----------------------------------------------------------------------
+ //
+ // ----------------------------------------------------------------------
+
+ protected void fireTransferProgress( TransferEvent transferEvent )
+ {
+ transferEventSupport.fireTransferProgress( transferEvent );
+ }
+
+ protected void fireGetCompleted( String resource )
+ {
+ long timestamp = System.currentTimeMillis();
+
+ TransferEvent transferEvent =
+ new TransferEvent( this, resource, TransferEvent.TRANSFER_COMPLETED, TransferEvent.REQUEST_GET );
+
+ transferEvent.setTimestamp( timestamp );
+
+ transferEventSupport.fireTransferCompleted( transferEvent );
+ }
+
+ protected void fireGetStarted( String resource )
+ {
+ long timestamp = System.currentTimeMillis();
+
+ TransferEvent transferEvent =
+ new TransferEvent( this, resource, TransferEvent.TRANSFER_STARTED, TransferEvent.REQUEST_GET );
+
+ transferEvent.setTimestamp( timestamp );
+
+ transferEventSupport.fireTransferStarted( transferEvent );
+ }
+
+ protected void firePutCompleted( String resource )
+ {
+ long timestamp = System.currentTimeMillis();
+
+ TransferEvent transferEvent =
+ new TransferEvent( this, resource, TransferEvent.TRANSFER_COMPLETED, TransferEvent.REQUEST_PUT );
+
+ transferEvent.setTimestamp( timestamp );
+
+ transferEventSupport.fireTransferCompleted( transferEvent );
+ }
+
+ protected void firePutStarted( String resource )
+ {
+ long timestamp = System.currentTimeMillis();
+
+ TransferEvent transferEvent =
+ new TransferEvent( this, resource, TransferEvent.TRANSFER_STARTED, TransferEvent.REQUEST_PUT );
+
+ transferEvent.setTimestamp( timestamp );
+
+ transferEventSupport.fireTransferStarted( transferEvent );
+ }
+
+ protected void fireSessionDisconnected()
+ {
+ long timestamp = System.currentTimeMillis();
+
+ SessionEvent sessionEvent = new SessionEvent( this, SessionEvent.SESSION_DISCONNECTED );
+
+ sessionEvent.setTimestamp( timestamp );
+
+ sessionEventSupport.fireSessionDisconnected( sessionEvent );
+ }
+
+ protected void fireSessionDisconnecting()
+ {
+ long timestamp = System.currentTimeMillis();
+
+ SessionEvent sessionEvent = new SessionEvent( this, SessionEvent.SESSION_DISCONNECTING );
+
+ sessionEvent.setTimestamp( timestamp );
+
+ sessionEventSupport.fireSessionDisconnecting( sessionEvent );
+ }
+
+ protected void fireSessionLoggedIn()
+ {
+ long timestamp = System.currentTimeMillis();
+
+ SessionEvent sessionEvent = new SessionEvent( this, SessionEvent.SESSION_LOGGED_IN );
+
+ sessionEvent.setTimestamp( timestamp );
+
+ sessionEventSupport.fireSessionLoggedIn( sessionEvent );
+ }
+
+ protected void fireSessionLoggedOff()
+ {
+ long timestamp = System.currentTimeMillis();
+
+ SessionEvent sessionEvent = new SessionEvent( this, SessionEvent.SESSION_LOGGED_OFF );
+
+ sessionEvent.setTimestamp( timestamp );
+
+ sessionEventSupport.fireSessionLoggedOff( sessionEvent );
+ }
+
+ protected void fireSessionOpened()
+ {
+ long timestamp = System.currentTimeMillis();
+
+ SessionEvent sessionEvent = new SessionEvent( this, SessionEvent.SESSION_OPENED );
+
+ sessionEvent.setTimestamp( timestamp );
+
+ sessionEventSupport.fireSessionOpened( sessionEvent );
+ }
+
+ protected void fireSessionOpening()
+ {
+ long timestamp = System.currentTimeMillis();
+
+ SessionEvent sessionEvent = new SessionEvent( this, SessionEvent.SESSION_OPENING );
+
+ sessionEvent.setTimestamp( timestamp );
+
+ sessionEventSupport.fireSessionOpening( sessionEvent );
+ }
+
+ protected void fireSessionConnectionRefused()
+ {
+
+ long timestamp = System.currentTimeMillis();
+
+ SessionEvent sessionEvent = new SessionEvent( this, SessionEvent.SESSION_CONNECTION_REFUSED );
+
+ sessionEvent.setTimestamp( timestamp );
+
+ sessionEventSupport.fireSessionConnectionRefused( sessionEvent );
+ }
+
+ protected void fireSessionError( Exception exception )
+ {
+ long timestamp = System.currentTimeMillis();
+
+ SessionEvent sessionEvent = new SessionEvent( this, exception );
+
+ sessionEvent.setTimestamp( timestamp );
+
+ sessionEventSupport.fireSessionError( sessionEvent );
+
+ }
+
+ protected void fireTransferDebug( String message )
+ {
+ transferEventSupport.fireDebug( message );
+ }
+
+ protected void fireSessionDebug( String message )
+ {
+ sessionEventSupport.fireDebug( message );
+ }
+
+ public boolean hasTransferListener( TransferListener listener )
+ {
+ return transferEventSupport.hasTransferListener( listener );
+ }
+
+ public void addTransferListener( TransferListener listener )
+ {
+ transferEventSupport.addTransferListener( listener );
+ }
+
+ public void removeTransferListener( TransferListener listener )
+ {
+ transferEventSupport.removeTransferListener( listener );
+ }
+
+ public void addSessionListener( SessionListener listener )
+ {
+ sessionEventSupport.addSessionListener( listener );
+ }
+
+ public boolean hasSessionListener( SessionListener listener )
+ {
+ return sessionEventSupport.hasSessionListener( listener );
+ }
+
+ public void removeSessionListener( SessionListener listener )
+ {
+ sessionEventSupport.removeSessionListener( listener );
+ }
+
+ protected void fireTransferError( String resource, Exception e )
+ {
+ TransferEvent transferEvent = new TransferEvent( this, resource, e );
+
+ transferEventSupport.fireTransferError( transferEvent );
+ }
+
+
+ public SessionEventSupport getSessionEventSupport()
+ {
+ return sessionEventSupport;
+ }
+
+ public void setSessionEventSupport( SessionEventSupport sessionEventSupport )
+ {
+ this.sessionEventSupport = sessionEventSupport;
+ }
+
+ public TransferEventSupport getTransferEventSupport()
+ {
+ return transferEventSupport;
+ }
+
+ public void setTransferEventSupport( TransferEventSupport transferEventSupport )
+ {
+ this.transferEventSupport = transferEventSupport;
+ }
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/ConnectionException.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/ConnectionException.java
new file mode 100644
index 0000000..f736f6b
--- /dev/null
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/ConnectionException.java
@@ -0,0 +1,45 @@
+package org.apache.maven.wagon;
+
+/*
+ * Copyright 2001-2004 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.
+ */
+
+/**
+ * The exception is thrown when a connection to repository cannot be estblished.
+ *
+ * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
+ * @version $Id$
+ */
+public class ConnectionException extends WagonException
+{
+
+
+ /**
+ * @see org.apache.maven.wagon.WagonException
+ */
+ public ConnectionException( final String message )
+ {
+ super( message );
+ }
+
+ /**
+ * @see org.apache.maven.wagon.WagonException
+ */
+ public ConnectionException( final String message, final Throwable cause )
+ {
+ super( message, cause );
+ }
+
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/PathUtils.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/PathUtils.java
new file mode 100644
index 0000000..d33bc96
--- /dev/null
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/PathUtils.java
@@ -0,0 +1,247 @@
+package org.apache.maven.wagon;
+
+/*
+ * Copyright 2001-2004 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.StringTokenizer;
+
+/**
+ * Various path (URL) manipulation routines
+ *
+ * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
+ * @version $Id$
+ */
+public class PathUtils
+{
+ /**
+ * Returns the directory path portion of a file specification string.
+ * Matches the equally named unix command.
+ *
+ * @return The directory portion excluding the ending file separator.
+ */
+ public static String dirname( final String path )
+ {
+ final int i = path.lastIndexOf( "/" );
+
+ return ( ( i >= 0 ) ? path.substring( 0, i ) : "" );
+ }
+
+ /**
+ * Returns the filename portion of a file specification string.
+ *
+ * @return The filename string with extension.
+ */
+ public static String filename( final String path )
+ {
+ final int i = path.lastIndexOf( "/" );
+ return ( ( i >= 0 ) ? path.substring( i + 1 ) : path );
+ }
+
+ public static String[] dirnames( final String path )
+ {
+ final String dirname = PathUtils.dirname( path );
+ return split( dirname, "/", -1 );
+
+ }
+
+ private static String[] split(
+ final String str,
+ final String separator,
+ final int max )
+ {
+ final StringTokenizer tok;
+ if ( separator == null )
+ {
+ // Null separator means we're using StringTokenizer's default
+ // delimiter, which comprises all whitespace characters.
+ tok = new StringTokenizer( str );
+ }
+ else
+ {
+ tok = new StringTokenizer( str, separator );
+ }
+
+ int listSize = tok.countTokens();
+ if ( max > 0 && listSize > max )
+ {
+ listSize = max;
+ }
+
+ final String[] list = new String[listSize];
+ int i = 0;
+ int lastTokenBegin;
+ int lastTokenEnd = 0;
+ while ( tok.hasMoreTokens() )
+ {
+ if ( max > 0 && i == listSize - 1 )
+ {
+ // In the situation where we hit the max yet have
+ // tokens left over in our input, the last list
+ // element gets all remaining text.
+ final String endToken = tok.nextToken();
+ lastTokenBegin = str.indexOf( endToken, lastTokenEnd );
+ list[i] = str.substring( lastTokenBegin );
+ break;
+ }
+ else
+ {
+ list[i] = tok.nextToken();
+ lastTokenBegin = str.indexOf( list[i], lastTokenEnd );
+ lastTokenEnd = lastTokenBegin + list[i].length();
+ }
+ i++;
+ }
+ return list;
+ }
+
+ /**
+ * Return the host name (Removes protocol and path from the URL) E.g: for input
+ * <code>http://www.codehause.org</code> this method will return <code>www.apache.org</code>
+ *
+ * @param url the url
+ *
+ * @return the host name
+ */
+ public static String host( final String url )
+ {
+ if ( url == null )
+ {
+ return "localhost";
+ }
+
+ final String protocol = PathUtils.protocol( url );
+ if ( protocol == null || protocol.equals( "file" ) )
+ {
+ return "";
+ }
+ String host = url.substring( url.indexOf( "://" ) + 3 ).trim();
+
+ int pos = host.indexOf( "/" );
+ if ( pos > 0 )
+ {
+ host = host.substring( 0, pos );
+ }
+ pos = host.indexOf( ":" );
+ if ( pos > 0 )
+ {
+ host = host.substring( 0, pos );
+ }
+ return host;
+ }
+
+ /**
+ * /**
+ * Return the protocol name.
+ * <br/>
+ * E.g: for input
+ * <code>http://www.codehause.org</code> this method will return <code>http</code>
+ *
+ * @param url the url
+ *
+ * @return the host name
+ */
+ public static String protocol( final String url )
+ {
+
+ final int pos = url.indexOf( "://" );
+ if ( pos == -1 )
+ {
+ return "";
+ }
+ return url.substring( 0, pos ).trim();
+ }
+
+ /**
+ * @param url
+ *
+ * @return
+ */
+ public static int port( final String url )
+ {
+
+ final String protocol = PathUtils.protocol( url );
+ if ( protocol == null || protocol.equals( "file" ) )
+ {
+ return WagonConstants.UNKNOWN_PORT;
+ }
+ final String host = PathUtils.host( url );
+ if ( host == null )
+ {
+ return WagonConstants.UNKNOWN_PORT;
+ }
+
+ final String prefix = protocol + "://" + host;
+ final int start = prefix.length();
+
+ if ( url.length() > start && url.charAt( start ) == ':' )
+ {
+ int end = url.indexOf( '/', start );
+ if ( end == -1 )
+ {
+ end = url.length();
+ }
+ return Integer.parseInt( url.substring( start + 1, end ) );
+ }
+ else
+ {
+ return WagonConstants.UNKNOWN_PORT;
+ }
+
+ }
+
+ /**
+ * @param url
+ *
+ * @return
+ */
+ public static String basedir( final String url )
+ {
+ final String protocol = PathUtils.protocol( url );
+ String retValue = null;
+ if ( protocol.equals( "file" ) )
+ {
+ retValue = url.substring( protocol.length() + 3 );
+ }
+ else
+ {
+ final String host = PathUtils.host( url );
+ final int port = PathUtils.port( url );
+ final int pos;
+ if ( port != WagonConstants.UNKNOWN_PORT )
+ {
+ pos = ( protocol + "://" + host + ":" + port + "/" ).length();
+
+ }
+ else
+ {
+ pos = ( protocol + "://" + host + "/" ).length();
+ }
+ if ( url.length() > pos )
+ {
+ retValue = url.substring( pos );
+
+ }
+
+ }
+
+ if ( retValue == null )
+ {
+ retValue = "";
+ }
+ return retValue.trim();
+ }
+
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/ResourceDoesNotExistException.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/ResourceDoesNotExistException.java
new file mode 100644
index 0000000..eff02a5
--- /dev/null
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/ResourceDoesNotExistException.java
@@ -0,0 +1,43 @@
+package org.apache.maven.wagon;
+
+/*
+ * Copyright 2001-2004 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.
+ */
+
+/**
+ * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
+ * @version $Id$
+ */
+public class ResourceDoesNotExistException extends WagonException
+{
+
+ /**
+ * @param message
+ */
+ public ResourceDoesNotExistException( final String message )
+ {
+ super( message );
+ }
+
+ /**
+ * @param message
+ * @param cause
+ */
+ public ResourceDoesNotExistException( final String message, final Throwable cause )
+ {
+ super( message, cause );
+ }
+
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/StreamWagon.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/StreamWagon.java
new file mode 100644
index 0000000..29543dd
--- /dev/null
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/StreamWagon.java
@@ -0,0 +1,120 @@
+package org.apache.maven.wagon;
+
+/*
+ * Copyright 2001-2004 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 org.apache.maven.wagon.artifact.Artifact;
+import org.apache.maven.wagon.authorization.AuthorizationException;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+public abstract class StreamWagon
+ extends AbstractWagon
+{
+ public abstract InputStream getInputStream( Artifact artifact )
+ throws Exception;
+
+ public abstract OutputStream getOutputStream( Artifact artifact )
+ throws Exception;
+
+ public abstract void openConnection()
+ throws Exception;
+
+ public abstract void closeConnection()
+ throws Exception;
+
+ //!! destination directory doesn't exist exception
+ public void get( Artifact artifact, File destination )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ String resource = artifactUrl( artifact );
+
+ if ( !destination.getParentFile().exists() )
+ {
+ if ( !destination.getParentFile().mkdirs() )
+ {
+ throw new TransferFailedException( "Specified destination directory cannot be created: " + destination.getParentFile() );
+ }
+ }
+
+ FileOutputStream os = null;
+
+ try
+ {
+ os = new FileOutputStream( destination );
+ }
+ catch ( FileNotFoundException e )
+ {
+ // This is taken care of above, if we cannot create the
+ // parent directory then an exception will be thrown above.
+ }
+
+ InputStream is;
+
+ try
+ {
+ is = getInputStream( artifact );
+ }
+ catch ( Exception e )
+ {
+ throw new TransferFailedException( "Cannot create input stream: ", e );
+ }
+
+ getTransfer( resource, is, os );
+ }
+
+ // source doesn't exist exception
+ public void put( File source, Artifact artifact )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ String resource = artifactUrl( artifact );
+
+ if ( !source.exists() )
+ {
+ throw new TransferFailedException( "Specified source file does not exist: " + source );
+ }
+
+ FileInputStream is = null;
+
+ try
+ {
+ is = new FileInputStream( source );
+ }
+ catch ( FileNotFoundException e )
+ {
+ // This is taken care of above, if we cannot create the
+ // parent directory then an exception will be thrown above.
+ }
+
+ OutputStream os;
+
+ try
+ {
+ os = getOutputStream( artifact );
+ }
+ catch ( Exception e )
+ {
+ throw new TransferFailedException( "Cannot create input stream: ", e );
+ }
+
+ putTransfer( resource, is, os );
+ }
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/TransferFailedException.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/TransferFailedException.java
new file mode 100644
index 0000000..eac6e07
--- /dev/null
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/TransferFailedException.java
@@ -0,0 +1,45 @@
+package org.apache.maven.wagon;
+
+/*
+ * Copyright 2001-2004 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.
+ */
+
+/**
+ * Exception which should be thrown when IO error occures during
+ * a transfer from repository
+ *
+ * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
+ * @version $Id$
+ */
+public class TransferFailedException extends WagonException
+{
+
+ /**
+ * @see org.apache.maven.wagon.WagonException
+ */
+ public TransferFailedException( final String message )
+ {
+ super( message );
+ }
+
+ /**
+ * @see org.apache.maven.wagon.WagonException
+ */
+ public TransferFailedException( final String message, final Throwable cause )
+ {
+ super( message, cause );
+ }
+
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/UnsupportedProtocolException.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/UnsupportedProtocolException.java
new file mode 100644
index 0000000..f65d3e5
--- /dev/null
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/UnsupportedProtocolException.java
@@ -0,0 +1,46 @@
+package org.apache.maven.wagon;
+
+/*
+ * Copyright 2001-2004 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.
+ */
+
+/**
+ * This exception is thrown when no Wagon provider is supporting protocol required by some repository
+ *
+ * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
+ * @version $Id$
+ */
+public class UnsupportedProtocolException extends WagonException
+{
+
+
+ /**
+ * @see WagonException
+ */
+ public UnsupportedProtocolException( final String message )
+ {
+ super( message );
+ }
+
+ /**
+ * @see WagonException
+ */
+ public UnsupportedProtocolException( final String message, final Throwable cause )
+ {
+ super( message, cause );
+ }
+
+
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/Wagon.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/Wagon.java
new file mode 100644
index 0000000..17b5184
--- /dev/null
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/Wagon.java
@@ -0,0 +1,76 @@
+package org.apache.maven.wagon;
+
+/*
+ * Copyright 2001-2004 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 org.apache.maven.wagon.artifact.Artifact;
+import org.apache.maven.wagon.authorization.AuthorizationException;
+import org.apache.maven.wagon.events.SessionListener;
+import org.apache.maven.wagon.events.TransferListener;
+import org.apache.maven.wagon.repository.Repository;
+
+import java.io.File;
+
+public interface Wagon
+{
+ String ROLE = Wagon.class.getName();
+
+ void get( Artifact artifact, File destination )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException;
+
+ void put( File source, Artifact artifact )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException;
+
+ String[] getSupportedProtocols();
+
+ Repository getRepository();
+
+ // ----------------------------------------------------------------------
+ // Connection/Disconnection
+ // ----------------------------------------------------------------------
+
+ void connect( Repository source )
+ throws Exception;
+
+ void openConnection()
+ throws Exception;
+
+ void disconnect()
+ throws Exception;
+
+ void closeConnection()
+ throws Exception;
+
+ // ----------------------------------------------------------------------
+ // Session listener
+ // ----------------------------------------------------------------------
+
+ void addSessionListener( SessionListener listener );
+
+ void removeSessionListener( SessionListener listener );
+
+ boolean hasSessionListener( SessionListener listener );
+
+ // ----------------------------------------------------------------------
+ // Transfer listener
+ // ----------------------------------------------------------------------
+
+ void addTransferListener( TransferListener listener );
+
+ void removeTransferListener( TransferListener listener );
+
+ boolean hasTransferListener( TransferListener listener );
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/WagonConstants.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/WagonConstants.java
new file mode 100644
index 0000000..a5301a3
--- /dev/null
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/WagonConstants.java
@@ -0,0 +1,32 @@
+package org.apache.maven.wagon;
+
+/*
+ * Copyright 2001-2004 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.
+ */
+
+/**
+ * This class contains constants used in Wagon API
+ *
+ * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
+ * @version $Id$
+ */
+public final class WagonConstants
+{
+ /** Indicates that port has not been set */
+ public final static int UNKNOWN_PORT = -1;
+
+ /** Indicates that lenght has not been set */
+ public final static int UNKNOWN_LENGTH = -1;
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/WagonException.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/WagonException.java
new file mode 100644
index 0000000..acd0ed0
--- /dev/null
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/WagonException.java
@@ -0,0 +1,110 @@
+package org.apache.maven.wagon;
+
+/*
+ * Copyright 2001-2004 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.
+ */
+
+/**
+ * Root class for all exception in Wagon API
+ *
+ * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
+ * @version $Id$
+ */
+public abstract class WagonException extends Exception
+{
+ /** the throwable that caused this throwable to get thrown */
+ private Throwable cause;
+
+
+ /**
+ * Constructs a new WagonException with the specified detail message.
+ * The cause is not initialized, and may subsequently be initialized by a call to initCause
+ *
+ * @param message - the detail message (which is saved for later retrieval by the getMessage() method).
+ * @param cause - the cause (which is saved for later retrieval by the getCause() method).
+ * (A null value is permitted, and indicates that the cause is nonexistent or unknown.)
+ */
+ public WagonException( final String message, final Throwable cause )
+ {
+ super( message );
+ initCause( cause );
+ }
+
+ /**
+ * Constructs a new WagonException with the specified detail message and cause.
+ *
+ * @param message - the detail message (which is saved for later retrieval by the getMessage() method).
+ */
+ public WagonException( final String message )
+ {
+ super( message );
+ }
+
+ /**
+ * Returns the cause of this throwable or null if the cause is nonexistent or unknown.
+ * (The cause is the throwable that caused this throwable to get thrown.)
+ *
+ * @return the cause of this throwable or null if the cause is nonexistent or unknown.
+ */
+ public Throwable getCause()
+ {
+// try
+// {
+// Class clazz = getClass().getSuperclass();
+//
+// Method method = clazz.getMethod( "gatCause" , null );
+//
+// Throwable retValue = (Throwable) method.invoke( this, null );
+// return retValue;
+// }
+// catch( Exception e)
+// {
+//
+// }
+
+ return cause;
+ }
+
+
+ /**
+ * Initializes the cause of this throwable to the specified value.
+ * (The cause is the throwable that caused this throwable to get thrown.)
+ * This method can be called at most once.
+ * It is generally called from within the constructor, or immediately after creating the throwable.
+ * If this throwable was created with WagonException(Throwable) or WagonException(String,Throwable),
+ * this method cannot be called even once.
+ *
+ * @return a reference to this Throwable instance.
+ */
+ public Throwable initCause( final Throwable cause )
+ {
+// try
+// {
+// Class clazz = getClass().getSuperclass();
+// Class[] parameterTypes = new Class[1];
+// parameterTypes[0] = Throwable.class;
+// Method method = clazz.getMethod( "initCause" , parameterTypes);
+// Object[] params = { cause };
+// method.invoke( this, params );
+// }
+// catch( Exception e)
+// {
+//
+// }
+ this.cause = cause;
+ return this;
+ }
+
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/WagonTestCase.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/WagonTestCase.java
new file mode 100644
index 0000000..0094419
--- /dev/null
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/WagonTestCase.java
@@ -0,0 +1,240 @@
+package org.apache.maven.wagon;
+
+import org.apache.maven.wagon.artifact.Artifact;
+import org.apache.maven.wagon.artifact.DefaultArtifact;
+import org.apache.maven.wagon.repository.Repository;
+import org.apache.maven.wagon.events.Debug;
+import org.apache.maven.wagon.authentication.AuthenticationInfo;
+import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
+import org.apache.maven.model.Model;
+import org.codehaus.plexus.PlexusTestCase;
+import org.codehaus.plexus.util.FileUtils;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.Writer;
+import java.io.FileReader;
+
+/**
+ * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
+ * @version $Id$
+ */
+public abstract class WagonTestCase
+ extends PlexusTestCase
+{
+ protected Repository localRepository;
+
+ protected Repository testRepository;
+
+ protected String localRepositoryPath;
+
+ protected MavenXpp3Reader modelReader;
+
+ protected Artifact artifact;
+
+ protected File sourceFile;
+
+ protected File destFile;
+
+ public WagonTestCase()
+ {
+ }
+
+ public WagonTestCase( String name )
+ {
+ super( name );
+ }
+
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ modelReader = new MavenXpp3Reader();
+
+ // ----------------------------------------------------------------------
+ //
+ // ----------------------------------------------------------------------
+
+ testRepository = new Repository();
+
+ testRepository.setUrl( getTestRepositoryUrl() );
+
+ testRepository.setAuthenticationInfo( getAuthInfo() );
+
+ // ----------------------------------------------------------------------
+ //
+ // ----------------------------------------------------------------------
+
+ localRepositoryPath = new File( basedir, "/target/local-repository" ).getPath();
+
+ localRepository = createFileRepository( "file://" + localRepositoryPath );
+
+ File f = new File( localRepositoryPath, "/maven/jars" );
+
+ if ( !f.exists() )
+ {
+ f.mkdirs();
+ }
+
+ f = new File( localRepositoryPath, "/maven/poms" );
+
+ if ( !f.exists() )
+ {
+ f.mkdirs();
+ }
+ }
+
+ protected abstract String getTestRepositoryUrl();
+
+ protected AuthenticationInfo getAuthInfo()
+ {
+ return new AuthenticationInfo();
+ }
+
+ protected abstract String getProtocol();
+
+ protected Wagon getWagon()
+ throws Exception
+ {
+ Wagon wagon = (Wagon) lookup( Wagon.ROLE, getProtocol() );
+
+ Debug debug = new Debug();
+
+ wagon.addSessionListener( debug );
+
+ wagon.addTransferListener( debug );
+
+ return wagon;
+ }
+
+ private void message( String message )
+ {
+ System.out.println( "---------------------------------------------------------------------------------------------------------" );
+ System.out.println( message );
+ System.out.println( "---------------------------------------------------------------------------------------------------------" );
+ }
+
+ protected void put()
+ throws Exception
+ {
+ message( "Putting test artifact into test repository " + testRepository );
+
+ Wagon wagon = getWagon();
+
+ wagon.connect( testRepository );
+
+ sourceFile = new File( basedir, "project.xml" );
+
+ wagon.put( sourceFile, getTestArtifact() );
+
+ wagon.disconnect();
+ }
+
+ protected void get()
+ throws Exception
+ {
+ message( "Getting test artifact from test repository " + testRepository );
+
+ Wagon wagon = getWagon();
+
+ wagon.connect( testRepository );
+
+ destFile = File.createTempFile( "wagon", ".tmp" );
+
+ wagon.get( getTestArtifact(), destFile );
+
+ wagon.disconnect();
+ }
+
+ public void testRoundTrip()
+ throws Exception
+ {
+ put();
+
+ get();
+
+ // Now compare the conents of the artifact that was placed in
+ // the repository with the contents of the artifact that was
+ // retrieved from the repository.
+
+ System.out.println( "---------------------------------------------------------------------------------------------------------" );
+
+ System.out.print( "Evaluating and comparing ... " );
+
+ String sourceContent = FileUtils.fileRead( sourceFile );
+
+ String destContent = FileUtils.fileRead( destFile );
+
+ assertEquals( sourceContent, destContent );
+
+ System.out.println( "OK" );
+
+ System.out.println( "---------------------------------------------------------------------------------------------------------" );
+
+ }
+
+ protected Artifact getTestArtifact()
+ throws Exception
+ {
+ if ( artifact == null )
+ {
+ Model model = modelReader.read( new FileReader( new File( basedir, "project.xml" ) ) );
+
+ artifact = new DefaultArtifact( model.getGroupId(), model.getArtifactId(), model.getVersion(), "pom" );
+ }
+
+ return artifact;
+ }
+
+ protected void customizeContext()
+ throws Exception
+ {
+ getContainer().addContextValue( "test.repository", localRepositoryPath );
+ }
+
+
+ protected Repository createFileRepository( String url )
+ {
+ File path = new File( url.substring( 7 ) );
+
+ path.mkdirs();
+
+ Repository repository = new Repository();
+
+ repository.setUrl( url );
+
+ return repository;
+ }
+
+ protected File generateFile( String file, String content )
+ throws IOException
+ {
+ File f = new File( file );
+
+ f.getParentFile().mkdirs();
+
+ Writer writer = new FileWriter( f );
+
+ writer.write( content );
+
+ writer.close();
+
+ return f;
+ }
+
+ protected void generateRepositoryArtifact( Artifact artifact, Repository repository, String content )
+ throws IOException
+ {
+ String fileName = repository.getBasedir() + "/" + repository.artifactPath( artifact );
+
+ generateFile( fileName, content );
+ }
+
+ protected String loadString( File file )
+ throws Exception
+ {
+ return FileUtils.fileRead( file );
+ }
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/authentication/AuthenticationException.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/authentication/AuthenticationException.java
new file mode 100644
index 0000000..8e933b3
--- /dev/null
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/authentication/AuthenticationException.java
@@ -0,0 +1,49 @@
+package org.apache.maven.wagon.authentication;
+
+import org.apache.maven.wagon.WagonException;
+
+/*
+ * Copyright 2001-2004 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.
+ */
+
+/**
+ * This exception is thrown when an authentication
+ * error occurs while accessing the remote repository.
+ * An authentication error can happen, for example,
+ * when the credentials supplied by the user are invalid
+ *
+ * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
+ * @version $Id$
+ */
+public class AuthenticationException extends WagonException
+{
+
+ /**
+ * @see org.apache.maven.wagon.WagonException
+ */
+ public AuthenticationException( final String message )
+ {
+ super( message );
+ }
+
+ /**
+ * @see org.apache.maven.wagon.WagonException
+ */
+ public AuthenticationException( final String message, final Throwable cause )
+ {
+ super( message, cause );
+ }
+
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/authentication/AuthenticationInfo.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/authentication/AuthenticationInfo.java
new file mode 100644
index 0000000..f5457d1
--- /dev/null
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/authentication/AuthenticationInfo.java
@@ -0,0 +1,150 @@
+package org.apache.maven.wagon.authentication;
+
+/*
+ * Copyright 2001-2004 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.Serializable;
+
+/**
+ * This class holds the set of properties used when instance of the <code>Wagon</code>
+ * will use during login opreration
+ *
+ * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
+ * @version $Id$
+ */
+public class AuthenticationInfo implements Serializable
+{
+
+ /** Username used to login to the host */
+ private String userName;
+
+ /** Password associated with the login */
+ private String password;
+
+ /** Repository group name */
+ private String group;
+
+ /** Passphrase of the user's private key file */
+ private String passphrase;
+
+ /** The absolute path to private key file */
+ private String privateKey;
+
+ /**
+ * Get the passphrase of the private key file. The passphrase is used only
+ * when host/protocol supports authentication via exchange of
+ * private/public keys and private key was used for authentication.
+ *
+ * @return passphrase of the private key file
+ */
+ public String getPassphrase()
+ {
+ return passphrase;
+ }
+
+ /**
+ * Set the passphrase of the private key file.
+ *
+ * @param passphrase passphrase of the private key file
+ */
+ public void setPassphrase( final String passphrase )
+ {
+ this.passphrase = passphrase;
+ }
+
+ /**
+ * Get the absolute path to the private key file.
+ *
+ * @return absolute path to private key
+ */
+ public String getPrivateKey()
+ {
+ return privateKey;
+ }
+
+ /**
+ * Set the absolute path to private key file.
+ *
+ * @param privateKey path to private key in local file system
+ */
+ public void setPrivateKey( final String privateKey )
+ {
+ this.privateKey = privateKey;
+ }
+
+ /**
+ * Get the repository group name to which an artifact will belong to after
+ * deployemnt. Not all protolcols permit the changing of the artifact
+ * group.
+ *
+ * @return repository group name
+ */
+ public String getGroup()
+ {
+ return group;
+ }
+
+ /**
+ * Set the repository group name for the deployed artifact.
+ *
+ * @param group repository group for deployed artifacts
+ */
+ public void setGroup( final String group )
+ {
+ this.group = group;
+ }
+
+ /**
+ * Get the user's password which is used when connecting to the repository.
+ *
+ * @return password of user
+ */
+ public String getPassword()
+ {
+ return password;
+ }
+
+ /**
+ * Set the user's password which is used when connecting to the repository.
+ *
+ * @param password password of the user
+ */
+ public void setPassword( final String password )
+ {
+ this.password = password;
+ }
+
+ /**
+ * Get the username used to access the repository.
+ *
+ * @return username at repository
+ */
+ public String getUserName()
+ {
+ return userName;
+ }
+
+ /**
+ * Set username used to access the repository.
+ *
+ * @param userName the username used to access repository
+ */
+ public void setUserName( final String userName )
+ {
+ this.userName = userName;
+ }
+
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/authorization/AuthorizationException.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/authorization/AuthorizationException.java
new file mode 100644
index 0000000..59f8e0f
--- /dev/null
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/authorization/AuthorizationException.java
@@ -0,0 +1,49 @@
+package org.apache.maven.wagon.authorization;
+
+import org.apache.maven.wagon.WagonException;
+
+/*
+ * Copyright 2001-2004 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.
+ */
+
+/**
+ * This exception is thrown when the user is not entitled to fetch from or deploy to
+ * prticular place in the repository.
+ *
+ * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
+ * @version $Id$
+ */
+public class AuthorizationException extends WagonException
+{
+
+
+ /**
+ * @see org.apache.maven.wagon.WagonException
+ */
+ public AuthorizationException( final String message )
+ {
+ super( message );
+ }
+
+ /**
+ * @see org.apache.maven.wagon.WagonException
+ */
+ public AuthorizationException( final String message, final Throwable cause )
+ {
+ super( message, cause );
+ }
+
+
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/Debug.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/Debug.java
new file mode 100644
index 0000000..6f33490
--- /dev/null
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/Debug.java
@@ -0,0 +1,186 @@
+package org.apache.maven.wagon.events;
+
+/*
+ * Copyright 2001-2004 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.
+ */
+
+/**
+ * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
+ * @version $Id$
+ */
+public class Debug
+ implements SessionListener, TransferListener
+{
+ long timestamp;
+ long transfer;
+
+ /**
+ * @see SessionListener#sessionOpening(SessionEvent)
+ */
+ public void sessionOpening( final SessionEvent sessionEvent )
+ {
+ //System.out.println( .getUrl() + " - Session: Opening ");
+ }
+
+ /**
+ * @see SessionListener#sessionOpened(SessionEvent)
+ */
+ public void sessionOpened( final SessionEvent sessionEvent )
+ {
+ System.out.println(
+ sessionEvent.getWagon().getRepository().getUrl() +
+ " - Session: Opened " );
+ }
+
+ /**
+ * @see SessionListener#sessionDisconnecting(SessionEvent)
+ */
+ public void sessionDisconnecting( final SessionEvent sessionEvent )
+ {
+ System.out.println(
+ sessionEvent.getWagon().getRepository().getUrl() +
+ " - Session: Disconnecting " );
+
+ }
+
+ /**
+ * @see SessionListener#sessionDisconnected(SessionEvent)
+ */
+ public void sessionDisconnected( final SessionEvent sessionEvent )
+ {
+ System.out.println(
+ sessionEvent.getWagon().getRepository().getUrl() +
+ " - Session: Disconnected" );
+ }
+
+ /**
+ * @see SessionListener#sessionConnectionRefused(SessionEvent)
+ */
+ public void sessionConnectionRefused( final SessionEvent sessionEvent )
+ {
+ System.out.println(
+ sessionEvent.getWagon().getRepository().getUrl() +
+ " - Session: Connection refused" );
+
+ }
+
+ /**
+ * @see SessionListener#sessionLoggedIn(SessionEvent)
+ */
+ public void sessionLoggedIn( final SessionEvent sessionEvent )
+ {
+ System.out.println(
+ sessionEvent.getWagon().getRepository().getUrl() +
+ " - Session: Logged in" );
+
+ }
+
+ /**
+ * @see SessionListener#sessionLoggedOff(SessionEvent)
+ */
+ public void sessionLoggedOff( final SessionEvent sessionEvent )
+ {
+ System.out.println(
+ sessionEvent.getWagon().getRepository().getUrl() +
+ " - Session: Logged off" );
+
+ }
+
+ /**
+ * @see TransferListener#debug(String)
+ */
+ public void debug( final String message )
+ {
+ System.out.println( message );
+
+ }
+
+ /**
+ * @see TransferListener#transferStarted(TransferEvent)
+ */
+ public void transferStarted( final TransferEvent transferEvent )
+ {
+ timestamp = transferEvent.getTimestamp();
+ transfer = 0;
+ if( transferEvent.getRequestType() == TransferEvent.REQUEST_GET )
+ {
+ final String message = "Downloading: " +
+ transferEvent.getResource() +
+ " from " +
+ transferEvent.getWagon().getRepository().getUrl();
+ System.out.println( message );
+ System.out.println( "" );
+ }
+ else
+ {
+ final String message = "Uploading: " +
+ transferEvent.getResource() +
+ " to " +
+ transferEvent.getWagon().getRepository().getUrl();
+ System.out.println( message );
+ System.out.println( "" );
+
+ }
+ }
+
+ /**
+ * @see TransferListener#transferProgress(TransferEvent)
+ */
+ public void transferProgress( final TransferEvent transferEvent )
+ {
+
+ System.out.print( "#" );
+ //String data = new String( transferEvent.getData(),0, transferEvent.getDataLength());
+ //System.out.println(data);
+ transfer += transferEvent.getProgress();
+ }
+
+ /**
+ * @see TransferListener#transferCompleted(TransferEvent)
+ */
+ public void transferCompleted( final TransferEvent transferEvent )
+ {
+ final double duration =
+ (double)( transferEvent.getTimestamp() - timestamp ) / 1000;
+
+ System.out.println();
+ final String message = "Transfer finished. " +
+ transfer +
+ " bytes copied in " +
+ duration +
+ " seconds";
+ System.out.println( message );
+
+ }
+
+ /**
+ * @see TransferListener#transferError(TransferEvent)
+ */
+ public void transferError( final TransferEvent transferEvent )
+ {
+ System.out.println( " Transfer error: " + transferEvent.getException() );
+
+ }
+
+ /**
+ * @see SessionListener#sessionError(SessionEvent)
+ */
+ public void sessionError( final SessionEvent sessionEvent )
+ {
+ System.out.println( " Session error: " + sessionEvent.getException() );
+
+ }
+
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/SessionEvent.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/SessionEvent.java
new file mode 100644
index 0000000..78df60f
--- /dev/null
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/SessionEvent.java
@@ -0,0 +1,161 @@
+package org.apache.maven.wagon.events;
+
+/*
+ * Copyright 2001-2004 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 org.apache.maven.wagon.Wagon;
+
+/**
+ *
+ * SessionEvent is used for notifing SessionListeners about
+ * occurences of various sistutation releated.
+ *
+ * The session event is emitted by <code>Wagon</code> objects when
+ *
+ * <ul>
+ * <li>Before connection to the repository will be opened</li>
+ * <li>After connection to the repository was opened</li>
+ * <li>After wagon has logged-in to the repository</li>
+ * <li>After wagon has logged-off from the repository</li>
+ * <li>Before connection to the repository will be closed</li>
+ * <li>After connection to the repository was closed</li>
+ * </ul>
+ *
+ * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
+ * @version $Id$
+ */
+public class SessionEvent extends WagonEvent
+{
+
+ /** A SESSION was closed. */
+ public final static int SESSION_CLOSED = 1;
+
+ /** A SESSION is about to be disconnected. */
+ public final static int SESSION_DISCONNECTING = 2;
+
+ /** A SESSION was disconnected (not currently used). */
+ public final static int SESSION_DISCONNECTED = 3;
+
+ /** A SESSION was refused. */
+ public final static int SESSION_CONNECTION_REFUSED = 4;
+
+ /** A SESSION is about to be opened. */
+ public final static int SESSION_OPENING = 5;
+
+ /** A SESSION was opened. */
+ public final static int SESSION_OPENED = 6;
+
+ /** A SESSION was opened. */
+ public final static int SESSION_LOGGED_IN = 7;
+
+ /** A SESSION was opened. */
+ public final static int SESSION_LOGGED_OFF = 8;
+
+ /** A SESSION was opened. */
+ public final static int SESSION_ERROR_OCCURRED = 9;
+
+ /** The type of the event. One of the SESSSION_XXX constans*/
+ private int eventType;
+
+ private Exception exception;
+
+ /**
+ * Creates new instance of SessionEvent
+ * @param wagon <code>Wagon<code> object which created this event
+ * @param eventType the type of the event
+ */
+ public SessionEvent(
+ final Wagon wagon,
+ final int eventType )
+ {
+ super( wagon );
+ this.eventType = eventType;
+
+ }
+
+ /**
+ * Creates new instance of SessionEvent. Sets event type to <code>SESSION_ERROR_OCCURRED</code>
+ * @param wagon <code>Wagon<code> object which created this event
+ * @param exception the exception
+ */
+ public SessionEvent(
+ final Wagon wagon,
+ final Exception exception )
+ {
+ super( wagon );
+ this.exception = exception;
+ this.eventType = SESSION_ERROR_OCCURRED;
+
+ }
+
+ /**
+ * @return Returns the type.
+ */
+ public int getEventType()
+ {
+ return eventType;
+ }
+
+ /**
+ * @return Returns the exception.
+ */
+ public Exception getException()
+ {
+ return exception;
+ }
+
+ /**
+ * @param eventType The eventType to set.
+ */
+ public void setEventType( final int eventType )
+ {
+ switch ( eventType )
+ {
+
+ case SessionEvent.SESSION_CLOSED:
+ break;
+ case SessionEvent.SESSION_DISCONNECTED:
+ break;
+ case SessionEvent.SESSION_DISCONNECTING:
+ break;
+ case SessionEvent.SESSION_ERROR_OCCURRED:
+ break;
+ case SessionEvent.SESSION_LOGGED_IN:
+ break;
+ case SessionEvent.SESSION_LOGGED_OFF:
+ break;
+ case SessionEvent.SESSION_OPENED:
+ break;
+ case SessionEvent.SESSION_OPENING:
+ break;
+ case SessionEvent.SESSION_CONNECTION_REFUSED:
+ break;
+ default :
+ throw new IllegalArgumentException(
+ "Illegal event type: " + eventType );
+ }
+ this.eventType = eventType;
+ }
+
+ /**
+ * @param exception The exception to set.
+ */
+ public void setException( final Exception exception )
+ {
+ this.exception = exception;
+ }
+
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/SessionEventSupport.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/SessionEventSupport.java
new file mode 100644
index 0000000..fc4a6e7
--- /dev/null
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/SessionEventSupport.java
@@ -0,0 +1,232 @@
+package org.apache.maven.wagon.events;
+
+/*
+ * Copyright 2001-2004 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.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * The class allows registration and deregistration of session listeners
+ *
+ * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
+ * @version $Id$
+ */
+public final class SessionEventSupport
+{
+ /** registred listeners */
+ private final List listeners = new ArrayList();
+
+ /**
+ * Adds the listener to the collection of listeners
+ * who will be notifed when any session event occurs
+ * in this <code>Wagon</code> object.
+ * <br/>
+ * If listener is <code>null</code>, no exception is thrown and no action is performed
+ *
+ * @param listener the transfer listener
+ *
+ * @see #removeSessionListener(SessionListener)
+ * @see TransferListener
+ */
+ public void addSessionListener( final SessionListener listener )
+ {
+ listeners.add( listener );
+ }
+
+ /**
+ * Removes the session listener from the collection of listeners so
+ * it no longer receives session events.
+ * <br/>
+ * If listener is <code>null</code> or specified listener was not added
+ * to this <code>SessionEventSupport</code> object
+ * no exception is thrown and no action is performed
+ *
+ * @param listener the session listener
+ *
+ * @see #addSessionListener(org.apache.maven.wagon.events.SessionListener)
+ */
+ public void removeSessionListener( final SessionListener listener )
+ {
+ listeners.remove( listener );
+ }
+
+ /**
+ * Returns whether the specified instance of session
+ * listener was added to the collection of listeners
+ * who will be notifed when an seesion event occurs
+ *
+ * @param listener the session listener
+ *
+ * @return <code>true<code>
+ * if given listner was added to the collection of listeners
+ * <code>false</code> otherwise
+ *
+ * @see org.apache.maven.wagon.events.SessionListener
+ * @see #addSessionListener(org.apache.maven.wagon.events.SessionListener)
+ */
+ public boolean hasSessionListener( final SessionListener listener )
+ {
+ return listeners.contains( listener );
+ }
+
+ /**
+ * Dispatches the given <code>SessionEvent</code>
+ * to all registred listeners (calls method {@link SessionListener#sessionDisconnected(SessionEvent)} on all of them}.
+ * The Event should be of type {@link SessionEvent#SESSION_DISCONNECTED}
+ *
+ * @param sessionEvent the SessionEvent which will be dispached to listeners
+ */
+ public void fireSessionDisconnected( final SessionEvent sessionEvent )
+ {
+ for ( Iterator iter = listeners.iterator(); iter.hasNext(); )
+ {
+ final SessionListener listener = ( SessionListener ) iter.next();
+ listener.sessionDisconnected( sessionEvent );
+ }
+ }
+
+ /**
+ * Dispatches the given <code>SessionEvent</code>
+ * to all registred listeners (calls method {@link SessionListener#sessionDisconnecting(SessionEvent)} } on all of them}.
+ * The Event should be of type {@link SessionEvent#SESSION_DISCONNECTING}
+ *
+ * @param sessionEvent the SessionEvent which will be dispached to listeners
+ */
+ public void fireSessionDisconnecting( final SessionEvent sessionEvent )
+ {
+ for ( Iterator iter = listeners.iterator(); iter.hasNext(); )
+ {
+ final SessionListener listener = ( SessionListener ) iter.next();
+ listener.sessionDisconnecting( sessionEvent );
+ }
+ }
+
+ /**
+ * Dispatches the given <code>SessionEvent</code>
+ * to all registred listeners (calls method {@link SessionListener#sessionLoggedIn(SessionEvent)} on all of them}.
+ * The Event should be of type {@link SessionEvent#SESSION_LOGGED_IN}
+ *
+ * @param sessionEvent the SessionEvent which will be dispached to listeners
+ */
+ public void fireSessionLoggedIn( final SessionEvent sessionEvent )
+ {
+ for ( Iterator iter = listeners.iterator(); iter.hasNext(); )
+ {
+ final SessionListener listener = ( SessionListener ) iter.next();
+ listener.sessionLoggedIn( sessionEvent );
+ }
+ }
+
+ /**
+ * Dispatches the given <code>SessionEvent</code>
+ * to all registred listeners (calls method {@link SessionListener#sessionLoggedOff(SessionEvent)} on all of them}.
+ * The Event should be of type {@link SessionEvent#SESSION_LOGGED_OFF}
+ *
+ * @param sessionEvent the SessionEvent which will be dispached to listeners
+ */
+ public void fireSessionLoggedOff( final SessionEvent sessionEvent )
+ {
+ for ( Iterator iter = listeners.iterator(); iter.hasNext(); )
+ {
+ final SessionListener listener = ( SessionListener ) iter.next();
+ listener.sessionLoggedOff( sessionEvent );
+ }
+ }
+
+ /**
+ * Dispatches the given <code>SessionEvent</code>
+ * to all registred listeners (calls method {@link SessionListener#sessionOpened(SessionEvent)} on all of them}.
+ * The Event should be of type {@link SessionEvent#SESSION_OPENED}
+ *
+ * @param sessionEvent the SessionEvent which will be dispached to listeners
+ */
+ public void fireSessionOpened( final SessionEvent sessionEvent )
+ {
+ for ( Iterator iter = listeners.iterator(); iter.hasNext(); )
+ {
+ final SessionListener listener = ( SessionListener ) iter.next();
+ listener.sessionOpened( sessionEvent );
+ }
+ }
+
+ /**
+ * Dispatches the given <code>SessionEvent</code>
+ * to all registred listeners (calls method {@link SessionListener#sessionOpening(SessionEvent)} on all of them}.
+ * The Event should be of type {@link SessionEvent#SESSION_OPENING}
+ *
+ * @param sessionEvent the SessionEvent which will be dispached to listeners
+ */
+ public void fireSessionOpening( final SessionEvent sessionEvent )
+ {
+ for ( Iterator iter = listeners.iterator(); iter.hasNext(); )
+ {
+ final SessionListener listener = ( SessionListener ) iter.next();
+ listener.sessionOpening( sessionEvent );
+ }
+ }
+
+ /**
+ * Dispatches the given <code>SessionEvent</code>
+ * to all registred listeners (calls method {@link SessionListener#sessionConnectionRefused(SessionEvent)} on all of them}.
+ * The Event should be of type {@link SessionEvent#SESSION_CONNECTION_REFUSED}
+ *
+ * @param sessionEvent the SessionEvent which will be dispached to listeners
+ */
+ public void fireSessionConnectionRefused( final SessionEvent sessionEvent )
+ {
+ for ( Iterator iter = listeners.iterator(); iter.hasNext(); )
+ {
+ final SessionListener listener = ( SessionListener ) iter.next();
+ listener.sessionConnectionRefused( sessionEvent );
+ }
+ }
+
+ /**
+ * Dispatches the given debug message
+ * to all registred listeners (calls method {@link SessionListener#debug(String)} on all of them}.
+ *
+ * @param message the debug message which will be dispached to listeners
+ */
+ public void fireDebug( final String message )
+ {
+ for ( Iterator iter = listeners.iterator(); iter.hasNext(); )
+ {
+ final SessionListener listener =
+ ( SessionListener ) iter.next();
+ listener.debug( message );
+ }
+ }
+
+ /**
+ * Dispatches the given <code>SessionEvent</code>
+ * to all registred listeners (calls method {@link SessionListener#sessionConnectionRefused(SessionEvent)} on all of them.
+ * The Event should be of type {@link SessionEvent#SESSION_ERROR_OCCURRED} and it is expected that
+ * {@link SessionEvent#getException()} method will return not null value
+ *
+ * @param sessionEvent the SessionEvent which will be dispached to listeners
+ */
+ public void fireSessionError( final SessionEvent sessionEvent )
+ {
+ for ( Iterator iter = listeners.iterator(); iter.hasNext(); )
+ {
+ final SessionListener listener =
+ ( SessionListener ) iter.next();
+ listener.sessionError( sessionEvent );
+ }
+ }
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/SessionListener.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/SessionListener.java
new file mode 100644
index 0000000..f74fd6f
--- /dev/null
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/SessionListener.java
@@ -0,0 +1,115 @@
+package org.apache.maven.wagon.events;
+
+/*
+ * Copyright 2001-2004 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.
+ */
+
+/**
+ * Interface for classes which wants to receive and respond to any session update events.
+ *
+ * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
+ * @version $Id$
+ */
+public interface SessionListener
+{
+
+ /**
+ * This method will be called when Wagon is about to open
+ * connection to the repository.
+ * The type of the event should
+ * be set to {@link SessionEvent.SESSION_OPENING}
+ *
+ * @param sessionEvent the session event
+ */
+ void sessionOpening( SessionEvent sessionEvent );
+
+ /**
+ * This method will be called when Wagon has sucessfully connected to
+ * to the repository.
+ * The type of the event should
+ * be set to {@link SessionEvent.SESSION_OPENED}
+ *
+ * @param sessionEvent the session event
+ */
+ void sessionOpened( SessionEvent sessionEvent );
+
+ /**
+ * This method will be called when Wagon has closed connection to
+ * to the repository.
+ * The type of the event should
+ * be set to {@link SessionEvent.SESSION_DISCONNECTING}
+ *
+ * @param sessionEvent the session event
+ */
+ void sessionDisconnecting( SessionEvent sessionEvent );
+
+ /**
+ * This method will be called when Wagon has closed connection to
+ * the repository.
+ * The type of the event should
+ * be set to {@link SessionEvent.SESSION_DISCONNECTED}
+ *
+ * @param sessionEvent the session event
+ */
+ void sessionDisconnected( SessionEvent sessionEvent );
+
+ /**
+ * This method will be called when Wagon when connection to
+ * the repository was refused.
+ *
+ * The type of the event should
+ * be set to {@link SessionEvent.SESSION_CONNECTION_REFUSED}
+ *
+ * @param sessionEvent the session event
+ */
+ void sessionConnectionRefused( SessionEvent sessionEvent );
+
+ /**
+ * This method will be called by Wagon when Wagon manged
+ * to login to the repository.
+ *
+ * @param sessionEvent the session event
+ */
+ void sessionLoggedIn( SessionEvent sessionEvent );
+
+ /**
+ * This method will be called by Wagon has logged off
+ * from the repository.
+ *
+ * The type of the event should
+ * be set to {@link SessionEvent.SESSION_LOGGED_OFF}
+ *
+ * @param sessionEvent the session event
+ */
+ void sessionLoggedOff( SessionEvent sessionEvent );
+
+ /**
+ * This method will be called by Wagon when an error occured.
+ *
+ * The type of the event should
+ * be set to {@link SessionEvent.SESSION_ERROR_OCCURRED}
+ *
+ * @param sessionEvent the session event
+ */
+ void sessionError( SessionEvent sessionEvent );
+
+ /**
+ * This methid allows to send arbitrary debug messages.
+ *
+ * @param message the debug messgae
+ */
+ void debug( String message );
+
+}
\ No newline at end of file
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/TransferEvent.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/TransferEvent.java
new file mode 100644
index 0000000..cbb9129
--- /dev/null
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/TransferEvent.java
@@ -0,0 +1,239 @@
+package org.apache.maven.wagon.events;
+
+/*
+ * Copyright 2001-2004 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 org.apache.maven.wagon.repository.Repository;
+import org.apache.maven.wagon.Wagon;
+
+/***
+ * TransferEvent is used to notify TransferListeners about progress
+ * in transfer of resources form/to the respository
+ *
+ * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
+ * @version $Id$
+ */
+public class TransferEvent extends WagonEvent
+{
+
+ /** A transfer was started. */
+ public final static int TRANSFER_STARTED = 1;
+
+ /** A transfer is completed. */
+ public final static int TRANSFER_COMPLETED = 2;
+
+ /** A transfer is in progress. */
+ public final static int TRANSFER_PROGRESS = 3;
+
+ /** An error occured during transfer */
+ public final static int TRANSFER_ERROR = 4;
+
+ /** Indicates GET transfer (from the repository) */
+ public final static int REQUEST_GET = 5;
+
+ /** Indicates PUT transfer (to the repository)*/
+ public final static int REQUEST_PUT = 6;
+
+
+ private String resource;
+
+ private int eventType;
+ private int requestType;
+
+ private byte[] data;
+ private int dataLength;
+
+ private Exception exception;
+
+ private long progress;
+
+ public TransferEvent(
+ final Wagon wagon,
+ final String resource,
+ final int eventType,
+ final int requestType )
+ {
+ super( wagon );
+ this.resource = resource;
+ setEventType( eventType );
+ setRequestType( requestType );
+
+ }
+
+ public TransferEvent(
+ final Wagon wagon,
+ final String resource,
+ final Exception exception )
+ {
+ super( wagon );
+ this.resource = resource;
+ setEventType( TRANSFER_ERROR );
+ this.exception = exception;
+
+ }
+
+
+
+ /**
+ * @return Returns the resource.
+ */
+ public String getResource()
+ {
+ return resource;
+ }
+
+ /**
+ * @return Returns the exception.
+ */
+ public Exception getException()
+ {
+ return exception;
+ }
+
+ /**
+ * Returns the request type.
+ * @return Returns the request type. The Request type is one of
+ * <code>TransferEvent.REQUEST_GET<code> or <code>TransferEvent.REQUEST_PUT<code>
+ */
+ public int getRequestType()
+ {
+ return requestType;
+ }
+
+ /**
+ * Sets the request type
+ * @param requestType The requestType to set.
+ * The Request type value should be either
+ * <code>TransferEvent.REQUEST_GET<code> or <code>TransferEvent.REQUEST_PUT<code>.
+ * @throws IllegalArgumentException when
+ */
+ public void setRequestType( final int requestType )
+ {
+ switch ( requestType )
+ {
+
+ case REQUEST_PUT:
+ break;
+ case REQUEST_GET:
+ break;
+
+ default :
+ throw new IllegalArgumentException(
+ "Illegal request type: " + requestType );
+ }
+
+ this.requestType = requestType;
+ }
+
+ /**
+ * @return Returns the eventType.
+ */
+ public int getEventType()
+ {
+ return eventType;
+ }
+
+ /**
+ * @param eventType The eventType to set.
+ */
+ public void setEventType( final int eventType )
+ {
+ switch ( eventType )
+ {
+
+ case TRANSFER_STARTED:
+ break;
+ case TRANSFER_COMPLETED:
+ break;
+ case TRANSFER_PROGRESS:
+ break;
+ case TRANSFER_ERROR:
+ break;
+ default :
+ throw new IllegalArgumentException(
+ "Illegal event type: " + eventType );
+ }
+
+ this.eventType = eventType;
+ }
+
+ /**
+ * The
+ * @param exception The exception to set.
+ */
+ public void setException( final Exception exception )
+ {
+ this.exception = exception;
+ }
+
+
+ /**
+ * @param resource The resource to set.
+ */
+ public void setResource( final String resource )
+ {
+ this.resource = resource;
+ }
+
+ /**
+ * @param progress
+ */
+ public void setProgress( final long progress )
+ {
+
+ this.progress = progress;
+ }
+
+ /**
+ * @return Returns the progress.
+ */
+ public long getProgress()
+ {
+ return progress;
+ }
+
+
+
+ /**
+ *
+ * @param data
+ * @param dataLength
+ */
+ public void setData( final byte[] data, final int dataLength )
+ {
+ this.data = data;
+ this.dataLength = dataLength;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public byte[] getData()
+ {
+ return data;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public int getDataLength()
+ {
+ return dataLength;
+ }
+
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/TransferEventSupport.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/TransferEventSupport.java
new file mode 100644
index 0000000..49d59a1
--- /dev/null
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/TransferEventSupport.java
@@ -0,0 +1,175 @@
+package org.apache.maven.wagon.events;
+
+/*
+ * Copyright 2001-2004 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.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * The class allows registration and removal of event listners of type
+ * TransferListener and dispatch of those events to those listeners
+ *
+ * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
+ * @version $Id$
+ */
+public final class TransferEventSupport
+{
+
+ /** registred listeners */
+ private final List listeners = new ArrayList();
+
+ /**
+ * Adds the listener to the collection of listeners
+ * who will be notifed when any transfer event occurs
+ * in this <code>Wagon</code> object.
+ * <br/>
+ * If listener is <code>null</code>, no exception is thrown and no action is performed
+ *
+ * @param listener the transfer listener
+ *
+ * @see #removeTransferListener(org.apache.maven.wagon.events.TransferListener)
+ * @see TransferListener
+ */
+ public void addTransferListener( final TransferListener listener )
+ {
+ listeners.add( listener );
+ }
+
+ /**
+ * Removes the transfer listener from the collection of listeners so
+ * it no longer receives transfer events.
+ * <br/>
+ * If listener is <code>null</code> or specified listener was not added
+ * to this <code>TransferEventSupport</code> object
+ * no exception is thrown and no action is performed
+ *
+ * @param listener the transfer listener
+ *
+ * @see #addTransferListener(TransferListener)
+ */
+ public void removeTransferListener( final TransferListener listener )
+ {
+ listeners.remove( listener );
+ }
+
+ /**
+ * Returns whether the specified instance of transfer
+ * listener was added to the collection of listeners
+ * who will be notifed when an transfer event occurs
+ *
+ * @param listener the transfer listener
+ *
+ * @return <code>true<code>
+ * if given listner was added to the collection of listeners
+ * <code>false</code> otherwise
+ *
+ * @see org.apache.maven.wagon.events.TransferEvent
+ * @see #addTransferListener(TransferListener)
+ */
+ public boolean hasTransferListener( final TransferListener listener )
+ {
+ return listeners.contains( listener );
+ }
+
+
+ /**
+ * Dispatches the given <code>TransferEvent</code>
+ * to all registred listeners (calls method {@link TransferListener#transferStarted(TransferEvent)} on all of them}.
+ * The Event should be of type {@link TransferEvent#TRANSFER_COMPLETED}
+ *
+ * @param transferEvent the TransferEvent which will be dispached to listeners
+ */
+ public void fireTransferStarted( final TransferEvent transferEvent )
+ {
+ for ( Iterator iter = listeners.iterator(); iter.hasNext(); )
+ {
+ final TransferListener listener = ( TransferListener ) iter.next();
+ listener.transferStarted( transferEvent );
+ }
+ }
+
+ /**
+ * Dispatches the given <code>TransferEvent</code>
+ * to all registred listeners (calls method {@link TransferListener#transferProgress(TransferEvent)} on all of them}.
+ * The Event should be of type {@link TransferEvent#TRANSFER_PROGRESS}.
+ *
+ * @param transferEvent the TransferEvent which will be dispached to listeners
+ */
+ public void fireTransferProgress( final TransferEvent transferEvent )
+ {
+ for ( Iterator iter = listeners.iterator(); iter.hasNext(); )
+ {
+ final TransferListener listener = ( TransferListener ) iter.next();
+ listener.transferProgress( transferEvent );
+
+ }
+ }
+
+ /**
+ * Dispatches the given <code>TransferEvent</code>
+ * to all registred listeners (calls method {@link TransferListener#transferCompleted(TransferEvent)} on all of them}.
+ * The Event should be of type {@link TransferEvent#TRANSFER_COMPLETED}
+ *
+ * @param transferEvent the TransferEvent which will be dispached to listeners
+ */
+ public void fireTransferCompleted( final TransferEvent transferEvent )
+ {
+ for ( Iterator iter = listeners.iterator(); iter.hasNext(); )
+ {
+ final TransferListener listener = ( TransferListener ) iter.next();
+ listener.transferCompleted( transferEvent );
+
+ }
+ }
+
+ /**
+ * Dispatches the given <code>TransferEvent</code>
+ * to all registred listeners (calls method {@link TransferListener#transferError(TransferEvent)} on all of them.
+ * The Event should be of type {@link TransferEvent#TRANSFER_ERROR} and it is expected that
+ * {@link TransferEvent#getException()} } method will return not null value
+ *
+ * @param transferEvent the TransferEvent which will be dispached to listeners
+ */
+ public void fireTransferError( final TransferEvent transferEvent )
+ {
+ for ( Iterator iter = listeners.iterator(); iter.hasNext(); )
+ {
+ final TransferListener listener = ( TransferListener ) iter.next();
+ listener.transferError( transferEvent );
+
+ }
+ }
+
+ /**
+ * Dispatches the given debug message
+ * to all registred listeners (calls method {@link TransferListener#debug(String)} on all of them.
+ *
+ * @param message the debug message which will be dispached to listeners
+ */
+ public void fireDebug( final String message )
+ {
+
+ for ( Iterator iter = listeners.iterator(); iter.hasNext(); )
+ {
+ final TransferListener listener = ( TransferListener ) iter.next();
+ listener.debug( message );
+
+ }
+ }
+
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/TransferListener.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/TransferListener.java
new file mode 100644
index 0000000..241389e
--- /dev/null
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/TransferListener.java
@@ -0,0 +1,51 @@
+package org.apache.maven.wagon.events;
+
+/*
+ * Copyright 2001-2004 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.
+ */
+
+/**
+ * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
+ * @version $Id$
+ */
+public interface TransferListener
+{
+
+ /**
+ * @param transferEvent
+ */
+ void transferStarted( TransferEvent transferEvent );
+
+ /**
+ * @param transferEvent
+ */
+ void transferProgress( TransferEvent transferEvent );
+
+ /**
+ * @param transferEvent
+ */
+ void transferCompleted( TransferEvent transferEvent );
+
+ /**
+ * @param transferEvent
+ */
+ void transferError( TransferEvent transferEvent );
+
+ /**
+ * @param message
+ */
+ void debug( String message );
+
+}
\ No newline at end of file
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/WagonEvent.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/WagonEvent.java
new file mode 100644
index 0000000..33d1ba7
--- /dev/null
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/WagonEvent.java
@@ -0,0 +1,76 @@
+package org.apache.maven.wagon.events;
+
+/*
+ * Copyright 2001-2004 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 org.apache.maven.wagon.Wagon;
+import org.apache.maven.wagon.repository.Repository;
+
+import java.util.EventObject;
+
+/**
+ * Base class for all events emitted by <code>Wagon</code> objects.
+ *
+ * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
+ * @version $Id$
+ */
+public class WagonEvent extends EventObject
+{
+ /**
+ * Repository to which the Wagon
+ * object which emitted this event is connected
+ */
+ protected Repository repository;
+
+ /** The time when event occured*/
+ protected long timestamp;
+
+ /**
+ * @param source The Wagon object on which the WagonEvent initially occurred
+ */
+ public WagonEvent( final Wagon source )
+ {
+ super( source );
+ }
+
+ /**
+ * Returns The Wagon object on which the WagonEvent initially occurred
+ * @return The Wagon object on which the WagonEvent initially occurred
+ */
+ public Wagon getWagon()
+ {
+ return ( Wagon ) getSource();
+ }
+
+ /**
+ * Returns the timestamp which indicated the time when this event has occured
+ * @return Returns the timestamp.
+ */
+ public long getTimestamp()
+ {
+ return timestamp;
+ }
+
+ /**
+ * Sets the timestamp which indicated the time when this event has occured
+ * @param timestamp The timestamp to set.
+ */
+ public void setTimestamp( final long timestamp )
+ {
+ this.timestamp = timestamp;
+ }
+
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/proxy/ProxyInfo.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/proxy/ProxyInfo.java
new file mode 100644
index 0000000..6390d72
--- /dev/null
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/proxy/ProxyInfo.java
@@ -0,0 +1,151 @@
+package org.apache.maven.wagon.proxy;
+
+/*
+ * Copyright 2001-2004 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 org.apache.maven.wagon.WagonConstants;
+
+import java.io.Serializable;
+
+/**
+ * Conatins set of properties used by <code>Wagon</code> objects
+ * while connection to the repository must go thru a proxy server.
+ *
+ * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
+ * @version $Id$
+ * @todo Propose standard types of proxy servers (e.g. <i>SOCKSv4</i>),
+ * which can be shared between wagon api and providers
+ */
+public class ProxyInfo implements Serializable
+{
+
+ /** Proxy server host */
+ private String host = null;
+
+ /** Username used to access the proxy server */
+ private String userName = null;
+
+ /** Password associated with the proxy server */
+ private String password = null;
+
+ /** Proxy server port */
+ private int port = WagonConstants.UNKNOWN_PORT;
+
+
+ /** Type of the proxy */
+ private String type = null;
+
+
+ /**
+ * Return proxy server host name.
+ *
+ * @return proxy server host name
+ */
+ public String getHost()
+ {
+ return host;
+ }
+
+ /**
+ * Set proxy host name.
+ *
+ * @param host proxy server host name
+ */
+ public void setHost( final String host )
+ {
+ this.host = host;
+ }
+
+ /**
+ * Get user's password used to login to proxy server.
+ *
+ * @return user's password at proxy host
+ */
+ public String getPassword()
+ {
+ return password;
+ }
+
+ /**
+ * Set the user's password for the proxy server.
+ *
+ * @param password password to use to login to a proxy server
+ */
+ public void setPassword( final String password )
+ {
+ this.password = password;
+ }
+
+ /**
+ * Get the proxy port.
+ *
+ * @return proxy server port
+ */
+ public int getPort()
+ {
+ return port;
+ }
+
+ /**
+ * Set the proxy port.
+ *
+ * @param port proxy server port
+ */
+ public void setPort( final int port )
+ {
+ this.port = port;
+ }
+
+ /**
+ * Get the proxy username.
+ *
+ * @return username for the proxy server
+ */
+ public String getUserName()
+ {
+ return userName;
+ }
+
+ /**
+ * Set the proxy username.
+ *
+ * @param userName username for the proxy server
+ */
+ public void setUserName( final String userName )
+ {
+ this.userName = userName;
+ }
+
+
+ /**
+ * Get the type of the proxy server.
+ *
+ * @return the type of the proxy server
+ */
+ public String getType()
+ {
+ return type;
+ }
+
+ /**
+ * @param type the type of the proxy server like <i>SOCKSv4</i>
+ */
+ public void setType( final String type )
+ {
+ this.type = type;
+ }
+
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/repository/Repository.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/repository/Repository.java
new file mode 100644
index 0000000..3e16ad2
--- /dev/null
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/repository/Repository.java
@@ -0,0 +1,220 @@
+package org.apache.maven.wagon.repository;
+
+/*
+ * Copyright 2001-2004 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 org.apache.maven.wagon.proxy.ProxyInfo;
+import org.apache.maven.wagon.authentication.AuthenticationInfo;
+import org.apache.maven.wagon.WagonConstants;
+import org.apache.maven.wagon.PathUtils;
+import org.apache.maven.wagon.artifact.Artifact;
+import org.codehaus.plexus.util.StringUtils;
+
+import java.io.Serializable;
+import java.net.URL;
+import java.util.Properties;
+
+/**
+ * This class is an abstraction of the location from/to resources
+ * can be transfered.
+ *
+ * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
+ * @version $Id$
+ */
+public class Repository
+ implements Serializable
+{
+ private String id;
+
+ private String name;
+
+ private String host;
+
+ private int port = WagonConstants.UNKNOWN_PORT;
+
+ private String basedir;
+
+ private String protocol;
+
+ private String layout;
+
+ private String url;
+
+ private ProxyInfo proxyInfo;
+
+ private AuthenticationInfo authenticationInfo;
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public AuthenticationInfo getAuthenticationInfo()
+ {
+ return authenticationInfo;
+ }
+
+ public void setAuthenticationInfo( AuthenticationInfo authenticationInfo )
+ {
+ this.authenticationInfo = authenticationInfo;
+ }
+
+ public ProxyInfo getProxyInfo()
+ {
+ return proxyInfo;
+ }
+
+ public void setProxyInfo( ProxyInfo proxyInfo )
+ {
+ this.proxyInfo = proxyInfo;
+ }
+
+ public String getBasedir()
+ {
+ return basedir;
+ }
+
+ public void setBasedir( String basedir )
+ {
+ this.basedir = basedir;
+ }
+
+ public void setName( String name )
+ {
+ this.name = name;
+ }
+
+ public int getPort()
+ {
+ return port;
+ }
+
+ public void setPort( int port )
+ {
+ this.port = port;
+ }
+
+ public void setUrl( String url )
+ {
+ this.url = url;
+
+ this.host = PathUtils.host( url );
+
+ this.protocol = PathUtils.protocol( url );
+
+ this.port = PathUtils.port( url );
+
+ this.basedir = PathUtils.basedir( url );
+ }
+
+ public String getUrl()
+ {
+ if ( url != null )
+ {
+ return url;
+ }
+
+ StringBuffer sb = new StringBuffer();
+
+ sb.append( protocol );
+
+ sb.append( "://" );
+
+ sb.append( host );
+
+ if ( port != WagonConstants.UNKNOWN_PORT )
+ {
+ sb.append( ":" );
+
+ sb.append( port );
+ }
+
+ sb.append( "/" );
+
+ sb.append( basedir );
+
+ return sb.toString();
+ }
+
+ public String getHost()
+ {
+ if ( host == null )
+ {
+ return "localhost";
+ }
+ return host;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public String toString()
+ {
+ if ( getName() != null )
+ {
+ return "[" + getName() + "] -> " + getUrl();
+ }
+
+ return getUrl();
+ }
+
+ public String getProtocol()
+ {
+ return protocol;
+ }
+
+ public String getLayout()
+ {
+ if ( layout == null )
+ {
+ return "${groupId}/${type}s/${artifactId}-${version}.${type}";
+ }
+
+ return layout;
+ }
+
+ public String artifactPath( Artifact artifact )
+ {
+ return interpolateLayout( artifact.getGroupId(), artifact.getArtifactId(), artifact.getType(), artifact.getVersion() );
+ }
+
+ public String fullArtifactPath( Artifact artifact )
+ {
+ return getBasedir() + "/" + artifactPath( artifact );
+ }
+
+ public String artifactUrl( Artifact artifact )
+ {
+ return getUrl() + "/" + artifactPath( artifact );
+ }
+
+ private String interpolateLayout( String groupId, String artifactId, String type, String version )
+ {
+ String layout = getLayout();
+
+ layout = StringUtils.replace( layout, "${groupId}", groupId );
+
+ layout = StringUtils.replace( layout, "${artifactId}", artifactId );
+
+ layout = StringUtils.replace( layout, "${type}", type );
+
+ layout = StringUtils.replace( layout, "${version}", version );
+
+ return layout;
+ }
+}
diff --git a/wagon-provider-api/src/main/resources/META-INF/plexus/components.xml b/wagon-provider-api/src/main/resources/META-INF/plexus/components.xml
new file mode 100644
index 0000000..42d1566
--- /dev/null
+++ b/wagon-provider-api/src/main/resources/META-INF/plexus/components.xml
@@ -0,0 +1,14 @@
+<component-set>
+ <components>
+ <component>
+ <role>org.apache.maven.wagon.manager.WagonManager</role>
+ <implementation>org.apache.maven.wagon.manager.DefaultWagonManager</implementation>
+ </component>
+ <component>
+ <role>org.apache.maven.wagon.Wagon</role>
+ <role-hint>file</role-hint>
+ <implementation>org.apache.maven.wagon.providers.file.FileWagon</implementation>
+ <instantiation-strategy>per-lookup</instantiation-strategy>
+ </component>
+ </components>
+</component-set>
\ No newline at end of file
diff --git a/wagon-provider-api/src/test/java/org/apache/maven/wagon/AbstractWagonTest.java b/wagon-provider-api/src/test/java/org/apache/maven/wagon/AbstractWagonTest.java
new file mode 100644
index 0000000..ef67f82
--- /dev/null
+++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/AbstractWagonTest.java
@@ -0,0 +1,249 @@
+package org.apache.maven.wagon;
+
+import junit.framework.TestCase;
+import org.apache.maven.wagon.artifact.Artifact;
+import org.apache.maven.wagon.artifact.DefaultArtifact;
+import org.apache.maven.wagon.events.MockSessionListener;
+import org.apache.maven.wagon.events.MockTransferListener;
+import org.apache.maven.wagon.repository.Repository;
+
+import java.io.File;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
+ * @version $Id$
+ */
+public class AbstractWagonTest extends TestCase
+{
+ private String basedir;
+ private MockWagon wagon = null;
+ private Artifact artifact;
+ private File destination;
+ private File source;
+ private MockSessionListener sessionListener = null;
+ private MockTransferListener transferListener = null;
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ basedir = System.getProperty( "basedir" );
+
+ artifact = new DefaultArtifact( "groupId", "artifactId", "version", "type", "extension" );
+
+ destination = new File( basedir, "destination" );
+
+ source = new File( basedir, "project.xml" );
+
+ wagon = new MockWagon();
+
+ sessionListener = new MockSessionListener();
+
+ wagon.addSessionListener( sessionListener );
+
+ transferListener = new MockTransferListener();
+
+ wagon.addTransferListener( transferListener );
+
+ }
+
+ public void testSessionListenerRegistration()
+ {
+ assertTrue( wagon.hasSessionListener( sessionListener ) );
+
+ wagon.removeSessionListener( sessionListener );
+
+ assertFalse( wagon.hasSessionListener( sessionListener ) );
+ }
+
+ public void testTransferListenerRegistration()
+ {
+ assertTrue( wagon.hasTransferListener( transferListener ) );
+
+ wagon.removeTransferListener( transferListener );
+
+ assertFalse( wagon.hasTransferListener( transferListener ) );
+ }
+
+ public void testSessionOpenEvents()
+ throws Exception
+ {
+ Repository repository = new Repository();
+
+ wagon.connect( repository );
+
+ assertEquals( repository, wagon.getRepository() );
+
+ assertTrue( sessionListener.isSessionOpenningCalled() );
+
+ assertTrue( sessionListener.isSessionOpenedCalled() );
+
+ //!!
+ //assertTrue( sessionListener.isSessionLoggedInCalled() );
+
+ //!!
+ //assertTrue( sessionListener.isSessionRefusedCalled() );
+
+ }
+
+ public void testSessionCloseEvents()
+ throws Exception
+ {
+ wagon.disconnect();
+
+ //!!
+ //assertTrue( sessionListener.isSessionLoggedOffCalled() );
+
+ assertTrue( sessionListener.isSessionDisconnectingCalled() );
+
+ assertTrue( sessionListener.isSessionDisconnectedCalled() );
+ }
+
+ public void testGetTransferEvents()
+ {
+ wagon.fireTransferDebug( "fetch debug message" );
+
+ try
+ {
+ Repository repository = new Repository();
+
+ wagon.connect( repository );
+
+ wagon.get( artifact, destination );
+ }
+
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+
+ fail( e.getMessage() );
+ }
+
+ assertTrue( transferListener.isTransferStartedCalled() );
+
+ assertTrue( transferListener.isTransferCompletedCalled() );
+
+ assertTrue( transferListener.isDebugCalled() );
+
+ assertTrue( transferListener.isTransferProgressCalled() );
+
+ assertEquals( "fetch debug message", transferListener.getDebugMessage() );
+
+ assertEquals( 5, transferListener.getNumberOfProgressCalls() );
+ }
+
+ public void testGetError()
+ {
+ MockTransferListener transferListener = new MockTransferListener();
+
+ try
+ {
+ Repository repository = new Repository();
+
+ MockWagon wagon = new MockWagon( true );
+
+ wagon.addTransferListener( transferListener );
+
+ wagon.connect( repository );
+
+ wagon.get( artifact, destination );
+
+ fail( "Transfer error was expected during deploy" );
+ }
+ catch ( Exception e )
+ {
+ }
+
+ assertTrue( transferListener.isTransferStartedCalled() );
+
+ assertTrue( transferListener.isTransferErrorCalled() );
+
+ assertFalse( transferListener.isTransferCompletedCalled() );
+ }
+
+ public void testPutTransferEvents()
+ {
+ wagon.fireTransferDebug( "deploy debug message" );
+
+ try
+ {
+ Repository repository = new Repository();
+
+ wagon.connect( repository );
+
+ wagon.put( source, artifact );
+ }
+ catch ( Exception e )
+ {
+ fail( e.getMessage() );
+ }
+
+ assertTrue( transferListener.isTransferStartedCalled() );
+
+ assertTrue( transferListener.isTransferCompletedCalled() );
+
+ assertTrue( transferListener.isDebugCalled() );
+
+ assertTrue( transferListener.isTransferProgressCalled() );
+
+ assertEquals( "deploy debug message", transferListener.getDebugMessage() );
+
+ //!!
+ //assertEquals( 5, transferListener.getNumberOfProgressCalls() );
+ }
+
+ /*
+ public void testPutError()
+ {
+ MockInputStream mockInputStream = new MockInputStream();
+
+ //forced io error!
+ mockInputStream.setForcedError( true );
+
+ StreamSource result = new StreamSource( mockInputStream );
+
+ PutRequest command = new PutRequest( result, "my favourite resource" );
+
+ try
+ {
+ wagon.transfer( command );
+
+ fail( "Transfer error was expected during fetch" );
+ }
+ catch ( Exception e )
+ {
+ }
+
+ assertTrue( transferListener.isTransferStartedCalled() );
+
+ assertTrue( transferListener.isTransferErrorCalled() );
+
+ assertFalse( transferListener.isTransferCompletedCalled() );
+ }
+ */
+
+ public void testStreamShutdown()
+ {
+ wagon.shutdownStream( (InputStream) null );
+
+ wagon.shutdownStream( (OutputStream) null );
+
+ MockInputStream inputStream = new MockInputStream();
+
+ assertFalse( inputStream.isClosed() );
+
+ wagon.shutdownStream( inputStream );
+
+ assertTrue( inputStream.isClosed() );
+
+ MockOutputStream outputStream = new MockOutputStream();
+
+ assertFalse( outputStream.isClosed() );
+
+ wagon.shutdownStream( outputStream );
+
+ assertTrue( outputStream.isClosed() );
+ }
+}
diff --git a/wagon-provider-api/src/test/java/org/apache/maven/wagon/CannotConnectExceptionTest.java b/wagon-provider-api/src/test/java/org/apache/maven/wagon/CannotConnectExceptionTest.java
new file mode 100644
index 0000000..00f0cbb
--- /dev/null
+++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/CannotConnectExceptionTest.java
@@ -0,0 +1,68 @@
+package org.apache.maven.wagon;
+
+/*
+ * ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met: 1.
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer. 2. Redistributions in
+ * binary form must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or other
+ * materials provided with the distribution. 3. The end-user documentation
+ * included with the redistribution, if any, must include the following
+ * acknowledgment: "This product includes software developed by the Apache
+ * Software Foundation (http://www.apache.org/)." Alternately, this
+ * acknowledgment may appear in the software itself, if and wherever such
+ * third-party acknowledgments normally appear. 4. The names "Apache" and
+ * "Apache Software Foundation" and "Apache Maven" must not be used to
+ * endorse or promote products derived from this software without prior written
+ * permission. For written permission, please contact apache@apache.org. 5.
+ * Products derived from this software may not be called "Apache", "Apache
+ * MavenSession", nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * on behalf of the Apache Software Foundation. For more information on the
+ * Apache Software Foundation, please see <http://www.apache.org/> .
+ *
+ * ====================================================================
+ */
+
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
+ * @version $Id$
+ */
+public class CannotConnectExceptionTest
+ extends TestCase
+{
+ public void testCannotConnectExceptionTest()
+ {
+ ConnectionException ae = new ConnectionException( "message" );
+
+ assertEquals( "message", ae.getMessage() );
+
+ ae = new ConnectionException( "full-message", new Throwable( "cause" ) );
+
+ assertEquals( "full-message", ae.getMessage() );
+
+ assertEquals( "cause", ae.getCause().getMessage() );
+ }
+}
diff --git a/wagon-provider-api/src/test/java/org/apache/maven/wagon/MockInputStream.java b/wagon-provider-api/src/test/java/org/apache/maven/wagon/MockInputStream.java
new file mode 100644
index 0000000..43d103f
--- /dev/null
+++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/MockInputStream.java
@@ -0,0 +1,103 @@
+package org.apache.maven.wagon;
+
+/*
+ * ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met: 1.
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer. 2. Redistributions in
+ * binary form must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or other
+ * materials provided with the distribution. 3. The end-user documentation
+ * included with the redistribution, if any, must include the following
+ * acknowledgment: "This product includes software developed by the Apache
+ * Software Foundation (http://www.apache.org/)." Alternately, this
+ * acknowledgment may appear in the software itself, if and wherever such
+ * third-party acknowledgments normally appear. 4. The names "Apache" and
+ * "Apache Software Foundation" and "Apache MavenSession" must not be used to
+ * endorse or promote products derived from this software without prior written
+ * permission. For written permission, please contact apache@apache.org. 5.
+ * Products derived from this software may not be called "Apache", "Apache
+ * MavenSession", nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * on behalf of the Apache Software Foundation. For more information on the
+ * Apache Software Foundation, please see <http://www.apache.org/> .
+ *
+ * ====================================================================
+ */
+
+import java.io.IOException;
+import java.io.InputStream;
+
+
+/**
+ * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
+ * @version $Id$
+ */
+public class MockInputStream extends InputStream
+{
+
+ private boolean closed = false;
+
+ boolean forcedError = false;
+
+ public void close()
+ {
+ closed = true;
+ }
+
+ /**
+ * @return Returns the closed.
+ */
+ public boolean isClosed()
+ {
+ return closed;
+ }
+
+ /**
+ * @return Returns the forcedError.
+ */
+ public boolean isForcedError()
+ {
+ return forcedError;
+ }
+
+ /**
+ * @see java.io.InputStream#read()
+ */
+ public int read() throws IOException
+ {
+ if ( forcedError )
+ {
+ throw new IOException( "Mock exception" );
+ }
+ return 0;
+ }
+
+ /**
+ * @param forcedError The forcedError to set.
+ */
+ public void setForcedError( final boolean forcedError )
+ {
+ this.forcedError = forcedError;
+ }
+
+}
diff --git a/wagon-provider-api/src/test/java/org/apache/maven/wagon/MockOutputStream.java b/wagon-provider-api/src/test/java/org/apache/maven/wagon/MockOutputStream.java
new file mode 100644
index 0000000..3ad70c1
--- /dev/null
+++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/MockOutputStream.java
@@ -0,0 +1,103 @@
+package org.apache.maven.wagon;
+
+/*
+ * ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met: 1.
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer. 2. Redistributions in
+ * binary form must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or other
+ * materials provided with the distribution. 3. The end-user documentation
+ * included with the redistribution, if any, must include the following
+ * acknowledgment: "This product includes software developed by the Apache
+ * Software Foundation (http://www.apache.org/)." Alternately, this
+ * acknowledgment may appear in the software itself, if and wherever such
+ * third-party acknowledgments normally appear. 4. The names "Apache" and
+ * "Apache Software Foundation" and "Apache MavenSession" must not be used to
+ * endorse or promote products derived from this software without prior written
+ * permission. For written permission, please contact apache@apache.org. 5.
+ * Products derived from this software may not be called "Apache", "Apache
+ * MavenSession", nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * on behalf of the Apache Software Foundation. For more information on the
+ * Apache Software Foundation, please see <http://www.apache.org/> .
+ *
+ * ====================================================================
+ */
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+
+/**
+ * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
+ * @version $Id$
+ */
+public class MockOutputStream extends OutputStream
+{
+
+ private boolean closed = false;
+ private boolean forcedError = false;
+
+ public void close()
+ {
+ closed = true;
+ }
+
+ /**
+ * @see java.io.OutputStream#write(int)
+ */
+ public void write( final int b ) throws IOException
+ {
+ if ( forcedError )
+ {
+ throw new IOException( "Mock exception" );
+ }
+
+ }
+
+ /**
+ * @return Returns the closed.
+ */
+ public boolean isClosed()
+ {
+ return closed;
+ }
+
+
+ /**
+ * @return Returns the forcedError.
+ */
+ public boolean isForcedError()
+ {
+ return forcedError;
+ }
+
+ /**
+ * @param forcedError The forcedError to set.
+ */
+ public void setForcedError( final boolean forcedError )
+ {
+ this.forcedError = forcedError;
+ }
+
+}
diff --git a/wagon-provider-api/src/test/java/org/apache/maven/wagon/MockWagon.java b/wagon-provider-api/src/test/java/org/apache/maven/wagon/MockWagon.java
new file mode 100644
index 0000000..5f6732e
--- /dev/null
+++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/MockWagon.java
@@ -0,0 +1,77 @@
+package org.apache.maven.wagon;
+
+import org.apache.maven.wagon.artifact.Artifact;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
+ * @version $Id$
+ */
+public class MockWagon
+ extends StreamWagon
+{
+ private boolean errorInputStream;
+
+ public MockWagon()
+ {
+ }
+
+ public MockWagon( boolean errorInputStream )
+ {
+ this.errorInputStream = errorInputStream;
+ }
+
+ public String[] getSupportedProtocols()
+ {
+ return new String[]{"mock"};
+ }
+
+ public InputStream getInputStream( Artifact artifact )
+ throws Exception
+ {
+ if ( errorInputStream )
+ {
+ MockInputStream is = new MockInputStream();
+
+ is.setForcedError( true );
+
+ return is;
+ }
+
+ byte[] buffer = new byte[1024 * 4 * 5];
+
+ ByteArrayInputStream is = new ByteArrayInputStream( buffer );
+
+ return is;
+ }
+
+ public OutputStream getOutputStream( Artifact artifact )
+ throws Exception
+ {
+ if ( errorInputStream )
+ {
+ MockOutputStream os = new MockOutputStream();
+
+ os.setForcedError( true );
+
+ return os;
+ }
+
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+
+ return os;
+ }
+
+
+ public void openConnection()
+ {
+ }
+
+ public void closeConnection()
+ {
+ }
+}
diff --git a/wagon-provider-api/src/test/java/org/apache/maven/wagon/NotAuthorizedExceptionTest.java b/wagon-provider-api/src/test/java/org/apache/maven/wagon/NotAuthorizedExceptionTest.java
new file mode 100644
index 0000000..e400952
--- /dev/null
+++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/NotAuthorizedExceptionTest.java
@@ -0,0 +1,69 @@
+package org.apache.maven.wagon;
+
+/*
+ * ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met: 1.
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer. 2. Redistributions in
+ * binary form must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or other
+ * materials provided with the distribution. 3. The end-user documentation
+ * included with the redistribution, if any, must include the following
+ * acknowledgment: "This product includes software developed by the Apache
+ * Software Foundation (http://www.apache.org/)." Alternately, this
+ * acknowledgment may appear in the software itself, if and wherever such
+ * third-party acknowledgments normally appear. 4. The names "Apache" and
+ * "Apache Software Foundation" and "Apache Maven" must not be used to
+ * endorse or promote products derived from this software without prior written
+ * permission. For written permission, please contact apache@apache.org. 5.
+ * Products derived from this software may not be called "Apache", "Apache
+ * MavenSession", nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * on behalf of the Apache Software Foundation. For more information on the
+ * Apache Software Foundation, please see <http://www.apache.org/> .
+ *
+ * ====================================================================
+ */
+
+import junit.framework.TestCase;
+import org.apache.maven.wagon.authorization.AuthorizationException;
+
+/**
+ * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
+ * @version $Id$
+ */
+public class NotAuthorizedExceptionTest
+ extends TestCase
+{
+ public void testNotAuthorizedExceptionTest()
+ {
+ AuthorizationException ae = new AuthorizationException( "message" );
+
+ assertEquals( "message", ae.getMessage() );
+
+ ae = new AuthorizationException( "full-message", new Throwable( "cause" ) );
+
+ assertEquals( "full-message", ae.getMessage() );
+
+ assertEquals( "cause", ae.getCause().getMessage() );
+ }
+}
diff --git a/wagon-provider-api/src/test/java/org/apache/maven/wagon/PathUtilsTest.java b/wagon-provider-api/src/test/java/org/apache/maven/wagon/PathUtilsTest.java
new file mode 100644
index 0000000..bfb4510
--- /dev/null
+++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/PathUtilsTest.java
@@ -0,0 +1,120 @@
+package org.apache.maven.wagon;
+
+/*
+ * ==================================================================== The
+ * Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met: 1.
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer. 2. Redistributions in
+ * binary form must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or other
+ * materials provided with the distribution. 3. The end-userName documentation
+ * included with the redistribution, if any, must include the following
+ * acknowledgment: "This product includes software developed by the Apache
+ * Software Foundation (http://www.apache.org/)." Alternately, this
+ * acknowledgment may appear in the software itself, if and wherever such
+ * third-party acknowledgments normally appear. 4. The names "Apache" and
+ * "Apache Software Foundation" and "Apache Maven" must not be used to endorse
+ * or promote products derived from this software without prior written
+ * permission. For written permission, please contact apache@apache.org. 5.
+ * Products derived from this software may not be called "Apache", "Apache
+ * Maven", nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * on behalf of the Apache Software Foundation. For more information on the
+ * Apache Software Foundation, please see <http://www.apache.org/> .
+ *
+ * ====================================================================
+ */
+
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
+ * @version $Id$
+ */
+public class PathUtilsTest extends TestCase
+{
+ public void testFilenameResolving()
+ {
+ assertEquals( "filename", PathUtils.filename( "dir/filename" ) );
+ assertEquals( "filename", PathUtils.filename( "filename" ) );
+ assertEquals( "filename", PathUtils.filename( "dir1/dir2/filename" ) );
+ }
+
+ public void testDirResolving()
+ {
+ assertEquals( "dir", PathUtils.dirname( "dir/filename" ) );
+ assertEquals( "", PathUtils.dirname( "filename" ) );
+ assertEquals( "dir1/dir2", PathUtils.dirname( "dir1/dir2/filename" ) );
+ }
+
+ public void testDirSpliting()
+ {
+ final String path = "a/b/c";
+ final String[] dirs = PathUtils.dirnames( path );
+ assertNotNull( dirs );
+ assertEquals( 2, dirs.length );
+ assertEquals( "a", dirs[0] );
+ assertEquals( "b", dirs[1] );
+
+ }
+
+ public void testHostResolving()
+ {
+ assertEquals(
+ "www.codehaus.org",
+ PathUtils.host( "http://www.codehaus.org" ) );
+ assertEquals( "localhost", PathUtils.host( null ) );
+
+ }
+
+ public void testProtocolResolving()
+ {
+ assertEquals( "http", PathUtils.protocol( "http://www.codehause.org" ) );
+ assertEquals( "file", PathUtils.protocol( "file:///c:/temp" ) );
+
+ }
+
+ public void testPortResolving()
+ {
+ assertEquals( 80, PathUtils.port( "http://www.codehause.org:80/maven" ) );
+ assertEquals(
+ WagonConstants.UNKNOWN_PORT,
+ PathUtils.port( "http://localhost/temp" ) );
+
+ assertEquals( 10, PathUtils.port( "ftp://localhost:10" ) );
+
+ }
+
+ public void testPortBasedir()
+ {
+ assertEquals(
+ "maven",
+ PathUtils.basedir( "http://www.codehause.org:80/maven" ) );
+ assertEquals( "temp", PathUtils.basedir( "http://localhost/temp" ) );
+
+ assertEquals( "c:/temp", PathUtils.basedir( "file://c:/temp" ) );
+ assertEquals( "", PathUtils.basedir( "http://localhost:80/" ) );
+ assertEquals( "", PathUtils.basedir( "http://localhost/" ) );
+
+ }
+
+}
diff --git a/wagon-provider-api/src/test/java/org/apache/maven/wagon/ResourceDoesNotExistExceptionTest.java b/wagon-provider-api/src/test/java/org/apache/maven/wagon/ResourceDoesNotExistExceptionTest.java
new file mode 100644
index 0000000..8192075
--- /dev/null
+++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/ResourceDoesNotExistExceptionTest.java
@@ -0,0 +1,68 @@
+package org.apache.maven.wagon;
+
+/*
+ * ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met: 1.
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer. 2. Redistributions in
+ * binary form must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or other
+ * materials provided with the distribution. 3. The end-user documentation
+ * included with the redistribution, if any, must include the following
+ * acknowledgment: "This product includes software developed by the Apache
+ * Software Foundation (http://www.apache.org/)." Alternately, this
+ * acknowledgment may appear in the software itself, if and wherever such
+ * third-party acknowledgments normally appear. 4. The names "Apache" and
+ * "Apache Software Foundation" and "Apache Maven" must not be used to
+ * endorse or promote products derived from this software without prior written
+ * permission. For written permission, please contact apache@apache.org. 5.
+ * Products derived from this software may not be called "Apache", "Apache
+ * MavenSession", nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * on behalf of the Apache Software Foundation. For more information on the
+ * Apache Software Foundation, please see <http://www.apache.org/> .
+ *
+ * ====================================================================
+ */
+
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
+ * @version $Id$
+ */
+public class ResourceDoesNotExistExceptionTest
+ extends TestCase
+{
+ public void testResourceDoesNotExistExceptionTest()
+ {
+ ResourceDoesNotExistException ae = new ResourceDoesNotExistException( "message" );
+
+ assertEquals( "message", ae.getMessage() );
+
+ ae = new ResourceDoesNotExistException( "full-message", new Throwable( "cause" ) );
+
+ assertEquals( "full-message", ae.getMessage() );
+
+ assertEquals( "cause", ae.getCause().getMessage() );
+ }
+}
diff --git a/wagon-provider-api/src/test/java/org/apache/maven/wagon/TestUtils.java b/wagon-provider-api/src/test/java/org/apache/maven/wagon/TestUtils.java
new file mode 100644
index 0000000..8c56294
--- /dev/null
+++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/TestUtils.java
@@ -0,0 +1,100 @@
+package org.apache.maven.wagon;
+
+/* ====================================================================
+ * The The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2003 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache Maven" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache Maven", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ * ====================================================================
+ */
+
+import junit.framework.TestCase;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
+ * @version $Id$
+ */
+public class TestUtils
+{
+
+ public static final File generateDirectory( final TestCase testcase ) throws IOException
+ {
+ final File baseDirectory = getBaseDirectory();
+ final File dir =
+ File
+ .createTempFile( testcase.getName(), ".tmp", baseDirectory )
+ .getCanonicalFile();
+ dir.delete();
+ dir.mkdirs();
+ if ( !dir.exists() )
+ {
+ throw new IOException( "Unable to create the directory for testdata" );
+ }
+ return dir;
+ }
+
+ public static final File getBaseDirectory()
+ {
+ final String tempDir = System.getProperty( "java.io.tmpdir" );
+ final String baseDir = System.getProperty( "basedir", tempDir );
+
+ final File base = new File( baseDir ).getAbsoluteFile();
+ final String pathname =
+ base + File.separator + "target" + File.separator + "test-data";
+ final File dir = new File( pathname );
+ dir.mkdirs();
+ return dir;
+ }
+
+}
diff --git a/wagon-provider-api/src/test/java/org/apache/maven/wagon/TransferFailedExceptionTest.java b/wagon-provider-api/src/test/java/org/apache/maven/wagon/TransferFailedExceptionTest.java
new file mode 100644
index 0000000..b08e4f1
--- /dev/null
+++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/TransferFailedExceptionTest.java
@@ -0,0 +1,68 @@
+package org.apache.maven.wagon;
+
+/*
+ * ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met: 1.
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer. 2. Redistributions in
+ * binary form must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or other
+ * materials provided with the distribution. 3. The end-user documentation
+ * included with the redistribution, if any, must include the following
+ * acknowledgment: "This product includes software developed by the Apache
+ * Software Foundation (http://www.apache.org/)." Alternately, this
+ * acknowledgment may appear in the software itself, if and wherever such
+ * third-party acknowledgments normally appear. 4. The names "Apache" and
+ * "Apache Software Foundation" and "Apache Maven" must not be used to
+ * endorse or promote products derived from this software without prior written
+ * permission. For written permission, please contact apache@apache.org. 5.
+ * Products derived from this software may not be called "Apache", "Apache
+ * MavenSession", nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * on behalf of the Apache Software Foundation. For more information on the
+ * Apache Software Foundation, please see <http://www.apache.org/> .
+ *
+ * ====================================================================
+ */
+
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
+ * @version $Id$
+ */
+public class TransferFailedExceptionTest
+ extends TestCase
+{
+ public void testTransferFailedExceptionTest()
+ {
+ TransferFailedException ae = new TransferFailedException( "message" );
+
+ assertEquals( "message", ae.getMessage() );
+
+ ae = new TransferFailedException( "full-message", new Throwable( "cause" ) );
+
+ assertEquals( "full-message", ae.getMessage() );
+
+ assertEquals( "cause", ae.getCause().getMessage() );
+ }
+}
diff --git a/wagon-provider-api/src/test/java/org/apache/maven/wagon/artifact/verifiy/SHA1VerifierTest.java b/wagon-provider-api/src/test/java/org/apache/maven/wagon/artifact/verifiy/SHA1VerifierTest.java
new file mode 100644
index 0000000..f0681e7
--- /dev/null
+++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/artifact/verifiy/SHA1VerifierTest.java
@@ -0,0 +1,64 @@
+package org.apache.maven.wagon.artifact.verify;
+
+import junit.framework.TestCase;
+
+public class SHA1VerifierTest
+ extends TestCase
+{
+ private SHA1Verifier s;
+
+ protected void setUp()
+ {
+ s = new SHA1Verifier();
+ }
+
+ public void testSHA1WithABC()
+ {
+ // input: "abc"
+ // checksum: A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D
+
+ s.init();
+
+ s.update( (byte) 'a' );
+
+ s.update( (byte) 'b' );
+
+ s.update( (byte) 'c' );
+
+ s.finish();
+
+ assertEquals( "A9993E364706816ABA3E25717850C26C9CD0D89D".toLowerCase(), s.digout() );
+ }
+
+ public void testSHA1WithLongerString()
+ {
+ // input: "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
+ // checksum: 84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1
+
+ s.init();
+
+ s.updateASCII( "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" );
+
+ s.finish();
+
+ assertEquals( "84983E441C3BD26EBAAE4AA1F95129E5E54670F1".toLowerCase(), s.digout() );
+
+ }
+
+ public void testSHA1WithAMillionAs()
+ {
+ // input: A million repetitions of "a"
+ // checksum: 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F
+
+ s.init();
+
+ for ( int i = 0; i < 1000000; i++ )
+ {
+ s.update( (byte) 'a' );
+ }
+
+ s.finish();
+
+ assertEquals( "34AA973CD4C4DAA4F61EEB2BDBAD27316534016F".toLowerCase(), s.digout() );
+ }
+}
diff --git a/wagon-provider-api/src/test/java/org/apache/maven/wagon/authentication/AuthenticationExceptionTest.java b/wagon-provider-api/src/test/java/org/apache/maven/wagon/authentication/AuthenticationExceptionTest.java
new file mode 100644
index 0000000..efa91e8
--- /dev/null
+++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/authentication/AuthenticationExceptionTest.java
@@ -0,0 +1,69 @@
+package org.apache.maven.wagon.authentication;
+
+/*
+ * ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met: 1.
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer. 2. Redistributions in
+ * binary form must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or other
+ * materials provided with the distribution. 3. The end-user documentation
+ * included with the redistribution, if any, must include the following
+ * acknowledgment: "This product includes software developed by the Apache
+ * Software Foundation (http://www.apache.org/)." Alternately, this
+ * acknowledgment may appear in the software itself, if and wherever such
+ * third-party acknowledgments normally appear. 4. The names "Apache" and
+ * "Apache Software Foundation" and "Apache Maven" must not be used to
+ * endorse or promote products derived from this software without prior written
+ * permission. For written permission, please contact apache@apache.org. 5.
+ * Products derived from this software may not be called "Apache", "Apache
+ * MavenSession", nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * on behalf of the Apache Software Foundation. For more information on the
+ * Apache Software Foundation, please see <http://www.apache.org/> .
+ *
+ * ====================================================================
+ */
+
+import junit.framework.TestCase;
+import org.apache.maven.wagon.authentication.AuthenticationException;
+
+/**
+ * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
+ * @version $Id$
+ */
+public class AuthenticationExceptionTest
+ extends TestCase
+{
+ public void testAuthenticationExceptionTest()
+ {
+ AuthenticationException ae = new AuthenticationException( "message" );
+
+ assertEquals( "message", ae.getMessage() );
+
+ ae = new AuthenticationException( "full-message", new Throwable( "cause" ) );
+
+ assertEquals( "full-message", ae.getMessage() );
+
+ assertEquals( "cause", ae.getCause().getMessage() );
+ }
+}
diff --git a/wagon-provider-api/src/test/java/org/apache/maven/wagon/authentication/AuthenticationInfoTest.java b/wagon-provider-api/src/test/java/org/apache/maven/wagon/authentication/AuthenticationInfoTest.java
new file mode 100644
index 0000000..5403ad2
--- /dev/null
+++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/authentication/AuthenticationInfoTest.java
@@ -0,0 +1,103 @@
+package org.apache.maven.wagon.authentication;
+
+/*
+ * ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met: 1.
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer. 2. Redistributions in
+ * binary form must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or other
+ * materials provided with the distribution. 3. The end-user documentation
+ * included with the redistribution, if any, must include the following
+ * acknowledgment: "This product includes software developed by the Apache
+ * Software Foundation (http://www.apache.org/)." Alternately, this
+ * acknowledgment may appear in the software itself, if and wherever such
+ * third-party acknowledgments normally appear. 4. The names "Apache" and
+ * "Apache Software Foundation" and "Apache Maven" must not be used to
+ * endorse or promote products derived from this software without prior written
+ * permission. For written permission, please contact apache@apache.org. 5.
+ * Products derived from this software may not be called "Apache", "Apache
+ * MavenSession", nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * on behalf of the Apache Software Foundation. For more information on the
+ * Apache Software Foundation, please see <http://www.apache.org/> .
+ *
+ * ====================================================================
+ */
+
+import junit.framework.TestCase;
+import org.apache.maven.wagon.authentication.AuthenticationInfo;
+
+/**
+ * @author <a href="mailto:jvanzyl@maven.org">Jason van Zyl</a>
+ * @version $Id$
+ */
+public class AuthenticationInfoTest
+ extends TestCase
+{
+ public AuthenticationInfoTest( final String name )
+ {
+ super( name );
+ }
+
+ public void setUp()
+ throws Exception
+ {
+ super.setUp();
+ }
+
+ public void tearDown()
+ throws Exception
+ {
+ super.tearDown();
+ }
+
+ public void testAuthenticationInfoProperties()
+ {
+ final AuthenticationInfo authenticationInfo = new AuthenticationInfo();
+
+
+ authenticationInfo.setUserName( "username" );
+
+ assertEquals( "username", authenticationInfo.getUserName() );
+
+
+ authenticationInfo.setPassword( "password" );
+
+ assertEquals( "password", authenticationInfo.getPassword() );
+
+
+ authenticationInfo.setGroup( "group" );
+
+ assertEquals( "group", authenticationInfo.getGroup() );
+
+
+ authenticationInfo.setPassphrase( "passphrase" );
+
+ assertEquals( "passphrase", authenticationInfo.getPassphrase() );
+
+
+ authenticationInfo.setPrivateKey( "privatekey" );
+
+ assertEquals( "privatekey", authenticationInfo.getPrivateKey() );
+ }
+}
diff --git a/wagon-provider-api/src/test/java/org/apache/maven/wagon/events/MockSessionListener.java b/wagon-provider-api/src/test/java/org/apache/maven/wagon/events/MockSessionListener.java
new file mode 100644
index 0000000..03c8ff7
--- /dev/null
+++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/events/MockSessionListener.java
@@ -0,0 +1,142 @@
+package org.apache.maven.wagon.events;
+
+/**
+ * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
+ * @version $Id$
+ */
+public class MockSessionListener implements SessionListener
+{
+
+ private boolean connectionOpenningCalled = false;
+ private boolean debugCalled = false;
+ private boolean connectionLoggedOffCalled = false;
+ private boolean connectionLoggedInCalled = false;
+ private boolean connectionRefusedCalled = false;
+ private boolean connectionDisconnectedCalled = false;
+ private boolean connectionDisconnectingCalled = false;
+ private boolean connectionOpenedCalled = false;
+ private SessionEvent sessionEvent;
+ private String message;
+ private boolean connectionErrorCalled;
+
+ public boolean isSessionDisconnectedCalled()
+ {
+ return connectionDisconnectedCalled;
+ }
+
+ public boolean isSessionDisconnectingCalled()
+ {
+ return connectionDisconnectingCalled;
+ }
+
+ public boolean isSessionLoggedInCalled()
+ {
+ return connectionLoggedInCalled;
+ }
+
+ public boolean isSessionLoggedOffCalled()
+ {
+ return connectionLoggedOffCalled;
+ }
+
+ public boolean isSessionOpenedCalled()
+ {
+ return connectionOpenedCalled;
+ }
+
+ public boolean isSessionOpenningCalled()
+ {
+ return connectionOpenningCalled;
+ }
+
+ public boolean isSessionRefusedCalled()
+ {
+ return connectionRefusedCalled;
+ }
+
+ public boolean isDebugCalled()
+ {
+ return debugCalled;
+ }
+
+ public void reset()
+ {
+ connectionOpenningCalled = false;
+ debugCalled = false;
+ connectionLoggedOffCalled = false;
+ connectionLoggedInCalled = false;
+ connectionRefusedCalled = false;
+ connectionDisconnectedCalled = false;
+ connectionDisconnectingCalled = false;
+ connectionOpenedCalled = false;
+ sessionEvent = null;
+ message = null;
+ }
+
+ public void sessionOpening( final SessionEvent connectionEvent )
+ {
+ connectionOpenningCalled = true;
+ this.sessionEvent = connectionEvent;
+ }
+
+ public void sessionOpened( final SessionEvent connectionEvent )
+ {
+ connectionOpenedCalled = true;
+ this.sessionEvent = connectionEvent;
+
+ }
+
+ public void sessionDisconnecting( final SessionEvent connectionEvent )
+ {
+
+ connectionDisconnectingCalled = true;
+ this.sessionEvent = connectionEvent;
+ }
+
+ public void sessionDisconnected( final SessionEvent connectionEvent )
+ {
+
+ connectionDisconnectedCalled = true;
+ this.sessionEvent = connectionEvent;
+ }
+
+ public void sessionConnectionRefused( final SessionEvent connectionEvent )
+ {
+ connectionRefusedCalled = true;
+ this.sessionEvent = connectionEvent;
+ }
+
+ public void sessionLoggedIn( final SessionEvent connectionEvent )
+ {
+ connectionLoggedInCalled = true;
+ this.sessionEvent = connectionEvent;
+ }
+
+ public void sessionLoggedOff( final SessionEvent connectionEvent )
+ {
+ connectionLoggedOffCalled = true;
+ this.sessionEvent = connectionEvent;
+ }
+
+ public void sessionError( final SessionEvent connectionEvent )
+ {
+ connectionErrorCalled = true;
+ this.sessionEvent = connectionEvent;
+ }
+
+ public void debug( final String message )
+ {
+ debugCalled = true;
+ this.message = message;
+ }
+
+ public SessionEvent getSessionEvent()
+ {
+ return sessionEvent;
+ }
+
+ public String getDebugMessage()
+ {
+ return message;
+ }
+}
diff --git a/wagon-provider-api/src/test/java/org/apache/maven/wagon/events/MockTransferListener.java b/wagon-provider-api/src/test/java/org/apache/maven/wagon/events/MockTransferListener.java
new file mode 100644
index 0000000..78ca56e
--- /dev/null
+++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/events/MockTransferListener.java
@@ -0,0 +1,193 @@
+package org.apache.maven.wagon.events;
+
+/* ====================================================================
+ * The The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2003 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache Maven" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache Maven", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ * ====================================================================
+ */
+
+
+/**
+ * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
+ * @version $Id$
+ */
+public class MockTransferListener implements TransferListener
+{
+
+ private String debugMessage;
+ private boolean debugCalled;
+ private TransferEvent transferEvent;
+ private boolean transferCompletedCalled;
+ private boolean transferProgressCalled;
+ private boolean transferStartedCalled;
+ private int numberOfProgressCalls;
+ private boolean transferErrorCalled;
+
+
+ /**
+ * @return Returns the debugCalled.
+ */
+ public boolean isDebugCalled()
+ {
+ return debugCalled;
+ }
+
+ /**
+ * @return Returns the transferCompletedCalled.
+ */
+ public boolean isTransferCompletedCalled()
+ {
+ return transferCompletedCalled;
+ }
+
+ /**
+ * @return Returns the transferEvent.
+ */
+ public TransferEvent getTransferEvent()
+ {
+ return transferEvent;
+ }
+
+ /**
+ * @return Returns the transferProgressCalled.
+ */
+ public boolean isTransferProgressCalled()
+ {
+ return transferProgressCalled;
+ }
+
+ /**
+ * @return Returns the transferStartedCalled.
+ */
+ public boolean isTransferStartedCalled()
+ {
+ return transferStartedCalled;
+ }
+
+ /**
+ * @see org.apache.maven.wagon.events.TransferListener#transferStarted(org.apache.maven.wagon.events.TransferEvent)
+ */
+ public void transferStarted( final TransferEvent transferEvent )
+ {
+ this.transferEvent = transferEvent;
+ transferStartedCalled = true;
+
+ }
+
+ /**
+ * @see org.apache.maven.wagon.events.TransferListener#transferProgress(org.apache.maven.wagon.events.TransferEvent)
+ */
+ public void transferProgress( final TransferEvent transferEvent )
+ {
+ this.transferEvent = transferEvent;
+ transferProgressCalled = true;
+ numberOfProgressCalls++;
+
+ }
+
+ /**
+ * @see org.apache.maven.wagon.events.TransferListener#transferCompleted(org.apache.maven.wagon.events.TransferEvent)
+ */
+ public void transferCompleted( final TransferEvent transferEvent )
+ {
+ this.transferEvent = transferEvent;
+ transferCompletedCalled = true;
+
+ }
+
+ /**
+ * @see org.apache.maven.wagon.events.TransferListener#debug(java.lang.String)
+ */
+ public void debug( final String message )
+ {
+ debugMessage = message;
+ debugCalled = true;
+
+ }
+
+ /**
+ * @return
+ */
+ public String getDebugMessage()
+ {
+
+ return debugMessage;
+ }
+
+ /**
+ * @return Returns the numberOfprogressCalls.
+ */
+ public int getNumberOfProgressCalls()
+ {
+ return numberOfProgressCalls;
+ }
+
+ /**
+ * @see org.apache.maven.wagon.events.TransferListener#transferError(org.apache.maven.wagon.events.TransferEvent)
+ */
+ public void transferError( final TransferEvent transferEvent )
+ {
+ this.transferEvent = transferEvent;
+ transferErrorCalled = true;
+
+ }
+
+ /**
+ * @return Returns the transferErrorCalled.
+ */
+ public boolean isTransferErrorCalled()
+ {
+ return transferErrorCalled;
+ }
+
+}
diff --git a/wagon-provider-api/src/test/java/org/apache/maven/wagon/events/SessionEventSupportTest.java b/wagon-provider-api/src/test/java/org/apache/maven/wagon/events/SessionEventSupportTest.java
new file mode 100644
index 0000000..8f11d6e
--- /dev/null
+++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/events/SessionEventSupportTest.java
@@ -0,0 +1,210 @@
+package org.apache.maven.wagon.events;
+
+import junit.framework.TestCase;
+import org.apache.maven.wagon.Wagon;
+import org.apache.maven.wagon.providers.file.FileWagon;
+
+/**
+ * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
+ * @version $Id$
+ */
+public class SessionEventSupportTest extends TestCase
+{
+
+ private SessionEventSupport eventSupport;
+
+
+ /**
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception
+ {
+
+ super.setUp();
+ eventSupport = new SessionEventSupport();
+
+
+ }
+
+ public void testSessionListenerRegistration()
+ {
+ final MockSessionListener mock1 = new MockSessionListener();
+ eventSupport.addSessionListener( mock1 );
+
+ assertTrue( eventSupport.hasSessionListener( mock1 ) );
+ final MockSessionListener mock2 = new MockSessionListener();
+
+ assertFalse( eventSupport.hasSessionListener( mock2 ) );
+
+ eventSupport.addSessionListener( mock2 );
+
+ assertTrue( eventSupport.hasSessionListener( mock1 ) );
+ assertTrue( eventSupport.hasSessionListener( mock2 ) );
+
+ eventSupport.removeSessionListener( mock2 );
+
+ assertTrue( eventSupport.hasSessionListener( mock1 ) );
+ assertFalse( eventSupport.hasSessionListener( mock2 ) );
+
+ eventSupport.removeSessionListener( mock1 );
+ assertFalse( eventSupport.hasSessionListener( mock1 ) );
+ }
+
+ public void testFireSessionDisconnected()
+ {
+
+ final MockSessionListener mock1 = new MockSessionListener();
+ eventSupport.addSessionListener( mock1 );
+
+ final MockSessionListener mock2 = new MockSessionListener();
+ eventSupport.addSessionListener( mock2 );
+
+ final Wagon wagon = new FileWagon();
+ final SessionEvent event = new SessionEvent( wagon, 1 );
+
+ eventSupport.fireSessionDisconnected( event );
+
+ assertTrue( mock1.isSessionDisconnectedCalled() );
+ assertTrue( mock2.isSessionDisconnectedCalled() );
+ assertEquals( event, mock1.getSessionEvent() );
+ assertEquals( event, mock2.getSessionEvent() );
+
+ }
+
+ public void testFireSessionDisconneting()
+ {
+ final MockSessionListener mock1 = new MockSessionListener();
+ eventSupport.addSessionListener( mock1 );
+
+ final MockSessionListener mock2 = new MockSessionListener();
+ eventSupport.addSessionListener( mock2 );
+
+ final Wagon wagon = new FileWagon();
+ final SessionEvent event = new SessionEvent( wagon, 1 );
+
+ eventSupport.fireSessionDisconnecting( event );
+
+ assertTrue( mock1.isSessionDisconnectingCalled() );
+ assertTrue( mock2.isSessionDisconnectingCalled() );
+ assertEquals( event, mock1.getSessionEvent() );
+ assertEquals( event, mock2.getSessionEvent() );
+ }
+
+ public void testFireSessionLoggedIn()
+ {
+ final MockSessionListener mock1 = new MockSessionListener();
+ eventSupport.addSessionListener( mock1 );
+
+ final MockSessionListener mock2 = new MockSessionListener();
+ eventSupport.addSessionListener( mock2 );
+
+ final Wagon wagon = new FileWagon();
+ final SessionEvent event = new SessionEvent( wagon, 1 );
+
+ eventSupport.fireSessionLoggedIn( event );
+
+ assertTrue( mock1.isSessionLoggedInCalled() );
+ assertTrue( mock2.isSessionLoggedInCalled() );
+ assertEquals( event, mock1.getSessionEvent() );
+ assertEquals( event, mock2.getSessionEvent() );
+
+ }
+
+ public void testFireSessionLoggedOff()
+ {
+ final MockSessionListener mock1 = new MockSessionListener();
+ eventSupport.addSessionListener( mock1 );
+
+ final MockSessionListener mock2 = new MockSessionListener();
+ eventSupport.addSessionListener( mock2 );
+
+ final Wagon wagon = new FileWagon();
+ final SessionEvent event = new SessionEvent( wagon, 1 );
+
+ eventSupport.fireSessionLoggedOff( event );
+
+ assertTrue( mock1.isSessionLoggedOffCalled() );
+ assertTrue( mock2.isSessionLoggedOffCalled() );
+ assertEquals( event, mock1.getSessionEvent() );
+ assertEquals( event, mock2.getSessionEvent() );
+ }
+
+ public void testFireSessionOpened()
+ {
+
+ final MockSessionListener mock1 = new MockSessionListener();
+ eventSupport.addSessionListener( mock1 );
+
+ final MockSessionListener mock2 = new MockSessionListener();
+ eventSupport.addSessionListener( mock2 );
+
+ final Wagon wagon = new FileWagon();
+ final SessionEvent event = new SessionEvent( wagon, 1 );
+
+ eventSupport.fireSessionOpened( event );
+
+ assertTrue( mock1.isSessionOpenedCalled() );
+ assertTrue( mock2.isSessionOpenedCalled() );
+ assertEquals( event, mock1.getSessionEvent() );
+ assertEquals( event, mock2.getSessionEvent() );
+
+ }
+
+ public void testFireSessionOpenning()
+ {
+
+ final MockSessionListener mock1 = new MockSessionListener();
+ eventSupport.addSessionListener( mock1 );
+
+ final MockSessionListener mock2 = new MockSessionListener();
+ eventSupport.addSessionListener( mock2 );
+
+ final Wagon wagon = new FileWagon();
+ final SessionEvent event = new SessionEvent( wagon, 1 );
+
+ eventSupport.fireSessionOpening( event );
+
+ assertTrue( mock1.isSessionOpenningCalled() );
+ assertTrue( mock2.isSessionOpenningCalled() );
+ assertEquals( event, mock1.getSessionEvent() );
+ assertEquals( event, mock2.getSessionEvent() );
+
+ }
+
+ public void testFireSessionRefused()
+ {
+ final MockSessionListener mock1 = new MockSessionListener();
+ eventSupport.addSessionListener( mock1 );
+
+ final MockSessionListener mock2 = new MockSessionListener();
+ eventSupport.addSessionListener( mock2 );
+
+ final Wagon wagon = new FileWagon();
+ final SessionEvent event = new SessionEvent( wagon, 1 );
+
+ eventSupport.fireSessionConnectionRefused( event );
+
+ assertTrue( mock1.isSessionRefusedCalled() );
+ assertTrue( mock2.isSessionRefusedCalled() );
+ assertEquals( event, mock1.getSessionEvent() );
+ assertEquals( event, mock2.getSessionEvent() );
+ }
+
+ public void testFireDebug()
+ {
+ final MockSessionListener mock1 = new MockSessionListener();
+ eventSupport.addSessionListener( mock1 );
+
+ final MockSessionListener mock2 = new MockSessionListener();
+ eventSupport.addSessionListener( mock2 );
+
+ eventSupport.fireDebug( "mm" );
+
+ assertTrue( mock1.isDebugCalled() );
+ assertTrue( mock2.isDebugCalled() );
+ assertEquals( "mm", mock1.getDebugMessage() );
+ assertEquals( "mm", mock2.getDebugMessage() );
+
+ }
+
+}
diff --git a/wagon-provider-api/src/test/java/org/apache/maven/wagon/events/SessionEventTest.java b/wagon-provider-api/src/test/java/org/apache/maven/wagon/events/SessionEventTest.java
new file mode 100644
index 0000000..8b2072e
--- /dev/null
+++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/events/SessionEventTest.java
@@ -0,0 +1,196 @@
+package org.apache.maven.wagon.events;
+
+/*
+ * ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met: 1.
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer. 2. Redistributions in
+ * binary form must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or other
+ * materials provided with the distribution. 3. The end-user documentation
+ * included with the redistribution, if any, must include the following
+ * acknowledgment: "This product includes software developed by the Apache
+ * Software Foundation (http://www.apache.org/)." Alternately, this
+ * acknowledgment may appear in the software itself, if and wherever such
+ * third-party acknowledgments normally appear. 4. The names "Apache" and
+ * "Apache Software Foundation" and "Apache Maven" must not be used to endorse
+ * or promote products derived from this software without prior written
+ * permission. For written permission, please contact apache@apache.org. 5.
+ * Products derived from this software may not be called "Apache", "Apache
+ * Maven", nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * on behalf of the Apache Software Foundation. For more information on the
+ * Apache Software Foundation, please see <http://www.apache.org/> .
+ *
+ * ====================================================================
+ */
+
+import junit.framework.TestCase;
+import org.apache.maven.wagon.authentication.AuthenticationException;
+import org.apache.maven.wagon.repository.Repository;
+import org.apache.maven.wagon.Wagon;
+import org.apache.maven.wagon.ConnectionException;
+import org.apache.maven.wagon.MockWagon;
+
+/**
+ * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
+ * @version $Id$
+ */
+public class SessionEventTest extends TestCase
+{
+
+ /*
+ * @see TestCase#setUp()
+ */
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ }
+
+ /**
+ * Constructor for SESSIONEventTest.
+ *
+ * @param arg0
+ */
+ public SessionEventTest( final String arg0 )
+ {
+ super( arg0 );
+ }
+
+ /*
+ * Class to test for void SESSIONEvent(Wagon, Repository, String, int,
+ * int)
+ */
+ public void testSessionEventProperties()
+ {
+
+ final Wagon wagon = new MockWagon();
+ final Repository repo = new Repository();
+ try
+ {
+ wagon.connect( repo );
+ }
+ catch ( Exception e )
+ {
+ fail( e.getMessage() );
+ }
+ final long timestamp = System.currentTimeMillis();
+ final Exception exception = new AuthenticationException( "dummy" );
+
+ SessionEvent event =
+ new SessionEvent(
+ wagon,
+ SessionEvent.SESSION_CLOSED );
+
+ assertEquals( wagon, event.getWagon() );
+ assertEquals( repo, event.getWagon().getRepository() );
+
+ assertEquals( SessionEvent.SESSION_CLOSED, event.getEventType() );
+
+
+ event = new SessionEvent( wagon, exception );
+
+ assertEquals( wagon, event.getWagon() );
+ assertEquals( repo, event.getWagon().getRepository() );
+ assertEquals( SessionEvent.SESSION_ERROR_OCCURRED, event.getEventType() );
+ assertEquals( exception, event.getException() );
+
+
+
+
+ event.setException( null );
+ assertEquals( null, event.getException() );
+
+ event.setException( exception );
+ assertEquals( exception, event.getException() );
+
+ event.setTimestamp( timestamp );
+ assertEquals( timestamp, event.getTimestamp() );
+
+ event.setEventType( SessionEvent.SESSION_CLOSED );
+ assertEquals( SessionEvent.SESSION_CLOSED, event.getEventType() );
+
+ event.setEventType( SessionEvent.SESSION_DISCONNECTED );
+ assertEquals( SessionEvent.SESSION_DISCONNECTED, event.getEventType() );
+
+ event.setEventType( SessionEvent.SESSION_DISCONNECTING );
+ assertEquals( SessionEvent.SESSION_DISCONNECTING, event.getEventType() );
+
+ event.setEventType( SessionEvent.SESSION_ERROR_OCCURRED );
+ assertEquals( SessionEvent.SESSION_ERROR_OCCURRED, event.getEventType() );
+
+ event.setEventType( SessionEvent.SESSION_LOGGED_IN );
+ assertEquals( SessionEvent.SESSION_LOGGED_IN, event.getEventType() );
+
+ event.setEventType( SessionEvent.SESSION_LOGGED_OFF );
+ assertEquals( SessionEvent.SESSION_LOGGED_OFF, event.getEventType() );
+
+ event.setEventType( SessionEvent.SESSION_OPENED );
+ assertEquals( SessionEvent.SESSION_OPENED, event.getEventType() );
+
+ event.setEventType( SessionEvent.SESSION_OPENING );
+ assertEquals( SessionEvent.SESSION_OPENING, event.getEventType() );
+
+ event.setEventType( SessionEvent.SESSION_CONNECTION_REFUSED );
+ assertEquals( SessionEvent.SESSION_CONNECTION_REFUSED, event.getEventType() );
+
+
+ try
+ {
+ event.setEventType( -1 );
+ fail( "Exception expected" );
+ }
+ catch ( IllegalArgumentException e )
+ {
+ }
+
+
+ }
+
+ public void testConstantValueConflict()
+ {
+ final int[] values =
+ {
+ SessionEvent.SESSION_CLOSED,
+ SessionEvent.SESSION_DISCONNECTED,
+ SessionEvent.SESSION_DISCONNECTING,
+ SessionEvent.SESSION_ERROR_OCCURRED,
+ SessionEvent.SESSION_LOGGED_IN,
+ SessionEvent.SESSION_LOGGED_OFF,
+ SessionEvent.SESSION_OPENED,
+ SessionEvent.SESSION_OPENING,
+ SessionEvent.SESSION_CONNECTION_REFUSED};
+
+ for ( int i = 0; i < values.length; i++ )
+ {
+ for ( int j = i + 1; j < values.length; j++ )
+ {
+
+ final String msg =
+ "Value confict at [i,j]=[" + i + "," + j + "]";
+ assertTrue( msg, values[i] != values[j] );
+ }
+ }
+
+ }
+
+}
diff --git a/wagon-provider-api/src/test/java/org/apache/maven/wagon/events/TransferEventSupportTest.java b/wagon-provider-api/src/test/java/org/apache/maven/wagon/events/TransferEventSupportTest.java
new file mode 100644
index 0000000..1074a31
--- /dev/null
+++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/events/TransferEventSupportTest.java
@@ -0,0 +1,159 @@
+package org.apache.maven.wagon.events;
+
+import junit.framework.TestCase;
+import org.apache.maven.wagon.Wagon;
+import org.apache.maven.wagon.providers.file.FileWagon;
+
+/**
+ * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
+ * @version $Id: TransferEventSupportTest.java,v 1.2 2003/11/16 12:41:02 michal
+ * Exp $
+ */
+public class TransferEventSupportTest extends TestCase
+{
+
+ private TransferEventSupport eventSupport;
+
+ /**
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception
+ {
+
+ super.setUp();
+ eventSupport = new TransferEventSupport();
+
+ }
+
+ public void testTransferListenerRegistration()
+ {
+ final MockTransferListener mock1 = new MockTransferListener();
+ eventSupport.addTransferListener( mock1 );
+
+ assertTrue( eventSupport.hasTransferListener( mock1 ) );
+ final MockTransferListener mock2 = new MockTransferListener();
+
+ assertFalse( eventSupport.hasTransferListener( mock2 ) );
+
+ eventSupport.addTransferListener( mock2 );
+
+ assertTrue( eventSupport.hasTransferListener( mock1 ) );
+ assertTrue( eventSupport.hasTransferListener( mock2 ) );
+
+ eventSupport.removeTransferListener( mock2 );
+
+ assertTrue( eventSupport.hasTransferListener( mock1 ) );
+ assertFalse( eventSupport.hasTransferListener( mock2 ) );
+
+ eventSupport.removeTransferListener( mock1 );
+ assertFalse( eventSupport.hasTransferListener( mock1 ) );
+ }
+
+ public void testFireTransferStarted()
+ {
+ final MockTransferListener mock1 = new MockTransferListener();
+ eventSupport.addTransferListener( mock1 );
+
+ final MockTransferListener mock2 = new MockTransferListener();
+ eventSupport.addTransferListener( mock2 );
+
+ final Wagon wagon = new FileWagon();
+ final TransferEvent event = getEvent( wagon );
+
+ eventSupport.fireTransferStarted( event );
+
+ assertTrue( mock1.isTransferStartedCalled() );
+ assertTrue( mock2.isTransferStartedCalled() );
+ assertEquals( event, mock1.getTransferEvent() );
+ assertEquals( event, mock2.getTransferEvent() );
+
+ }
+
+ public void testFireTransferProgress()
+ {
+ final MockTransferListener mock1 = new MockTransferListener();
+ eventSupport.addTransferListener( mock1 );
+
+ final MockTransferListener mock2 = new MockTransferListener();
+ eventSupport.addTransferListener( mock2 );
+
+ final Wagon wagon = new FileWagon();
+ final TransferEvent event = getEvent( wagon );
+
+ eventSupport.fireTransferProgress( event );
+
+ assertTrue( mock1.isTransferProgressCalled() );
+ assertTrue( mock2.isTransferProgressCalled() );
+ assertEquals( event, mock1.getTransferEvent() );
+ assertEquals( event, mock2.getTransferEvent() );
+ }
+
+ public void testFireTransferCompleted()
+ {
+ final MockTransferListener mock1 = new MockTransferListener();
+ eventSupport.addTransferListener( mock1 );
+
+ final MockTransferListener mock2 = new MockTransferListener();
+ eventSupport.addTransferListener( mock2 );
+
+ final Wagon wagon = new FileWagon();
+ final TransferEvent event = getEvent( wagon );
+
+ eventSupport.fireTransferCompleted( event );
+
+ assertTrue( mock1.isTransferCompletedCalled() );
+ assertTrue( mock2.isTransferCompletedCalled() );
+ assertEquals( event, mock1.getTransferEvent() );
+ assertEquals( event, mock2.getTransferEvent() );
+
+ }
+
+ public void testFireTransferError()
+ {
+ final MockTransferListener mock1 = new MockTransferListener();
+ eventSupport.addTransferListener( mock1 );
+
+ final MockTransferListener mock2 = new MockTransferListener();
+ eventSupport.addTransferListener( mock2 );
+
+ final Wagon wagon = new FileWagon();
+ final TransferEvent event = getEvent( wagon );
+
+ eventSupport.fireTransferError( event );
+
+ assertTrue( mock1.isTransferErrorCalled() );
+ assertTrue( mock2.isTransferErrorCalled() );
+ assertEquals( event, mock1.getTransferEvent() );
+ assertEquals( event, mock2.getTransferEvent() );
+
+ }
+
+ public void testFireDebug()
+ {
+ final MockTransferListener mock1 = new MockTransferListener();
+ eventSupport.addTransferListener( mock1 );
+
+ final MockTransferListener mock2 = new MockTransferListener();
+ eventSupport.addTransferListener( mock2 );
+
+ eventSupport.fireDebug( "mm" );
+
+ assertTrue( mock1.isDebugCalled() );
+ assertTrue( mock2.isDebugCalled() );
+ assertEquals( "mm", mock1.getDebugMessage() );
+ assertEquals( "mm", mock2.getDebugMessage() );
+
+ }
+
+ private TransferEvent getEvent( final Wagon wagon )
+ {
+ final TransferEvent event =
+ new TransferEvent(
+ wagon,
+ null,
+ TransferEvent.TRANSFER_COMPLETED,
+ TransferEvent.REQUEST_GET );
+ return event;
+ }
+
+}
diff --git a/wagon-provider-api/src/test/java/org/apache/maven/wagon/events/TransferEventTest.java b/wagon-provider-api/src/test/java/org/apache/maven/wagon/events/TransferEventTest.java
new file mode 100644
index 0000000..6fcecf2
--- /dev/null
+++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/events/TransferEventTest.java
@@ -0,0 +1,158 @@
+package org.apache.maven.wagon.events;
+
+import junit.framework.TestCase;
+import org.apache.maven.wagon.authentication.AuthenticationException;
+import org.apache.maven.wagon.repository.Repository;
+import org.apache.maven.wagon.Wagon;
+import org.apache.maven.wagon.providers.file.FileWagon;
+
+/**
+ * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
+ * @version $Id$
+ */
+public class TransferEventTest extends TestCase
+{
+
+ /*
+ * @see TestCase#setUp()
+ */
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ }
+
+ /**
+ * Constructor for TransferEventTest.
+ *
+ * @param arg0
+ */
+ public TransferEventTest( final String arg0 )
+ {
+ super( arg0 );
+ }
+
+ /*
+ * Class to test for void TransferEvent(Wagon, Repository, String, int,
+ * int)
+ */
+ public void testTransferEventProperties()
+ {
+
+ final Wagon wagon = new FileWagon();
+ final Repository repo = new Repository();
+ try
+ {
+ wagon.connect( repo );
+ }
+ catch ( Exception e )
+ {
+ fail( e.getMessage() );
+ }
+ final long timestamp = System.currentTimeMillis();
+ final Exception exception = new AuthenticationException( "dummy" );
+
+ TransferEvent event =
+ new TransferEvent(
+ wagon,
+ "mm",
+ TransferEvent.TRANSFER_COMPLETED,
+ TransferEvent.REQUEST_GET );
+
+ assertEquals( wagon, event.getWagon() );
+ assertEquals( repo, event.getWagon().getRepository() );
+ assertEquals( "mm", event.getResource() );
+ assertEquals( TransferEvent.TRANSFER_COMPLETED, event.getEventType() );
+ assertEquals( TransferEvent.REQUEST_GET, event.getRequestType() );
+
+ event = new TransferEvent( wagon, "mm", exception );
+
+ assertEquals( wagon, event.getWagon() );
+ assertEquals( repo, event.getWagon().getRepository() );
+ assertEquals( "mm", event.getResource() );
+ assertEquals( TransferEvent.TRANSFER_ERROR, event.getEventType() );
+ assertEquals( exception, event.getException() );
+
+
+
+ event.setResource( null );
+ assertEquals( null, event.getResource() );
+
+ event.setResource( "/foo/baa" );
+ assertEquals( "/foo/baa", event.getResource() );
+
+ event.setException( null );
+ assertEquals( null, event.getException() );
+
+ event.setException( exception );
+ assertEquals( exception, event.getException() );
+
+ event.setTimestamp( timestamp );
+ assertEquals( timestamp, event.getTimestamp() );
+
+ event.setRequestType( TransferEvent.REQUEST_PUT );
+ assertEquals( TransferEvent.REQUEST_PUT, event.getRequestType() );
+
+ event.setRequestType( TransferEvent.REQUEST_GET );
+ assertEquals( TransferEvent.REQUEST_GET, event.getRequestType() );
+
+ try
+ {
+ event.setRequestType( -1 );
+ fail( "Exception expected" );
+ }
+ catch ( IllegalArgumentException e )
+ {
+ }
+
+ event.setEventType( TransferEvent.TRANSFER_COMPLETED );
+ assertEquals( TransferEvent.TRANSFER_COMPLETED, event.getEventType() );
+
+ event.setEventType( TransferEvent.TRANSFER_ERROR );
+ assertEquals( TransferEvent.TRANSFER_ERROR, event.getEventType() );
+
+ event.setEventType( TransferEvent.TRANSFER_STARTED );
+ assertEquals( TransferEvent.TRANSFER_STARTED, event.getEventType() );
+
+ event.setEventType( TransferEvent.TRANSFER_PROGRESS );
+ assertEquals( TransferEvent.TRANSFER_PROGRESS, event.getEventType() );
+
+ try
+ {
+ event.setEventType( -1 );
+ fail( "Exception expected" );
+ }
+ catch ( IllegalArgumentException e )
+ {
+ }
+
+
+ event.setProgress( ( long ) 10 );
+ assertEquals( ( long ) 10, event.getProgress() );
+
+ }
+
+ public void testConstantValueConflict()
+ {
+ final int[] values =
+ {
+ TransferEvent.TRANSFER_COMPLETED,
+ TransferEvent.TRANSFER_ERROR,
+ TransferEvent.TRANSFER_STARTED,
+ TransferEvent.TRANSFER_PROGRESS,
+ TransferEvent.REQUEST_GET,
+ TransferEvent.REQUEST_PUT};
+
+ for ( int i = 0; i < values.length; i++ )
+ {
+ for ( int j = i + 1; j < values.length; j++ )
+ {
+
+ final String msg =
+ "Value confict at [i,j]=[" + i + "," + j + "]";
+ assertTrue( msg, values[i] != values[j] );
+ }
+ }
+
+ }
+
+}
diff --git a/wagon-provider-api/src/test/java/org/apache/maven/wagon/manager/DefaultWagonManagerTest.java b/wagon-provider-api/src/test/java/org/apache/maven/wagon/manager/DefaultWagonManagerTest.java
new file mode 100644
index 0000000..2235161
--- /dev/null
+++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/manager/DefaultWagonManagerTest.java
@@ -0,0 +1,57 @@
+package org.apache.maven.wagon.manager;
+
+import org.apache.maven.wagon.UnsupportedProtocolException;
+import org.apache.maven.wagon.Wagon;
+import org.codehaus.plexus.PlexusTestCase;
+
+/**
+ * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
+ * @version $Id$
+ */
+public class DefaultWagonManagerTest
+ extends PlexusTestCase
+{
+ public void testDefaltWagonManager()
+ throws Exception
+ {
+ WagonManager wagonManager = (WagonManager) lookup( WagonManager.ROLE );
+
+ Wagon wagon = null;
+
+ try
+ {
+ wagon = (Wagon) wagonManager.getWagon( "a" );
+
+ assertNotNull( wagon );
+
+ wagon = (Wagon) wagonManager.getWagon( "b1" );
+
+ assertNotNull( wagon );
+
+ wagon = (Wagon) wagonManager.getWagon( "b2" );
+
+ assertNotNull( wagon );
+
+ wagon = (Wagon) wagonManager.getWagon( "c" );
+
+ assertNotNull( wagon );
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+
+ fail( e.getMessage() );
+ }
+
+ try
+ {
+ wagon = (Wagon) wagonManager.getWagon( "d" );
+
+ fail( "Expected :" + UnsupportedProtocolException.class.getName() );
+ }
+ catch ( UnsupportedProtocolException e )
+ {
+ //ok
+ }
+ }
+}
diff --git a/wagon-provider-api/src/test/java/org/apache/maven/wagon/manager/DefaultWagonManagerTest.xml b/wagon-provider-api/src/test/java/org/apache/maven/wagon/manager/DefaultWagonManagerTest.xml
new file mode 100644
index 0000000..a00b97c
--- /dev/null
+++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/manager/DefaultWagonManagerTest.xml
@@ -0,0 +1,24 @@
+<plexus>
+ <components>
+ <component>
+ <role>org.apache.maven.wagon.Wagon</role>
+ <role-hint>a</role-hint>
+ <implementation>org.apache.maven.wagon.manager.WagonA</implementation>
+ </component>
+ <component>
+ <role>org.apache.maven.wagon.Wagon</role>
+ <role-hint>b1</role-hint>
+ <implementation>org.apache.maven.wagon.manager.WagonB</implementation>
+ </component>
+ <component>
+ <role>org.apache.maven.wagon.Wagon</role>
+ <role-hint>b2</role-hint>
+ <implementation>org.apache.maven.wagon.manager.WagonB</implementation>
+ </component>
+ <component>
+ <role>org.apache.maven.wagon.Wagon</role>
+ <role-hint>c</role-hint>
+ <implementation>org.apache.maven.wagon.manager.WagonC</implementation>
+ </component>
+ </components>
+</plexus>
\ No newline at end of file
diff --git a/wagon-provider-api/src/test/java/org/apache/maven/wagon/manager/WagonA.java b/wagon-provider-api/src/test/java/org/apache/maven/wagon/manager/WagonA.java
new file mode 100644
index 0000000..da6f06a
--- /dev/null
+++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/manager/WagonA.java
@@ -0,0 +1,19 @@
+package org.apache.maven.wagon.manager;
+
+import org.apache.maven.wagon.providers.file.FileWagon;
+
+/**
+ *
+ *
+ * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
+ *
+ * @version $Id$
+ */
+public class WagonA
+ extends FileWagon
+{
+ public String[] getSupportedProtocols()
+ {
+ return new String[]{ "a" };
+ }
+}
diff --git a/wagon-provider-api/src/test/java/org/apache/maven/wagon/manager/WagonB.java b/wagon-provider-api/src/test/java/org/apache/maven/wagon/manager/WagonB.java
new file mode 100644
index 0000000..131b61a
--- /dev/null
+++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/manager/WagonB.java
@@ -0,0 +1,19 @@
+package org.apache.maven.wagon.manager;
+
+import org.apache.maven.wagon.providers.file.FileWagon;
+
+/**
+ *
+ *
+ * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
+ *
+ * @version $Id$
+ */
+public class WagonB
+ extends FileWagon
+{
+ public String[] getSupportedProtocols()
+ {
+ return new String[]{ "b1", "b2" };
+ }
+}
diff --git a/wagon-provider-api/src/test/java/org/apache/maven/wagon/manager/WagonC.java b/wagon-provider-api/src/test/java/org/apache/maven/wagon/manager/WagonC.java
new file mode 100644
index 0000000..db50c8e
--- /dev/null
+++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/manager/WagonC.java
@@ -0,0 +1,19 @@
+package org.apache.maven.wagon.manager;
+
+import org.apache.maven.wagon.providers.file.FileWagon;
+
+/**
+ *
+ *
+ * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
+ *
+ * @version $Id$
+ */
+public class WagonC
+ extends FileWagon
+{
+ public String[] getSupportedProtocols()
+ {
+ return new String[]{ "c" };
+ }
+}
diff --git a/wagon-provider-api/src/test/java/org/apache/maven/wagon/providers/file/FileWagonTest.java b/wagon-provider-api/src/test/java/org/apache/maven/wagon/providers/file/FileWagonTest.java
new file mode 100644
index 0000000..f1645d6
--- /dev/null
+++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/providers/file/FileWagonTest.java
@@ -0,0 +1,38 @@
+package org.apache.maven.wagon.providers.file;
+
+/*
+ * Copyright 2001-2004 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 org.apache.maven.wagon.WagonTestCase;
+
+/**
+ * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
+ * @version $Id$
+ */
+public class FileWagonTest
+ extends WagonTestCase
+{
+ protected String getProtocol()
+ {
+ return "file";
+ }
+
+ protected String getTestRepositoryUrl()
+ {
+ return "file://" + basedir + "/target/file-repository";
+ }
+}
diff --git a/wagon-provider-api/src/test/java/org/apache/maven/wagon/proxy/ProxyInfoTest.java b/wagon-provider-api/src/test/java/org/apache/maven/wagon/proxy/ProxyInfoTest.java
new file mode 100644
index 0000000..dcb1d3f
--- /dev/null
+++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/proxy/ProxyInfoTest.java
@@ -0,0 +1,103 @@
+package org.apache.maven.wagon.proxy;
+
+/*
+ * ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met: 1.
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer. 2. Redistributions in
+ * binary form must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or other
+ * materials provided with the distribution. 3. The end-user documentation
+ * included with the redistribution, if any, must include the following
+ * acknowledgment: "This product includes software developed by the Apache
+ * Software Foundation (http://www.apache.org/)." Alternately, this
+ * acknowledgment may appear in the software itself, if and wherever such
+ * third-party acknowledgments normally appear. 4. The names "Apache" and
+ * "Apache Software Foundation" and "Apache Maven" must not be used to
+ * endorse or promote products derived from this software without prior written
+ * permission. For written permission, please contact apache@apache.org. 5.
+ * Products derived from this software may not be called "Apache", "Apache
+ * MavenSession", nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * on behalf of the Apache Software Foundation. For more information on the
+ * Apache Software Foundation, please see <http://www.apache.org/> .
+ *
+ * ====================================================================
+ */
+
+import junit.framework.TestCase;
+import org.apache.maven.wagon.proxy.ProxyInfo;
+
+/**
+ * @author <a href="mailto:jvanzyl@maven.org">Jason van Zyl</a>
+ * @version $Id$
+ */
+public class ProxyInfoTest
+ extends TestCase
+{
+ public ProxyInfoTest( final String name )
+ {
+ super( name );
+ }
+
+ public void setUp()
+ throws Exception
+ {
+ super.setUp();
+ }
+
+ public void tearDown()
+ throws Exception
+ {
+ super.tearDown();
+ }
+
+ public void testProxyInfoProperties()
+
+ {
+ final ProxyInfo proxyInfo = new ProxyInfo();
+
+
+ proxyInfo.setUserName( "username" );
+
+ assertEquals( "username", proxyInfo.getUserName() );
+
+
+ proxyInfo.setPassword( "password" );
+
+ assertEquals( "password", proxyInfo.getPassword() );
+
+
+ proxyInfo.setHost( "http://www.ibiblio.org" );
+
+ assertEquals( "http://www.ibiblio.org", proxyInfo.getHost() );
+
+
+ proxyInfo.setPort( 0 );
+
+ assertEquals( 0, proxyInfo.getPort() );
+
+ proxyInfo.setType( "SOCKSv4" );
+
+ assertEquals( "SOCKSv4", proxyInfo.getType() );
+ }
+}
diff --git a/wagon-provider-api/src/test/java/org/apache/maven/wagon/repository/RepositoryTest.java b/wagon-provider-api/src/test/java/org/apache/maven/wagon/repository/RepositoryTest.java
new file mode 100644
index 0000000..5bc7a4f
--- /dev/null
+++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/repository/RepositoryTest.java
@@ -0,0 +1,131 @@
+package org.apache.maven.wagon.repository;
+
+/*
+ * ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met: 1.
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer. 2. Redistributions in
+ * binary form must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or other
+ * materials provided with the distribution. 3. The end-user documentation
+ * included with the redistribution, if any, must include the following
+ * acknowledgment: "This product includes software developed by the Apache
+ * Software Foundation (http://www.apache.org/)." Alternately, this
+ * acknowledgment may appear in the software itself, if and wherever such
+ * third-party acknowledgments normally appear. 4. The names "Apache" and
+ * "Apache Software Foundation" and "Apache Maven" must not be used to
+ * endorse or promote products derived from this software without prior written
+ * permission. For written permission, please contact apache@apache.org. 5.
+ * Products derived from this software may not be called "Apache", "Apache
+ * MavenSession", nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * on behalf of the Apache Software Foundation. For more information on the
+ * Apache Software Foundation, please see <http://www.apache.org/> .
+ *
+ * ====================================================================
+ */
+
+import junit.framework.TestCase;
+import org.apache.maven.wagon.WagonConstants;
+import org.apache.maven.wagon.authentication.AuthenticationInfo;
+import org.apache.maven.wagon.proxy.ProxyInfo;
+
+/**
+ * @author <a href="mailto:jvanzyl@maven.org">Jason van Zyl</a>
+ * @version $Id$
+ */
+public class RepositoryTest
+ extends TestCase
+{
+ public RepositoryTest( final String name )
+ {
+ super( name );
+ }
+
+ public void setUp()
+ throws Exception
+ {
+ super.setUp();
+ }
+
+ public void tearDown()
+ throws Exception
+ {
+ super.tearDown();
+ }
+
+ public void testRepositoryProperties()
+ throws Exception
+ {
+ Repository repository = new Repository();
+
+ repository.setAuthenticationInfo( new AuthenticationInfo() );
+
+ assertNotNull( repository.getAuthenticationInfo() );
+
+ repository.setProxyInfo( new ProxyInfo() );
+
+ assertNotNull( repository.getProxyInfo() );
+
+ repository.setBasedir( "directory" );
+
+ assertEquals( "directory", repository.getBasedir() );
+
+ repository.setName( "name" );
+
+ assertEquals( "name", repository.getName() );
+
+ repository.setPort( 0 );
+
+ assertEquals( 0, repository.getPort() );
+
+ assertEquals( "localhost", repository.getHost() );
+
+ repository.setUrl( "http://www.ibiblio.org" );
+
+ assertEquals( "http", repository.getProtocol() );
+
+ assertEquals( "www.ibiblio.org", repository.getHost() );
+
+ assertEquals( "", repository.getBasedir() );
+
+ assertEquals( WagonConstants.UNKNOWN_PORT, repository.getPort() );
+
+ repository.setUrl( "https://www.ibiblio.org:100/maven" );
+
+ assertEquals( "https://www.ibiblio.org:100/maven", repository.getUrl() );
+
+ assertEquals( "https", repository.getProtocol() );
+
+ assertEquals( "www.ibiblio.org", repository.getHost() );
+
+ assertEquals( "maven", repository.getBasedir() );
+
+ assertEquals( 100, repository.getPort() );
+
+ assertEquals( "www.ibiblio.org", repository.getHost() );
+
+ repository.setBasedir( "basedir" );
+
+ assertEquals( "basedir", repository.getBasedir() );
+ }
+}
diff --git a/wagon-provider-api/xdocs/changes.xml b/wagon-provider-api/xdocs/changes.xml
new file mode 100644
index 0000000..1d013df
--- /dev/null
+++ b/wagon-provider-api/xdocs/changes.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<document>
+ <properties>
+ <title>Changes</title>
+ <author email="michal.maczka@dimatics.com">Michal Maczka</author>
+ </properties>
+ <body>
+ <release version="1.0-beta-1" date="in CVS">
+ <action dev="mmaczka" type="add">
+ Imported to Apache CVS
+ </action>
+ </release>
+ </body>
+</document>
+
diff --git a/wagon-provider-api/xdocs/index.xml b/wagon-provider-api/xdocs/index.xml
new file mode 100644
index 0000000..ed026eb
--- /dev/null
+++ b/wagon-provider-api/xdocs/index.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+
+<document>
+
+ <properties>
+ <title>Wagon API</title>
+ <author email="michal.maczka@dimatics.com">Michal Maczka</author>
+ </properties>
+
+ <body>
+
+ <section name="Wagon API">
+ <p>
+ The "Wagon API" project defines a simple API for transfering resources
+ (artifacts) to and from repositories. The word repository is used in this contextx as
+ it is commonly used in <a href"http://maven.apache.org/misc/glossary.html">Maven</a>
+ And means a storage of artfacts.
+ Wagon is a helper project for Maven and it is planned that Wagon will be used in feature
+ versions of Maven.
+
+ </p>
+ </section>
+
+ </body>
+</document>
diff --git a/wagon-provider-api/xdocs/navigation.xml b/wagon-provider-api/xdocs/navigation.xml
new file mode 100644
index 0000000..bffc859
--- /dev/null
+++ b/wagon-provider-api/xdocs/navigation.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<project
+ name="Wagon FTP provider"
+ href="http://maven.apache.org">
+
+ <title>Wagon</title>
+ <logo href="http://maven.apache.org/maven/images/maven.jsp">Maven</logo>
+ <organizationLogo href="/images/jakarta-logo.gif">Jakarta</organizationLogo>
+ <body>
+ <links>
+ <item name="Maven" href="http://maven.apache.org"/>
+ <item name="Wagon Main" href="http://maven.apache.org/wagon"/>
+ <item name="Jakarta Commons/Net" href="http://jakarta.apache.org/commons/net/"/>
+ </links>
+
+ <menu name="Wagon">
+ <item name="Main" href="/index.html"/>
+ <item name="Status" href="/status.html"/>
+ <item name="News" href="/news.html"/>
+ </menu>
+ </body>
+</project>
+