Search in sources :

Example 46 with WebRequest

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

the class RepositoryServletRepositoryGroupTest method testGetInvalidManagedRepositoryInGroupReturnNotFound.

/*
    * Test Case 3.a
    */
@Test
public void testGetInvalidManagedRepositoryInGroupReturnNotFound() throws Exception {
    String resourceName = "dummy/dummy-no-resource/1.0/dummy-no-resource-1.0.txt";
    WebRequest request = new GetMethodWebRequest("http://machine.com/repository/" + REPO_GROUP_WITH_INVALID_REPOS + "/" + resourceName);
    WebResponse response = getServletUnitClient().getResponse(request);
    assertResponseInternalServerError(response);
}
Also used : WebResponse(com.gargoylesoftware.htmlunit.WebResponse) WebRequest(com.gargoylesoftware.htmlunit.WebRequest) Test(org.junit.Test)

Example 47 with WebRequest

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

the class RepositoryServletNoProxyTest method testGetNoProxyDualExtensionDefaultLayout.

/**
 * [MRM-481] Artifact requests with a .xml.zip extension fail with a 404 Error
 */
@Test
public void testGetNoProxyDualExtensionDefaultLayout() throws Exception {
    String expectedContents = "the-contents-of-the-dual-extension";
    String dualExtensionPath = "org/project/example-presentation/3.2/example-presentation-3.2.xml.zip";
    Path checksumFile = repoRootInternal.resolve(dualExtensionPath);
    Files.createDirectories(checksumFile.getParent());
    org.apache.archiva.common.utils.FileUtils.writeStringToFile(checksumFile, Charset.defaultCharset(), expectedContents);
    WebRequest request = new GetMethodWebRequest("http://machine.com/repository/internal/" + dualExtensionPath);
    WebResponse response = getServletUnitClient().getResponse(request);
    assertResponseOK(response);
    assertEquals("Expected file contents", expectedContents, response.getContentAsString());
}
Also used : Path(java.nio.file.Path) WebResponse(com.gargoylesoftware.htmlunit.WebResponse) WebRequest(com.gargoylesoftware.htmlunit.WebRequest) Test(org.junit.Test)

Example 48 with WebRequest

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

the class RepositoryServletNoProxyTest method testGetNoProxyChecksumDefaultLayoutManagedLegacy.

@Test
public void testGetNoProxyChecksumDefaultLayoutManagedLegacy() throws Exception {
    String commonsLangSha1 = "commons-lang/commons-lang/2.1/commons-lang-2.1.jar.sha1";
    Path checksumFile = repoRootLegacy.resolve("commons-lang/jars/commons-lang-2.1.jar.sha1");
    Files.createDirectories(checksumFile.getParent());
    org.apache.archiva.common.utils.FileUtils.writeStringToFile(checksumFile, Charset.defaultCharset(), "dummy-checksum");
    WebRequest request = new GetMethodWebRequest("http://machine.com/repository/legacy/" + commonsLangSha1);
    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 49 with WebRequest

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

the class RepositoryServletNoProxyTest method testGetNoProxyTimestampedSnapshotArtifactLegacyLayout.

@Test
public void testGetNoProxyTimestampedSnapshotArtifactLegacyLayout() throws Exception {
    String commonsLangJar = "commons-lang/commons-lang/2.1-SNAPSHOT/commons-lang-2.1-20050821.023400-1.jar";
    String expectedArtifactContents = "dummy-commons-lang-snapshot-artifact";
    Path artifactFile = repoRootInternal.resolve(commonsLangJar);
    Files.createDirectories(artifactFile.getParent());
    org.apache.archiva.common.utils.FileUtils.writeStringToFile(artifactFile, Charset.defaultCharset(), expectedArtifactContents);
    WebRequest request = new GetMethodWebRequest("http://machine.com/repository/internal/" + "commons-lang/jars/commons-lang-2.1-20050821.023400-1.jar");
    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 50 with WebRequest

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

the class RepositoryServletNoProxyTest method testGetNoProxySnapshotArtifactDefaultLayoutManagedLegacy.

@Test
public void testGetNoProxySnapshotArtifactDefaultLayoutManagedLegacy() throws Exception {
    String commonsLangJar = "commons-lang/commons-lang/2.1-SNAPSHOT/commons-lang-2.1-SNAPSHOT.jar";
    String expectedArtifactContents = "dummy-commons-lang-snapshot-artifact";
    Path artifactFile = repoRootLegacy.resolve("commons-lang/jars/commons-lang-2.1-SNAPSHOT.jar");
    Files.createDirectories(artifactFile.getParent());
    org.apache.archiva.common.utils.FileUtils.writeStringToFile(artifactFile, Charset.defaultCharset(), expectedArtifactContents);
    WebRequest request = new GetMethodWebRequest("http://machine.com/repository/legacy/" + commonsLangJar);
    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