mirror of https://github.com/apache/archiva.git
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:
parent
2b4b9f0c0b
commit
534334dd98
|
@ -198,6 +198,7 @@
|
|||
<plexus.home>${project.build.directory}/appserver-base</plexus.home>
|
||||
<derby.system.home>${project.build.directory}/appserver-base</derby.system.home>
|
||||
<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.driver.name>org.apache.derby.jdbc.EmbeddedDriver</redback.jdbc.driver.name>
|
||||
</systemPropertyVariables>
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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" ) );
|
||||
}
|
||||
|
||||
sr.registerServlet( "/repository/*", UnauthenticatedRepositoryServlet.class.getName() );
|
||||
sc = sr.newClient();
|
||||
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();
|
||||
|
||||
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() )
|
||||
|
|
|
@ -26,9 +26,8 @@ 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
|
||||
|
@ -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,25 +83,28 @@ 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++ )
|
||||
|
|
|
@ -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());
|
||||
|
||||
|
|
|
@ -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() );
|
||||
|
|
|
@ -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() );
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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" ) );
|
||||
|
|
|
@ -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() );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue