use of com.gargoylesoftware.htmlunit.WebRequest in project archiva by apache.
the class RepositoryServletNoProxyTest method testGetNoProxyTimestampedSnapshotArtifactLegacyLayoutManagedLegacy.
@Test
public void testGetNoProxyTimestampedSnapshotArtifactLegacyLayoutManagedLegacy() throws Exception {
String commonsLangJar = "commons-lang/jars/commons-lang-2.1-20050821.023400-1.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);
}
use of com.gargoylesoftware.htmlunit.WebRequest in project archiva by apache.
the class RepositoryServletNoProxyTest method testGetNoProxyDualExtensionDefaultLayoutManagedLegacy.
/**
* [MRM-481] Artifact requests with a .xml.zip extension fail with a 404 Error
*/
@Test
public void testGetNoProxyDualExtensionDefaultLayoutManagedLegacy() 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 = repoRootLegacy.resolve("org.project/distributions/example-presentation-3.2.xml.zip");
Files.createDirectories(checksumFile.getParent());
org.apache.archiva.common.utils.FileUtils.writeStringToFile(checksumFile, Charset.defaultCharset(), expectedContents);
WebRequest request = new GetMethodWebRequest("http://machine.com/repository/legacy/" + dualExtensionPath);
WebResponse response = getServletUnitClient().getResponse(request);
assertResponseNotFound(response);
}
use of com.gargoylesoftware.htmlunit.WebRequest in project archiva by apache.
the class RepositoryServletNoProxyTest method testGetNoProxyDistributionLegacyLayoutManagedLegacy.
@Test
public void testGetNoProxyDistributionLegacyLayoutManagedLegacy() throws Exception {
String expectedContents = "the-contents-of-the-dual-extension";
String dualExtensionPath = "org.project/distributions/example-presentation-3.2.zip";
Path checksumFile = repoRootLegacy.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/legacy/" + dualExtensionPath);
WebResponse response = getServletUnitClient().getResponse(request);
assertResponseNotFound(response);
}
use of com.gargoylesoftware.htmlunit.WebRequest in project archiva by apache.
the class RepositoryServletNoProxyTest method testGetNoProxyArtifactDefaultLayoutManagedLegacy.
@Test
public void testGetNoProxyArtifactDefaultLayoutManagedLegacy() throws Exception {
String commonsLangJar = "commons-lang/commons-lang/2.1/commons-lang-2.1.jar";
String expectedArtifactContents = "dummy-commons-lang-artifact";
Path artifactFile = repoRootLegacy.resolve("commons-lang/jars/commons-lang-2.1.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);
}
use of com.gargoylesoftware.htmlunit.WebRequest in project archiva by apache.
the class RepositoryServletProxiedPassthroughTest method assertGetProxiedResource.
private void assertGetProxiedResource(int expectation, boolean hasManagedCopy, long deltaManagedToRemoteTimestamp, String path, String contents) throws Exception {
// --- Setup
setupCentralRemoteRepo();
setupCleanInternalRepo();
String expectedRemoteContents = contents;
String expectedManagedContents = null;
Path remoteFile = populateRepo(remoteCentral, path, expectedRemoteContents);
if (hasManagedCopy) {
expectedManagedContents = contents;
Path managedFile = populateRepo(repoRootInternal, path, expectedManagedContents);
Files.setLastModifiedTime(managedFile, FileTime.fromMillis(Files.getLastModifiedTime(remoteFile).toMillis() + deltaManagedToRemoteTimestamp));
}
setupConnector(REPOID_INTERNAL, remoteCentral);
saveConfiguration();
// --- Execution
// process the response code later, not via an exception.
// HttpUnitOptions.setExceptionsThrownOnErrorStatus( false );
WebRequest request = new GetMethodWebRequest("http://machine.com/repository/internal/" + path);
WebResponse response = getServletUnitClient().getResponse(request);
switch(expectation) {
case EXPECT_MANAGED_CONTENTS:
assertResponseOK(response);
assertTrue("Invalid Test Case: Can't expect managed contents with " + "test that doesn't have a managed copy in the first place.", hasManagedCopy);
assertEquals("Expected managed file contents", expectedManagedContents, response.getContentAsString());
break;
case EXPECT_REMOTE_CONTENTS:
assertResponseOK(response, path);
assertEquals("Expected remote file contents", expectedRemoteContents, response.getContentAsString());
break;
case EXPECT_NOT_FOUND:
assertResponseNotFound(response);
assertManagedFileNotExists(repoRootInternal, path);
break;
}
}
Aggregations