Search in sources :

Example 1 with MavenRepositoryRequestInfo

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());
    }
}
Also used : MavenRepositoryRequestInfo(org.apache.archiva.maven.repository.content.MavenRepositoryRequestInfo) DavException(org.apache.jackrabbit.webdav.DavException) ManagedRepositoryContent(org.apache.archiva.repository.ManagedRepositoryContent) DavResourceLocator(org.apache.jackrabbit.webdav.DavResourceLocator) Test(org.junit.Test)

Aggregations

MavenRepositoryRequestInfo (org.apache.archiva.maven.repository.content.MavenRepositoryRequestInfo)1 ManagedRepositoryContent (org.apache.archiva.repository.ManagedRepositoryContent)1 DavException (org.apache.jackrabbit.webdav.DavException)1 DavResourceLocator (org.apache.jackrabbit.webdav.DavResourceLocator)1 Test (org.junit.Test)1