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.");
}
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);
}
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());
}
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);
}
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);
}
Aggregations