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 2010/03/24 00:48:30 UTC
svn commit: r926862 -
/maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4428FollowHttpRedirectTest.java
Author: bentmann
Date: Tue Mar 23 23:48:30 2010
New Revision: 926862
URL: http://svn.apache.org/viewvc?rev=926862&view=rev
Log:
o Strengthened IT
Modified:
maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4428FollowHttpRedirectTest.java
Modified: maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4428FollowHttpRedirectTest.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4428FollowHttpRedirectTest.java?rev=926862&r1=926861&r2=926862&view=diff
==============================================================================
--- maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4428FollowHttpRedirectTest.java (original)
+++ maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4428FollowHttpRedirectTest.java Tue Mar 23 23:48:30 2010
@@ -93,9 +93,25 @@ public class MavenITmng4428FollowHttpRed
testit( false, true );
}
+ /**
+ * Verify that redirects using a relative location URL are getting followed. While a relative URL violates the
+ * HTTP spec, popular HTTP clients do support them so we better do, too.
+ */
+ public void testitRelativeLocation()
+ throws Exception
+ {
+ testit( true, true );
+ }
+
private void testit( boolean fromHttp, boolean toHttp )
throws Exception
{
+ testit( fromHttp, toHttp, false );
+ }
+
+ private void testit( boolean fromHttp, boolean toHttp, boolean relativeLocation )
+ throws Exception
+ {
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4428" );
Verifier verifier = new Verifier( testDir.getAbsolutePath() );
@@ -110,7 +126,7 @@ public class MavenITmng4428FollowHttpRed
server.addConnector( newHttpsConnector( storePath, storePwd, keyPwd ) );
Connector from = server.getConnectors()[ fromHttp ? 0 : 1 ];
Connector to = server.getConnectors()[ toHttp ? 0 : 1 ];
- server.setHandler( new RedirectHandler( toHttp ? "http" : "https", to ) );
+ server.setHandler( new RedirectHandler( toHttp ? "http" : "https", relativeLocation ? null : to ) );
server.start();
try
@@ -173,8 +189,11 @@ public class MavenITmng4428FollowHttpRed
String uri = request.getRequestURI();
if ( uri.startsWith( "/repo/" ) )
{
- String location = protocol + "://localhost:" + connector.getLocalPort() + "/redirected/"
- + uri.substring( 6 );
+ String location = "/redirected/" + uri.substring( 6 );
+ if ( protocol != null && connector != null )
+ {
+ location = protocol + "://localhost:" + connector.getLocalPort() + location;
+ }
if ( uri.endsWith( ".pom" ) )
{
response.setStatus( HttpServletResponse.SC_MOVED_TEMPORARILY );