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
This commit is contained in:
Olivier Lamy 2011-11-04 15:29:31 +00:00
parent 2b4b9f0c0b
commit 534334dd98
15 changed files with 120 additions and 113 deletions

View File

@ -198,6 +198,7 @@
<plexus.home>${project.build.directory}/appserver-base</plexus.home> <plexus.home>${project.build.directory}/appserver-base</plexus.home>
<derby.system.home>${project.build.directory}/appserver-base</derby.system.home> <derby.system.home>${project.build.directory}/appserver-base</derby.system.home>
<test.resources.path>${project.build.testOutputDirectory}</test.resources.path> <test.resources.path>${project.build.testOutputDirectory}</test.resources.path>
<archiva.user.configFileName>${project.build.testOutputDirectory}/repository-archiva.xml</archiva.user.configFileName>
<redback.jdbc.url>jdbc:derby:memory:users-test;create=true</redback.jdbc.url> <redback.jdbc.url>jdbc:derby:memory:users-test;create=true</redback.jdbc.url>
<redback.jdbc.driver.name>org.apache.derby.jdbc.EmbeddedDriver</redback.jdbc.driver.name> <redback.jdbc.driver.name>org.apache.derby.jdbc.EmbeddedDriver</redback.jdbc.driver.name>
</systemPropertyVariables> </systemPropertyVariables>

View File

@ -58,7 +58,7 @@ public abstract class AbstractRepositoryServletProxiedMetadataTestCase
HttpUnitOptions.setExceptionsThrownOnErrorStatus( false ); HttpUnitOptions.setExceptionsThrownOnErrorStatus( false );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + path ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + path );
WebResponse response = sc.getResponse( request ); WebResponse response = getServletUnitClient().getResponse( request );
assertResponseOK( response ); assertResponseOK( response );
return response.getText(); return response.getText();
} }

View File

@ -33,12 +33,8 @@ import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.archiva.configuration.RemoteRepositoryConfiguration; import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
import org.apache.archiva.webdav.util.MavenIndexerCleaner; import org.apache.archiva.webdav.util.MavenIndexerCleaner;
import org.apache.commons.io.FileUtils; 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.After;
import org.junit.Before; import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -50,8 +46,6 @@ import javax.inject.Inject;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
/** /**
* AbstractRepositoryServletTestCase * AbstractRepositoryServletTestCase
@ -67,13 +61,13 @@ public abstract class AbstractRepositoryServletTestCase
protected static final String REPOID_LEGACY = "legacy"; protected static final String REPOID_LEGACY = "legacy";
protected ServletUnitClient sc;
protected File repoRootInternal; protected File repoRootInternal;
protected File repoRootLegacy; protected File repoRootLegacy;
private ServletRunner sr; protected ServletUnitClient servletUnitClient;
private ServletRunner servletRunner;
protected ArchivaConfiguration archivaConfiguration; protected ArchivaConfiguration archivaConfiguration;
@ -89,8 +83,6 @@ public abstract class AbstractRepositoryServletTestCase
saveConfiguration( archivaConfiguration ); saveConfiguration( archivaConfiguration );
} }
@Before @Before
public void setUp() public void setUp()
throws Exception throws Exception
@ -135,10 +127,22 @@ public abstract class AbstractRepositoryServletTestCase
applicationContext.getBean( MavenIndexerCleaner.class ).cleanupIndex(); applicationContext.getBean( MavenIndexerCleaner.class ).cleanupIndex();
sr = new ServletRunner( new File( "src/test/resources/WEB-INF/web.xml" ) ); }
sr.registerServlet( "/repository/*", UnauthenticatedRepositoryServlet.class.getName() ); protected ServletUnitClient getServletUnitClient()
sc = sr.newClient(); 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();
return servletUnitClient;
} }
@Override @Override
@ -147,14 +151,14 @@ public abstract class AbstractRepositoryServletTestCase
throws Exception 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() ) if ( repoRootInternal.exists() )

View File

@ -26,12 +26,11 @@ import com.meterware.httpunit.WebResponse;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import javax.servlet.http.HttpServletResponse;
import java.io.File; import java.io.File;
import javax.servlet.http.HttpServletResponse;
/** /**
* RepositoryServletBrowseTest * RepositoryServletBrowseTest
* *
* @version $Id$ * @version $Id$
*/ */
@ -41,10 +40,10 @@ public class RepositoryServletBrowseTest
@Override @Override
@Before @Before
public void setUp() public void setUp()
throws Exception throws Exception
{ {
super.setUp(); super.setUp();
new File( repoRootInternal, "org/apache/archiva" ).mkdirs(); new File( repoRootInternal, "org/apache/archiva" ).mkdirs();
new File( repoRootInternal, "org/codehaus/mojo/" ).mkdirs(); new File( repoRootInternal, "org/codehaus/mojo/" ).mkdirs();
new File( repoRootInternal, "net/sourceforge" ).mkdirs(); new File( repoRootInternal, "net/sourceforge" ).mkdirs();
@ -56,13 +55,13 @@ public class RepositoryServletBrowseTest
throws Exception throws Exception
{ {
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" ); 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() ); assertEquals( "Response", HttpServletResponse.SC_OK, response.getResponseCode() );
// dumpResponse( response ); // dumpResponse( response );
String expectedLinks[] = new String[] { "commons-lang/", "net/", "org/" }; String expectedLinks[] = new String[]{ ".indexer", "commons-lang/", "net/", "org/" };
assertLinks(expectedLinks, response.getLinks()); assertLinks( expectedLinks, response.getLinks() );
} }
@Test @Test
@ -70,11 +69,11 @@ public class RepositoryServletBrowseTest
throws Exception throws Exception
{ {
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/org" ); 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() ); assertEquals( "Response", HttpServletResponse.SC_OK, response.getResponseCode() );
String expectedLinks[] = new String[] { "../", "apache/", "codehaus/" }; String expectedLinks[] = new String[]{ "../", "apache/", "codehaus/" };
assertLinks(expectedLinks, response.getLinks()); assertLinks( expectedLinks, response.getLinks() );
} }
@Test @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" ).mkdirs();
new File( repoRootInternal, "org/apache/archiva/artifactId/1.0/artifactId-1.0.jar" ).createNewFile(); 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" ); WebRequest request =
WebResponse response = sc.getResponse( 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() ); assertEquals( "1st Response", HttpServletResponse.SC_OK, response.getResponseCode() );
request = new GetMethodWebRequest( "http://machine.com/repository/internal/org/apache/archiva/artifactId/" ); 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() ); 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" ); request = new GetMethodWebRequest(
response = sc.getResponse( request ); "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() ); 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/" ); request = new GetMethodWebRequest(
response = sc.getResponse( request ); "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() ); 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 ); assertEquals( "Links.length", expectedLinks.length, actualLinks.length );
for ( int i = 0; i < actualLinks.length; i++ ) for ( int i = 0; i < actualLinks.length; i++ )
{ {
assertEquals( "Link[" + i + "]", expectedLinks[i], actualLinks[i].getURLString() ); assertEquals( "Link[" + i + "]", expectedLinks[i], actualLinks[i].getURLString() );
} }
} }
} }

