Search in sources :

Example 51 with WebRequest

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

the class RepositoryServletNoProxyTest method testGetNoProxyProjectMetadataDefaultLayoutManagedLegacy.

@Test
public void testGetNoProxyProjectMetadataDefaultLayoutManagedLegacy() throws Exception {
    // TODO: find out what it is meant to be from maven-artifact
    String commonsLangMetadata = "commons-lang/commons-lang/maven-metadata.xml";
    String expectedMetadataContents = "dummy-project-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)

Example 52 with WebRequest

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

the class RepositoryServletNoProxyTest method testGetNoProxySnapshotArtifactLegacyLayoutManagedLegacy.

@Test
public void testGetNoProxySnapshotArtifactLegacyLayoutManagedLegacy() throws Exception {
    String commonsLangJar = "commons-lang/jars/commons-lang-2.1-SNAPSHOT.jar";
    String expectedArtifactContents = "dummy-commons-lang-snapshot-artifact";
    Path artifactFile = repoRootLegacy.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/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)

Example 53 with WebRequest

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

the class RepositoryServletNoProxyTest method testGetNoProxyArtifactLegacyLayoutManagedLegacy.

@Test
public void testGetNoProxyArtifactLegacyLayoutManagedLegacy() throws Exception {
    String commonsLangJar = "commons-lang/jars/commons-lang-2.1.jar";
    String expectedArtifactContents = "dummy-commons-lang-artifact";
    Path artifactFile = repoRootLegacy.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/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)

Example 54 with WebRequest

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

the class RepositoryServletNoProxyTest method testGetNoProxyChecksumLegacyLayoutManagedLegacy.

@Test
public void testGetNoProxyChecksumLegacyLayoutManagedLegacy() throws Exception {
    String commonsLangSha1 = "commons-lang/jars/commons-lang-2.1.jar.sha1";
    Path checksumFile = repoRootLegacy.resolve(commonsLangSha1);
    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 55 with WebRequest

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

the class RepositoryServletNoProxyTest method testGetNoProxySnapshotRedirectToTimestampedSnapshot.

@Test
public void testGetNoProxySnapshotRedirectToTimestampedSnapshot() throws Exception {
    String commonsLangQuery = "commons-lang/commons-lang/2.1-SNAPSHOT/commons-lang-2.1-SNAPSHOT.jar";
    String commonsLangMetadata = "commons-lang/commons-lang/2.1-SNAPSHOT/maven-metadata.xml";
    String commonsLangJar = "commons-lang/commons-lang/2.1-SNAPSHOT/commons-lang-2.1-20050821.023400-1.jar";
    String expectedArtifactContents = "dummy-commons-lang-snapshot-artifact";
    archivaConfiguration.getConfiguration().getWebapp().getUi().setApplicationUrl("http://localhost");
    Path artifactFile = repoRootInternal.resolve(commonsLangJar);
    Files.createDirectories(artifactFile.getParent());
    org.apache.archiva.common.utils.FileUtils.writeStringToFile(artifactFile, Charset.defaultCharset(), expectedArtifactContents);
    Path metadataFile = repoRootInternal.resolve(commonsLangMetadata);
    Files.createDirectories(metadataFile.getParent());
    org.apache.archiva.common.utils.FileUtils.writeStringToFile(metadataFile, Charset.defaultCharset(), createVersionMetadata("commons-lang", "commons-lang", "2.1-SNAPSHOT", "20050821.023400", "1", "20050821.023400"));
    WebRequest webRequest = new GetMethodWebRequest("http://localhost/repository/internal/" + commonsLangQuery);
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setRequestURI(webRequest.getUrl().getPath());
    request.addHeader("User-Agent", "Apache Archiva unit test");
    request.setMethod(webRequest.getHttpMethod().name());
    final MockHttpServletResponse response = execute(request);
    assertEquals(HttpServletResponse.SC_MOVED_TEMPORARILY, response.getStatus());
    assertEquals("http://localhost/repository/internal/" + commonsLangJar, response.getHeader("Location"));
}
Also used : Path(java.nio.file.Path) WebRequest(com.gargoylesoftware.htmlunit.WebRequest) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) 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