From 534334dd98231f56dfa7a32be0551d8128093f64 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Fri, 4 Nov 2011 15:29:31 +0000 Subject: [PATCH] fix unit test in webdav weird issue with spring context not the same in servlet runner git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1197599 13f79535-47bb-0310-9956-ffa450edef68 --- .../archiva-web/archiva-webdav/pom.xml | 1 + ...ositoryServletProxiedMetadataTestCase.java | 2 +- .../AbstractRepositoryServletTestCase.java | 40 +++++++------- .../webdav/RepositoryServletBrowseTest.java | 52 +++++++++--------- .../webdav/RepositoryServletDeployTest.java | 36 ++++++------- .../RepositoryServletNoProxyMetadataTest.java | 8 +-- .../webdav/RepositoryServletNoProxyTest.java | 54 +++++++++---------- ...positoryServletProxiedPassthroughTest.java | 2 +- ...ervletProxiedPluginSnapshotPolicyTest.java | 2 +- ...sitoryServletProxiedReleasePolicyTest.java | 2 +- ...RepositoryServletProxiedRelocatedTest.java | 2 +- ...itoryServletProxiedSnapshotPolicyTest.java | 2 +- ...tProxiedTimestampedSnapshotPolicyTest.java | 2 +- .../RepositoryServletRepositoryGroupTest.java | 18 +++---- .../archiva/webdav/RepositoryServletTest.java | 10 ++-- 15 files changed, 120 insertions(+), 113 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-webdav/pom.xml b/archiva-modules/archiva-web/archiva-webdav/pom.xml index 693ec98d5..6047ef797 100644 --- a/archiva-modules/archiva-web/archiva-webdav/pom.xml +++ b/archiva-modules/archiva-web/archiva-webdav/pom.xml @@ -198,6 +198,7 @@ ${project.build.directory}/appserver-base ${project.build.directory}/appserver-base ${project.build.testOutputDirectory} + ${project.build.testOutputDirectory}/repository-archiva.xml jdbc:derby:memory:users-test;create=true org.apache.derby.jdbc.EmbeddedDriver diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletProxiedMetadataTestCase.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletProxiedMetadataTestCase.java index 9d28a797b..838163379 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletProxiedMetadataTestCase.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletProxiedMetadataTestCase.java @@ -58,7 +58,7 @@ public abstract class AbstractRepositoryServletProxiedMetadataTestCase HttpUnitOptions.setExceptionsThrownOnErrorStatus( false ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + path ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); assertResponseOK( response ); return response.getText(); } 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 766124d4c..67df84d1b 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 @@ -33,12 +33,8 @@ import org.apache.archiva.configuration.ManagedRepositoryConfiguration; import org.apache.archiva.configuration.RemoteRepositoryConfiguration; import org.apache.archiva.webdav.util.MavenIndexerCleaner; import org.apache.commons.io.FileUtils; -import org.apache.lucene.store.Lock; -import org.apache.lucene.store.LockReleaseFailedException; -import org.apache.lucene.store.NativeFSLockFactory; import org.junit.After; import org.junit.Before; -import org.junit.BeforeClass; import org.junit.runner.RunWith; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -50,8 +46,6 @@ import javax.inject.Inject; import javax.servlet.http.HttpServletResponse; import java.io.File; import java.io.IOException; -import java.lang.reflect.Field; -import java.lang.reflect.Method; /** * AbstractRepositoryServletTestCase @@ -67,13 +61,13 @@ public abstract class AbstractRepositoryServletTestCase protected static final String REPOID_LEGACY = "legacy"; - protected ServletUnitClient sc; - protected File repoRootInternal; protected File repoRootLegacy; - private ServletRunner sr; + protected ServletUnitClient servletUnitClient; + + private ServletRunner servletRunner; protected ArchivaConfiguration archivaConfiguration; @@ -89,8 +83,6 @@ public abstract class AbstractRepositoryServletTestCase saveConfiguration( archivaConfiguration ); } - - @Before public void setUp() throws Exception @@ -135,10 +127,22 @@ public abstract class AbstractRepositoryServletTestCase applicationContext.getBean( MavenIndexerCleaner.class ).cleanupIndex(); - sr = new ServletRunner( new File( "src/test/resources/WEB-INF/web.xml" ) ); + } + + protected ServletUnitClient getServletUnitClient() + throws Exception + { + if ( servletUnitClient != null ) + { + return servletUnitClient; + } + servletRunner = new ServletRunner( new File( "src/test/resources/WEB-INF/web.xml" ) ); + + servletRunner.registerServlet( "/repository/*", UnauthenticatedRepositoryServlet.class.getName() ); + + servletUnitClient = servletRunner.newClient(); - sr.registerServlet( "/repository/*", UnauthenticatedRepositoryServlet.class.getName() ); - sc = sr.newClient(); + return servletUnitClient; } @Override @@ -147,14 +151,14 @@ public abstract class AbstractRepositoryServletTestCase throws Exception { - if ( sc != null ) + if ( servletUnitClient != null ) { - sc.clearContents(); + servletUnitClient.clearContents(); } - if ( sr != null ) + if ( servletRunner != null ) { - sr.shutDown(); + servletRunner.shutDown(); } if ( repoRootInternal.exists() ) 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 10a11247c..66dd6541a 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 @@ -26,12 +26,11 @@ import com.meterware.httpunit.WebResponse; import org.junit.Before; import org.junit.Test; -import java.io.File; - import javax.servlet.http.HttpServletResponse; +import java.io.File; /** - * RepositoryServletBrowseTest + * RepositoryServletBrowseTest * * @version $Id$ */ @@ -41,10 +40,10 @@ public class RepositoryServletBrowseTest @Override @Before public void setUp() - throws Exception + throws Exception { super.setUp(); - + new File( repoRootInternal, "org/apache/archiva" ).mkdirs(); new File( repoRootInternal, "org/codehaus/mojo/" ).mkdirs(); new File( repoRootInternal, "net/sourceforge" ).mkdirs(); @@ -56,13 +55,13 @@ public class RepositoryServletBrowseTest throws Exception { WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); assertEquals( "Response", HttpServletResponse.SC_OK, response.getResponseCode() ); // dumpResponse( response ); - String expectedLinks[] = new String[] { "commons-lang/", "net/", "org/" }; - assertLinks(expectedLinks, response.getLinks()); + String expectedLinks[] = new String[]{ ".indexer", "commons-lang/", "net/", "org/" }; + assertLinks( expectedLinks, response.getLinks() ); } @Test @@ -70,11 +69,11 @@ public class RepositoryServletBrowseTest throws Exception { WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/org" ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); assertEquals( "Response", HttpServletResponse.SC_OK, response.getResponseCode() ); - - String expectedLinks[] = new String[] { "../", "apache/", "codehaus/" }; - assertLinks(expectedLinks, response.getLinks()); + + String expectedLinks[] = new String[]{ "../", "apache/", "codehaus/" }; + assertLinks( expectedLinks, response.getLinks() ); } @Test @@ -84,30 +83,33 @@ public class RepositoryServletBrowseTest new File( repoRootInternal, "org/apache/archiva/artifactId/1.0" ).mkdirs(); new File( repoRootInternal, "org/apache/archiva/artifactId/1.0/artifactId-1.0.jar" ).createNewFile(); - WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/org/apache/archiva/artifactId" ); - WebResponse response = sc.getResponse( request ); + WebRequest request = + new GetMethodWebRequest( "http://machine.com/repository/internal/org/apache/archiva/artifactId" ); + WebResponse response = getServletUnitClient().getResponse( request ); assertEquals( "1st Response", HttpServletResponse.SC_OK, response.getResponseCode() ); request = new GetMethodWebRequest( "http://machine.com/repository/internal/org/apache/archiva/artifactId/" ); - response = sc.getResponse( request ); + response = getServletUnitClient().getResponse( request ); assertEquals( "2nd Response", HttpServletResponse.SC_OK, response.getResponseCode() ); - - request = new GetMethodWebRequest( "http://machine.com/repository/internal/org/apache/archiva/artifactId/1.0/artifactId-1.0.jar" ); - response = sc.getResponse( request ); + + request = new GetMethodWebRequest( + "http://machine.com/repository/internal/org/apache/archiva/artifactId/1.0/artifactId-1.0.jar" ); + response = getServletUnitClient().getResponse( request ); assertEquals( "3rd Response", HttpServletResponse.SC_OK, response.getResponseCode() ); - - request = new GetMethodWebRequest( "http://machine.com/repository/internal/org/apache/archiva/artifactId/1.0/artifactId-1.0.jar/" ); - response = sc.getResponse( request ); + + request = new GetMethodWebRequest( + "http://machine.com/repository/internal/org/apache/archiva/artifactId/1.0/artifactId-1.0.jar/" ); + response = getServletUnitClient().getResponse( request ); assertEquals( "4th Response", HttpServletResponse.SC_NOT_FOUND, response.getResponseCode() ); } - - - private void assertLinks(String expectedLinks[], WebLink actualLinks[]) + + + private void assertLinks( String expectedLinks[], WebLink actualLinks[] ) { assertEquals( "Links.length", expectedLinks.length, actualLinks.length ); for ( int i = 0; i < actualLinks.length; i++ ) { assertEquals( "Link[" + i + "]", expectedLinks[i], actualLinks[i].getURLString() ); - } + } } } diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletDeployTest.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletDeployTest.java index a8a699fe6..1bad73f90 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletDeployTest.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletDeployTest.java @@ -56,7 +56,7 @@ public class RepositoryServletDeployTest WebRequest request = new PutMethodWebRequest( putUrl, is, "application/octet-stream" ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); assertResponseCreated( response ); assertFileContents( "artifact.jar\n", repoRootInternal, ARTIFACT_DEFAULT_LAYOUT ); } @@ -83,23 +83,23 @@ public class RepositoryServletDeployTest // send request #1 and verify it's successful WebRequest request = new PutMethodWebRequest( putUrl, is, "application/octet-stream" ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); assertResponseCreated( response ); is = getClass().getResourceAsStream( "/artifact.jar.sha1" ); request = new PutMethodWebRequest( checksumUrl, is, "application/octet-stream" ); - response = sc.getResponse( request ); + response = getServletUnitClient().getResponse( request ); assertResponseCreated( response ); is = getClass().getResourceAsStream( "/maven-metadata.xml" ); request = new PutMethodWebRequest( metadataUrl, is, "application/octet-stream" ); - response = sc.getResponse( request ); + response = getServletUnitClient().getResponse( request ); assertResponseCreated( response ); // send request #2 and verify it's blocked is = getClass().getResourceAsStream( "/artifact.jar" ); request = new PutMethodWebRequest( putUrl, is, "application/octet-stream" ); - response = sc.getResponse( request ); + response = getServletUnitClient().getResponse( request ); assertResponseConflictError( response ); } @@ -124,23 +124,23 @@ public class RepositoryServletDeployTest // send request #1 and verify it's successful WebRequest request = new PutMethodWebRequest( putUrl, is, "application/octet-stream" ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); assertResponseCreated( response ); is = getClass().getResourceAsStream( "/artifact.jar.sha1" ); request = new PutMethodWebRequest( checksumUrl, is, "application/octet-stream" ); - response = sc.getResponse( request ); + response = getServletUnitClient().getResponse( request ); assertResponseCreated( response ); is = getClass().getResourceAsStream( "/maven-metadata.xml" ); request = new PutMethodWebRequest( metadataUrl, is, "application/octet-stream" ); - response = sc.getResponse( request ); + response = getServletUnitClient().getResponse( request ); assertResponseCreated( response ); // send request #2 and verify if it's still successful is = getClass().getResourceAsStream( "/artifact.jar" ); request = new PutMethodWebRequest( putUrl, is, "application/octet-stream" ); - response = sc.getResponse( request ); + response = getServletUnitClient().getResponse( request ); assertResponseNoContent( response ); } @@ -160,23 +160,23 @@ public class RepositoryServletDeployTest // send request #1 and verify it's successful WebRequest request = new PutMethodWebRequest( putUrl, is, "application/octet-stream" ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); assertResponseCreated( response ); is = getClass().getResourceAsStream( "/artifact.jar.sha1" ); request = new PutMethodWebRequest( checksumUrl, is, "application/octet-stream" ); - response = sc.getResponse( request ); + response = getServletUnitClient().getResponse( request ); assertResponseCreated( response ); is = getClass().getResourceAsStream( "/maven-metadata.xml" ); request = new PutMethodWebRequest( metadataUrl, is, "application/octet-stream" ); - response = sc.getResponse( request ); + response = getServletUnitClient().getResponse( request ); assertResponseCreated( response ); // send request #2 and verify it's re-deployed is = getClass().getResourceAsStream( "/artifact.jar" ); request = new PutMethodWebRequest( putUrl, is, "application/octet-stream" ); - response = sc.getResponse( request ); + response = getServletUnitClient().getResponse( request ); assertResponseNoContent( response ); } @@ -196,23 +196,23 @@ public class RepositoryServletDeployTest // send request #1 and verify it's successful WebRequest request = new PutMethodWebRequest( putUrl, is, "application/octet-stream" ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); assertResponseCreated( response ); is = getClass().getResourceAsStream( "/artifact.jar.sha1" ); request = new PutMethodWebRequest( checksumUrl, is, "application/octet-stream" ); - response = sc.getResponse( request ); + response = getServletUnitClient().getResponse( request ); assertResponseCreated( response ); is = getClass().getResourceAsStream( "/maven-metadata.xml" ); request = new PutMethodWebRequest( metadataUrl, is, "application/octet-stream" ); - response = sc.getResponse( request ); + response = getServletUnitClient().getResponse( request ); assertResponseCreated( response ); // send request #2 and verify it's re-deployed is = getClass().getResourceAsStream( "/artifact.jar" ); request = new PutMethodWebRequest( putUrl, is, "application/octet-stream" ); - response = sc.getResponse( request ); + response = getServletUnitClient().getResponse( request ); assertResponseNoContent( response ); } @@ -226,7 +226,7 @@ public class RepositoryServletDeployTest WebRequest request = new MkColMethodWebRequest( putUrl ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); assertEquals(HttpServletResponse.SC_CONFLICT, response.getResponseCode()); diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletNoProxyMetadataTest.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletNoProxyMetadataTest.java index 1382defaa..3e1e13943 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletNoProxyMetadataTest.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletNoProxyMetadataTest.java @@ -48,7 +48,7 @@ public class RepositoryServletNoProxyMetadataTest FileUtils.writeStringToFile( checksumFile, expectedMetadataContents, null ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); assertResponseOK( response ); assertEquals( "Expected file contents", expectedMetadataContents, response.getText() ); @@ -67,7 +67,7 @@ public class RepositoryServletNoProxyMetadataTest FileUtils.writeStringToFile( checksumFile, expectedMetadataContents, null ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); assertResponseOK( response ); assertEquals( "Expected file contents", expectedMetadataContents, response.getText() ); @@ -86,7 +86,7 @@ public class RepositoryServletNoProxyMetadataTest FileUtils.writeStringToFile( checksumFile, expectedMetadataContents, null ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); assertResponseOK( response ); assertEquals( "Expected file contents", expectedMetadataContents, response.getText() ); @@ -105,7 +105,7 @@ public class RepositoryServletNoProxyMetadataTest FileUtils.writeStringToFile( checksumFile, expectedMetadataContents, null ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + assemblyPluginMetadata ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); assertResponseOK( response ); assertEquals( "Expected file contents", expectedMetadataContents, response.getText() ); diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletNoProxyTest.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletNoProxyTest.java index d7310e8b4..c94ac4a34 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletNoProxyTest.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletNoProxyTest.java @@ -59,7 +59,7 @@ public class RepositoryServletNoProxyTest FileUtils.writeStringToFile( checksumFile, "dummy-checksum", null ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangSha1 ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); assertNotNull( response.getHeaderField( "last-modified" ) ); } @@ -76,7 +76,7 @@ public class RepositoryServletNoProxyTest FileUtils.writeStringToFile( checksumFile, "dummy-checksum", null ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangSha1 ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); assertResponseOK( response ); assertEquals( "Expected file contents", "dummy-checksum", response.getText() ); @@ -95,7 +95,7 @@ public class RepositoryServletNoProxyTest WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + "commons-lang/jars/commons-lang-2.1.jar.sha1" ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); assertResponseOK( response ); assertEquals( "Expected file contents", "dummy-checksum", response.getText() ); @@ -114,7 +114,7 @@ public class RepositoryServletNoProxyTest FileUtils.writeStringToFile( metadataFile, expectedMetadataContents, null ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); assertResponseOK( response ); assertEquals( "Expected file contents", expectedMetadataContents, response.getText() ); @@ -133,7 +133,7 @@ public class RepositoryServletNoProxyTest FileUtils.writeStringToFile( metadataFile, expectedMetadataContents, null ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); assertResponseOK( response ); assertEquals( "Expected file contents", expectedMetadataContents, response.getText() ); @@ -152,7 +152,7 @@ public class RepositoryServletNoProxyTest FileUtils.writeStringToFile( metadataFile, expectedMetadataContents, null ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); assertResponseOK( response ); assertEquals( "Expected file contents", expectedMetadataContents, response.getText() ); @@ -171,7 +171,7 @@ public class RepositoryServletNoProxyTest FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangJar ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); assertResponseOK( response ); assertEquals( "Expected file contents", expectedArtifactContents, response.getText() ); @@ -191,7 +191,7 @@ public class RepositoryServletNoProxyTest WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + "commons-lang/jars/commons-lang-2.1.jar" ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); assertResponseOK( response ); assertEquals( "Expected file contents", expectedArtifactContents, response.getText() ); @@ -210,7 +210,7 @@ public class RepositoryServletNoProxyTest FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangJar ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); assertResponseOK( response ); assertEquals( "Expected file contents", expectedArtifactContents, response.getText() ); @@ -230,7 +230,7 @@ public class RepositoryServletNoProxyTest WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + "commons-lang/jars/commons-lang-2.1-SNAPSHOT.jar" ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); assertResponseOK( response ); assertEquals( "Expected file contents", expectedArtifactContents, response.getText() ); @@ -249,7 +249,7 @@ public class RepositoryServletNoProxyTest FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangJar ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); assertResponseOK( response ); assertEquals( "Expected file contents", expectedArtifactContents, response.getText() ); @@ -269,7 +269,7 @@ public class RepositoryServletNoProxyTest WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + "commons-lang/jars/commons-lang-2.1-20050821.023400-1.jar" ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); assertResponseOK( response ); assertEquals( "Expected file contents", expectedArtifactContents, response.getText() ); @@ -291,7 +291,7 @@ public class RepositoryServletNoProxyTest FileUtils.writeStringToFile( checksumFile, expectedContents, null ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + dualExtensionPath ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); assertResponseOK( response ); assertEquals( "Expected file contents", expectedContents, response.getText() ); @@ -311,7 +311,7 @@ public class RepositoryServletNoProxyTest WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + "org.project/distributions/example-presentation-3.2.zip" ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); assertResponseOK( response ); assertEquals( "Expected file contents", expectedContents, response.getText() ); @@ -329,7 +329,7 @@ public class RepositoryServletNoProxyTest FileUtils.writeStringToFile( checksumFile, "dummy-checksum", null ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangSha1 ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); assertResponseOK( response ); assertEquals( "Expected file contents", "dummy-checksum", response.getText() ); @@ -346,7 +346,7 @@ public class RepositoryServletNoProxyTest FileUtils.writeStringToFile( checksumFile, "dummy-checksum", null ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangSha1 ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); assertResponseOK( response ); assertEquals( "Expected file contents", "dummy-checksum", response.getText() ); @@ -366,7 +366,7 @@ public class RepositoryServletNoProxyTest FileUtils.writeStringToFile( metadataFile, expectedMetadataContents, null ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangMetadata ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); assertResponseOK( response ); assertEquals( "Expected file contents", expectedMetadataContents, response.getText() ); @@ -386,7 +386,7 @@ public class RepositoryServletNoProxyTest FileUtils.writeStringToFile( metadataFile, expectedMetadataContents, null ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangMetadata ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); assertResponseOK( response ); assertEquals( "Expected file contents", expectedMetadataContents, response.getText() ); @@ -405,7 +405,7 @@ public class RepositoryServletNoProxyTest FileUtils.writeStringToFile( metadataFile, expectedMetadataContents, null ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangMetadata ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); assertResponseOK( response ); assertEquals( "Expected file contents", expectedMetadataContents, response.getText() ); @@ -424,7 +424,7 @@ public class RepositoryServletNoProxyTest FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangJar ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); assertResponseOK( response ); assertEquals( "Expected file contents", expectedArtifactContents, response.getText() ); @@ -443,7 +443,7 @@ public class RepositoryServletNoProxyTest FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangJar ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); assertResponseOK( response ); assertEquals( "Expected file contents", expectedArtifactContents, response.getText() ); @@ -462,7 +462,7 @@ public class RepositoryServletNoProxyTest FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangJar ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); assertResponseOK( response ); assertEquals( "Expected file contents", expectedArtifactContents, response.getText() ); @@ -481,7 +481,7 @@ public class RepositoryServletNoProxyTest FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangJar ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); assertResponseOK( response ); assertEquals( "Expected file contents", expectedArtifactContents, response.getText() ); @@ -501,7 +501,7 @@ public class RepositoryServletNoProxyTest FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangJar ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); assertResponseOK( response ); assertEquals( "Expected file contents", expectedArtifactContents, response.getText() ); @@ -520,7 +520,7 @@ public class RepositoryServletNoProxyTest FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangJar ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); assertResponseOK( response ); assertEquals( "Expected file contents", expectedArtifactContents, response.getText() ); @@ -542,7 +542,7 @@ public class RepositoryServletNoProxyTest FileUtils.writeStringToFile( checksumFile, expectedContents, null ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + dualExtensionPath ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); assertResponseOK( response ); assertEquals( "Expected file contents", expectedContents, response.getText() ); @@ -561,7 +561,7 @@ public class RepositoryServletNoProxyTest FileUtils.writeStringToFile( checksumFile, expectedContents, null ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + dualExtensionPath ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); assertResponseOK( response ); assertEquals( "Expected file contents", expectedContents, response.getText() ); diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletProxiedPassthroughTest.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletProxiedPassthroughTest.java index 0746d9fba..655061f8c 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletProxiedPassthroughTest.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletProxiedPassthroughTest.java @@ -155,7 +155,7 @@ public class RepositoryServletProxiedPassthroughTest HttpUnitOptions.setExceptionsThrownOnErrorStatus( false ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + path ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); // --- Verification diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletProxiedPluginSnapshotPolicyTest.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletProxiedPluginSnapshotPolicyTest.java index fda87c6bc..4735b69a0 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletProxiedPluginSnapshotPolicyTest.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletProxiedPluginSnapshotPolicyTest.java @@ -190,7 +190,7 @@ public class RepositoryServletProxiedPluginSnapshotPolicyTest HttpUnitOptions.setExceptionsThrownOnErrorStatus( false ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + resourcePath ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); // --- Verification diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletProxiedReleasePolicyTest.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletProxiedReleasePolicyTest.java index 465987e8d..007e75ca7 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletProxiedReleasePolicyTest.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletProxiedReleasePolicyTest.java @@ -186,7 +186,7 @@ public class RepositoryServletProxiedReleasePolicyTest HttpUnitOptions.setExceptionsThrownOnErrorStatus( false ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + resourcePath ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); // --- Verification diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletProxiedRelocatedTest.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletProxiedRelocatedTest.java index 6bea9a39d..1d5e13df8 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletProxiedRelocatedTest.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletProxiedRelocatedTest.java @@ -72,7 +72,7 @@ public class RepositoryServletProxiedRelocatedTest HttpUnitOptions.setExceptionsThrownOnErrorStatus( false ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + resourcePath ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); // --- Verification assertResponseOK( response ); diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletProxiedSnapshotPolicyTest.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletProxiedSnapshotPolicyTest.java index 8ec525e76..2e4ada243 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletProxiedSnapshotPolicyTest.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletProxiedSnapshotPolicyTest.java @@ -208,7 +208,7 @@ public class RepositoryServletProxiedSnapshotPolicyTest HttpUnitOptions.setExceptionsThrownOnErrorStatus( false ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + resourcePath ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); // --- Verification diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletProxiedTimestampedSnapshotPolicyTest.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletProxiedTimestampedSnapshotPolicyTest.java index 50fbdad9f..edf732907 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletProxiedTimestampedSnapshotPolicyTest.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletProxiedTimestampedSnapshotPolicyTest.java @@ -205,7 +205,7 @@ public class RepositoryServletProxiedTimestampedSnapshotPolicyTest HttpUnitOptions.setExceptionsThrownOnErrorStatus( false ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + resourcePath ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); // --- Verification diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletRepositoryGroupTest.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletRepositoryGroupTest.java index 5a8639f06..bd792d368 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletRepositoryGroupTest.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletRepositoryGroupTest.java @@ -152,7 +152,7 @@ public class RepositoryServletRepositoryGroupTest WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/" + resourceName ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); assertResponseOK( response ); assertEquals( "Expected file contents", "first", response.getText() ); @@ -173,7 +173,7 @@ public class RepositoryServletRepositoryGroupTest WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/" + resourceName ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); assertResponseOK( response ); assertEquals( "Expected file contents", "last", response.getText() ); @@ -190,7 +190,7 @@ public class RepositoryServletRepositoryGroupTest WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/" + resourceName ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); assertResponseNotFound( response ); } @@ -206,7 +206,7 @@ public class RepositoryServletRepositoryGroupTest WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/" + REPO_GROUP_WITH_INVALID_REPOS + "/" + resourceName ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); assertResponseInternalServerError( response ); } @@ -223,7 +223,7 @@ public class RepositoryServletRepositoryGroupTest InputStream is = getClass().getResourceAsStream( "/artifact.jar" ); WebRequest request = new PutMethodWebRequest( putUrl, is, "text/plain" ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); assertResponseMethodNotAllowed( response ); } @@ -257,7 +257,7 @@ public class RepositoryServletRepositoryGroupTest WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/dummy/" + "dummy-merged-metadata-resource/maven-metadata.xml" ); - WebResponse response = sc.getResource( request ); + WebResponse response = getServletUnitClient().getResource( request ); File returnedMetadata = new File( "target/test-classes/retrievedMetadataFile.xml" ); FileUtils.writeStringToFile( returnedMetadata, response.getText() ); @@ -282,7 +282,7 @@ public class RepositoryServletRepositoryGroupTest // request the sha1 checksum of the metadata request = new GetMethodWebRequest( "http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/dummy/" + "dummy-merged-metadata-resource/maven-metadata.xml.sha1" ); - response = sc.getResource( request ); + response = getServletUnitClient().getResource( request ); assertResponseOK( response ); assertEquals( "add113b0d7f8c6adb92a5015a7a3701081edf998 maven-metadata-group-with-valid-repos.xml", @@ -291,7 +291,7 @@ public class RepositoryServletRepositoryGroupTest // request the md5 checksum of the metadata request = new GetMethodWebRequest( "http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/dummy/" + "dummy-merged-metadata-resource/maven-metadata.xml.md5" ); - response = sc.getResource( request ); + response = getServletUnitClient().getResource( request ); assertResponseOK( response ); assertEquals( "5b85ea4aa5f52bb76760041a52f98de8 maven-metadata-group-with-valid-repos.xml", @@ -317,7 +317,7 @@ public class RepositoryServletRepositoryGroupTest WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/dummy/dummy-artifact/" ); - WebResponse response = sc.getResource( request ); + WebResponse response = getServletUnitClient().getResource( request ); assertResponseOK( response ); assertTrue( StringUtils.contains( response.getText(), "Collection" ) ); diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletTest.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletTest.java index 2ddb2328a..9fb384d85 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletTest.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletTest.java @@ -48,7 +48,7 @@ public class RepositoryServletTest public void testGetRepository() throws Exception { - RepositoryServlet servlet = (RepositoryServlet) sc.newInvocation( REQUEST_PATH ).getServlet(); + RepositoryServlet servlet = (RepositoryServlet) getServletUnitClient().newInvocation( REQUEST_PATH ).getServlet(); assertNotNull( servlet ); assertRepositoryValid( servlet, REPOID_INTERNAL ); @@ -58,7 +58,7 @@ public class RepositoryServletTest public void testGetRepositoryAfterDelete() throws Exception { - RepositoryServlet servlet = (RepositoryServlet) sc.newInvocation( REQUEST_PATH ).getServlet(); + RepositoryServlet servlet = (RepositoryServlet) getServletUnitClient().newInvocation( REQUEST_PATH ).getServlet(); assertNotNull( servlet ); ArchivaConfiguration archivaConfiguration = servlet.getConfiguration(); @@ -74,7 +74,7 @@ public class RepositoryServletTest public void testGetRepositoryAfterAdd() throws Exception { - RepositoryServlet servlet = (RepositoryServlet) sc.newInvocation( REQUEST_PATH ).getServlet(); + RepositoryServlet servlet = (RepositoryServlet) getServletUnitClient().newInvocation( REQUEST_PATH ).getServlet(); assertNotNull( servlet ); ArchivaConfiguration archivaConfiguration = servlet.getConfiguration(); @@ -108,7 +108,7 @@ public class RepositoryServletTest populateRepo( repoRootInternal, ".index/filecontent/segments.gen", "index file" ); WebRequest request = new GetMethodWebRequest( path ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); assertResponseOK( response ); assertEquals( "index file", response.getText() ); } @@ -120,7 +120,7 @@ public class RepositoryServletTest String path = REQUEST_PATH + ".index/filecontent/foo.bar"; WebRequest request = new GetMethodWebRequest( path ); - WebResponse response = sc.getResponse( request ); + WebResponse response = getServletUnitClient().getResponse( request ); assertResponseNotFound( response ); assertEquals( "Invalid path to Artifact: legacy paths should have an expected type ending in [s] in the second part of the path.", response.getResponseMessage() ); } -- 2.39.5