View File

@ -56,7 +56,7 @@ public class RepositoryServletDeployTest
WebRequest request = new PutMethodWebRequest( putUrl, is, "application/octet-stream" ); WebRequest request = new PutMethodWebRequest( putUrl, is, "application/octet-stream" );
WebResponse response = sc.getResponse( request ); WebResponse response = getServletUnitClient().getResponse( request );
assertResponseCreated( response ); assertResponseCreated( response );
assertFileContents( "artifact.jar\n", repoRootInternal, ARTIFACT_DEFAULT_LAYOUT ); assertFileContents( "artifact.jar\n", repoRootInternal, ARTIFACT_DEFAULT_LAYOUT );
} }
@ -83,23 +83,23 @@ public class RepositoryServletDeployTest
// send request #1 and verify it's successful // send request #1 and verify it's successful
WebRequest request = new PutMethodWebRequest( putUrl, is, "application/octet-stream" ); WebRequest request = new PutMethodWebRequest( putUrl, is, "application/octet-stream" );
WebResponse response = sc.getResponse( request ); WebResponse response = getServletUnitClient().getResponse( request );
assertResponseCreated( response ); assertResponseCreated( response );
is = getClass().getResourceAsStream( "/artifact.jar.sha1" ); is = getClass().getResourceAsStream( "/artifact.jar.sha1" );
request = new PutMethodWebRequest( checksumUrl, is, "application/octet-stream" ); request = new PutMethodWebRequest( checksumUrl, is, "application/octet-stream" );
response = sc.getResponse( request ); response = getServletUnitClient().getResponse( request );
assertResponseCreated( response ); assertResponseCreated( response );
is = getClass().getResourceAsStream( "/maven-metadata.xml" ); is = getClass().getResourceAsStream( "/maven-metadata.xml" );
request = new PutMethodWebRequest( metadataUrl, is, "application/octet-stream" ); request = new PutMethodWebRequest( metadataUrl, is, "application/octet-stream" );
response = sc.getResponse( request ); response = getServletUnitClient().getResponse( request );
assertResponseCreated( response ); assertResponseCreated( response );
// send request #2 and verify it's blocked // send request #2 and verify it's blocked
is = getClass().getResourceAsStream( "/artifact.jar" ); is = getClass().getResourceAsStream( "/artifact.jar" );
request = new PutMethodWebRequest( putUrl, is, "application/octet-stream" ); request = new PutMethodWebRequest( putUrl, is, "application/octet-stream" );
response = sc.getResponse( request ); response = getServletUnitClient().getResponse( request );
assertResponseConflictError( response ); assertResponseConflictError( response );
} }
@ -124,23 +124,23 @@ public class RepositoryServletDeployTest
// send request #1 and verify it's successful // send request #1 and verify it's successful
WebRequest request = new PutMethodWebRequest( putUrl, is, "application/octet-stream" ); WebRequest request = new PutMethodWebRequest( putUrl, is, "application/octet-stream" );
WebResponse response = sc.getResponse( request ); WebResponse response = getServletUnitClient().getResponse( request );
assertResponseCreated( response ); assertResponseCreated( response );
is = getClass().getResourceAsStream( "/artifact.jar.sha1" ); is = getClass().getResourceAsStream( "/artifact.jar.sha1" );
request = new PutMethodWebRequest( checksumUrl, is, "application/octet-stream" ); request = new PutMethodWebRequest( checksumUrl, is, "application/octet-stream" );
response = sc.getResponse( request ); response = getServletUnitClient().getResponse( request );
assertResponseCreated( response ); assertResponseCreated( response );
is = getClass().getResourceAsStream( "/maven-metadata.xml" ); is = getClass().getResourceAsStream( "/maven-metadata.xml" );
request = new PutMethodWebRequest( metadataUrl, is, "application/octet-stream" ); request = new PutMethodWebRequest( metadataUrl, is, "application/octet-stream" );
response = sc.getResponse( request ); response = getServletUnitClient().getResponse( request );
assertResponseCreated( response ); assertResponseCreated( response );
// send request #2 and verify if it's still successful // send request #2 and verify if it's still successful
is = getClass().getResourceAsStream( "/artifact.jar" ); is = getClass().getResourceAsStream( "/artifact.jar" );
request = new PutMethodWebRequest( putUrl, is, "application/octet-stream" ); request = new PutMethodWebRequest( putUrl, is, "application/octet-stream" );
response = sc.getResponse( request ); response = getServletUnitClient().getResponse( request );
assertResponseNoContent( response ); assertResponseNoContent( response );
} }
@ -160,23 +160,23 @@ public class RepositoryServletDeployTest
// send request #1 and verify it's successful // send request #1 and verify it's successful
WebRequest request = new PutMethodWebRequest( putUrl, is, "application/octet-stream" ); WebRequest request = new PutMethodWebRequest( putUrl, is, "application/octet-stream" );
WebResponse response = sc.getResponse( request ); WebResponse response = getServletUnitClient().getResponse( request );
assertResponseCreated( response ); assertResponseCreated( response );
is = getClass().getResourceAsStream( "/artifact.jar.sha1" ); is = getClass().getResourceAsStream( "/artifact.jar.sha1" );
request = new PutMethodWebRequest( checksumUrl, is, "application/octet-stream" ); request = new PutMethodWebRequest( checksumUrl, is, "application/octet-stream" );
response = sc.getResponse( request ); response = getServletUnitClient().getResponse( request );
assertResponseCreated( response ); assertResponseCreated( response );
is = getClass().getResourceAsStream( "/maven-metadata.xml" ); is = getClass().getResourceAsStream( "/maven-metadata.xml" );
request = new PutMethodWebRequest( metadataUrl, is, "application/octet-stream" ); request = new PutMethodWebRequest( metadataUrl, is, "application/octet-stream" );
response = sc.getResponse( request ); response = getServletUnitClient().getResponse( request );
assertResponseCreated( response ); assertResponseCreated( response );
// send request #2 and verify it's re-deployed // send request #2 and verify it's re-deployed
is = getClass().getResourceAsStream( "/artifact.jar" ); is = getClass().getResourceAsStream( "/artifact.jar" );
request = new PutMethodWebRequest( putUrl, is, "application/octet-stream" ); request = new PutMethodWebRequest( putUrl, is, "application/octet-stream" );
response = sc.getResponse( request ); response = getServletUnitClient().getResponse( request );
assertResponseNoContent( response ); assertResponseNoContent( response );
} }
@ -196,23 +196,23 @@ public class RepositoryServletDeployTest
// send request #1 and verify it's successful // send request #1 and verify it's successful
WebRequest request = new PutMethodWebRequest( putUrl, is, "application/octet-stream" ); WebRequest request = new PutMethodWebRequest( putUrl, is, "application/octet-stream" );
WebResponse response = sc.getResponse( request ); WebResponse response = getServletUnitClient().getResponse( request );
assertResponseCreated( response ); assertResponseCreated( response );
is = getClass().getResourceAsStream( "/artifact.jar.sha1" ); is = getClass().getResourceAsStream( "/artifact.jar.sha1" );
request = new PutMethodWebRequest( checksumUrl, is, "application/octet-stream" ); request = new PutMethodWebRequest( checksumUrl, is, "application/octet-stream" );
response = sc.getResponse( request ); response = getServletUnitClient().getResponse( request );
assertResponseCreated( response ); assertResponseCreated( response );
is = getClass().getResourceAsStream( "/maven-metadata.xml" ); is = getClass().getResourceAsStream( "/maven-metadata.xml" );
request = new PutMethodWebRequest( metadataUrl, is, "application/octet-stream" ); request = new PutMethodWebRequest( metadataUrl, is, "application/octet-stream" );
response = sc.getResponse( request ); response = getServletUnitClient().getResponse( request );
assertResponseCreated( response ); assertResponseCreated( response );
// send request #2 and verify it's re-deployed // send request #2 and verify it's re-deployed
is = getClass().getResourceAsStream( "/artifact.jar" ); is = getClass().getResourceAsStream( "/artifact.jar" );
request = new PutMethodWebRequest( putUrl, is, "application/octet-stream" ); request = new PutMethodWebRequest( putUrl, is, "application/octet-stream" );
response = sc.getResponse( request ); response = getServletUnitClient().getResponse( request );
assertResponseNoContent( response ); assertResponseNoContent( response );
} }
@ -226,7 +226,7 @@ public class RepositoryServletDeployTest
WebRequest request = new MkColMethodWebRequest( putUrl ); WebRequest request = new MkColMethodWebRequest( putUrl );
WebResponse response = sc.getResponse( request ); WebResponse response = getServletUnitClient().getResponse( request );
assertEquals(HttpServletResponse.SC_CONFLICT, response.getResponseCode()); assertEquals(HttpServletResponse.SC_CONFLICT, response.getResponseCode());

