use of org.apache.archiva.maven.repository.content.MavenRepositoryRequestInfo in project archiva by apache.
the class ArchivaDavResourceFactoryTest method testRequestArtifactMetadataThreePartsRepoHasDefaultLayout.
// MRM-1239
@Test
public void testRequestArtifactMetadataThreePartsRepoHasDefaultLayout() throws Exception {
// should fetch metadata
DavResourceLocator locator = new ArchivaDavResourceLocator("", "/repository/" + INTERNAL_REPO + "/eclipse/jdtcore/maven-metadata.xml", INTERNAL_REPO, new ArchivaDavLocatorFactory());
ManagedRepositoryContent internalRepo = createManagedRepositoryContent(INTERNAL_REPO);
// use actual object (this performs the isMetadata, isDefault and isSupportFile check!)
MavenRepositoryRequestInfo repoRequest = new MavenRepositoryRequestInfo(internalRepo.getRepository());
try {
reset(request);
when(request.getMethod()).thenReturn("GET");
when(request.getRemoteAddr()).thenReturn("http://localhost:8080");
when(request.getContextPath()).thenReturn("");
when(request.getDavSession()).thenReturn(new ArchivaDavSession());
when(request.getRequestURI()).thenReturn("http://localhost:8080/archiva/repository/" + INTERNAL_REPO + "/eclipse/jdtcore/maven-metadata.xml");
response.setHeader("Pragma", "no-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader(eq("Last-Modified"), anyLong());
resourceFactory.createResource(locator, request, response);
verify(request, times(4)).getMethod();
verify(request, times(3)).getRemoteAddr();
verify(request, times(1)).getContextPath();
verify(request, times(2)).getDavSession();
} catch (DavException e) {
e.printStackTrace();
fail("A DavException should not have been thrown! " + e.getMessage());
}
}
Aggregations