use of org.apache.archiva.configuration.RemoteRepositoryConfiguration in project archiva by apache.
the class RepositoryRegistryTest method putRemoteRepositoryFromConfig.
@Test
public void putRemoteRepositoryFromConfig() throws Exception {
RemoteRepositoryConfiguration cfg = new RemoteRepositoryConfiguration();
cfg.setId("test002");
cfg.setName("This is test 002");
RemoteRepository repo = repositoryRegistry.putRepository(cfg);
assertNotNull(repo);
assertEquals("test002", repo.getId());
assertEquals("This is test 002", repo.getName());
assertNotNull(repo.getContent());
archivaConfiguration.reload();
Collection<RemoteRepository> repos = repositoryRegistry.getRemoteRepositories();
assertEquals(2, repos.size());
RemoteRepository internalRepo = repositoryRegistry.getRemoteRepository("central");
cfg = new RemoteRepositoryConfiguration();
cfg.setId("central");
cfg.setName("This is central test 002");
repo = repositoryRegistry.putRepository(cfg);
assertTrue(internalRepo == repo);
assertEquals("This is central test 002", repo.getName());
assertEquals(2, repositoryRegistry.getRemoteRepositories().size());
repositoryRegistry.reload();
assertEquals(2, repositoryRegistry.getRemoteRepositories().size());
}
use of org.apache.archiva.configuration.RemoteRepositoryConfiguration in project archiva by apache.
the class RepositoryProviderMock method getRemoteConfiguration.
@Override
public RemoteRepositoryConfiguration getRemoteConfiguration(RemoteRepository remoteRepository) throws RepositoryException {
RemoteRepositoryConfiguration configuration = new RemoteRepositoryConfiguration();
configuration.setId(remoteRepository.getId());
configuration.setName(remoteRepository.getName());
configuration.setDescription(remoteRepository.getDescription());
configuration.setLayout(remoteRepository.getLayout());
configuration.setRefreshCronExpression(remoteRepository.getSchedulingDefinition());
configuration.setCheckPath(remoteRepository.getCheckPath());
configuration.setExtraHeaders(remoteRepository.getExtraHeaders());
configuration.setExtraParameters(remoteRepository.getExtraParameters());
configuration.setTimeout((int) remoteRepository.getTimeout().getSeconds());
RepositoryCredentials creds = remoteRepository.getLoginCredentials();
if (creds != null) {
PasswordCredentials pwdCreds = (PasswordCredentials) creds;
configuration.setUsername(pwdCreds.getUsername());
configuration.setPassword(new String(pwdCreds.getPassword()));
}
configuration.setUrl(remoteRepository.getLocation() == null ? "" : remoteRepository.getLocation().toString());
RemoteIndexFeature rif = remoteRepository.getFeature(RemoteIndexFeature.class).get();
configuration.setDownloadRemoteIndex(rif.isDownloadRemoteIndex());
configuration.setDownloadRemoteIndexOnStartup(rif.isDownloadRemoteIndexOnStartup());
configuration.setIndexDir(rif.getIndexUri() == null ? "" : rif.getIndexUri().toString());
configuration.setRemoteDownloadNetworkProxyId(rif.getProxyId());
return configuration;
}
use of org.apache.archiva.configuration.RemoteRepositoryConfiguration in project archiva by apache.
the class MavenRepositoryProviderTest method createRemoteInstance.
@Test
public void createRemoteInstance() throws Exception {
RemoteRepositoryConfiguration repo = new RemoteRepositoryConfiguration();
repo.setUsername("testuser001");
repo.setPassword("pwd0000abc");
repo.setCheckPath("test/check.html");
repo.setTimeout(50);
repo.setUrl("https://repo.maven.apache.org/maven2/test");
repo.setDownloadRemoteIndex(true);
repo.setDownloadRemoteIndexOnStartup(true);
Map<String, String> header = new HashMap<>();
header.put("header1", "value1");
header.put("header2", "value2");
repo.setExtraHeaders(header);
Map<String, String> params = new HashMap<>();
params.put("param1", "pval1");
params.put("param2", "pval2");
repo.setExtraParameters(params);
repo.setRefreshCronExpression("0 1 07 ? * MON");
repo.setRemoteDownloadTimeout(333);
repo.setRemoteIndexUrl("testremote/.index");
repo.setDescription("This is a test");
repo.setId("test001");
repo.setName("Remote Test Repo 001");
repo.setIndexDir("testindex/.index");
repo.setLayout("maven2");
repo.setType(RepositoryType.MAVEN.toString());
repo.setIndexDir("local/.index");
RemoteRepository mr = provider.createRemoteInstance(repo);
assertEquals("test001", mr.getId());
assertEquals("This is a test", mr.getDescription());
assertNotNull(mr.getLocation());
assertEquals("https://repo.maven.apache.org/maven2/test", mr.getLocation().toString());
assertEquals("Remote Test Repo 001", mr.getName());
assertEquals("test001", mr.getId());
assertEquals("0 1 07 ? * MON", mr.getSchedulingDefinition());
assertEquals(50, mr.getTimeout().get(ChronoUnit.SECONDS));
assertTrue(mr.isScanned());
assertNotNull(mr.getLoginCredentials());
assertTrue(mr.getLoginCredentials() instanceof PasswordCredentials);
PasswordCredentials creds = (PasswordCredentials) mr.getLoginCredentials();
assertEquals("testuser001", creds.getUsername());
assertEquals("pwd0000abc", new String(creds.getPassword()));
assertEquals("value1", mr.getExtraHeaders().get("header1"));
assertEquals("pval2", mr.getExtraParameters().get("param2"));
assertEquals("maven2", mr.getLayout());
try {
ArtifactCleanupFeature artifactCleanupFeature = mr.getFeature(ArtifactCleanupFeature.class).get();
throw new Exception("artifactCleanupFeature should not be available");
} catch (UnsupportedFeatureException e) {
// correct
}
IndexCreationFeature indexCreationFeature = mr.getFeature(IndexCreationFeature.class).get();
assertEquals("local/.index", indexCreationFeature.getIndexPath().toString());
try {
StagingRepositoryFeature stagingRepositoryFeature = mr.getFeature(StagingRepositoryFeature.class).get();
throw new Exception("stagingRepositoryFeature should not be available");
} catch (UnsupportedFeatureException e) {
// correct
}
RemoteIndexFeature remoteIndexFeature = mr.getFeature(RemoteIndexFeature.class).get();
assertNull(remoteIndexFeature.getProxyId());
}
use of org.apache.archiva.configuration.RemoteRepositoryConfiguration in project archiva by apache.
the class Maven2RepositoryMetadataResolverMRM1411RepoGroupTest 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(false);
c.addManagedRepository(testRepo);
testRepoS = new ManagedRepositoryConfiguration();
testRepoS.setId(TEST_SNAP_REPO_ID);
testRepoS.setLocation(Paths.get("target/test-repositorys").toAbsolutePath().toString());
testRepoS.setReleases(false);
testRepoS.setSnapshots(true);
c.addManagedRepository(testRepoS);
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);
ProxyConnectorConfiguration proxyConnectors = new ProxyConnectorConfiguration();
proxyConnectors.setSourceRepoId(TEST_SNAP_REPO_ID);
proxyConnectors.setTargetRepoId(TEST_REMOTE_REPO_ID);
proxyConnectors.setDisabled(false);
c.addProxyConnector(proxyConnectors);
List<String> repos = new ArrayList<>();
repos.add(TEST_REPO_ID);
repos.add(TEST_SNAP_REPO_ID);
RepositoryGroupConfiguration repoGroup = new RepositoryGroupConfiguration();
repoGroup.setId(TEST_REPO_GROUP_ID);
repoGroup.setRepositories(repos);
c.addRepositoryGroup(repoGroup);
configuration.save(c);
repositoryRegistry.reload();
assertFalse(c.getManagedRepositories().get(0).isSnapshots());
assertTrue(c.getManagedRepositories().get(0).isReleases());
assertTrue(c.getManagedRepositories().get(1).isSnapshots());
assertFalse(c.getManagedRepositories().get(1).isReleases());
wagonFactory = mock(WagonFactory.class);
storage.setWagonFactory(wagonFactory);
Wagon wagon = new MockWagon();
when(wagonFactory.getWagon(new WagonFactoryRequest().protocol("wagon#http"))).thenReturn(wagon);
}
use of org.apache.archiva.configuration.RemoteRepositoryConfiguration in project archiva by apache.
the class Maven2RepositoryMetadataResolverMRM1411Test method testGetProjectVersionMetadataWithParentNoRemoteReposConfigured.
@Test
public void testGetProjectVersionMetadataWithParentNoRemoteReposConfigured() throws Exception {
// remove configuration
Configuration config = configuration.getConfiguration();
RemoteRepositoryConfiguration remoteRepo = config.findRemoteRepositoryById(TEST_REMOTE_REPO_ID);
config.removeRemoteRepository(remoteRepo);
configuration.save(config);
copyTestArtifactWithParent("target/test-classes/com/example/test/test-artifact-module-a", "target/test-repository/com/example/test/test-artifact-module-a");
ProjectVersionMetadata metadata = storage.readProjectVersionMetadata(new ReadMetadataRequest(TEST_REPO_ID, "com.example.test", "test-artifact-module-a", "1.0"));
assertEquals("1.0", metadata.getId());
MavenProjectFacet facet = (MavenProjectFacet) metadata.getFacet(MavenProjectFacet.FACET_ID);
assertNotNull(facet);
assertEquals("com.example.test", facet.getGroupId());
assertEquals("test-artifact-module-a", facet.getArtifactId());
assertEquals("jar", facet.getPackaging());
List<String> paths = new ArrayList<>();
paths.add("target/test-repository/com/example/test/test-artifact-module-a");
paths.add("target/test-repository/com/example/test/test-artifact-parent");
paths.add("target/test-repository/com/example/test/test-artifact-root");
deleteTestArtifactWithParent(paths);
}
Aggregations