Search in sources :

Example 61 with WebRequest

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));
}
Also used : Path(java.nio.file.Path) MkColMethodWebRequest(org.apache.archiva.webdav.httpunit.MkColMethodWebRequest) WebResponse(com.gargoylesoftware.htmlunit.WebResponse) WebRequest(com.gargoylesoftware.htmlunit.WebRequest) MkColMethodWebRequest(org.apache.archiva.webdav.httpunit.MkColMethodWebRequest) Test(org.junit.Test)

Example 62 with WebRequest

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);
}
Also used : WebResponse(com.gargoylesoftware.htmlunit.WebResponse) WebRequest(com.gargoylesoftware.htmlunit.WebRequest) MkColMethodWebRequest(org.apache.archiva.webdav.httpunit.MkColMethodWebRequest) InputStream(java.io.InputStream) Test(org.junit.Test)

Example 63 with WebRequest

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);
}
Also used : WebResponse(com.gargoylesoftware.htmlunit.WebResponse) WebRequest(com.gargoylesoftware.htmlunit.WebRequest) MkColMethodWebRequest(org.apache.archiva.webdav.httpunit.MkColMethodWebRequest) InputStream(java.io.InputStream) Test(org.junit.Test)

Example 64 with WebRequest

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);
}
Also used : WebResponse(com.gargoylesoftware.htmlunit.WebResponse) WebRequest(com.gargoylesoftware.htmlunit.WebRequest) MkColMethodWebRequest(org.apache.archiva.webdav.httpunit.MkColMethodWebRequest) InputStream(java.io.InputStream) Test(org.junit.Test)

Example 65 with WebRequest

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());
}
Also used : Path(java.nio.file.Path) WebResponse(com.gargoylesoftware.htmlunit.WebResponse) WebRequest(com.gargoylesoftware.htmlunit.WebRequest) Test(org.junit.Test)

Aggregations

WebRequest (com.gargoylesoftware.htmlunit.WebRequest)84 Test (org.junit.Test)65 WebResponse (com.gargoylesoftware.htmlunit.WebResponse)49 URL (java.net.URL)31 Path (java.nio.file.Path)31 FailingHttpStatusCodeException (com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException)12 TextPage (com.gargoylesoftware.htmlunit.TextPage)12 InputStream (java.io.InputStream)7 MkColMethodWebRequest (org.apache.archiva.webdav.httpunit.MkColMethodWebRequest)7 JenkinsRule (org.jvnet.hudson.test.JenkinsRule)7 WebClient (com.gargoylesoftware.htmlunit.WebClient)5 HtmlPage (com.gargoylesoftware.htmlunit.html.HtmlPage)5 IOException (java.io.IOException)5 FreeStyleProject (hudson.model.FreeStyleProject)4 Page (com.gargoylesoftware.htmlunit.Page)3 NameValuePair (com.gargoylesoftware.htmlunit.util.NameValuePair)3 HashMap (java.util.HashMap)3 Issue (org.jvnet.hudson.test.Issue)3 SeleniumOperationException (com.axway.ats.uiengine.exceptions.SeleniumOperationException)2 IncorrectnessListener (com.gargoylesoftware.htmlunit.IncorrectnessListener)2