View File

@ -48,7 +48,7 @@ public class RepositoryServletNoProxyMetadataTest
FileUtils.writeStringToFile( checksumFile, expectedMetadataContents, null ); FileUtils.writeStringToFile( checksumFile, expectedMetadataContents, null );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata );
WebResponse response = sc.getResponse( request ); WebResponse response = getServletUnitClient().getResponse( request );
assertResponseOK( response ); assertResponseOK( response );
assertEquals( "Expected file contents", expectedMetadataContents, response.getText() ); assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
@ -67,7 +67,7 @@ public class RepositoryServletNoProxyMetadataTest
FileUtils.writeStringToFile( checksumFile, expectedMetadataContents, null ); FileUtils.writeStringToFile( checksumFile, expectedMetadataContents, null );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata );
WebResponse response = sc.getResponse( request ); WebResponse response = getServletUnitClient().getResponse( request );
assertResponseOK( response ); assertResponseOK( response );
assertEquals( "Expected file contents", expectedMetadataContents, response.getText() ); assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
@ -86,7 +86,7 @@ public class RepositoryServletNoProxyMetadataTest
FileUtils.writeStringToFile( checksumFile, expectedMetadataContents, null ); FileUtils.writeStringToFile( checksumFile, expectedMetadataContents, null );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata );
WebResponse response = sc.getResponse( request ); WebResponse response = getServletUnitClient().getResponse( request );
assertResponseOK( response ); assertResponseOK( response );
assertEquals( "Expected file contents", expectedMetadataContents, response.getText() ); assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
@ -105,7 +105,7 @@ public class RepositoryServletNoProxyMetadataTest
FileUtils.writeStringToFile( checksumFile, expectedMetadataContents, null ); FileUtils.writeStringToFile( checksumFile, expectedMetadataContents, null );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + assemblyPluginMetadata ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + assemblyPluginMetadata );
WebResponse response = sc.getResponse( request ); WebResponse response = getServletUnitClient().getResponse( request );
assertResponseOK( response ); assertResponseOK( response );
assertEquals( "Expected file contents", expectedMetadataContents, response.getText() ); assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );

