Search in sources :

Example 1 with ManagedRepositoryConfiguration

use of org.apache.archiva.configuration.ManagedRepositoryConfiguration in project archiva by apache.

the class RepositoryServletTest method testGetRepositoryAfterAdd.

@Test
public void testGetRepositoryAfterAdd() throws Exception {
    RepositoryServlet servlet = RepositoryServlet.class.cast(findServlet("repository"));
    assertNotNull(servlet);
    ArchivaConfiguration archivaConfiguration = servlet.getConfiguration();
    Configuration c = archivaConfiguration.getConfiguration();
    ManagedRepositoryConfiguration repo = new ManagedRepositoryConfiguration();
    repo.setId(NEW_REPOSITORY_ID);
    repo.setName(NEW_REPOSITORY_NAME);
    Path repoRoot = Paths.get("target/test-repository-root");
    if (!Files.exists(repoRoot)) {
        Files.createDirectories(repoRoot);
    }
    repo.setLocation(repoRoot.toAbsolutePath().toString());
    c.addManagedRepository(repo);
    saveConfiguration(archivaConfiguration);
    ManagedRepository repository = servlet.getRepository(NEW_REPOSITORY_ID);
    assertNotNull(repository);
    assertEquals(NEW_REPOSITORY_NAME, repository.getName());
    // check other is still intact
    assertRepositoryValid(servlet, REPOID_INTERNAL);
}
Also used : Path(java.nio.file.Path) ManagedRepository(org.apache.archiva.admin.model.beans.ManagedRepository) ManagedRepositoryConfiguration(org.apache.archiva.configuration.ManagedRepositoryConfiguration) Configuration(org.apache.archiva.configuration.Configuration) ArchivaConfiguration(org.apache.archiva.configuration.ArchivaConfiguration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.ManagedRepositoryConfiguration) ArchivaConfiguration(org.apache.archiva.configuration.ArchivaConfiguration) Test(org.junit.Test)

Example 2 with ManagedRepositoryConfiguration

use of org.apache.archiva.configuration.ManagedRepositoryConfiguration 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);
}
Also used : WebResponse(com.gargoylesoftware.htmlunit.WebResponse) ManagedRepositoryConfiguration(org.apache.archiva.configuration.ManagedRepositoryConfiguration) WebRequest(com.gargoylesoftware.htmlunit.WebRequest) MkColMethodWebRequest(org.apache.archiva.webdav.httpunit.MkColMethodWebRequest) InputStream(java.io.InputStream) Test(org.junit.Test)

Example 3 with ManagedRepositoryConfiguration

use of org.apache.archiva.configuration.ManagedRepositoryConfiguration in project archiva by apache.

the class MavenRepositoryProviderTest method getManagedConfiguration.

@Test
public void getManagedConfiguration() throws Exception {
    MavenManagedRepository repo = new MavenManagedRepository("test01", "My Test repo", Paths.get("target/repositories"));
    repo.setLocation(new URI("file:///this.is/a/test"));
    repo.setScanned(true);
    repo.setDescription(repo.getPrimaryLocale(), "This is a description");
    repo.setLayout("maven2");
    repo.setBlocksRedeployment(true);
    repo.setName(repo.getPrimaryLocale(), "test0002");
    repo.setSchedulingDefinition("0 0 05 ? * WED");
    repo.addActiveReleaseScheme(ReleaseScheme.RELEASE);
    repo.addActiveReleaseScheme(ReleaseScheme.SNAPSHOT);
    StagingRepositoryFeature stagingFeat = repo.getFeature(StagingRepositoryFeature.class).get();
    stagingFeat.setStageRepoNeeded(true);
    IndexCreationFeature indexCreationFeature = repo.getFeature(IndexCreationFeature.class).get();
    indexCreationFeature.setIndexPath(new URI("test/.indexes"));
    indexCreationFeature.setSkipPackedIndexCreation(true);
    ArtifactCleanupFeature artifactCleanupFeature = repo.getFeature(ArtifactCleanupFeature.class).get();
    artifactCleanupFeature.setRetentionPeriod(Period.ofDays(5));
    artifactCleanupFeature.setRetentionCount(7);
    artifactCleanupFeature.setDeleteReleasedSnapshots(true);
    ManagedRepositoryConfiguration cfg = provider.getManagedConfiguration(repo);
    assertEquals("/this.is/a/test", cfg.getLocation());
    assertTrue(cfg.isScanned());
    assertEquals("This is a description", cfg.getDescription());
    assertEquals("maven2", cfg.getLayout());
    assertTrue(cfg.isBlockRedeployments());
    assertEquals("test0002", cfg.getName());
    assertEquals("0 0 05 ? * WED", cfg.getRefreshCronExpression());
    assertTrue(cfg.isStageRepoNeeded());
    assertEquals("test/.indexes", cfg.getIndexDir());
    assertTrue(cfg.isSkipPackedIndexCreation());
    assertEquals(5, cfg.getRetentionPeriod());
    assertEquals(7, cfg.getRetentionCount());
    assertTrue(cfg.isDeleteReleasedSnapshots());
    assertTrue(cfg.isReleases());
    assertTrue(cfg.isSnapshots());
    assertTrue(cfg.isScanned());
}
Also used : IndexCreationFeature(org.apache.archiva.repository.features.IndexCreationFeature) ManagedRepositoryConfiguration(org.apache.archiva.configuration.ManagedRepositoryConfiguration) ArtifactCleanupFeature(org.apache.archiva.repository.features.ArtifactCleanupFeature) StagingRepositoryFeature(org.apache.archiva.repository.features.StagingRepositoryFeature) URI(java.net.URI) Test(org.junit.Test)

