Search in sources :

Example 1 with ManagedRepositoryContent

use of org.apache.archiva.repository.ManagedRepositoryContent in project archiva by apache.

the class RepositoryRequestTest method testNativePathBadRequestTooShort.

@Test
public void testNativePathBadRequestTooShort() throws Exception {
    ManagedRepositoryContent repository = createManagedRepo("default");
    // Test bad request path (too short)
    try {
        repoRequest.toNativePath("org.apache.derby/license.txt", repository);
        fail("Should have thrown an exception about a too short path.");
    } catch (LayoutException e) {
    // expected path.
    }
}
Also used : LayoutException(org.apache.archiva.repository.LayoutException) ManagedRepositoryContent(org.apache.archiva.repository.ManagedRepositoryContent) Test(org.junit.Test)

Example 2 with ManagedRepositoryContent

use of org.apache.archiva.repository.ManagedRepositoryContent in project archiva by apache.

the class RepositoryRequestTest method createManagedRepositoryContent.

protected ManagedRepositoryContent createManagedRepositoryContent(String id, String name, Path location, String layout) throws Exception {
    MavenManagedRepository repo = new MavenManagedRepository(id, name, archivaConfiguration.getRepositoryBaseDir());
    repo.setLocation(location.toAbsolutePath().toUri());
    repo.setLayout(layout);
    RepositoryContentProvider provider = applicationContext.getBean("repositoryContentProvider#maven", RepositoryContentProvider.class);
    ManagedRepositoryContent repoContent = provider.createManagedContent(repo);
    return repoContent;
}
Also used : RepositoryContentProvider(org.apache.archiva.repository.RepositoryContentProvider) MavenManagedRepository(org.apache.archiva.repository.maven2.MavenManagedRepository) ManagedRepositoryContent(org.apache.archiva.repository.ManagedRepositoryContent)

Example 3 with ManagedRepositoryContent

use of org.apache.archiva.repository.ManagedRepositoryContent in project archiva by apache.

the class RepositoryRequestTest method testNativePathBadRequestBlank.

@Test
public void testNativePathBadRequestBlank() throws Exception {
    ManagedRepositoryContent repository = createManagedRepo("default");
    // Test bad request path (too short)
    try {
        repoRequest.toNativePath("", repository);
        fail("Should have thrown an exception about an blank request.");
    } catch (LayoutException e) {
    // expected path.
    }
}
Also used : LayoutException(org.apache.archiva.repository.LayoutException) ManagedRepositoryContent(org.apache.archiva.repository.ManagedRepositoryContent) Test(org.junit.Test)

Example 4 with ManagedRepositoryContent

use of org.apache.archiva.repository.ManagedRepositoryContent in project archiva by apache.

the class RepositoryRequestTest method testNativePathBadRequestUnknownType.

@Test
public void testNativePathBadRequestUnknownType() throws Exception {
    ManagedRepositoryContent repository = createManagedRepo("default");
    // Test bad request path (too short)
    try {
        repoRequest.toNativePath("org/apache/derby/derby/10.2.2.0/license.txt", repository);
        fail("Should have thrown an exception about an invalid type.");
    } catch (LayoutException e) {
    // expected path.
    }
}
Also used : LayoutException(org.apache.archiva.repository.LayoutException) ManagedRepositoryContent(org.apache.archiva.repository.ManagedRepositoryContent) Test(org.junit.Test)

Example 5 with ManagedRepositoryContent

use of org.apache.archiva.repository.ManagedRepositoryContent in project archiva by apache.

the class MetadataToolsTest method createTestRepoContent.

private ManagedRepositoryContent createTestRepoContent() throws Exception {
    Path repoRoot = Paths.get("target/metadata-tests/" + name.getMethodName());
    if (Files.exists(repoRoot)) {
        org.apache.archiva.common.utils.FileUtils.deleteDirectory(repoRoot);
    }
    Files.createDirectories(repoRoot);
    MavenManagedRepository repoConfig = createRepository("test-repo", "Test Repository: " + name.getMethodName(), repoRoot);
    RepositoryContentProvider provider = applicationContext.getBean("repositoryContentProvider#maven", RepositoryContentProvider.class);
    ManagedRepositoryContent repoContent = provider.createManagedContent(repoConfig);
    return repoContent;
}
Also used : Path(java.nio.file.Path) RepositoryContentProvider(org.apache.archiva.repository.RepositoryContentProvider) MavenManagedRepository(org.apache.archiva.repository.maven2.MavenManagedRepository) ManagedRepositoryContent(org.apache.archiva.repository.ManagedRepositoryContent)

Aggregations

ManagedRepositoryContent (org.apache.archiva.repository.ManagedRepositoryContent)41 Path (java.nio.file.Path)16 Test (org.junit.Test)13 RepositoryException (org.apache.archiva.repository.RepositoryException)12 ArchivaRestServiceException (org.apache.archiva.rest.api.services.ArchivaRestServiceException)11 DavException (org.apache.jackrabbit.webdav.DavException)10 ArrayList (java.util.ArrayList)9 MetadataRepositoryException (org.apache.archiva.metadata.repository.MetadataRepositoryException)9 IOException (java.io.IOException)8 ArtifactReference (org.apache.archiva.model.ArtifactReference)8 VersionedReference (org.apache.archiva.model.VersionedReference)7 RepositoryAdminException (org.apache.archiva.admin.model.RepositoryAdminException)6 LayoutException (org.apache.archiva.repository.LayoutException)6 RepositoryContentProvider (org.apache.archiva.repository.RepositoryContentProvider)6 DavResourceLocator (org.apache.jackrabbit.webdav.DavResourceLocator)6 ManagedRepository (org.apache.archiva.admin.model.beans.ManagedRepository)5 MetadataRepository (org.apache.archiva.metadata.repository.MetadataRepository)5 ArchivaRepositoryMetadata (org.apache.archiva.model.ArchivaRepositoryMetadata)5 ManagedRepository (org.apache.archiva.repository.ManagedRepository)5 MavenManagedRepository (org.apache.archiva.repository.maven2.MavenManagedRepository)5