aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules/archiva-web
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2015-02-16 21:59:08 +1100
committerOlivier Lamy <olamy@apache.org>2015-02-16 21:59:08 +1100
commit9356efc2b14b75f936970938a35f3ecd7c7f0a71 (patch)
tree49dc4eb78714e01a42ea08ac9b9b272a91ed1c2e /archiva-modules/archiva-web
parent92c5e83cf9f6f100a5fbdc0b377ff6bad61a422e (diff)
downloadarchiva-9356efc2b14b75f936970938a35f3ecd7c7f0a71.tar.gz
archiva-9356efc2b14b75f936970938a35f3ecd7c7f0a71.zip
add unit test for both MRM-935 and MRM-837
Diffstat (limited to 'archiva-modules/archiva-web')
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletTestCase.java8
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletDeployTest.java42
2 files changed, 46 insertions, 4 deletions
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletTestCase.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletTestCase.java
index a9beb5273..9b7ae9068 100644
--- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletTestCase.java
+++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletTestCase.java
@@ -479,7 +479,7 @@ public abstract class AbstractRepositoryServletTestCase
request.setMethod( webRequest.getHttpMethod().name() );
- if (webRequest.getHttpMethod() == HttpMethod.PUT )
+ if ( webRequest.getHttpMethod() == HttpMethod.PUT )
{
PutMethodWebRequest putRequest = PutMethodWebRequest.class.cast( webRequest );
request.setContentType( putRequest.contentType );
@@ -497,7 +497,7 @@ public abstract class AbstractRepositoryServletTestCase
|| response.getStatus() == HttpServletResponse.SC_MOVED_TEMPORARILY )
{
String location = response.getHeader( "Location" );
- log.debug("follow redirect to {}", location);
+ log.debug( "follow redirect to {}", location );
return getWebResponse( new GetMethodWebRequest( location ) );
}
@@ -660,9 +660,9 @@ public abstract class AbstractRepositoryServletTestCase
protected void assertResponseOK( WebResponse response )
{
-
assertNotNull( "Should have recieved a response", response );
- Assert.assertEquals( "Should have been an OK response code", HttpServletResponse.SC_OK,
+ Assert.assertEquals( "Should have been an OK response code", //
+ HttpServletResponse.SC_OK, //
response.getStatusCode() );
}
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletDeployTest.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletDeployTest.java
index 591a39db5..400090d88 100644
--- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletDeployTest.java
+++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletDeployTest.java
@@ -240,6 +240,48 @@ public class RepositoryServletDeployTest
File mkColLocalPath = new File(repoRootInternal, "path/to/");
assertFalse(mkColLocalPath.exists());
}
+
+ @Test
+ public void testArtifactsDeploymentArtifactIsSnapshot()
+ throws Exception
+ {
+ setupCleanRepo( repoRootInternal );
+
+ String putUrl = "http://machine.com/repository/internal/path/to/artifact/SNAPSHOT/artifact-SNAPSHOT.jar";
+ String metadataUrl = "http://machine.com/repository/internal/path/to/artifact/maven-metadata.xml";
+ String checksumUrl = "http://machine.com/repository/internal/path/to/artifact/SNAPSHOT/artifact-SNAPSHOT.jar.sha1";
+
+ InputStream is = getClass().getResourceAsStream( "/artifact.jar" );
+ // verify that the file exists in resources-dir
+ assertNotNull( "artifact.jar inputstream", is );
+
+ // send request #1 and verify it's successful
+ WebRequest request = new PutMethodWebRequest( putUrl, is, "application/octet-stream" );
+ WebResponse response = getServletUnitClient().getResponse( request );
+ assertResponseCreated( response );
+
+ is = getClass().getResourceAsStream( "/artifact.jar.sha1" );
+ request = new PutMethodWebRequest( checksumUrl, is, "application/octet-stream" );
+ response = getServletUnitClient().getResponse( request );
+ assertResponseCreated( response );
+
+ is = getClass().getResourceAsStream( "/maven-metadata.xml" );
+ request = new PutMethodWebRequest( metadataUrl, is, "application/octet-stream" );
+ 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 = getServletUnitClient().getResponse( request );
+ assertResponseNoContent( response );
+
+ request = new GetMethodWebRequest( putUrl );
+ response = getServletUnitClient().getResponse( request );
+ assertResponseOK( response );
+
+
+ }
protected void assertResponseNoContent( WebResponse response )
{