View File

@ -59,7 +59,7 @@ public class RepositoryServletNoProxyTest
FileUtils.writeStringToFile( checksumFile, "dummy-checksum", null ); FileUtils.writeStringToFile( checksumFile, "dummy-checksum", null );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangSha1 ); 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" ) ); assertNotNull( response.getHeaderField( "last-modified" ) );
} }
@ -76,7 +76,7 @@ public class RepositoryServletNoProxyTest
FileUtils.writeStringToFile( checksumFile, "dummy-checksum", null ); FileUtils.writeStringToFile( checksumFile, "dummy-checksum", null );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangSha1 ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangSha1 );
WebResponse response = sc.getResponse( request ); WebResponse response = getServletUnitClient().getResponse( request );
assertResponseOK( response ); assertResponseOK( response );
assertEquals( "Expected file contents", "dummy-checksum", response.getText() ); assertEquals( "Expected file contents", "dummy-checksum", response.getText() );
@ -95,7 +95,7 @@ public class RepositoryServletNoProxyTest
WebRequest request = new GetMethodWebRequest( WebRequest request = new GetMethodWebRequest(
"http://machine.com/repository/internal/" + "commons-lang/jars/commons-lang-2.1.jar.sha1" ); "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 ); assertResponseOK( response );
assertEquals( "Expected file contents", "dummy-checksum", response.getText() ); assertEquals( "Expected file contents", "dummy-checksum", response.getText() );
@ -114,7 +114,7 @@ public class RepositoryServletNoProxyTest
FileUtils.writeStringToFile( metadataFile, expectedMetadataContents, null ); FileUtils.writeStringToFile( metadataFile, expectedMetadataContents, null );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata );
WebResponse response = sc.getResponse( request ); WebResponse response = getServletUnitClient().getResponse( request );
assertResponseOK( response ); assertResponseOK( response );
assertEquals( "Expected file contents", expectedMetadataContents, response.getText() ); assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
@ -133,7 +133,7 @@ public class RepositoryServletNoProxyTest
FileUtils.writeStringToFile( metadataFile, expectedMetadataContents, null ); FileUtils.writeStringToFile( metadataFile, expectedMetadataContents, null );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata );
WebResponse response = sc.getResponse( request ); WebResponse response = getServletUnitClient().getResponse( request );
assertResponseOK( response ); assertResponseOK( response );
assertEquals( "Expected file contents", expectedMetadataContents, response.getText() ); assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
@ -152,7 +152,7 @@ public class RepositoryServletNoProxyTest
FileUtils.writeStringToFile( metadataFile, expectedMetadataContents, null ); FileUtils.writeStringToFile( metadataFile, expectedMetadataContents, null );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata );
WebResponse response = sc.getResponse( request ); WebResponse response = getServletUnitClient().getResponse( request );
assertResponseOK( response ); assertResponseOK( response );
assertEquals( "Expected file contents", expectedMetadataContents, response.getText() ); assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
@ -171,7 +171,7 @@ public class RepositoryServletNoProxyTest
FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null ); FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangJar ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangJar );
WebResponse response = sc.getResponse( request ); WebResponse response = getServletUnitClient().getResponse( request );
assertResponseOK( response ); assertResponseOK( response );
assertEquals( "Expected file contents", expectedArtifactContents, response.getText() ); assertEquals( "Expected file contents", expectedArtifactContents, response.getText() );
@ -191,7 +191,7 @@ public class RepositoryServletNoProxyTest
WebRequest request = new GetMethodWebRequest( WebRequest request = new GetMethodWebRequest(
"http://machine.com/repository/internal/" + "commons-lang/jars/commons-lang-2.1.jar" ); "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 ); assertResponseOK( response );
assertEquals( "Expected file contents", expectedArtifactContents, response.getText() ); assertEquals( "Expected file contents", expectedArtifactContents, response.getText() );
@ -210,7 +210,7 @@ public class RepositoryServletNoProxyTest
FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null ); FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangJar ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangJar );
WebResponse response = sc.getResponse( request ); WebResponse response = getServletUnitClient().getResponse( request );
assertResponseOK( response ); assertResponseOK( response );
assertEquals( "Expected file contents", expectedArtifactContents, response.getText() ); assertEquals( "Expected file contents", expectedArtifactContents, response.getText() );
@ -230,7 +230,7 @@ public class RepositoryServletNoProxyTest
WebRequest request = new GetMethodWebRequest( WebRequest request = new GetMethodWebRequest(
"http://machine.com/repository/internal/" + "commons-lang/jars/commons-lang-2.1-SNAPSHOT.jar" ); "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 ); assertResponseOK( response );
assertEquals( "Expected file contents", expectedArtifactContents, response.getText() ); assertEquals( "Expected file contents", expectedArtifactContents, response.getText() );
@ -249,7 +249,7 @@ public class RepositoryServletNoProxyTest
FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null ); FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangJar ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangJar );
WebResponse response = sc.getResponse( request ); WebResponse response = getServletUnitClient().getResponse( request );
assertResponseOK( response ); assertResponseOK( response );
assertEquals( "Expected file contents", expectedArtifactContents, response.getText() ); assertEquals( "Expected file contents", expectedArtifactContents, response.getText() );
@ -269,7 +269,7 @@ public class RepositoryServletNoProxyTest
WebRequest request = new GetMethodWebRequest( WebRequest request = new GetMethodWebRequest(
"http://machine.com/repository/internal/" + "commons-lang/jars/commons-lang-2.1-20050821.023400-1.jar" ); "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 ); assertResponseOK( response );
assertEquals( "Expected file contents", expectedArtifactContents, response.getText() ); assertEquals( "Expected file contents", expectedArtifactContents, response.getText() );
@ -291,7 +291,7 @@ public class RepositoryServletNoProxyTest
FileUtils.writeStringToFile( checksumFile, expectedContents, null ); FileUtils.writeStringToFile( checksumFile, expectedContents, null );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + dualExtensionPath ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + dualExtensionPath );
WebResponse response = sc.getResponse( request ); WebResponse response = getServletUnitClient().getResponse( request );
assertResponseOK( response ); assertResponseOK( response );
assertEquals( "Expected file contents", expectedContents, response.getText() ); assertEquals( "Expected file contents", expectedContents, response.getText() );
@ -311,7 +311,7 @@ public class RepositoryServletNoProxyTest
WebRequest request = new GetMethodWebRequest( WebRequest request = new GetMethodWebRequest(
"http://machine.com/repository/internal/" + "org.project/distributions/example-presentation-3.2.zip" ); "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 ); assertResponseOK( response );
assertEquals( "Expected file contents", expectedContents, response.getText() ); assertEquals( "Expected file contents", expectedContents, response.getText() );
@ -329,7 +329,7 @@ public class RepositoryServletNoProxyTest
FileUtils.writeStringToFile( checksumFile, "dummy-checksum", null ); FileUtils.writeStringToFile( checksumFile, "dummy-checksum", null );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangSha1 ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangSha1 );
WebResponse response = sc.getResponse( request ); WebResponse response = getServletUnitClient().getResponse( request );
assertResponseOK( response ); assertResponseOK( response );
assertEquals( "Expected file contents", "dummy-checksum", response.getText() ); assertEquals( "Expected file contents", "dummy-checksum", response.getText() );
@ -346,7 +346,7 @@ public class RepositoryServletNoProxyTest
FileUtils.writeStringToFile( checksumFile, "dummy-checksum", null ); FileUtils.writeStringToFile( checksumFile, "dummy-checksum", null );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangSha1 ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangSha1 );
WebResponse response = sc.getResponse( request ); WebResponse response = getServletUnitClient().getResponse( request );
assertResponseOK( response ); assertResponseOK( response );
assertEquals( "Expected file contents", "dummy-checksum", response.getText() ); assertEquals( "Expected file contents", "dummy-checksum", response.getText() );
@ -366,7 +366,7 @@ public class RepositoryServletNoProxyTest
FileUtils.writeStringToFile( metadataFile, expectedMetadataContents, null ); FileUtils.writeStringToFile( metadataFile, expectedMetadataContents, null );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangMetadata ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangMetadata );
WebResponse response = sc.getResponse( request ); WebResponse response = getServletUnitClient().getResponse( request );
assertResponseOK( response ); assertResponseOK( response );
assertEquals( "Expected file contents", expectedMetadataContents, response.getText() ); assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
@ -386,7 +386,7 @@ public class RepositoryServletNoProxyTest
FileUtils.writeStringToFile( metadataFile, expectedMetadataContents, null ); FileUtils.writeStringToFile( metadataFile, expectedMetadataContents, null );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangMetadata ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangMetadata );
WebResponse response = sc.getResponse( request ); WebResponse response = getServletUnitClient().getResponse( request );
assertResponseOK( response ); assertResponseOK( response );
assertEquals( "Expected file contents", expectedMetadataContents, response.getText() ); assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
@ -405,7 +405,7 @@ public class RepositoryServletNoProxyTest
FileUtils.writeStringToFile( metadataFile, expectedMetadataContents, null ); FileUtils.writeStringToFile( metadataFile, expectedMetadataContents, null );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangMetadata ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangMetadata );
WebResponse response = sc.getResponse( request ); WebResponse response = getServletUnitClient().getResponse( request );
assertResponseOK( response ); assertResponseOK( response );
assertEquals( "Expected file contents", expectedMetadataContents, response.getText() ); assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
@ -424,7 +424,7 @@ public class RepositoryServletNoProxyTest
FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null ); FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangJar ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangJar );
WebResponse response = sc.getResponse( request ); WebResponse response = getServletUnitClient().getResponse( request );
assertResponseOK( response ); assertResponseOK( response );
assertEquals( "Expected file contents", expectedArtifactContents, response.getText() ); assertEquals( "Expected file contents", expectedArtifactContents, response.getText() );
@ -443,7 +443,7 @@ public class RepositoryServletNoProxyTest
FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null ); FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangJar ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangJar );
WebResponse response = sc.getResponse( request ); WebResponse response = getServletUnitClient().getResponse( request );
assertResponseOK( response ); assertResponseOK( response );
assertEquals( "Expected file contents", expectedArtifactContents, response.getText() ); assertEquals( "Expected file contents", expectedArtifactContents, response.getText() );
@ -462,7 +462,7 @@ public class RepositoryServletNoProxyTest
FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null ); FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangJar ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangJar );
WebResponse response = sc.getResponse( request ); WebResponse response = getServletUnitClient().getResponse( request );
assertResponseOK( response ); assertResponseOK( response );
assertEquals( "Expected file contents", expectedArtifactContents, response.getText() ); assertEquals( "Expected file contents", expectedArtifactContents, response.getText() );
@ -481,7 +481,7 @@ public class RepositoryServletNoProxyTest
FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null ); FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangJar ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangJar );
WebResponse response = sc.getResponse( request ); WebResponse response = getServletUnitClient().getResponse( request );
assertResponseOK( response ); assertResponseOK( response );
assertEquals( "Expected file contents", expectedArtifactContents, response.getText() ); assertEquals( "Expected file contents", expectedArtifactContents, response.getText() );
@ -501,7 +501,7 @@ public class RepositoryServletNoProxyTest
FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null ); FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangJar ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangJar );
WebResponse response = sc.getResponse( request ); WebResponse response = getServletUnitClient().getResponse( request );
assertResponseOK( response ); assertResponseOK( response );
assertEquals( "Expected file contents", expectedArtifactContents, response.getText() ); assertEquals( "Expected file contents", expectedArtifactContents, response.getText() );
@ -520,7 +520,7 @@ public class RepositoryServletNoProxyTest
FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null ); FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangJar ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangJar );
WebResponse response = sc.getResponse( request ); WebResponse response = getServletUnitClient().getResponse( request );
assertResponseOK( response ); assertResponseOK( response );
assertEquals( "Expected file contents", expectedArtifactContents, response.getText() ); assertEquals( "Expected file contents", expectedArtifactContents, response.getText() );
@ -542,7 +542,7 @@ public class RepositoryServletNoProxyTest
FileUtils.writeStringToFile( checksumFile, expectedContents, null ); FileUtils.writeStringToFile( checksumFile, expectedContents, null );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + dualExtensionPath ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + dualExtensionPath );
WebResponse response = sc.getResponse( request ); WebResponse response = getServletUnitClient().getResponse( request );
assertResponseOK( response ); assertResponseOK( response );
assertEquals( "Expected file contents", expectedContents, response.getText() ); assertEquals( "Expected file contents", expectedContents, response.getText() );
@ -561,7 +561,7 @@ public class RepositoryServletNoProxyTest
FileUtils.writeStringToFile( checksumFile, expectedContents, null ); FileUtils.writeStringToFile( checksumFile, expectedContents, null );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + dualExtensionPath ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + dualExtensionPath );
WebResponse response = sc.getResponse( request ); WebResponse response = getServletUnitClient().getResponse( request );
assertResponseOK( response ); assertResponseOK( response );
assertEquals( "Expected file contents", expectedContents, response.getText() ); assertEquals( "Expected file contents", expectedContents, response.getText() );

View File

@ -155,7 +155,7 @@ public class RepositoryServletProxiedPassthroughTest
HttpUnitOptions.setExceptionsThrownOnErrorStatus( false ); HttpUnitOptions.setExceptionsThrownOnErrorStatus( false );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + path ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + path );
WebResponse response = sc.getResponse( request ); WebResponse response = getServletUnitClient().getResponse( request );
// --- Verification // --- Verification

View File

@ -190,7 +190,7 @@ public class RepositoryServletProxiedPluginSnapshotPolicyTest
HttpUnitOptions.setExceptionsThrownOnErrorStatus( false ); HttpUnitOptions.setExceptionsThrownOnErrorStatus( false );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + resourcePath ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + resourcePath );
WebResponse response = sc.getResponse( request ); WebResponse response = getServletUnitClient().getResponse( request );
// --- Verification // --- Verification

View File

@ -186,7 +186,7 @@ public class RepositoryServletProxiedReleasePolicyTest
HttpUnitOptions.setExceptionsThrownOnErrorStatus( false ); HttpUnitOptions.setExceptionsThrownOnErrorStatus( false );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + resourcePath ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + resourcePath );
WebResponse response = sc.getResponse( request ); WebResponse response = getServletUnitClient().getResponse( request );
// --- Verification // --- Verification