Example 4 with ManagedRepositoryConfiguration

use of org.apache.archiva.configuration.ManagedRepositoryConfiguration in project archiva by apache.

the class MavenRepositoryProviderTest method createManagedInstance.

@Test
public void createManagedInstance() throws Exception {
    ManagedRepositoryConfiguration repo = new ManagedRepositoryConfiguration();
    repo.setId("testm001");
    repo.setName("Managed Test Repo 001");
    repo.setDescription("This is a managed test");
    repo.setRetentionPeriod(37);
    repoLocation = Files.createTempDirectory("test-repo-001");
    repo.setLocation(repoLocation.toAbsolutePath().toString());
    repo.setSnapshots(true);
    repo.setReleases(true);
    repo.setRefreshCronExpression("4 0 0 ? * TUE");
    repo.setScanned(true);
    repo.setBlockRedeployments(true);
    repo.setDeleteReleasedSnapshots(true);
    repo.setRetentionCount(33);
    repo.setSkipPackedIndexCreation(true);
    repo.setStageRepoNeeded(true);
    repo.setIndexDir("testmanaged/.index");
    repo.setLayout("maven2");
    repo.setType(RepositoryType.MAVEN.toString());
    ManagedRepository mr = provider.createManagedInstance(repo);
    assertNotNull(mr.getLocation());
    String repoUri = repoLocation.toUri().toString();
    assertTrue(Files.exists(repoLocation));
    repoUri = repoUri.substring(0, repoUri.length() - 1);
    assertEquals(repoUri, mr.getLocation().toString());
    assertEquals("This is a managed test", mr.getDescription());
    assertEquals("Managed Test Repo 001", mr.getName());
    assertEquals(2, mr.getActiveReleaseSchemes().size());
    assertTrue(mr.getActiveReleaseSchemes().contains(ReleaseScheme.RELEASE));
    assertTrue(mr.getActiveReleaseSchemes().contains(ReleaseScheme.SNAPSHOT));
    assertEquals("testm001", mr.getId());
    assertTrue(mr.blocksRedeployments());
    assertEquals("4 0 0 ? * TUE", mr.getSchedulingDefinition());
    assertTrue(mr.isScanned());
    ArtifactCleanupFeature artifactCleanupFeature = mr.getFeature(ArtifactCleanupFeature.class).get();
    assertEquals(Period.ofDays(37), artifactCleanupFeature.getRetentionPeriod());
    assertTrue(artifactCleanupFeature.isDeleteReleasedSnapshots());
    assertEquals(33, artifactCleanupFeature.getRetentionCount());
    IndexCreationFeature indexCreationFeature = mr.getFeature(IndexCreationFeature.class).get();
    assertNotNull(indexCreationFeature.getIndexPath());
    assertEquals("testmanaged/.index", indexCreationFeature.getIndexPath().toString());
    assertFalse(indexCreationFeature.getIndexPath().isAbsolute());
    assertTrue(indexCreationFeature.isSkipPackedIndexCreation());
    StagingRepositoryFeature stagingRepositoryFeature = mr.getFeature(StagingRepositoryFeature.class).get();
    assertTrue(stagingRepositoryFeature.isStageRepoNeeded());
    assertNull(stagingRepositoryFeature.getStagingRepository());
}
Also used : IndexCreationFeature(org.apache.archiva.repository.features.IndexCreationFeature) ManagedRepository(org.apache.archiva.repository.ManagedRepository) ManagedRepositoryConfiguration(org.apache.archiva.configuration.ManagedRepositoryConfiguration) ArtifactCleanupFeature(org.apache.archiva.repository.features.ArtifactCleanupFeature) StagingRepositoryFeature(org.apache.archiva.repository.features.StagingRepositoryFeature) Test(org.junit.Test)

