Search in sources :

Example 11 with WebRequest

use of com.gargoylesoftware.htmlunit.WebRequest in project archiva by apache.

the class RepositoryServletDeployTest method testPutWithMissingParentCollection.

@Test
public void testPutWithMissingParentCollection() throws Exception {
    setupCleanRepo(repoRootInternal);
    String putUrl = "http://machine.com/repository/internal" + ARTIFACT_DEFAULT_LAYOUT;
    InputStream is = getClass().getResourceAsStream("/artifact.jar");
    // verify that the file exists in resources-dir
    assertNotNull("artifact.jar inputstream", is);
    WebRequest request = new PutMethodWebRequest(putUrl, is, "application/octet-stream");
    WebResponse response = getServletUnitClient().getResponse(request);
    assertResponseCreated(response);
    assertFileContents("artifact.jar\n", repoRootInternal, ARTIFACT_DEFAULT_LAYOUT);
}
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 12 with WebRequest

use of com.gargoylesoftware.htmlunit.WebRequest in project archiva by apache.

the class RepositoryServletNoProxyMetadataTest method testGetGroupMetadataDefaultLayout.

@Test
public void testGetGroupMetadataDefaultLayout() throws Exception {
    String commonsLangMetadata = "commons-lang/maven-metadata.xml";
    String expectedMetadataContents = "metadata-for-commons-lang-group";
    Path checksumFile = repoRootInternal.resolve(commonsLangMetadata);
    Files.createDirectories(checksumFile.getParent());
    org.apache.archiva.common.utils.FileUtils.writeStringToFile(checksumFile, Charset.defaultCharset(), expectedMetadataContents);
    WebRequest request = new GetMethodWebRequest("http://machine.com/repository/internal/" + commonsLangMetadata);
    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)

Example 13 with WebRequest

use of com.gargoylesoftware.htmlunit.WebRequest in project archiva by apache.

the class RepositoryServletNoProxyMetadataTest method testGetProjectMetadataDefaultLayout.

@Test
public void testGetProjectMetadataDefaultLayout() throws Exception {
    String commonsLangMetadata = "commons-lang/commons-lang/maven-metadata.xml";
    String expectedMetadataContents = "metadata-for-commons-lang-version-for-project";
    Path checksumFile = repoRootInternal.resolve(commonsLangMetadata);
    Files.createDirectories(checksumFile.getParent());
    org.apache.archiva.common.utils.FileUtils.writeStringToFile(checksumFile, Charset.defaultCharset(), expectedMetadataContents);
    WebRequest request = new GetMethodWebRequest("http://machine.com/repository/internal/" + commonsLangMetadata);
    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)

Example 14 with WebRequest

use of com.gargoylesoftware.htmlunit.WebRequest in project archiva by apache.

the class RepositoryServletNoProxyTest method testGetNoProxyVersionedMetadataDefaultLayoutManagedLegacy.

@Test
public void testGetNoProxyVersionedMetadataDefaultLayoutManagedLegacy() throws Exception {
    String commonsLangMetadata = "commons-lang/commons-lang/2.1/maven-metadata.xml";
    String expectedMetadataContents = "dummy-versioned-metadata";
    // TODO: find out what this should be from maven-artifact
    Path metadataFile = repoRootLegacy.resolve(commonsLangMetadata);
    Files.createDirectories(metadataFile.getParent());
    org.apache.archiva.common.utils.FileUtils.writeStringToFile(metadataFile, Charset.defaultCharset(), expectedMetadataContents);
    WebRequest request = new GetMethodWebRequest("http://machine.com/repository/legacy/" + commonsLangMetadata);
    WebResponse response = getServletUnitClient().getResponse(request);
    assertResponseNotFound(response);
}
Also used : Path(java.nio.file.Path) WebResponse(com.gargoylesoftware.htmlunit.WebResponse) WebRequest(com.gargoylesoftware.htmlunit.WebRequest) Test(org.junit.Test)

Example 15 with WebRequest

use of com.gargoylesoftware.htmlunit.WebRequest in project archiva by apache.

the class RepositoryServletNoProxyTest method testGetNoProxyGroupMetadataDefaultLayoutManagedLegacy.

@Test
public void testGetNoProxyGroupMetadataDefaultLayoutManagedLegacy() throws Exception {
    String commonsLangMetadata = "commons-lang/maven-metadata.xml";
    String expectedMetadataContents = "dummy-group-metadata";
    Path metadataFile = repoRootLegacy.resolve(commonsLangMetadata);
    Files.createDirectories(metadataFile.getParent());
    org.apache.archiva.common.utils.FileUtils.writeStringToFile(metadataFile, Charset.defaultCharset(), expectedMetadataContents);
    WebRequest request = new GetMethodWebRequest("http://machine.com/repository/legacy/" + commonsLangMetadata);
    WebResponse response = getServletUnitClient().getResponse(request);
    assertResponseNotFound(response);
}
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