Search in sources :

Example 6 with WebRequest

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

the class RepositoryServletTest method testGetRepositoryInvalidPathPassthroughMissing.

@Test
public void testGetRepositoryInvalidPathPassthroughMissing() throws Exception {
    String path = REQUEST_PATH + ".index/filecontent/foo.bar";
    WebRequest request = new GetMethodWebRequest(path);
    WebResponse response = getServletUnitClient().getResponse(request);
    assertResponseNotFound(response);
    // 
    assertThat(response.getContentAsString()).contains("Legacy Maven1 repository not supported anymore.");
}
Also used : WebResponse(com.gargoylesoftware.htmlunit.WebResponse) WebRequest(com.gargoylesoftware.htmlunit.WebRequest) Test(org.junit.Test)

Example 7 with WebRequest

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

the class RepositoryServletBrowseTest method testBrowse.

@Test
public void testBrowse() throws Exception {
    WebRequest request = new GetMethodWebRequest("http://machine.com/repository/internal/");
    WebResponse response = getServletUnitClient().getResponse(request);
    assertEquals("Response", HttpServletResponse.SC_OK, response.getStatusCode());
    // dumpResponse( response );
    List<String> expectedLinks = Arrays.asList("commons-lang/", "net/", "org/");
    Document document = Jsoup.parse(response.getContentAsString());
    Elements elements = document.getElementsByTag("a");
    assertLinks(expectedLinks, elements);
}
Also used : WebResponse(com.gargoylesoftware.htmlunit.WebResponse) WebRequest(com.gargoylesoftware.htmlunit.WebRequest) Document(org.jsoup.nodes.Document) Elements(org.jsoup.select.Elements) Test(org.junit.Test)

Example 8 with WebRequest

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

the class RepositoryServletBrowseTest method testGetDirectoryWhichHasMatchingFile.

@Test
public // MRM-893
void testGetDirectoryWhichHasMatchingFile() throws Exception {
    Files.createDirectories(repoRootInternal.resolve("org/apache/archiva/artifactId/1.0"));
    Files.createFile(repoRootInternal.resolve("org/apache/archiva/artifactId/1.0/artifactId-1.0.jar"));
    WebRequest request = new GetMethodWebRequest("http://machine.com/repository/internal/org/apache/archiva/artifactId");
    WebResponse response = getServletUnitClient().getResponse(request, true);
    assertEquals("1st Response", HttpServletResponse.SC_OK, response.getStatusCode());
    request = new GetMethodWebRequest("http://machine.com/repository/internal/org/apache/archiva/artifactId/");
    response = getServletUnitClient().getResponse(request);
    assertEquals("2nd Response", HttpServletResponse.SC_OK, response.getStatusCode());
    request = new GetMethodWebRequest("http://machine.com/repository/internal/org/apache/archiva/artifactId/1.0/artifactId-1.0.jar");
    response = getServletUnitClient().getResponse(request);
    assertEquals("3rd Response", HttpServletResponse.SC_OK, response.getStatusCode());
    request = new GetMethodWebRequest("http://machine.com/repository/internal/org/apache/archiva/artifactId/1.0/artifactId-1.0.jar/");
    response = getServletUnitClient().getResponse(request);
    assertEquals("4th Response", HttpServletResponse.SC_NOT_FOUND, response.getStatusCode());
}
Also used : WebResponse(com.gargoylesoftware.htmlunit.WebResponse) WebRequest(com.gargoylesoftware.htmlunit.WebRequest) Test(org.junit.Test)

Example 9 with WebRequest

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

the class RepositoryServletDeployTest method testReleaseArtifactsRedeploymentIsAllowed.

@Test
public void testReleaseArtifactsRedeploymentIsAllowed() throws Exception {
    setupCleanRepo(repoRootInternal);
    ManagedRepositoryConfiguration managedRepo = archivaConfiguration.getConfiguration().findManagedRepositoryById(REPOID_INTERNAL);
    managedRepo.setBlockRedeployments(false);
    saveConfiguration(archivaConfiguration);
    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 if it's still successful
    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) ManagedRepositoryConfiguration(org.apache.archiva.configuration.ManagedRepositoryConfiguration) WebRequest(com.gargoylesoftware.htmlunit.WebRequest) MkColMethodWebRequest(org.apache.archiva.webdav.httpunit.MkColMethodWebRequest) InputStream(java.io.InputStream) Test(org.junit.Test)

Example 10 with WebRequest

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

the class RepositoryServletDeployTest method testArtifactsDeploymentArtifactIsSnapshot.

@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);
}
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)

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