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 );
|| 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 ) );
}
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() );
}
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 )
{