Author: brett
Date: Wed Jul 29 01:40:29 2009
New Revision: 798744

URL: http://svn.apache.org/viewvc?rev=798744&view=rev
Log:
[MNG-4254] improve integration tests to verify the default wagons

Modified:
    
maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4254SelectableWagonProvidersTest.java
    
maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4254/pom.xml
    
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/pom.xml
    
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/src/main/java/org/apache/maven/plugin/coreit/LoadResourceMojo.java

Modified: 
maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4254SelectableWagonProvidersTest.java
URL: 
http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4254SelectableWagonProvidersTest.java?rev=798744&r1=798743&r2=798744&view=diff
==============================================================================
--- 
maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4254SelectableWagonProvidersTest.java
 (original)
+++ 
maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4254SelectableWagonProvidersTest.java
 Wed Jul 29 01:40:29 2009
@@ -25,6 +25,7 @@
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Properties;
 
 /**
  * This is a test set for <a 
href="http://jira.codehaus.org/browse/MNG-3506";>MNG-3506</a>.
@@ -50,7 +51,6 @@
 
         List cliOptions = new ArrayList();
         cliOptions.add( "-Dmaven.wagon.provider.http=coreit" );
-//        cliOptions.add( "-X" );
         cliOptions.add( "-V" );
         
         verifier.setCliOptions( cliOptions );
@@ -62,6 +62,8 @@
         verifier.resetStreams();
 
         assertTrue( "target/wagon.properties should exist.", new File( 
testDir, "target/wagon.properties" ).exists() );
+        Properties props = verifier.loadProperties( 
"target/wagon-impl.properties" );
+        assertEquals( 
"org.apache.maven.wagon.providers.coreit.CoreItHttpWagon", props.getProperty( 
"wagon.class" ) );
     }
 
     public void testSettingsUsage()
@@ -74,7 +76,6 @@
         List cliOptions = new ArrayList();
         cliOptions.add( "--settings" );
         cliOptions.add( "settings.xml" );
-//        cliOptions.add( "-X" );
         cliOptions.add( "-V" );
 
         verifier.setCliOptions( cliOptions );
@@ -86,5 +87,53 @@
         verifier.resetStreams();
 
         assertTrue( "target/wagon.properties should exist.", new File( 
testDir, "target/wagon.properties" ).exists() );
+        Properties props = verifier.loadProperties( 
"target/wagon-impl.properties" );
+        assertEquals( 
"org.apache.maven.wagon.providers.coreit.CoreItHttpWagon", props.getProperty( 
"wagon.class" ) );
     }
+
+    public void testDefaultHttpWagon()
+        throws IOException, VerificationException
+    {
+        File testDir = ResourceExtractor.simpleExtractResources( getClass(), 
"/mng-4254" );
+
+        Verifier verifier = new Verifier( testDir.getAbsolutePath() );
+
+        List cliOptions = new ArrayList();
+        cliOptions.add( "-V" );
+
+        verifier.setCliOptions( cliOptions );
+        
+        verifier.setLogFileName( "log-default-http.txt" );
+        verifier.executeGoal( "validate" );
+
+        verifier.verifyErrorFreeLog();
+        verifier.resetStreams();
+
+        Properties props = verifier.loadProperties( 
"target/wagon-impl.properties" );
+        assertEquals( 
"org.apache.maven.wagon.providers.http.LightweightHttpWagon", 
props.getProperty( "wagon.class" ) );
+    }
+
+    public void testDefaultHttpsWagon()
+        throws IOException, VerificationException
+    {
+        File testDir = ResourceExtractor.simpleExtractResources( getClass(), 
"/mng-4254" );
+
+        Verifier verifier = new Verifier( testDir.getAbsolutePath() );
+
+        List cliOptions = new ArrayList();
+        cliOptions.add( "-V" );
+        cliOptions.add( "-DwagonProtocol=https" );
+
+        verifier.setCliOptions( cliOptions );
+        
+        verifier.setLogFileName( "log-default-https.txt" );
+        verifier.executeGoal( "validate" );
+
+        verifier.verifyErrorFreeLog();
+        verifier.resetStreams();
+
+        Properties props = verifier.loadProperties( 
"target/wagon-impl.properties" );
+        assertEquals( 
"org.apache.maven.wagon.providers.http.LightweightHttpsWagon", 
props.getProperty( "wagon.class" ) );
+    }
+
 }

Modified: 
maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4254/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4254/pom.xml?rev=798744&r1=798743&r2=798744&view=diff
==============================================================================
--- 
maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4254/pom.xml
 (original)
+++ 
maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4254/pom.xml
 Wed Jul 29 01:40:29 2009
@@ -21,5 +21,29 @@
         <version>2.1-SNAPSHOT</version>
       </extension>
     </extensions>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.its.plugins</groupId>
+        <artifactId>maven-it-plugin-uses-wagon</artifactId>
+        <version>2.1-SNAPSHOT</version>
+        <configuration>
+          
<wagonClassLoaderOutput>target/wagon-impl.properties</wagonClassLoaderOutput>
+          <wagonProtocol>${wagonProtocol}</wagonProtocol>
+          <repositoryId>${repositoryId}</repositoryId>
+        </configuration>
+        <executions>
+          <execution>
+            <id>test</id>
+            <goals>
+              <goal>load-resource</goal>
+           </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
   </build>
+  <properties>
+    <wagonProtocol>http</wagonProtocol>
+    <repositoryId>test</repositoryId>
+  </properties>
 </project>

Modified: 
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/pom.xml?rev=798744&r1=798743&r2=798744&view=diff
==============================================================================
--- 
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/pom.xml
 (original)
+++ 
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/pom.xml
 Wed Jul 29 01:40:29 2009
@@ -43,7 +43,7 @@
     <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-artifact-manager</artifactId>
-      <version>2.0</version>
+      <version>2.0.9</version>
     </dependency>
     <dependency>
       <groupId>org.apache.maven.wagon</groupId>

Modified: 
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/src/main/java/org/apache/maven/plugin/coreit/LoadResourceMojo.java
URL: 
http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/src/main/java/org/apache/maven/plugin/coreit/LoadResourceMojo.java?rev=798744&r1=798743&r2=798744&view=diff
==============================================================================
--- 
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/src/main/java/org/apache/maven/plugin/coreit/LoadResourceMojo.java
 (original)
+++ 
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/src/main/java/org/apache/maven/plugin/coreit/LoadResourceMojo.java
 Wed Jul 29 01:40:29 2009
@@ -23,6 +23,7 @@
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.wagon.repository.Repository;
 
 import java.io.File;
 import java.io.FileOutputStream;
@@ -70,6 +71,13 @@
     private String wagonProtocol;
 
     /**
+     * The repository to load the wagon for, if applicable.
+     * 
+     * @parameter expression="${wagon.repositoryId}"
+     */
+    private String repositoryId;
+
+    /**
      * The set of resources to load. For each specified absolute resource path 
<code>ARP</code> that was successfully
      * loaded, the generated properties files will contain a key named 
<code>ARP</code> whose value gives the URL to the
      * resource. In addition, the keys <code>ARP.count</code>, 
<code>ARP.0</code>, <code>ARP.1</code> etc. will
@@ -92,7 +100,14 @@
         Object wagon;
         try
         {
-            wagon = wagonManager.getWagon( wagonProtocol );
+            if ( repositoryId != null )
+            {
+                wagon = wagonManager.getWagon( new Repository( repositoryId, 
wagonProtocol + "://host/path" ) );
+            }
+            else
+            {
+                wagon = wagonManager.getWagon( wagonProtocol );
+            }
         }
         catch ( Exception e )
         {
@@ -104,31 +119,35 @@
         getLog().info( "[MAVEN-CORE-IT-LOG] Using class loader " + classLoader 
);
 
         Properties loaderProperties = new Properties();
+        loaderProperties.setProperty( "wagon.class", 
wagon.getClass().getName() );
 
-        for ( int i = 0; i < resourcePaths.length; i++ )
+        if ( resourcePaths != null )
         {
-            String path = resourcePaths[i];
-            getLog().info( "[MAVEN-CORE-IT-LOG] Loading resource " + path );
-
-            URL url = classLoader.getResource( path );
-            getLog().info( "[MAVEN-CORE-IT-LOG]   Loaded resource from " + url 
);
-            if ( url != null )
-            {
-                loaderProperties.setProperty( path, url.toString() );
-            }
-
-            try
+            for ( int i = 0; i < resourcePaths.length; i++ )
             {
-                List urls = Collections.list( classLoader.getResources( path ) 
);
-                loaderProperties.setProperty( path + ".count", "" + 
urls.size() );
-                for ( int j = 0; j < urls.size(); j++ )
+                String path = resourcePaths[i];
+                getLog().info( "[MAVEN-CORE-IT-LOG] Loading resource " + path 
);
+    
+                URL url = classLoader.getResource( path );
+                getLog().info( "[MAVEN-CORE-IT-LOG]   Loaded resource from " + 
url );
+                if ( url != null )
                 {
-                    loaderProperties.setProperty( path + "." + j, urls.get( j 
).toString() );
+                    loaderProperties.setProperty( path, url.toString() );
+                }
+    
+                try
+                {
+                    List urls = Collections.list( classLoader.getResources( 
path ) );
+                    loaderProperties.setProperty( path + ".count", "" + 
urls.size() );
+                    for ( int j = 0; j < urls.size(); j++ )
+                    {
+                        loaderProperties.setProperty( path + "." + j, 
urls.get( j ).toString() );
+                    }
+                }
+                catch ( IOException e )
+                {
+                    throw new MojoExecutionException( "Resources could not be 
enumerated: " + path, e );
                 }
-            }
-            catch ( IOException e )
-            {
-                throw new MojoExecutionException( "Resources could not be 
enumerated: " + path, e );
             }
         }
 


Reply via email to