View File

@ -72,7 +72,7 @@ public class RepositoryServletProxiedRelocatedTest
HttpUnitOptions.setExceptionsThrownOnErrorStatus( false ); HttpUnitOptions.setExceptionsThrownOnErrorStatus( false );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + resourcePath ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + resourcePath );
WebResponse response = sc.getResponse( request ); WebResponse response = getServletUnitClient().getResponse( request );
// --- Verification // --- Verification
assertResponseOK( response ); assertResponseOK( response );

View File

@ -208,7 +208,7 @@ public class RepositoryServletProxiedSnapshotPolicyTest
HttpUnitOptions.setExceptionsThrownOnErrorStatus( false ); HttpUnitOptions.setExceptionsThrownOnErrorStatus( false );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + resourcePath ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + resourcePath );
WebResponse response = sc.getResponse( request ); WebResponse response = getServletUnitClient().getResponse( request );
// --- Verification // --- Verification

View File

@ -205,7 +205,7 @@ public class RepositoryServletProxiedTimestampedSnapshotPolicyTest
HttpUnitOptions.setExceptionsThrownOnErrorStatus( false ); HttpUnitOptions.setExceptionsThrownOnErrorStatus( false );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + resourcePath ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + resourcePath );
WebResponse response = sc.getResponse( request ); WebResponse response = getServletUnitClient().getResponse( request );
// --- Verification // --- Verification

