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