use of com.gargoylesoftware.htmlunit.WebRequest in project archiva by apache.
the class RepositoryServletDeployTest method testMkColWithMissingParentCollectionFails.
@Test
public void testMkColWithMissingParentCollectionFails() throws Exception {
setupCleanRepo(repoRootInternal);
String putUrl = "http://machine.com/repository/internal/path/to/";
WebRequest request = new MkColMethodWebRequest(putUrl);
WebResponse response = getServletUnitClient().getResponse(request);
assertEquals(HttpServletResponse.SC_CONFLICT, response.getStatusCode());
Path mkColLocalPath = repoRootInternal.resolve("path/to/");
assertFalse(Files.exists(mkColLocalPath));
}
use of com.gargoylesoftware.htmlunit.WebRequest in project archiva by apache.
the class RepositoryServletDeployTest method testReleaseArtifactsRedeploymentArtifactIsSnapshot.
@Test
public void testReleaseArtifactsRedeploymentArtifactIsSnapshot() throws Exception {
setupCleanRepo(repoRootInternal);
String putUrl = "http://machine.com/repository/internal/path/to/artifact/1.0-SNAPSHOT/artifact-1.0-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/1.0-SNAPSHOT/artifact-1.0-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);
}
use of com.gargoylesoftware.htmlunit.WebRequest in project archiva by apache.
the class RepositoryServletDeployTest method testReleaseArtifactsRedeploymentInvalidPath.
@Test
public void testReleaseArtifactsRedeploymentInvalidPath() throws Exception {
setupCleanRepo(repoRootInternal);
String putUrl = "http://machine.com/repository/internal/artifact.jar";
String metadataUrl = "http://machine.com/repository/internal/maven-metadata.xml";
String checksumUrl = "http://machine.com/repository/internal/artifact.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);
}
use of com.gargoylesoftware.htmlunit.WebRequest in project archiva by apache.
the class RepositoryServletDeployTest method testReleaseArtifactsRedeploymentValidPath.
/**
* MRM-747
* test whether trying to overwrite existing relase-artifact is blocked by returning HTTP-code 409
*
* @throws Exception
*/
@Test
public void testReleaseArtifactsRedeploymentValidPath() throws Exception {
setupCleanRepo(repoRootInternal);
String putUrl = "http://machine.com/repository/internal" + ARTIFACT_DEFAULT_LAYOUT;
String metadataUrl = "http://machine.com/repository/internal/path/to/artifact/maven-metadata.xml";
String checksumUrl = "http://machine.com/repository/internal" + ARTIFACT_DEFAULT_LAYOUT + ".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 blocked
is = getClass().getResourceAsStream("/artifact.jar");
request = new PutMethodWebRequest(putUrl, is, "application/octet-stream");
response = getServletUnitClient().getResponse(request);
assertResponseConflictError(response);
}
use of com.gargoylesoftware.htmlunit.WebRequest in project archiva by apache.
the class RepositoryServletNoProxyMetadataTest method testGetSnapshotVersionMetadataDefaultLayout.
@Test
public void testGetSnapshotVersionMetadataDefaultLayout() throws Exception {
String assemblyPluginMetadata = "org/apache/maven/plugins/maven-assembly-plugin/2.2-beta-2-SNAPSHOT/maven-metadata.xml";
String expectedMetadataContents = "metadata-for-assembly-plugin-version-2.2-beta-2-SNAPSHOT";
Path checksumFile = repoRootInternal.resolve(assemblyPluginMetadata);
Files.createDirectories(checksumFile.getParent());
org.apache.archiva.common.utils.FileUtils.writeStringToFile(checksumFile, Charset.defaultCharset(), expectedMetadataContents);
WebRequest request = new GetMethodWebRequest("http://machine.com/repository/internal/" + assemblyPluginMetadata);
WebResponse response = getServletUnitClient().getResponse(request);
assertResponseOK(response);
assertEquals("Expected file contents", expectedMetadataContents, response.getContentAsString());
}
Aggregations