add a test for the regression in the wagon upgrade, and a test that new issue MNG-3599 is working once fixed

git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@680140 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Porter 2008-07-27 16:24:10 +00:00
parent 7af22cf688
commit 39d3edf7f2
3 changed files with 159 additions and 0 deletions

View File

@ -0,0 +1,118 @@
package org.apache.maven.integrationtests;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.it.Verifier;
import org.apache.maven.it.util.FileUtils;
import org.apache.maven.it.util.StringUtils;
import org.apache.maven.it.util.ResourceExtractor;
import org.mortbay.jetty.Handler;
import org.mortbay.jetty.Request;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.handler.AbstractHandler;
public class MavenITmng3599useHttpProxyForWebDAV
extends AbstractMavenIntegrationTestCase
{
private Server server;
private int port;
public void setUp()
throws Exception
{
Handler handler = new AbstractHandler()
{
public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch )
throws IOException, ServletException
{
response.setContentType( "text/plain" );
if ( request.getHeader( "Proxy-Connection" ) != null )
{
response.setStatus( HttpServletResponse.SC_OK );
response.getWriter().println( "some content" );
}
else
{
response.setStatus( HttpServletResponse.SC_NOT_FOUND );
}
( (Request) request ).setHandled( true );
}
};
server = new Server( 0 );
server.setHandler( handler );
server.start();
port = server.getConnectors()[0].getLocalPort();
}
protected void tearDown()
throws Exception
{
super.tearDown();
server.stop();
}
/**
* Test that HTTP proxy is used for HTTP and for WebDAV.
*/
public void testmng3599useHttpProxyForWebDAV()
throws Exception
{
// TODO: create settings file
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3599-useHttpProxyForWebDAV" );
String settings = FileUtils.fileRead( new File( testDir, "settings.xml.template" ) );
settings = StringUtils.replace( settings, "@port@", Integer.valueOf( port ).toString() );
String newSettings = StringUtils.replace( settings, "@protocol@", "http" );
FileUtils.fileWrite( new File( testDir, "settings.xml" ).getAbsolutePath(), newSettings );
Verifier verifier = new Verifier( testDir.getAbsolutePath() );
List cliOptions = new ArrayList();
cliOptions.add( "--settings" );
cliOptions.add( "settings.xml" );
verifier.setCliOptions( cliOptions );
verifier.deleteArtifact( "org.apache.maven.its.mng3599", "test-dependency", "1.0", "jar" );
verifier.executeGoal( "compile" );
verifier.verifyErrorFreeLog();
verifier.resetStreams();
verifier.assertArtifactPresent( "org.apache.maven.its.mng3599", "test-dependency", "1.0", "jar" );
verifier.assertArtifactContents( "org.apache.maven.its.mng3599", "test-dependency", "1.0", "jar", "some content\n" );
// Doesn't work until 2.0.10+
// TODO: reinstate for 2.1 when WebDAV works
if ( matchesVersionRange( "(2.0.9,2.1-ALPHA-1-SNAPSHOT)" ) )
{
newSettings = StringUtils.replace( settings, "@protocol@", "dav" );
FileUtils.fileWrite( new File( testDir, "settings.xml" ).getAbsolutePath(), newSettings );
verifier.deleteArtifact( "org.apache.maven.its.mng3599", "test-dependency", "1.0", "jar" );
verifier.executeGoal( "compile" );
verifier.verifyErrorFreeLog();
verifier.resetStreams();
verifier.assertArtifactPresent( "org.apache.maven.its.mng3599", "test-dependency", "1.0", "jar" );
verifier.assertArtifactContents( "org.apache.maven.its.mng3599", "test-dependency", "1.0", "jar", "some content\n" );
}
else
{
System.out.print( " [skipping DAV test for < 2.0.10 / 2.1 alpha]" );
}
}
}

View File

@ -0,0 +1,23 @@
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.its.mng3599</groupId>
<artifactId>test</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>test-dependency</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-webdav-jackrabbit</artifactId>
<version>1.0-beta-3</version>
</extension>
</extensions>
</build>
</project>

View File

@ -0,0 +1,18 @@
<settings>
<mirrors>
<mirror>
<id>test-mirror</id>
<url>@protocol@://www.example.com/</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>
<proxies>
<proxy>
<id>http-proxy</id>
<protocol>http</protocol>
<host>localhost</host>
<port>@port@</port>
</proxy>
</proxies>
</settings>