Example 5 with ManagedRepositoryConfiguration

use of org.apache.archiva.configuration.ManagedRepositoryConfiguration in project archiva by apache.

the class Maven2RepositoryMetadataResolverMRM1411Test method setUp.

@Before
@Override
public void setUp() throws Exception {
    super.setUp();
    c = new Configuration();
    testRepo = new ManagedRepositoryConfiguration();
    testRepo.setId(TEST_REPO_ID);
    testRepo.setLocation(Paths.get("target/test-repository").toAbsolutePath().toString());
    testRepo.setReleases(true);
    testRepo.setSnapshots(true);
    c.addManagedRepository(testRepo);
    RemoteRepositoryConfiguration testRemoteRepo = new RemoteRepositoryConfiguration();
    testRemoteRepo.setId(TEST_REMOTE_REPO_ID);
    testRemoteRepo.setLayout("default");
    testRemoteRepo.setName("Central Repository");
    testRemoteRepo.setUrl("http://central.repo.com/maven2");
    testRemoteRepo.setTimeout(10);
    c.addRemoteRepository(testRemoteRepo);
    ProxyConnectorConfiguration proxyConnector = new ProxyConnectorConfiguration();
    proxyConnector.setSourceRepoId(TEST_REPO_ID);
    proxyConnector.setTargetRepoId(TEST_REMOTE_REPO_ID);
    proxyConnector.setDisabled(false);
    c.addProxyConnector(proxyConnector);
    configuration.save(c);
    repositoryRegistry.reload();
    assertTrue(c.getManagedRepositories().get(0).isSnapshots());
    assertTrue(c.getManagedRepositories().get(0).isReleases());
    wagonFactory = mock(WagonFactory.class);
    storage.setWagonFactory(wagonFactory);
    Wagon wagon = new MockWagon();
    when(wagonFactory.getWagon(new WagonFactoryRequest("wagon#http", new HashMap<String, String>()))).thenReturn(wagon);
}
Also used : WagonFactoryRequest(org.apache.archiva.proxy.common.WagonFactoryRequest) ArchivaConfiguration(org.apache.archiva.configuration.ArchivaConfiguration) ProxyConnectorConfiguration(org.apache.archiva.configuration.ProxyConnectorConfiguration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.ManagedRepositoryConfiguration) RemoteRepositoryConfiguration(org.apache.archiva.configuration.RemoteRepositoryConfiguration) ContextConfiguration(org.springframework.test.context.ContextConfiguration) Configuration(org.apache.archiva.configuration.Configuration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.ManagedRepositoryConfiguration) HashMap(java.util.HashMap) RemoteRepositoryConfiguration(org.apache.archiva.configuration.RemoteRepositoryConfiguration) ProxyConnectorConfiguration(org.apache.archiva.configuration.ProxyConnectorConfiguration) WagonFactory(org.apache.archiva.proxy.common.WagonFactory) Wagon(org.apache.maven.wagon.Wagon) Before(org.junit.Before)

Aggregations

ManagedRepositoryConfiguration (org.apache.archiva.configuration.ManagedRepositoryConfiguration)46 Configuration (org.apache.archiva.configuration.Configuration)17 ArchivaConfiguration (org.apache.archiva.configuration.ArchivaConfiguration)14 Path (java.nio.file.Path)9 ProxyConnectorConfiguration (org.apache.archiva.configuration.ProxyConnectorConfiguration)9 Before (org.junit.Before)9 ContextConfiguration (org.springframework.test.context.ContextConfiguration)9 Test (org.junit.Test)8 IndeterminateConfigurationException (org.apache.archiva.configuration.IndeterminateConfigurationException)7 RemoteRepositoryConfiguration (org.apache.archiva.configuration.RemoteRepositoryConfiguration)7 RegistryException (org.apache.archiva.redback.components.registry.RegistryException)7 StagingRepositoryFeature (org.apache.archiva.repository.features.StagingRepositoryFeature)7 ArrayList (java.util.ArrayList)6 RepositoryGroupConfiguration (org.apache.archiva.configuration.RepositoryGroupConfiguration)5 IndexUpdateFailedException (org.apache.archiva.indexer.IndexUpdateFailedException)5 ArtifactCleanupFeature (org.apache.archiva.repository.features.ArtifactCleanupFeature)5 IndexCreationFeature (org.apache.archiva.repository.features.IndexCreationFeature)5 IOException (java.io.IOException)4 MetadataRepositoryException (org.apache.archiva.metadata.repository.MetadataRepositoryException)4 RepositoryException (org.apache.archiva.repository.RepositoryException)4