]> source.dussan.org Git - archiva.git/commitdiff
add unit test for both MRM-935 and MRM-837
authorOlivier Lamy <olamy@apache.org>
Mon, 16 Feb 2015 10:59:08 +0000 (21:59 +1100)
committerOlivier Lamy <olamy@apache.org>
Mon, 16 Feb 2015 10:59:08 +0000 (21:59 +1100)
archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletTestCase.java
archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletDeployTest.java

index a9beb5273984e35618aa8ec829f4a6acb0371853..9b7ae90680b796c3225a5d1e4aa573ba974213aa 100644 (file)
@@ -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() );
     }
 
index 591a39db55b5cced1b988a1037bb144caabebe80..400090d8875721a76fd4e3832470b0ec9c10e48b 100644 (file)
@@ -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 )
     {