You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by be...@apache.org on 2009/07/05 20:07:07 UTC
svn commit: r791292 - in
/maven/core-integration-testing/trunk/core-it-suite/src/test:
java/org/apache/maven/it/ resources/mng-3415/
resources/mng-3415/maven-find-local-repo-plugin/
resources/mng-3415/project/ resources/mng-3415/project/src/
Author: bentmann
Date: Sun Jul 5 18:07:06 2009
New Revision: 791292
URL: http://svn.apache.org/viewvc?rev=791292&view=rev
Log:
o Decoupled IT from production plugins and console output
Removed:
maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-3415/maven-find-local-repo-plugin/
maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-3415/project/src/
Modified:
maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3415JunkRepositoryMetadataTest.java
maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-3415/project/pom.xml
maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-3415/settings-template.xml
Modified: maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3415JunkRepositoryMetadataTest.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3415JunkRepositoryMetadataTest.java?rev=791292&r1=791291&r2=791292&view=diff
==============================================================================
--- maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3415JunkRepositoryMetadataTest.java (original)
+++ maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3415JunkRepositoryMetadataTest.java Sun Jul 5 18:07:06 2009
@@ -31,6 +31,14 @@
import java.util.List;
import java.util.Properties;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.mortbay.jetty.Handler;
+import org.mortbay.jetty.Request;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.handler.AbstractHandler;
+
/**
* This is a sample integration test. The IT tests typically
* operate by having a sample project in the
@@ -80,7 +88,7 @@
* 3. Build the test project the second time
* a. See (2.a) and (2.b) above; the same criteria applies here.
*/
- public void testitMNG3415()
+ public void testitTransferFailed()
throws Exception
{
String methodName = getMethodName();
@@ -91,13 +99,16 @@
Verifier verifier;
verifier = new Verifier( projectDir.getAbsolutePath() );
+ verifier.setAutoclean( false );
+ verifier.deleteArtifacts( "org.apache.maven.its.mng3415" );
- File localRepo = findLocalRepoDirectory();
+ File localRepo = new File( verifier.localRepo );
setupDummyDependency( testDir, localRepo, true );
Properties filterProps = verifier.newDefaultFilterProperties();
- filterProps.put( "@baseurl@", "invalid" + filterProps.getProperty( "@baseurl@" ).substring( "file".length() ) );
+ filterProps.put( "@protocol@", "invalid" );
+ filterProps.put( "@port@", "0" );
File settings = verifier.filterFile( "../settings-template.xml", "settings-a.xml", "UTF-8", filterProps );
List cliOptions = new ArrayList();
@@ -107,7 +118,7 @@
verifier.setCliOptions( cliOptions );
verifier.setLogFileName( "log-" + methodName + "-firstBuild.txt" );
- verifier.executeGoal( "package" );
+ verifier.executeGoal( "validate" );
verifier.verifyErrorFreeLog();
@@ -116,7 +127,7 @@
setupDummyDependency( testDir, localRepo, true );
verifier.setLogFileName( "log-" + methodName + "-secondBuild.txt" );
- verifier.executeGoal( "package" );
+ verifier.executeGoal( "validate" );
verifier.verifyErrorFreeLog();
verifier.resetStreams();
@@ -146,11 +157,9 @@
* c. Create the settings file for use in this test, which contains the VALID
* remote repository entry.
* 2. Build the test project the first time
- * a. Verify that a log message checking the remote repository for the metadata file
- * is in the build output for the test-repo
+ * a. Verify that the remote repository is checked for the metadata file
* 3. Build the test project the second time
- * a. Verify that a log message checking the remote repository for the metadata file
- * IS NOT in the build output for the test-repo
+ * a. Verify that the remote repository is NOT checked for the metadata file again
* b. Verify that the file used for updateInterval calculations was NOT changed from
* the first build.
*/
@@ -165,48 +174,79 @@
Verifier verifier;
verifier = new Verifier( projectDir.getAbsolutePath() );
+ verifier.setAutoclean( false );
+ verifier.deleteArtifacts( "org.apache.maven.its.mng3415" );
- File localRepo = findLocalRepoDirectory();
+ File localRepo = new File( verifier.localRepo );
- setupDummyDependency( testDir, localRepo, true );
+ final List requestUris = new ArrayList();
- Properties filterProps = verifier.newDefaultFilterProperties();
- File settings = verifier.filterFile( "../settings-template.xml", "settings-b.xml", "UTF-8", filterProps );
+ Handler repoHandler = new AbstractHandler()
+ {
+ public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch )
+ {
+ System.out.println( "Handling " + request.getMethod() + " " + request.getRequestURL() );
- List cliOptions = new ArrayList();
- cliOptions.add( "-X" );
- cliOptions.add( "-s" );
- cliOptions.add( settings.getName() );
+ requestUris.add( request.getRequestURI() );
- verifier.setCliOptions( cliOptions );
+ response.setStatus( HttpServletResponse.SC_NOT_FOUND );
- verifier.setLogFileName( "log-" + methodName + "-firstBuild.txt" );
- verifier.executeGoal( "package" );
+ ( (Request) request ).setHandled( true );
+ }
+ };
- verifier.verifyErrorFreeLog();
+ Server server = new Server( 0 );
+ server.setHandler( repoHandler );
+ server.start();
- File firstLogFile = new File( projectDir, verifier.getLogFileName() );
+ try
+ {
+ int port = server.getConnectors()[0].getLocalPort();
- // FIXME: There really should be a better way than matching console output!
- assertOutputLinePresent( verifier, firstLogFile, "snapshot org.apache.maven.its.mng3415:missing:1.0-SNAPSHOT: checking for updates from testing-repo" );
+ Properties filterProps = verifier.newDefaultFilterProperties();
+ filterProps.put( "@protocol@", "http" );
+ filterProps.put( "@port@", Integer.toString( port ) );
+ File settings = verifier.filterFile( "../settings-template.xml", "settings-b.xml", "UTF-8", filterProps );
- File updateCheckFile = getUpdateCheckFile( localRepo );
- long firstLastMod = updateCheckFile.lastModified();
+ List cliOptions = new ArrayList();
+ cliOptions.add( "-X" );
+ cliOptions.add( "-s" );
+ cliOptions.add( settings.getName() );
- setupDummyDependency( testDir, localRepo, false );
+ verifier.setCliOptions( cliOptions );
- verifier.setLogFileName( "log-" + methodName + "-secondBuild.txt" );
- verifier.executeGoal( "package" );
+ setupDummyDependency( testDir, localRepo, true );
- verifier.verifyErrorFreeLog();
- verifier.resetStreams();
+ verifier.setLogFileName( "log-" + methodName + "-firstBuild.txt" );
+ verifier.executeGoal( "validate" );
+
+ verifier.verifyErrorFreeLog();
+
+ assertTrue( requestUris.toString(),
+ requestUris.contains( "/org/apache/maven/its/mng3415/missing/1.0-SNAPSHOT/maven-metadata.xml" ) );
+
+ requestUris.clear();
+
+ File updateCheckFile = getUpdateCheckFile( localRepo );
+ long firstLastMod = updateCheckFile.lastModified();
+
+ setupDummyDependency( testDir, localRepo, false );
+
+ verifier.setLogFileName( "log-" + methodName + "-secondBuild.txt" );
+ verifier.executeGoal( "validate" );
- File secondLogFile = new File( projectDir, verifier.getLogFileName() );
+ verifier.verifyErrorFreeLog();
+ verifier.resetStreams();
- // FIXME: There really should be a better way than matching console output!
- assertOutputLineMissing( verifier, secondLogFile, "snapshot org.apache.maven.its.mng3415:missing:1.0-SNAPSHOT: checking for updates from testing-repo" );
+ assertFalse( requestUris.toString(),
+ requestUris.contains( "/org/apache/maven/its/mng3415/missing/1.0-SNAPSHOT/maven-metadata.xml" ) );
- assertEquals( "Last-modified time should be unchanged from first build through second build for the file we use for updateInterval checks.", firstLastMod, updateCheckFile.lastModified() );
+ assertEquals( "Last-modified time should be unchanged from first build through second build for the file we use for updateInterval checks.", firstLastMod, updateCheckFile.lastModified() );
+ }
+ finally
+ {
+ server.stop();
+ }
}
private void assertMetadataMissing( File localRepo )
@@ -231,6 +271,7 @@
}
File resolverStatus = new File( metadata.getParentFile(), "resolver-status.properties" );
+
if ( resetUpdateInterval && resolverStatus.exists() )
{
System.out.println( "Deleting resolver-status.properties file related to: " + metadata );
@@ -286,77 +327,4 @@
}
}
- private File findLocalRepoDirectory()
- throws VerificationException, IOException
- {
- File testDir = ResourceExtractor.simpleExtractResources( getClass(),
- RESOURCE_BASE
- + "/maven-find-local-repo-plugin" );
-
- Verifier verifier = new Verifier( testDir.getAbsolutePath() );
-
- verifier.deleteArtifact( "org.apache.maven.its.plugins", "maven-find-local-repo-plugin", "1.0-SNAPSHOT", "jar" );
-
- verifier.executeGoal( "install" );
-
- verifier.verifyErrorFreeLog();
- verifier.resetStreams();
-
- verifier.executeGoal( "org.apache.maven.its.plugins:maven-find-local-repo-plugin:1.0-SNAPSHOT:find" );
-
- verifier.verifyErrorFreeLog();
- verifier.resetStreams();
-
- List lines = verifier.loadFile( new File( testDir, "target/local-repository-location.txt" ),
- false );
-
- File localRepo = new File( (String) lines.get( 0 ) );
-
- System.out.println( "Using local repository at: " + localRepo );
-
- return localRepo;
- }
-
- private void assertOutputLinePresent( Verifier verifier,
- File logFile,
- String lineContents )
- throws VerificationException
- {
- List lines = verifier.loadFile( logFile, false );
-
- boolean found = false;
- for ( Iterator it = lines.iterator(); it.hasNext(); )
- {
- String line = (String) it.next();
- if ( line.indexOf( lineContents ) > -1 )
- {
- found = true;
- break;
- }
- }
-
- assertTrue( "Build output in:\n\n" + logFile + "\n\nshould contain line with contents:\n\n" + lineContents + "\n", found );
- }
-
- private void assertOutputLineMissing( Verifier verifier,
- File logFile,
- String lineContents )
- throws VerificationException
- {
- List lines = verifier.loadFile( logFile, false );
-
- boolean found = false;
- for ( Iterator it = lines.iterator(); it.hasNext(); )
- {
- String line = (String) it.next();
- if ( line.indexOf( lineContents ) > -1 )
- {
- found = true;
- break;
- }
- }
-
- assertFalse( "Build output in:\n\n" + logFile + "\n\nshould NOT contain line with contents:\n\n" + lineContents + "\n", found );
- }
-
}
Modified: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-3415/project/pom.xml
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-3415/project/pom.xml?rev=791292&r1=791291&r2=791292&view=diff
==============================================================================
--- maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-3415/project/pom.xml (original)
+++ maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-3415/project/pom.xml Sun Jul 5 18:07:06 2009
@@ -1,10 +1,20 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
+
<groupId>org.apache.maven.its.mng3415</groupId>
<artifactId>project</artifactId>
<version>1</version>
+ <name>Maven Integration Test :: MNG-3415</name>
+ <description>
+ Test that failures to resolve the artifact metadata are properly handled. In particular, we need to distinguish
+ between a network failure and a missing metadata file in the remote repo. After a network failure, we immediately
+ want to retry the remote repo during the next build, regardless of the repo's update policy. In case the metadata
+ (and hence the corresponding artifact) is simply missing from the repo, we don't want to recheck this repo on each
+ build but wait until the update interval has elapsed (see also MNG-2712).
+ </description>
+
<dependencies>
<dependency>
<groupId>org.apache.maven.its.mng3415</groupId>
@@ -13,11 +23,24 @@
<type>pom</type>
<scope>compile</scope>
</dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- <scope>test</scope>
- </dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.its.plugins</groupId>
+ <artifactId>maven-it-plugin-dependency-resolution</artifactId>
+ <version>2.1-SNAPSHOT</version>
+ <executions>
+ <execution>
+ <id>test</id>
+ <phase>validate</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
</project>
Modified: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-3415/settings-template.xml
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-3415/settings-template.xml?rev=791292&r1=791291&r2=791292&view=diff
==============================================================================
--- maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-3415/settings-template.xml (original)
+++ maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-3415/settings-template.xml Sun Jul 5 18:07:06 2009
@@ -26,7 +26,7 @@
<repositories>
<repository>
<id>testing-repo</id>
- <url>@baseurl@/remote-repository</url>
+ <url>@protocol@://localhost:@port@</url>
</repository>
</repositories>
</profile>