diff options
author | Olivier Lamy <olamy@apache.org> | 2014-01-06 05:32:07 +0000 |
---|---|---|
committer | Olivier Lamy <olamy@apache.org> | 2014-01-06 05:32:07 +0000 |
commit | 91af8c3d5a7cf17c3449c3857f6622168377c536 (patch) | |
tree | f95f4ec3ce64cdf0553c399176688e78b3d25ee1 /archiva-modules/archiva-web/archiva-webdav | |
parent | 69c9ae20de27637c6f4f2aa3fac7e0924fb8106b (diff) | |
download | archiva-91af8c3d5a7cf17c3449c3857f6622168377c536.tar.gz archiva-91af8c3d5a7cf17c3449c3857f6622168377c536.zip |
follow redirect as previous testing tool did
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1555675 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/archiva-web/archiva-webdav')
2 files changed, 19 insertions, 5 deletions
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletTestCase.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletTestCase.java index 5eaccf4a1..87162ace7 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletTestCase.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletTestCase.java @@ -135,7 +135,6 @@ public abstract class AbstractRepositoryServletTestCase } FileUtils.copyFile( testConf, testConfDest ); - repoRootInternal = new File( appserverBase, "data/repositories/internal" ); repoRootLegacy = new File( appserverBase, "data/repositories/legacy" ); Configuration config = archivaConfiguration.getConfiguration(); @@ -508,10 +507,10 @@ public abstract class AbstractRepositoryServletTestCase protected WebResponse getWebResponse( String path ) throws Exception { - return getWebResponse( new GetMethodWebRequest( "http://localhost" + path ) ); + return getWebResponse( new GetMethodWebRequest( "http://localhost" + path ) );//, false ); } - protected WebResponse getWebResponse( WebRequest webRequest ) + protected WebResponse getWebResponse( WebRequest webRequest ) //, boolean followRedirect ) throws Exception { @@ -527,6 +526,14 @@ public abstract class AbstractRepositoryServletTestCase final MockHttpServletResponse response = execute( request ); + if ( response.getStatus() == HttpServletResponse.SC_MOVED_PERMANENTLY + || response.getStatus() == HttpServletResponse.SC_MOVED_TEMPORARILY ) + { + String location = response.getHeader( "Location" ); + log.debug("follow redirect to {}", location); + return getWebResponse( new GetMethodWebRequest( location ) ); + } + return new WebResponse( null, null, 1 ) { @Override @@ -608,7 +615,14 @@ public abstract class AbstractRepositoryServletTestCase public WebResponse getResponse( WebRequest request ) throws Exception { - return abstractRepositoryServletTestCase.getWebResponse( request ); + return getResponse( request, false ); + } + + public WebResponse getResponse( WebRequest request, boolean followRedirect ) + throws Exception + { + // alwasy following redirect as it's normal + return abstractRepositoryServletTestCase.getWebResponse( request );//, followRedirect ); } public WebResponse getResource( WebRequest request ) diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletBrowseTest.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletBrowseTest.java index b468c867f..55228453f 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletBrowseTest.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletBrowseTest.java @@ -99,7 +99,7 @@ public class RepositoryServletBrowseTest WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/org/apache/archiva/artifactId" ); - WebResponse response = getServletUnitClient().getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request, true ); assertEquals( "1st Response", HttpServletResponse.SC_OK, response.getStatusCode() ); request = new GetMethodWebRequest( "http://machine.com/repository/internal/org/apache/archiva/artifactId/" ); |