View File

@ -152,7 +152,7 @@ public class RepositoryServletRepositoryGroupTest
WebRequest request = new GetMethodWebRequest( WebRequest request = new GetMethodWebRequest(
"http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/" + resourceName ); "http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/" + resourceName );
WebResponse response = sc.getResponse( request ); WebResponse response = getServletUnitClient().getResponse( request );
assertResponseOK( response ); assertResponseOK( response );
assertEquals( "Expected file contents", "first", response.getText() ); assertEquals( "Expected file contents", "first", response.getText() );
@ -173,7 +173,7 @@ public class RepositoryServletRepositoryGroupTest
WebRequest request = new GetMethodWebRequest( WebRequest request = new GetMethodWebRequest(
"http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/" + resourceName ); "http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/" + resourceName );
WebResponse response = sc.getResponse( request ); WebResponse response = getServletUnitClient().getResponse( request );
assertResponseOK( response ); assertResponseOK( response );
assertEquals( "Expected file contents", "last", response.getText() ); assertEquals( "Expected file contents", "last", response.getText() );
@ -190,7 +190,7 @@ public class RepositoryServletRepositoryGroupTest
WebRequest request = new GetMethodWebRequest( WebRequest request = new GetMethodWebRequest(
"http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/" + resourceName ); "http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/" + resourceName );
WebResponse response = sc.getResponse( request ); WebResponse response = getServletUnitClient().getResponse( request );
assertResponseNotFound( response ); assertResponseNotFound( response );
} }
@ -206,7 +206,7 @@ public class RepositoryServletRepositoryGroupTest
WebRequest request = new GetMethodWebRequest( WebRequest request = new GetMethodWebRequest(
"http://machine.com/repository/" + REPO_GROUP_WITH_INVALID_REPOS + "/" + resourceName ); "http://machine.com/repository/" + REPO_GROUP_WITH_INVALID_REPOS + "/" + resourceName );
WebResponse response = sc.getResponse( request ); WebResponse response = getServletUnitClient().getResponse( request );
assertResponseInternalServerError( response ); assertResponseInternalServerError( response );
} }
@ -223,7 +223,7 @@ public class RepositoryServletRepositoryGroupTest
InputStream is = getClass().getResourceAsStream( "/artifact.jar" ); InputStream is = getClass().getResourceAsStream( "/artifact.jar" );
WebRequest request = new PutMethodWebRequest( putUrl, is, "text/plain" ); WebRequest request = new PutMethodWebRequest( putUrl, is, "text/plain" );
WebResponse response = sc.getResponse( request ); WebResponse response = getServletUnitClient().getResponse( request );
assertResponseMethodNotAllowed( response ); assertResponseMethodNotAllowed( response );
} }
@ -257,7 +257,7 @@ public class RepositoryServletRepositoryGroupTest
WebRequest request = new GetMethodWebRequest( WebRequest request = new GetMethodWebRequest(
"http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/dummy/" "http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/dummy/"
+ "dummy-merged-metadata-resource/maven-metadata.xml" ); + "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" ); File returnedMetadata = new File( "target/test-classes/retrievedMetadataFile.xml" );
FileUtils.writeStringToFile( returnedMetadata, response.getText() ); FileUtils.writeStringToFile( returnedMetadata, response.getText() );
@ -282,7 +282,7 @@ public class RepositoryServletRepositoryGroupTest
// request the sha1 checksum of the metadata // request the sha1 checksum of the metadata
request = new GetMethodWebRequest( "http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/dummy/" request = new GetMethodWebRequest( "http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/dummy/"
+ "dummy-merged-metadata-resource/maven-metadata.xml.sha1" ); + "dummy-merged-metadata-resource/maven-metadata.xml.sha1" );
response = sc.getResource( request ); response = getServletUnitClient().getResource( request );
assertResponseOK( response ); assertResponseOK( response );
assertEquals( "add113b0d7f8c6adb92a5015a7a3701081edf998 maven-metadata-group-with-valid-repos.xml", assertEquals( "add113b0d7f8c6adb92a5015a7a3701081edf998 maven-metadata-group-with-valid-repos.xml",
@ -291,7 +291,7 @@ public class RepositoryServletRepositoryGroupTest
// request the md5 checksum of the metadata // request the md5 checksum of the metadata
request = new GetMethodWebRequest( "http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/dummy/" request = new GetMethodWebRequest( "http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/dummy/"
+ "dummy-merged-metadata-resource/maven-metadata.xml.md5" ); + "dummy-merged-metadata-resource/maven-metadata.xml.md5" );
response = sc.getResource( request ); response = getServletUnitClient().getResource( request );
assertResponseOK( response ); assertResponseOK( response );
assertEquals( "5b85ea4aa5f52bb76760041a52f98de8 maven-metadata-group-with-valid-repos.xml", assertEquals( "5b85ea4aa5f52bb76760041a52f98de8 maven-metadata-group-with-valid-repos.xml",
@ -317,7 +317,7 @@ public class RepositoryServletRepositoryGroupTest
WebRequest request = new GetMethodWebRequest( WebRequest request = new GetMethodWebRequest(
"http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/dummy/dummy-artifact/" ); "http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/dummy/dummy-artifact/" );
WebResponse response = sc.getResource( request ); WebResponse response = getServletUnitClient().getResource( request );
assertResponseOK( response ); assertResponseOK( response );
assertTrue( StringUtils.contains( response.getText(), "Collection" ) ); assertTrue( StringUtils.contains( response.getText(), "Collection" ) );

View File

@ -48,7 +48,7 @@ public class RepositoryServletTest
public void testGetRepository() public void testGetRepository()
throws Exception throws Exception
{ {
RepositoryServlet servlet = (RepositoryServlet) sc.newInvocation( REQUEST_PATH ).getServlet(); RepositoryServlet servlet = (RepositoryServlet) getServletUnitClient().newInvocation( REQUEST_PATH ).getServlet();
assertNotNull( servlet ); assertNotNull( servlet );
assertRepositoryValid( servlet, REPOID_INTERNAL ); assertRepositoryValid( servlet, REPOID_INTERNAL );
@ -58,7 +58,7 @@ public class RepositoryServletTest
public void testGetRepositoryAfterDelete() public void testGetRepositoryAfterDelete()
throws Exception throws Exception
{ {
RepositoryServlet servlet = (RepositoryServlet) sc.newInvocation( REQUEST_PATH ).getServlet(); RepositoryServlet servlet = (RepositoryServlet) getServletUnitClient().newInvocation( REQUEST_PATH ).getServlet();
assertNotNull( servlet ); assertNotNull( servlet );
ArchivaConfiguration archivaConfiguration = servlet.getConfiguration(); ArchivaConfiguration archivaConfiguration = servlet.getConfiguration();
@ -74,7 +74,7 @@ public class RepositoryServletTest
public void testGetRepositoryAfterAdd() public void testGetRepositoryAfterAdd()
throws Exception throws Exception
{ {
RepositoryServlet servlet = (RepositoryServlet) sc.newInvocation( REQUEST_PATH ).getServlet(); RepositoryServlet servlet = (RepositoryServlet) getServletUnitClient().newInvocation( REQUEST_PATH ).getServlet();
assertNotNull( servlet ); assertNotNull( servlet );
ArchivaConfiguration archivaConfiguration = servlet.getConfiguration(); ArchivaConfiguration archivaConfiguration = servlet.getConfiguration();
@ -108,7 +108,7 @@ public class RepositoryServletTest
populateRepo( repoRootInternal, ".index/filecontent/segments.gen", "index file" ); populateRepo( repoRootInternal, ".index/filecontent/segments.gen", "index file" );
WebRequest request = new GetMethodWebRequest( path ); WebRequest request = new GetMethodWebRequest( path );
WebResponse response = sc.getResponse( request ); WebResponse response = getServletUnitClient().getResponse( request );
assertResponseOK( response ); assertResponseOK( response );
assertEquals( "index file", response.getText() ); assertEquals( "index file", response.getText() );
} }
@ -120,7 +120,7 @@ public class RepositoryServletTest
String path = REQUEST_PATH + ".index/filecontent/foo.bar"; String path = REQUEST_PATH + ".index/filecontent/foo.bar";
WebRequest request = new GetMethodWebRequest( path ); WebRequest request = new GetMethodWebRequest( path );
WebResponse response = sc.getResponse( request ); WebResponse response = getServletUnitClient().getResponse( request );
assertResponseNotFound( response ); 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() ); assertEquals( "Invalid path to Artifact: legacy paths should have an expected type ending in [s] in the second part of the path.", response.getResponseMessage() );
} }